tmex-cli 0.16.0 → 0.16.1

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 (72) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/runtime/server.js +24 -2
  3. package/package.json +1 -1
  4. package/resources/fe-dist/assets/DevicePage-Ccz8gNji.js +24 -0
  5. package/resources/fe-dist/assets/{DevicesPage-_SYGKgwy.js → DevicesPage-sJHXbS_f.js} +1 -1
  6. package/resources/fe-dist/assets/{FilePage-Blf_MlAq.js → FilePage-7FFd1YcW.js} +1 -1
  7. package/resources/fe-dist/assets/{SettingsPage-BRt22APt.js → SettingsPage-FrEtqZyI.js} +1 -1
  8. package/resources/fe-dist/assets/{agent-tab-DRkW6D0y.js → agent-tab-9THUj7Cf.js} +1 -1
  9. package/resources/fe-dist/assets/{api-C2-crTt8.js → api-DV7-9Pvt.js} +1 -1
  10. package/resources/fe-dist/assets/{arc-Bzi-2Wgo.js → arc-PDHKfnGP.js} +1 -1
  11. package/resources/fe-dist/assets/{architectureDiagram-3BPJPVTR-DZYFrhja.js → architectureDiagram-3BPJPVTR-BiPHTh1e.js} +1 -1
  12. package/resources/fe-dist/assets/{blockDiagram-GPEHLZMM-lpc1A1G1.js → blockDiagram-GPEHLZMM-DP_BRHKg.js} +1 -1
  13. package/resources/fe-dist/assets/{c4Diagram-AAUBKEIU-DOc1BzPY.js → c4Diagram-AAUBKEIU-D16QYgyT.js} +1 -1
  14. package/resources/fe-dist/assets/{card-BA66zlg1.js → card-DmfNw0hd.js} +1 -1
  15. package/resources/fe-dist/assets/channel-Dzz9b4fW.js +1 -0
  16. package/resources/fe-dist/assets/{chunk-2J33WTMH-DqycjO3G.js → chunk-2J33WTMH-DOjtL7ww.js} +1 -1
  17. package/resources/fe-dist/assets/{chunk-4BX2VUAB-t2B-Cl6x.js → chunk-4BX2VUAB-BbT67ZXa.js} +1 -1
  18. package/resources/fe-dist/assets/{chunk-55IACEB6-BmFdQL7n.js → chunk-55IACEB6-CnnXwmY_.js} +1 -1
  19. package/resources/fe-dist/assets/{chunk-727SXJPM-DEa9FPer.js → chunk-727SXJPM-TyUdLEW5.js} +1 -1
  20. package/resources/fe-dist/assets/{chunk-AQP2D5EJ-DiZ9AoB9.js → chunk-AQP2D5EJ-BMpK4dqa.js} +1 -1
  21. package/resources/fe-dist/assets/{chunk-FMBD7UC4-DLcIMhi1.js → chunk-FMBD7UC4-Dx0HVCZZ.js} +1 -1
  22. package/resources/fe-dist/assets/{chunk-ND2GUHAM-Cu1P2Ot8.js → chunk-ND2GUHAM-BQCoMEti.js} +1 -1
  23. package/resources/fe-dist/assets/{chunk-QZHKN3VN-C8ki16q3.js → chunk-QZHKN3VN-ilmf5OgK.js} +1 -1
  24. package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-BB9_4XLL.js +1 -0
  25. package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-BB9_4XLL.js +1 -0
  26. package/resources/fe-dist/assets/{copy-C8vDYUVz.js → copy-Ct5TNzGp.js} +1 -1
  27. package/resources/fe-dist/assets/{cose-bilkent-S5V4N54A-baMBJteT.js → cose-bilkent-S5V4N54A-CpWhM7Za.js} +1 -1
  28. package/resources/fe-dist/assets/{dagre-BM42HDAG-CwWSiSwb.js → dagre-BM42HDAG-CWJttTzC.js} +1 -1
  29. package/resources/fe-dist/assets/{diagram-2AECGRRQ-CeSwouYZ.js → diagram-2AECGRRQ-BD8ny_Yg.js} +1 -1
  30. package/resources/fe-dist/assets/{diagram-5GNKFQAL-DgxdcMax.js → diagram-5GNKFQAL-CeHcPWRz.js} +1 -1
  31. package/resources/fe-dist/assets/{diagram-KO2AKTUF-DrglkRZC.js → diagram-KO2AKTUF-tVlrBE8C.js} +1 -1
  32. package/resources/fe-dist/assets/{diagram-LMA3HP47-BLHZ3p7v.js → diagram-LMA3HP47-DGUn-oQn.js} +1 -1
  33. package/resources/fe-dist/assets/{diagram-OG6HWLK6-_I_mMaa6.js → diagram-OG6HWLK6-xKCd1kwA.js} +1 -1
  34. package/resources/fe-dist/assets/{erDiagram-TEJ5UH35-Zkbnn8Kh.js → erDiagram-TEJ5UH35-C6M5qkGl.js} +1 -1
  35. package/resources/fe-dist/assets/{files-tab-CPud4eIT.js → files-tab-BWkYfaye.js} +1 -1
  36. package/resources/fe-dist/assets/{flowDiagram-I6XJVG4X-BnV7dZI4.js → flowDiagram-I6XJVG4X-D0MZDHnB.js} +1 -1
  37. package/resources/fe-dist/assets/{ganttDiagram-6RSMTGT7-Cn2f5kRI.js → ganttDiagram-6RSMTGT7-YeduSSa_.js} +1 -1
  38. package/resources/fe-dist/assets/{gitGraphDiagram-PVQCEYII-CEswG7nI.js → gitGraphDiagram-PVQCEYII-Nem1Mvvg.js} +1 -1
  39. package/resources/fe-dist/assets/{index-BK6c5W5S.js → index-B3ddLSja.js} +28 -28
  40. package/resources/fe-dist/assets/{index-DLyPliOu.js → index-iee3U_rD.js} +1 -1
  41. package/resources/fe-dist/assets/{infoDiagram-5YYISTIA-Dsx1fQI9.js → infoDiagram-5YYISTIA-Bh6bbh_V.js} +1 -1
  42. package/resources/fe-dist/assets/{ishikawaDiagram-YF4QCWOH-CgNMvXgO.js → ishikawaDiagram-YF4QCWOH-CsZHu48j.js} +1 -1
  43. package/resources/fe-dist/assets/{journeyDiagram-JHISSGLW-CVeui1xn.js → journeyDiagram-JHISSGLW-CPgnovXt.js} +1 -1
  44. package/resources/fe-dist/assets/{kanban-definition-UN3LZRKU-WnLUDsz4.js → kanban-definition-UN3LZRKU-D4OAuDsS.js} +1 -1
  45. package/resources/fe-dist/assets/{linear-B0SWPrkI.js → linear-CcA4wV7f.js} +1 -1
  46. package/resources/fe-dist/assets/{markdown-preview-CDjnYorp.js → markdown-preview-CBGlxpTs.js} +3 -3
  47. package/resources/fe-dist/assets/{mermaid.core-CXD-Pc2r.js → mermaid.core-D-CshtYr.js} +5 -5
  48. package/resources/fe-dist/assets/{mindmap-definition-RKZ34NQL-DYEXXmag.js → mindmap-definition-RKZ34NQL-DBpI1nMC.js} +1 -1
  49. package/resources/fe-dist/assets/{pieDiagram-4H26LBE5-DkZtnbYj.js → pieDiagram-4H26LBE5-D4kh0_Y0.js} +1 -1
  50. package/resources/fe-dist/assets/{quadrantDiagram-W4KKPZXB-DblvGass.js → quadrantDiagram-W4KKPZXB-DNw3oGHQ.js} +1 -1
  51. package/resources/fe-dist/assets/{requirementDiagram-4Y6WPE33-KAX1DxRY.js → requirementDiagram-4Y6WPE33-DqtMaND0.js} +1 -1
  52. package/resources/fe-dist/assets/{sankeyDiagram-5OEKKPKP-h9Z2LXNr.js → sankeyDiagram-5OEKKPKP-D-m9Pyie.js} +1 -1
  53. package/resources/fe-dist/assets/{send-BVxB0Ywb.js → send-DaOB9hLq.js} +1 -1
  54. package/resources/fe-dist/assets/{sequenceDiagram-3UESZ5HK-DUJcq5qX.js → sequenceDiagram-3UESZ5HK-CjrimNJf.js} +1 -1
  55. package/resources/fe-dist/assets/{stateDiagram-AJRCARHV-BBT56nPD.js → stateDiagram-AJRCARHV-BT5d8Z8W.js} +1 -1
  56. package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-kSh9IuUW.js +1 -0
  57. package/resources/fe-dist/assets/terminal-settings-panel-DDhlnbRH.js +25 -0
  58. package/resources/fe-dist/assets/{timeline-definition-PNZ67QCA-DLkgXxGG.js → timeline-definition-PNZ67QCA-BeocAFDX.js} +1 -1
  59. package/resources/fe-dist/assets/{transfer-toast-BYw9LLNi.js → transfer-toast-DXl4RHsV.js} +1 -1
  60. package/resources/fe-dist/assets/{triangle-alert-D4oQhgpz.js → triangle-alert-FQRTtbTP.js} +1 -1
  61. package/resources/fe-dist/assets/{vennDiagram-CIIHVFJN-CyUw7cRl.js → vennDiagram-CIIHVFJN-CYlmUB5_.js} +1 -1
  62. package/resources/fe-dist/assets/{wardley-L42UT6IY-UVd2D_HQ.js → wardley-L42UT6IY-CTyaodt9.js} +1 -1
  63. package/resources/fe-dist/assets/{wardleyDiagram-YWT4CUSO-B6As-5ml.js → wardleyDiagram-YWT4CUSO-DNlEcEwQ.js} +1 -1
  64. package/resources/fe-dist/assets/{xychartDiagram-2RQKCTM6-DFypVaEh.js → xychartDiagram-2RQKCTM6-7Zi-6P-I.js} +1 -1
  65. package/resources/fe-dist/assets/{zap-DxVtkroR.js → zap-BFIAXPXd.js} +1 -1
  66. package/resources/fe-dist/index.html +1 -1
  67. package/resources/fe-dist/assets/DevicePage-CxCVolw8.js +0 -24
  68. package/resources/fe-dist/assets/channel-DFyg9jlp.js +0 -1
  69. package/resources/fe-dist/assets/classDiagram-4FO5ZUOK-CAgGMVvn.js +0 -1
  70. package/resources/fe-dist/assets/classDiagram-v2-Q7XG4LA2-CAgGMVvn.js +0 -1
  71. package/resources/fe-dist/assets/stateDiagram-v2-BHNVJYJU-wyzFZc_5.js +0 -1
  72. package/resources/fe-dist/assets/terminal-settings-panel-DHrIp0wf.js +0 -25
@@ -1,4 +1,4 @@
1
- import{s as gi,g as xi,q as Xt,p as di,a as fi,b as pi,_ as a,l as Yt,I as mi,e as yi,z as bi,D as _t,i as Ai,F as Nt,G as wi,K as Ci,am as Si,R as Wt}from"./mermaid.core-CXD-Pc2r.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-BENe2yWM.js";import{l as zt}from"./linear-B0SWPrkI.js";import"./index-BK6c5W5S.js";import"./defaultLocale-DX6XiGOO.js";function Ri(e,t,i){e=+e,t=+t,i=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+i;for(var s=-1,n=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(n);++s<n;)o[s]=e+s*i;return o}function bt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,u,p=!1,f=0,T=0,P=.5;delete e.unknown;function _(){var y=t().length,E=n<s,v=E?n:s,L=E?s:n;o=(L-v)/Math.max(1,y-f+T*2),p&&(o=Math.floor(o)),v+=(L-v-o*(y-f))*P,u=o*(1-f),p&&(v=Math.round(v),u=Math.round(u));var I=Ri(y).map(function(m){return v+o*m});return i(E?I.reverse():I)}return e.domain=function(y){return arguments.length?(t(y),_()):t()},e.range=function(y){return arguments.length?([s,n]=y,s=+s,n=+n,_()):[s,n]},e.rangeRound=function(y){return[s,n]=y,s=+s,n=+n,p=!0,_()},e.bandwidth=function(){return u},e.step=function(){return o},e.round=function(y){return arguments.length?(p=!!y,_()):p},e.padding=function(y){return arguments.length?(f=Math.min(1,T=+y),_()):f},e.paddingInner=function(y){return arguments.length?(f=Math.min(1,y),_()):f},e.paddingOuter=function(y){return arguments.length?(T=+y,_()):T},e.align=function(y){return arguments.length?(P=Math.max(0,Math.min(1,y)),_()):P},e.copy=function(){return bt(t(),[s,n]).round(p).paddingInner(f).paddingOuter(T).align(P)},_i.apply(_(),arguments)}var At=(function(){var e=a(function(F,h,c,g){for(c=c||{},g=F.length;g--;c[F[g]]=h);return c},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],u=[1,7],p=[1,5,10,12,14,16,18,19,21,23,34,35,36],f=[1,25],T=[1,26],P=[1,28],_=[1,29],y=[1,30],E=[1,31],v=[1,32],L=[1,33],I=[1,34],m=[1,35],R=[1,36],l=[1,37],W=[1,43],O=[1,42],X=[1,47],Y=[1,50],S=[1,10,12,14,16,18,19,21,23,34,35,36],U=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],b=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],w=[1,64],V={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:a(function(h,c,g,x,C,r,rt){var d=r.length-1;switch(C){case 5:x.setOrientation(r[d]);break;case 9:x.setDiagramTitle(r[d].text.trim());break;case 12:x.setLineData({text:"",type:"text"},r[d]);break;case 13:x.setLineData(r[d-1],r[d]);break;case 14:x.setBarData({text:"",type:"text"},r[d]);break;case 15:x.setBarData(r[d-1],r[d]);break;case 16:this.$=r[d].trim(),x.setAccTitle(this.$);break;case 17:case 18:this.$=r[d].trim(),x.setAccDescription(this.$);break;case 19:this.$=r[d-1];break;case 20:this.$=[Number(r[d-2]),...r[d]];break;case 21:this.$=[Number(r[d])];break;case 22:x.setXAxisTitle(r[d]);break;case 23:x.setXAxisTitle(r[d-1]);break;case 24:x.setXAxisTitle({type:"text",text:""});break;case 25:x.setXAxisBand(r[d]);break;case 26:x.setXAxisRangeData(Number(r[d-2]),Number(r[d]));break;case 27:this.$=r[d-1];break;case 28:this.$=[r[d-2],...r[d]];break;case 29:this.$=[r[d]];break;case 30:x.setYAxisTitle(r[d]);break;case 31:x.setYAxisTitle(r[d-1]);break;case 32:x.setYAxisTitle({type:"text",text:""});break;case 33:x.setYAxisRangeData(Number(r[d-2]),Number(r[d]));break;case 37:this.$={text:r[d],type:"text"};break;case 38:this.$={text:r[d],type:"text"};break;case 39:this.$={text:r[d],type:"markdown"};break;case 40:this.$=r[d];break;case 41:this.$=r[d-1]+""+r[d];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,34:n,35:o,36:u}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,34:n,35:o,36:u}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],34:n,35:o,36:u}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,34]),e(p,[2,35]),e(p,[2,36]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,34:n,35:o,36:u}),{1:[2,3]},e(p,[2,5]),e(t,[2,7],{4:22,34:n,35:o,36:u}),{11:23,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:39,13:38,24:W,27:O,29:40,30:41,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:45,15:44,27:X,33:46,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:49,17:48,24:Y,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:52,17:51,24:Y,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{20:[1,53]},{22:[1,54]},e(S,[2,18]),{1:[2,2]},e(S,[2,8]),e(S,[2,9]),e(U,[2,37],{40:55,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l}),e(U,[2,38]),e(U,[2,39]),e(b,[2,40]),e(b,[2,42]),e(b,[2,43]),e(b,[2,44]),e(b,[2,45]),e(b,[2,46]),e(b,[2,47]),e(b,[2,48]),e(b,[2,49]),e(b,[2,50]),e(b,[2,51]),e(S,[2,10]),e(S,[2,22],{30:41,29:56,24:W,27:O}),e(S,[2,24]),e(S,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},e(S,[2,11]),e(S,[2,30],{33:60,27:X}),e(S,[2,32]),{31:[1,61]},e(S,[2,12]),{17:62,24:Y},{25:63,27:w},e(S,[2,14]),{17:65,24:Y},e(S,[2,16]),e(S,[2,17]),e(b,[2,41]),e(S,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},e(S,[2,31]),{27:[1,69]},e(S,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},e(S,[2,15]),e(S,[2,26]),e(S,[2,27]),{11:59,32:72,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},e(S,[2,33]),e(S,[2,19]),{25:73,27:w},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:a(function(h,c){if(c.recoverable)this.trace(h);else{var g=new Error(h);throw g.hash=c,g}},"parseError"),parse:a(function(h){var c=this,g=[0],x=[],C=[null],r=[],rt=this.table,d="",ct=0,It=0,hi=2,Mt=1,li=r.slice.call(arguments,1),D=Object.create(this.lexer),$={yy:{}};for(var ft in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ft)&&($.yy[ft]=this.yy[ft]);D.setInput(h,$.yy),$.yy.lexer=D,$.yy.parser=this,typeof D.yylloc>"u"&&(D.yylloc={});var pt=D.yylloc;r.push(pt);var ci=D.options&&D.options.ranges;typeof $.yy.parseError=="function"?this.parseError=$.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ui(B){g.length=g.length-2*B,C.length=C.length-B,r.length=r.length-B}a(ui,"popStack");function Vt(){var B;return B=x.pop()||D.lex()||Mt,typeof B!="number"&&(B instanceof Array&&(x=B,B=x.pop()),B=c.symbols_[B]||B),B}a(Vt,"lex");for(var M,q,z,mt,G={},ut,N,Bt,gt;;){if(q=g[g.length-1],this.defaultActions[q]?z=this.defaultActions[q]:((M===null||typeof M>"u")&&(M=Vt()),z=rt[q]&&rt[q][M]),typeof z>"u"||!z.length||!z[0]){var yt="";gt=[];for(ut in rt[q])this.terminals_[ut]&&ut>hi&&gt.push("'"+this.terminals_[ut]+"'");D.showPosition?yt="Parse error on line "+(ct+1)+`:
1
+ import{s as gi,g as xi,q as Xt,p as di,a as fi,b as pi,_ as a,l as Yt,I as mi,e as yi,z as bi,D as _t,i as Ai,F as Nt,G as wi,K as Ci,am as Si,R as Wt}from"./mermaid.core-D-CshtYr.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-BENe2yWM.js";import{l as zt}from"./linear-CcA4wV7f.js";import"./index-B3ddLSja.js";import"./defaultLocale-DX6XiGOO.js";function Ri(e,t,i){e=+e,t=+t,i=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+i;for(var s=-1,n=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(n);++s<n;)o[s]=e+s*i;return o}function bt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,u,p=!1,f=0,T=0,P=.5;delete e.unknown;function _(){var y=t().length,E=n<s,v=E?n:s,L=E?s:n;o=(L-v)/Math.max(1,y-f+T*2),p&&(o=Math.floor(o)),v+=(L-v-o*(y-f))*P,u=o*(1-f),p&&(v=Math.round(v),u=Math.round(u));var I=Ri(y).map(function(m){return v+o*m});return i(E?I.reverse():I)}return e.domain=function(y){return arguments.length?(t(y),_()):t()},e.range=function(y){return arguments.length?([s,n]=y,s=+s,n=+n,_()):[s,n]},e.rangeRound=function(y){return[s,n]=y,s=+s,n=+n,p=!0,_()},e.bandwidth=function(){return u},e.step=function(){return o},e.round=function(y){return arguments.length?(p=!!y,_()):p},e.padding=function(y){return arguments.length?(f=Math.min(1,T=+y),_()):f},e.paddingInner=function(y){return arguments.length?(f=Math.min(1,y),_()):f},e.paddingOuter=function(y){return arguments.length?(T=+y,_()):T},e.align=function(y){return arguments.length?(P=Math.max(0,Math.min(1,y)),_()):P},e.copy=function(){return bt(t(),[s,n]).round(p).paddingInner(f).paddingOuter(T).align(P)},_i.apply(_(),arguments)}var At=(function(){var e=a(function(F,h,c,g){for(c=c||{},g=F.length;g--;c[F[g]]=h);return c},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],u=[1,7],p=[1,5,10,12,14,16,18,19,21,23,34,35,36],f=[1,25],T=[1,26],P=[1,28],_=[1,29],y=[1,30],E=[1,31],v=[1,32],L=[1,33],I=[1,34],m=[1,35],R=[1,36],l=[1,37],W=[1,43],O=[1,42],X=[1,47],Y=[1,50],S=[1,10,12,14,16,18,19,21,23,34,35,36],U=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],b=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],w=[1,64],V={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:a(function(h,c,g,x,C,r,rt){var d=r.length-1;switch(C){case 5:x.setOrientation(r[d]);break;case 9:x.setDiagramTitle(r[d].text.trim());break;case 12:x.setLineData({text:"",type:"text"},r[d]);break;case 13:x.setLineData(r[d-1],r[d]);break;case 14:x.setBarData({text:"",type:"text"},r[d]);break;case 15:x.setBarData(r[d-1],r[d]);break;case 16:this.$=r[d].trim(),x.setAccTitle(this.$);break;case 17:case 18:this.$=r[d].trim(),x.setAccDescription(this.$);break;case 19:this.$=r[d-1];break;case 20:this.$=[Number(r[d-2]),...r[d]];break;case 21:this.$=[Number(r[d])];break;case 22:x.setXAxisTitle(r[d]);break;case 23:x.setXAxisTitle(r[d-1]);break;case 24:x.setXAxisTitle({type:"text",text:""});break;case 25:x.setXAxisBand(r[d]);break;case 26:x.setXAxisRangeData(Number(r[d-2]),Number(r[d]));break;case 27:this.$=r[d-1];break;case 28:this.$=[r[d-2],...r[d]];break;case 29:this.$=[r[d]];break;case 30:x.setYAxisTitle(r[d]);break;case 31:x.setYAxisTitle(r[d-1]);break;case 32:x.setYAxisTitle({type:"text",text:""});break;case 33:x.setYAxisRangeData(Number(r[d-2]),Number(r[d]));break;case 37:this.$={text:r[d],type:"text"};break;case 38:this.$={text:r[d],type:"text"};break;case 39:this.$={text:r[d],type:"markdown"};break;case 40:this.$=r[d];break;case 41:this.$=r[d-1]+""+r[d];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,34:n,35:o,36:u}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,34:n,35:o,36:u}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],34:n,35:o,36:u}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(p,[2,34]),e(p,[2,35]),e(p,[2,36]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,34:n,35:o,36:u}),{1:[2,3]},e(p,[2,5]),e(t,[2,7],{4:22,34:n,35:o,36:u}),{11:23,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:39,13:38,24:W,27:O,29:40,30:41,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:45,15:44,27:X,33:46,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:49,17:48,24:Y,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{11:52,17:51,24:Y,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},{20:[1,53]},{22:[1,54]},e(S,[2,18]),{1:[2,2]},e(S,[2,8]),e(S,[2,9]),e(U,[2,37],{40:55,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l}),e(U,[2,38]),e(U,[2,39]),e(b,[2,40]),e(b,[2,42]),e(b,[2,43]),e(b,[2,44]),e(b,[2,45]),e(b,[2,46]),e(b,[2,47]),e(b,[2,48]),e(b,[2,49]),e(b,[2,50]),e(b,[2,51]),e(S,[2,10]),e(S,[2,22],{30:41,29:56,24:W,27:O}),e(S,[2,24]),e(S,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},e(S,[2,11]),e(S,[2,30],{33:60,27:X}),e(S,[2,32]),{31:[1,61]},e(S,[2,12]),{17:62,24:Y},{25:63,27:w},e(S,[2,14]),{17:65,24:Y},e(S,[2,16]),e(S,[2,17]),e(b,[2,41]),e(S,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},e(S,[2,31]),{27:[1,69]},e(S,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},e(S,[2,15]),e(S,[2,26]),e(S,[2,27]),{11:59,32:72,37:24,38:f,39:T,40:27,41:P,42:_,43:y,44:E,45:v,46:L,47:I,48:m,49:R,50:l},e(S,[2,33]),e(S,[2,19]),{25:73,27:w},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:a(function(h,c){if(c.recoverable)this.trace(h);else{var g=new Error(h);throw g.hash=c,g}},"parseError"),parse:a(function(h){var c=this,g=[0],x=[],C=[null],r=[],rt=this.table,d="",ct=0,It=0,hi=2,Mt=1,li=r.slice.call(arguments,1),D=Object.create(this.lexer),$={yy:{}};for(var ft in this.yy)Object.prototype.hasOwnProperty.call(this.yy,ft)&&($.yy[ft]=this.yy[ft]);D.setInput(h,$.yy),$.yy.lexer=D,$.yy.parser=this,typeof D.yylloc>"u"&&(D.yylloc={});var pt=D.yylloc;r.push(pt);var ci=D.options&&D.options.ranges;typeof $.yy.parseError=="function"?this.parseError=$.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ui(B){g.length=g.length-2*B,C.length=C.length-B,r.length=r.length-B}a(ui,"popStack");function Vt(){var B;return B=x.pop()||D.lex()||Mt,typeof B!="number"&&(B instanceof Array&&(x=B,B=x.pop()),B=c.symbols_[B]||B),B}a(Vt,"lex");for(var M,q,z,mt,G={},ut,N,Bt,gt;;){if(q=g[g.length-1],this.defaultActions[q]?z=this.defaultActions[q]:((M===null||typeof M>"u")&&(M=Vt()),z=rt[q]&&rt[q][M]),typeof z>"u"||!z.length||!z[0]){var yt="";gt=[];for(ut in rt[q])this.terminals_[ut]&&ut>hi&&gt.push("'"+this.terminals_[ut]+"'");D.showPosition?yt="Parse error on line "+(ct+1)+`:
2
2
  `+D.showPosition()+`
3
3
  Expecting `+gt.join(", ")+", got '"+(this.terminals_[M]||M)+"'":yt="Parse error on line "+(ct+1)+": Unexpected "+(M==Mt?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(yt,{text:D.match,token:this.terminals_[M]||M,line:D.yylineno,loc:pt,expected:gt})}if(z[0]instanceof Array&&z.length>1)throw new Error("Parse Error: multiple actions possible at state: "+q+", token: "+M);switch(z[0]){case 1:g.push(M),C.push(D.yytext),r.push(D.yylloc),g.push(z[1]),M=null,It=D.yyleng,d=D.yytext,ct=D.yylineno,pt=D.yylloc;break;case 2:if(N=this.productions_[z[1]][1],G.$=C[C.length-N],G._$={first_line:r[r.length-(N||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(N||1)].first_column,last_column:r[r.length-1].last_column},ci&&(G._$.range=[r[r.length-(N||1)].range[0],r[r.length-1].range[1]]),mt=this.performAction.apply(G,[d,It,ct,$.yy,z[1],C,r].concat(li)),typeof mt<"u")return mt;N&&(g=g.slice(0,-1*N*2),C=C.slice(0,-1*N),r=r.slice(0,-1*N)),g.push(this.productions_[z[1]][0]),C.push(G.$),r.push(G._$),Bt=rt[g[g.length-2]][g[g.length-1]],g.push(Bt);break;case 3:return!0}}return!0},"parse")},k=(function(){var F={EOF:1,parseError:a(function(c,g){if(this.yy.parser)this.yy.parser.parseError(c,g);else throw new Error(c)},"parseError"),setInput:a(function(h,c){return this.yy=c||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var c=h.match(/(?:\r\n?|\n).*/g);return c?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:a(function(h){var c=h.length,g=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-c),this.offset-=c;var x=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),g.length-1&&(this.yylineno-=g.length-1);var C=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:g?(g.length===x.length?this.yylloc.first_column:0)+x[x.length-g.length].length-g[0].length:this.yylloc.first_column-c},this.options.ranges&&(this.yylloc.range=[C[0],C[0]+this.yyleng-c]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(h){this.unput(this.match.slice(h))},"less"),pastInput:a(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var h=this.pastInput(),c=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{Y as a}from"./index-BK6c5W5S.js";/**
1
+ import{Y as a}from"./index-B3ddLSja.js";/**
2
2
  * @license lucide-react v0.564.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -19,7 +19,7 @@
19
19
  <link rel="apple-touch-icon" href="/tmex.png" />
20
20
  <meta name="description" content="tmex - Web 接入多设备 tmux 的终端控制平台" />
21
21
  <title>tmex</title>
22
- <script type="module" crossorigin src="/assets/index-BK6c5W5S.js"></script>
22
+ <script type="module" crossorigin src="/assets/index-B3ddLSja.js"></script>
23
23
  <link rel="stylesheet" crossorigin href="/assets/index-CuFTSN9i.css">
24
24
  </head>
25
25
  <body>
@@ -1,24 +0,0 @@
1
- import{Y as Xe,u as Pe,j as o,aD as Et,aE as Rt,aF as Tt,aG as Ct,aH as jt,at as Nt,r as n,d as O,af as ge,ai as at,ah as lt,ag as Mt,aj as Pt,aI as kt,aJ as It,o as Me,aK as Lt,D as At,p as Dt,q as _t,s as zt,aL as Ze,aw as ut,b as dt,aM as et,aN as $t,c as tt,aC as ft,aO as Ce,aP as Bt,ay as Ft,aq as qe,y as Ht,a2 as Wt,B as Re,T as Ot,aQ as Xt,aR as qt,aS as Yt,aT as Ut,aU as Vt,$ as Kt,aV as Gt,A as Qt,f as Jt,g as Zt,i as en,k as tn,l as nn,m as rn,n as sn}from"./index-BK6c5W5S.js";import{T as on,C as cn,c as an,F as ln,a as ht,R as un,A as dn,f as fn,t as hn,S as mn}from"./terminal-settings-panel-DHrIp0wf.js";import{e as wn}from"./selection-clipboard-D3gUQQ7L.js";import{C as pn}from"./copy-C8vDYUVz.js";import{S as ot,K as gn}from"./send-BVxB0Ywb.js";const xn=/^[0-9a-fA-F]{4}$/;function vn(e){if(typeof e!="string"||e.length<6)return null;const t=e.slice(0,4);if(!xn.test(t)||e[4]!==",")return null;const r={input:e,pos:5},c=mt(r);return!c||r.pos!==e.length?null:{checksum:t,root:c}}function $e(e){const t=e.pos;for(;e.pos<e.input.length;){const r=e.input.charCodeAt(e.pos);if(r<48||r>57)break;e.pos+=1}return e.pos===t?null:Number.parseInt(e.input.slice(t,e.pos),10)}function Be(e,t){return e.input[e.pos]!==t?!1:(e.pos+=1,!0)}function mt(e){const t=$e(e);if(t===null||!Be(e,"x"))return null;const r=$e(e);if(r===null||!Be(e,","))return null;const c=$e(e);if(c===null||!Be(e,","))return null;const l=$e(e);if(l===null)return null;const m=e.input[e.pos];if(m===","){e.pos+=1;const v=$e(e);return v===null?null:{type:"leaf",paneNumId:v,width:t,height:r,x:c,y:l}}if(m==="{"||m==="["){const v=m==="{"?"}":"]";e.pos+=1;const b=[];for(;;){const C=mt(e);if(!C)return null;if(b.push(C),!Be(e,",")){if(Be(e,v))break;return null}}return b.length<2?null:{type:m==="{"?"row":"column",width:t,height:r,x:c,y:l,children:b}}return null}function Ye(e){return`%${e.paneNumId}`}/**
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 bn=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],Sn=Xe("columns-2",bn);/**
7
- * @license lucide-react v0.564.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const yn=[["path",{d:"m13.5 8.5-5 5",key:"1cs55j"}],["path",{d:"m8.5 8.5 5 5",key:"a8mexj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],En=Xe("search-x",yn);/**
12
- * @license lucide-react v0.564.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Rn=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],Tn=Xe("settings-2",Rn);/**
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 Cn=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],jn=Xe("smartphone",Cn);function Nn({open:e,onOpenChange:t}){const{t:r}=Pe();return o.jsx(Et,{open:e,onOpenChange:t,children:o.jsxs(Rt,{side:"bottom",className:"max-h-[88dvh] overflow-y-auto pb-[var(--tmex-safe-area-bottom)] sm:mx-auto sm:max-w-md sm:rounded-t-2xl sm:border sm:border-b-0","data-testid":"keyboard-behavior-sheet",children:[o.jsxs(Tt,{children:[o.jsx(Ct,{children:r("settings.terminal.title")}),o.jsx(jt,{children:r("settings.terminal.savedInBrowser")})]}),o.jsx("div",{className:"px-4 pb-4",children:o.jsx(on,{})})]})})}function Mn({visible:e,canPaste:t,onCopy:r,onPaste:c,onDismiss:l}){const{t:m}=Pe();if(!e)return null;const v=b=>{b.preventDefault()};return o.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:[o.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:v,onClick:r,"data-testid":"terminal-selection-copy",children:[o.jsx(pn,{className:"h-4 w-4"}),m("terminal.copy")]}),t&&o.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:v,onClick:c,"data-testid":"terminal-selection-paste",children:[o.jsx(cn,{className:"h-4 w-4"}),m("terminal.paste")]}),o.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:v,onClick:l,"aria-label":m("terminal.clearSelection"),"data-testid":"terminal-selection-dismiss",children:o.jsx(Nt,{className:"h-4 w-4"})})]})}function wt(e){if(!e)return e;const t=e.replace(/\r\n/g,`
22
- `);return(t.endsWith(`
23
- `)?t.slice(0,-1):t).replace(/\n/g,`\r
24
- `)}const Pn="\x1B[?1049h\x1B[H\x1B[2J";function kn(e){return Pn+wt(e)}function In(e,t){let r=t,c=0;for(const b of e)b===10&&!r&&(c+=1),r=b===13;const l=r;if(c===0)return{normalized:e,endedWithCR:l};const m=new Uint8Array(e.length+c);let v=0;r=t;for(const b of e)b===10&&!r&&(m[v]=13,v+=1),m[v]=b,v+=1,r=b===13;return{normalized:m,endedWithCR:l}}const Ln=1.3,An=36,Dn=500,_n=12;function zn(e,t){const r=n.useRef(!1);return n.useEffect(()=>{const c=e.current;if(!c||!(window.innerWidth<768||navigator.maxTouchPoints>0||"ontouchstart"in window))return;r.current=!0;let m=0,v=null,b=!1,C=0,F=0,z=0,j=null,i=!1;const y=()=>{j!==null&&(clearTimeout(j),j=null)},ue=S=>S?!!(S.closest(".scrollbar")||S.closest(".slider")||S.closest(".xterm-scroll-area")):!1,U=(S,p,k)=>{const R=k instanceof Element?k:null;if(ue(R))return!0;const _=document.elementFromPoint(S,p);if(ue(_))return!0;const G=c.querySelector(".xterm");if(!(G instanceof HTMLElement))return!1;const u=G.getBoundingClientRect(),A=S>=u.left&&S<=u.right,Y=p>=u.top&&p<=u.bottom;return!A||!Y?!1:S>=u.right-An},M=()=>[c.querySelector(".xterm-viewport"),c.querySelector(".xterm-scrollable-element")].filter(p=>p instanceof HTMLElement),ce=S=>{if(v===null)return null;for(let p=0;p<S.length;p+=1){const k=S.item(p);if(k&&k.identifier===v)return k}return null},ne=S=>{if(y(),S.touches.length!==1)return;const p=S.touches.item(0);p&&(v=p.identifier,m=p.clientY,C=0,b=U(p.clientX,p.clientY,S.target),F=p.clientX,z=p.clientY,i=!1,b||(j=setTimeout(()=>{var R;j=null;const k=(t==null?void 0:t())??null;(R=k==null?void 0:k.startTouchSelection)!=null&&R.call(k,F,z,"word")&&(i=!0)},Dn)))},me=S=>{var A,Y,H,D,V,de,re,we,J;const p=ce(S.touches)??S.touches.item(0);if(!p)return;if(i){const Q=(t==null?void 0:t())??null;(A=Q==null?void 0:Q.updateTouchSelection)==null||A.call(Q,p.clientX,p.clientY),S.cancelable&&S.preventDefault();return}if(j!==null&&Math.hypot(p.clientX-F,p.clientY-z)>_n&&y(),b||(b=U(p.clientX,p.clientY,S.target),b&&(C=0)),b)return;const k=p.clientY,R=m-k;if(m=k,R===0)return;let _=!1,G=!1;const u=(t==null?void 0:t())??null;if(u){const Q=u==null?void 0:u._core,ee=((V=(D=(H=(Y=Q==null?void 0:Q._renderService)==null?void 0:Y.dimensions)==null?void 0:H.css)==null?void 0:D.cell)==null?void 0:V.height)??18;C+=R*Ln;const E=C>0?Math.floor(C/ee):Math.ceil(C/ee);if(typeof u.handleViewportGesture=="function")E!==0&&(_=u.handleViewportGesture({source:"touch",deltaY:E*ee,clientX:p.clientX,clientY:p.clientY}),C-=E*ee);else if(E!==0){const a=((re=(de=u.buffer)==null?void 0:de.active)==null?void 0:re.viewportY)??0;u.scrollLines(E);const h=((J=(we=u.buffer)==null?void 0:we.active)==null?void 0:J.viewportY)??0;_=a!==h,G=E<0&&a<=0&&h<=0,C-=E*ee}}else{const Q=M();if(Q.length===0)return;for(const ee of Q){const E=ee.scrollTop;ee.scrollTop+=R;const a=ee.scrollTop;Math.abs(a-E)>0&&(_=!0),R<0&&a<=0&&(G=!0)}if(!_){const ee=c.querySelector(".xterm");if(ee instanceof HTMLElement){const E=new WheelEvent("wheel",{bubbles:!0,cancelable:!0,deltaMode:WheelEvent.DOM_DELTA_PIXEL,deltaY:R}),a=ee.dispatchEvent(E);_=E.defaultPrevented||!a}}}S.cancelable&&(_||G)&&S.preventDefault()},Z=S=>{var k;if(y(),!(v===null||!ce(S.changedTouches))&&(v=null,C=0,b=!1,i)){i=!1;const R=(t==null?void 0:t())??null;(k=R==null?void 0:R.endTouchSelection)==null||k.call(R)}},d=S=>{i&&S.preventDefault()};return c.addEventListener("touchstart",ne,{passive:!0}),c.addEventListener("touchmove",me,{passive:!1}),c.addEventListener("touchend",Z,{passive:!0}),c.addEventListener("touchcancel",Z,{passive:!0}),c.addEventListener("contextmenu",d),()=>{r.current=!1,y(),c.removeEventListener("touchstart",ne),c.removeEventListener("touchmove",me),c.removeEventListener("touchend",Z),c.removeEventListener("touchcancel",Z),c.removeEventListener("contextmenu",d)}},[e,t]),r}function $n({now:e,remoteSize:t,pendingLocalSize:r,ttlMs:c=2e3}){return!r||e-r.at>c?!0:r.cols===t.cols&&r.rows===t.rows}function Bn({currentSize:e,containerSize:t,force:r=!1}){return r?!0:e.cols!==t.cols||e.rows!==t.rows}function Fn({deviceId:e,paneId:t,deviceConnected:r,isSelectionInvalid:c,sizingMode:l="report",onResize:m,onSync:v,getContainerRect:b}){const C=n.useRef(null),F=n.useRef(null),z=n.useRef(null),j=n.useRef(null),i=n.useRef(0),y=n.useRef([]),ue=n.useRef(null),U=n.useRef(null),M=n.useRef(b),ce=n.useRef(!1),ne=n.useRef(m),me=n.useRef(v);n.useEffect(()=>{ne.current=m},[m]),n.useEffect(()=>{me.current=v},[v]),n.useEffect(()=>{M.current=b},[b]);const Z=n.useCallback(()=>{var re,we,J,Q,ee,E,a,h,N,T;const u=U.current,A=ue.current;if(!u||!A||!u.element)return null;let Y;try{const W=A.proposeDimensions();if(!W)throw new Error("fitAddon.proposeDimensions() returned null");Y=Math.max(2,W.cols)}catch{const W=u._core,se=((Q=(J=(we=(re=W==null?void 0:W._renderService)==null?void 0:re.dimensions)==null?void 0:we.css)==null?void 0:J.cell)==null?void 0:Q.width)??9,K=(ee=M.current)==null?void 0:ee.call(M);if(!K||K.width===0)return null;Y=Math.max(2,Math.floor(K.width/se))}const H=(E=M.current)==null?void 0:E.call(M);if(!H||H.height===0)return null;const D=u._core,V=((T=(N=(h=(a=D==null?void 0:D._renderService)==null?void 0:a.dimensions)==null?void 0:h.css)==null?void 0:N.cell)==null?void 0:T.height)??17,de=Math.max(2,Math.floor(H.height/V));return{cols:Y,rows:de}},[]),d=n.useCallback((u,A)=>{const Y=U.current;Y&&(Y.cols===u&&Y.rows===A||Y.resize(u,A))},[]),S=n.useCallback((u,A=!1)=>{if(l==="follow"||!e||!t||!r||c&&u!=="sync"||!A&&Date.now()<i.current||!U.current)return!1;const H=Z();if(!H)return!1;const{cols:D,rows:V}=H,de=z.current;return!A&&de&&de.cols===D&&de.rows===V?(d(D,V),!0):(d(D,V),u==="sync"?me.current(D,V):ne.current(D,V),z.current={cols:D,rows:V},j.current={cols:D,rows:V,at:Date.now()},!0)},[d,r,e,c,Z,t,l]),p=n.useCallback((u="resize",A={})=>{const{immediate:Y=!1,force:H=!1}=A;F.current!==null&&(window.clearTimeout(F.current),F.current=null),C.current!==null&&(cancelAnimationFrame(C.current),C.current=null);const D=()=>{C.current=requestAnimationFrame(()=>{C.current=null,S(u,H)})};if(Y){D();return}F.current=window.setTimeout(()=>{F.current=null,D()},150)},[S]),k=n.useCallback(()=>{for(const u of y.current)window.clearTimeout(u);y.current=[]},[]),R=n.useCallback(()=>{var A;k(),p("sync",{immediate:!0,force:!0});const u=window.setTimeout(()=>{p("sync",{immediate:!0,force:!0})},60);y.current.push(u),typeof document<"u"&&"fonts"in document&&((A=document.fonts)!=null&&A.ready)&&document.fonts.ready.then(()=>{p("sync",{immediate:!0,force:!0})}).catch(()=>{})},[k,p]);n.useEffect(()=>{let u=null;const A=()=>{u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=null,p("resize")})};return window.addEventListener("resize",A),()=>{window.removeEventListener("resize",A),u!==null&&cancelAnimationFrame(u)}},[p]),n.useEffect(()=>{const u=()=>{var re;const D=U.current,V=Z();if(!D||!V)return;if(!Bn({currentSize:{cols:Math.max(2,D.cols),rows:Math.max(2,D.rows)},containerSize:V})){(re=D.refresh)==null||re.call(D);return}p("sync",{force:!0})},A=()=>{if(document.visibilityState!=="visible"){ce.current=!0;return}ce.current&&(ce.current=!1,u())},Y=()=>{ce.current=!0},H=()=>{ce.current&&(ce.current=!1,u())};return document.addEventListener("visibilitychange",A),window.addEventListener("blur",Y),window.addEventListener("focus",H),()=>{document.removeEventListener("visibilitychange",A),window.removeEventListener("blur",Y),window.removeEventListener("focus",H)}},[Z,p]),n.useEffect(()=>()=>{k(),F.current!==null&&window.clearTimeout(F.current),C.current!==null&&cancelAnimationFrame(C.current)},[k]);const _=n.useCallback(u=>{ue.current=u},[]),G=n.useCallback(u=>{U.current=u},[]);return{scheduleResize:p,runPostSelectResize:R,clearPostSelectResizeTimers:k,setFitAddon:_,setTerminal:G,lastReportedSize:z,pendingLocalSize:j,suppressLocalResizeUntil:i}}const Hn=1e4,Ve="tmex:terminal-mode-cache";function Wn(e,t){try{const r=sessionStorage.getItem(Ve);return r?JSON.parse(r)[`${e}:${t}`]??null:null}catch{return null}}function On(e,t,r){try{const c=sessionStorage.getItem(Ve),l=c?JSON.parse(c):{},m=`${e}:${t}`;r?l[m]=r:delete l[m],sessionStorage.setItem(Ve,JSON.stringify(l))}catch{}}function Xn(){return{mouseX10:!1,mouseNormal:!0,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1}}function qn(e,t){if(!t)return e?{...e,mouseX10:!1,mouseNormal:!1,mouseButton:!1,mouseAny:!1,mouseUtf8:!1,mouseSgrPixels:!1,mouseUrxvt:!1,altScreen1047:!1,altScreen1049:!1}:null;const r=Xn();if(!e)return r;const c=e.mouseNormal||e.mouseButton||e.mouseAny;return{...e,mouseX10:!1,mouseUtf8:!1,mouseSgr:!0,mouseSgrPixels:!1,mouseUrxvt:!1,altScroll:!0,altScreen1047:!1,altScreen1049:!1,mouseNormal:c?e.mouseNormal:r.mouseNormal}}function Yn(e){var r;const t=globalThis;t.__tmexE2eXterm=e,t.__tmexE2eTerminal=e,t.__tmexE2eTerminalEngine=ht,t.__tmexE2eTerminalRenderer=((r=e.getRendererKind)==null?void 0:r.call(e))??null}function Un(e){if(!e)return;const t=globalThis;t.__tmexE2eTerminal!==e&&t.__tmexE2eXterm!==e||(t.__tmexE2eXterm=null,t.__tmexE2eTerminal=null,t.__tmexE2eTerminalEngine=null,t.__tmexE2eTerminalRenderer=null,t.__tmexE2eTerminalSelectionText=null)}const nt=n.forwardRef(({deviceId:e,paneId:t,theme:r,inputMode:c,deviceConnected:l,isSelectionInvalid:m,sizingMode:v="report",autoFocus:b=!0,onResize:C,onSync:F,children:z},j)=>{const[i,y]=n.useState(null),[ue,U]=n.useState(!1),M=O(f=>f.sendInput),ce=ge(f=>f.terminalFontId),ne=ge(f=>f.terminalFontSize),me=ge(f=>f.terminalLineHeight),{t:Z}=Pe(),d=n.useMemo(()=>{switch(r){case"light":return lt;default:return at}},[r]),S=n.useRef(null),p=n.useRef(null),k=n.useRef(null),R=n.useRef(e),_=n.useRef(t),G=n.useRef(e),u=n.useRef(t),A=n.useRef(l&&!m),Y=n.useRef(c),H=n.useRef(d),D=n.useRef(!1),V=n.useRef(!1),de=n.useRef(null),re=n.useRef(!1),we=n.useCallback((f,x,L)=>{!(f!=null&&f.exportModeSnapshot)||!x||!L||On(x,L,f.exportModeSnapshot())},[]),J=n.useCallback(()=>i,[i]);zn(S,J),n.useEffect(()=>{R.current=e,_.current=t,V.current=!1},[e,t]),n.useEffect(()=>{A.current=l&&!m},[l,m]),n.useEffect(()=>{Y.current=c},[c]),n.useEffect(()=>{H.current=d},[d]);const Q=n.useCallback(f=>{if(!f||c!=="direct"||!A.current)return;const x=R.current,L=_.current;!x||!L||M(x,L,f,!1)},[c,M]),{pendingLocalSize:ee,scheduleResize:E,runPostSelectResize:a,setFitAddon:h,setTerminal:N}=Fn({deviceId:e,paneId:t,deviceConnected:l,isSelectionInvalid:m,sizingMode:v,onResize:C,onSync:F,getContainerRect:()=>{const f=S.current;if(!f)return null;const x=f.getBoundingClientRect();return{width:x.width,height:x.height}}});n.useEffect(()=>{let f=!1,x=null;return(async()=>{if(await Mt(ce,ne),f)return;const L=await an({fontFamily:Pt(ce),fontSize:ne,lineHeight:me,scrollback:Hn,theme:H.current,disableStdin:Y.current==="editor"});if(f){L.dispose();return}x=L,p.current&&L.open(p.current),y(L)})(),()=>{f=!0,y(null),Un(x),x==null||x.dispose()}},[ce,ne,me]),n.useEffect(()=>{!i||!b||Yn(i)},[i,b]),n.useEffect(()=>{!i||!("setTheme"in i)||i.setTheme(d)},[i,d]),n.useEffect(()=>{!i||!("setDisableStdin"in i)||i.setDisableStdin(c==="editor")},[i,c]),n.useEffect(()=>{if(!(i!=null&&i.getCursorViewportRect))return;const f=()=>{var x;return((x=i.getCursorViewportRect)==null?void 0:x.call(i))??null};return Lt(f),()=>kt(f)},[i]),n.useEffect(()=>{!i||c!=="direct"||!b||window.innerWidth<768||"ontouchstart"in window||i.focus()},[i,c,b]);const T=n.useMemo(()=>i?{onReset:()=>{we(i,G.current,u.current),re.current=!0,i.reset(),D.current=!1,a()},onApplyHistory:(f,x)=>{var P;const L=qn(Wn(R.current,_.current),x);L&&((P=i.restoreModeSnapshot)==null||P.call(i,L));const $=x?kn(f):wt(f);V.current=!0,i.write($),re.current=!1,G.current=R.current,u.current=_.current,we(i,R.current,_.current)},onOutput:f=>{const x=In(f,D.current);D.current=x.endedWithCR,i.write(x.normalized),V.current&&(i.buffer.active.baseY<=1&&i.scrollToTop(),V.current=!1),G.current=R.current,u.current=_.current,we(i,R.current,_.current)}}:null,[i,we,a]);n.useEffect(()=>{i?de.current!==i&&(D.current=!1,G.current=R.current,u.current=_.current,de.current=i):de.current=null},[i]),n.useEffect(()=>{if(!(!i||!e||!t))return()=>{if(re.current){re.current=!1;return}we(i,G.current,u.current)}},[e,i,t,we]),n.useEffect(()=>{if(!(!T||!e||!t))return It(e,t,T)},[T,e,t]),n.useEffect(()=>{if(!i){k.current=null,h(null),N(null);return}const f=new ln;return i.loadAddon(f),k.current=f,h(f),N(i),a(),()=>{try{f.dispose()}finally{k.current=null,h(null),N(null)}}},[i,a,h,N]),n.useEffect(()=>{const f=S.current;if(!f)return;let x=null;const L=new ResizeObserver(()=>{x!==null&&cancelAnimationFrame(x),x=requestAnimationFrame(()=>{x=null,E("resize")})});return L.observe(f),()=>{L.disconnect(),x!==null&&cancelAnimationFrame(x)}},[E]),n.useEffect(()=>{if(!i||!e||!t)return;const f=i.onData(x=>{!l||m||Q(x)});return i.attachCustomKeyEventHandler(x=>!l||m||x.type!=="keydown"||c!=="direct"?!0:x.shiftKey&&x.key==="Enter"?(x.preventDefault(),Q("\x1B[13;2u"),!1):!0),()=>{f.dispose(),i.attachCustomKeyEventHandler(()=>!0)}},[i,l,m,c,Q,e,t]),n.useEffect(()=>{if(!(i!=null&&i.onLinkActivated))return;const f=i.onLinkActivated(x=>{window.open(x,"_blank","noopener,noreferrer")});return()=>f.dispose()},[i]),n.useEffect(()=>{if(!(i!=null&&i.onSelectionChange)){U(!1);return}const f=i.onSelectionChange(x=>{U(!!x)});return()=>{f.dispose(),U(!1)}},[i]);const W=n.useCallback(()=>{var x;if(!i)return;const f=((x=i.getSelection)==null?void 0:x.call(i))??"";f&&wn(f).then(()=>{Me.success(Z("terminal.copied"))}).catch(()=>{Me.error(Z("terminal.copyFailed"))}).finally(()=>{var L;(L=i.clearSelection)==null||L.call(i),i.focus()})},[i,Z]),se=n.useCallback(()=>{var x;if(!i)return;((x=navigator.clipboard)!=null&&x.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(L=>{var $;L&&i.paste(L),($=i.clearSelection)==null||$.call(i),i.focus()}).catch(()=>{Me.error(Z("terminal.pasteFailed"))})},[i,Z]),K=n.useCallback(()=>{var f;(f=i==null?void 0:i.clearSelection)==null||f.call(i),i==null||i.focus()},[i]);return n.useImperativeHandle(j,()=>({write:f=>i==null?void 0:i.write(f),reset:()=>{i==null||i.reset(),D.current=!1},scrollToBottom:()=>i==null?void 0:i.scrollToBottom(),resize:(f,x)=>i==null?void 0:i.resize(f,x),getTerminal:()=>i??null,getSize:()=>i?{cols:Math.max(2,i.cols),rows:Math.max(2,i.rows)}:null,runPostSelectResize:()=>a(),scheduleResize:(f,x)=>E(f,x),calculateSizeFromContainer:()=>{var Se,B,oe,X,q,xe,ie,he,pe,ye,ke,Ae,ae,Ie,je,Le;const f=S.current,x=i,L=k.current;if(!f||!x)return null;const $=f.getBoundingClientRect();if($.width===0||$.height===0)return null;const P=x._core;let fe;if(L)try{const Te=L.proposeDimensions();if(Te)fe=Math.max(2,Te.cols);else{const De=((X=(oe=(B=(Se=P==null?void 0:P._renderService)==null?void 0:Se.dimensions)==null?void 0:B.css)==null?void 0:oe.cell)==null?void 0:X.width)??9;fe=Math.max(2,Math.floor($.width/De))}}catch{const Te=((he=(ie=(xe=(q=P==null?void 0:P._renderService)==null?void 0:q.dimensions)==null?void 0:xe.css)==null?void 0:ie.cell)==null?void 0:he.width)??9;fe=Math.max(2,Math.floor($.width/Te))}else{const Te=((Ae=(ke=(ye=(pe=P==null?void 0:P._renderService)==null?void 0:pe.dimensions)==null?void 0:ye.css)==null?void 0:ke.cell)==null?void 0:Ae.width)??9;fe=Math.max(2,Math.floor($.width/Te))}const Ee=((Le=(je=(Ie=(ae=P==null?void 0:P._renderService)==null?void 0:ae.dimensions)==null?void 0:Ie.css)==null?void 0:je.cell)==null?void 0:Le.height)??17,be=Math.max(2,Math.floor($.height/Ee));return{cols:fe,rows:be}},getPendingLocalSize:()=>ee.current,getCellSize:()=>{var L,$,P;const f=i==null?void 0:i._core,x=(P=($=(L=f==null?void 0:f._renderService)==null?void 0:L.dimensions)==null?void 0:$.css)==null?void 0:P.cell;return!(x!=null&&x.width)||!(x!=null&&x.height)?null:{width:x.width,height:x.height}}}),[i,ee,a,E]),o.jsxs("div",{className:"flex h-full w-full flex-col",style:{backgroundColor:d.background},"data-terminal-engine":ht,children:[o.jsxs("div",{ref:S,className:"relative min-h-0 w-full flex-1",children:[o.jsx("div",{ref:p,className:"absolute inset-0"}),o.jsx(Mn,{visible:ue,canPaste:c==="direct"&&l&&!m,onCopy:W,onPaste:se,onDismiss:K})]}),z]})});nt.displayName="Terminal";function Vn({window:e,currentPaneId:t,onSelectPane:r}){const{t:c}=Pe();return o.jsxs(At,{children:[o.jsxs(Dt,{"data-testid":"pane-switcher-button","aria-label":c("window.switchPane"),title:c("window.switchPane"),className:"relative inline-flex size-7 items-center justify-center rounded-[min(var(--radius-md),12px)] text-sm hover:bg-muted hover:text-foreground data-popup-open:bg-muted",children:[o.jsx(Sn,{className:"h-4 w-4"}),o.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-primary px-0.5 text-[9px] font-medium leading-none text-primary-foreground",children:e.panes.length})]}),o.jsx(_t,{align:"end",backdrop:!0,className:"min-w-56 max-w-[80vw]","data-testid":"pane-switcher-menu",children:e.panes.map(l=>{const m=l.id===t;return o.jsxs(zt,{"data-testid":"pane-switcher-item","data-pane-id":l.id,className:`py-2 [@media(any-pointer:coarse)]:py-2.5 ${m?"bg-primary/10 text-primary":l.active?"bg-accent text-accent-foreground":""}`,onClick:()=>{m||r(l.id)},children:[o.jsxs("span",{className:"min-w-0 flex-1",children:[o.jsx("span",{className:"font-mono text-[11px] leading-tight font-medium line-clamp-2 [overflow-wrap:break-word]",children:l.customName||l.title||c("window.pane")}),l.currentCommand&&o.jsx("span",{className:"font-mono text-[10.5px] leading-tight text-muted-foreground line-clamp-1 break-all",children:l.currentPath?`${l.currentCommand}@${l.currentPath}`:l.currentCommand})]}),m&&o.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-primary"})]},l.id)})})]})}const He=2;function We(e){if(e.type==="leaf")return He;if(e.type==="row"){let r=e.children.length-1;for(const c of e.children)r+=We(c);return r}let t=He;for(const r of e.children)t=Math.max(t,We(r));return t}function Oe(e){if(e.type==="leaf")return He;if(e.type==="column"){let r=e.children.length-1;for(const c of e.children)r+=Oe(c);return r}let t=He;for(const r of e.children)t=Math.max(t,Oe(r));return t}function Ke(e){return e.type==="leaf"?e:e.type==="row"?Ke(e.children[e.children.length-1]):Ke(e.children[0])}function Ge(e){return e.type==="leaf"?e:e.type==="column"?Ge(e.children[e.children.length-1]):Ge(e.children[0])}function Kn(e,t){const r=[],c=[],l=m=>{if(m.type==="leaf"){r.push({paneId:Ye(m),cols:m.width,rows:m.height,rect:{left:m.x*t.width,top:m.y*t.height,width:m.width*t.width,height:m.height*t.height}});return}for(let v=0;v<m.children.length;v+=1){const b=m.children[v];if(l(b),v===m.children.length-1)continue;const C=m.children[v+1];if(m.type==="row"){const F=Ke(b);c.push({axis:"x",rect:{left:(b.x+b.width)*t.width,top:m.y*t.height,width:t.width,height:m.height*t.height},edgeLeafPaneId:Ye(F),edgeLeafSizeCells:F.width,minDeltaCells:-(b.width-We(b)),maxDeltaCells:C.width-We(C)})}else{const F=Ge(b);c.push({axis:"y",rect:{left:m.x*t.width,top:(b.y+b.height)*t.height,width:m.width*t.width,height:t.height},edgeLeafPaneId:Ye(F),edgeLeafSizeCells:F.height,minDeltaCells:-(b.height-Oe(b)),maxDeltaCells:C.height-Oe(C)})}}};return l(e),{panes:r,gutters:c}}function Qe(e){if(e.type==="leaf")return 1;if(e.type==="column"){let r=0;for(const c of e.children)r+=Qe(c);return r}let t=1;for(const r of e.children)t=Math.max(t,Qe(r));return t}function Je(e){if(e.type==="leaf")return 1;if(e.type==="row"){let r=0;for(const c of e.children)r+=Je(c);return r}let t=1;for(const r of e.children)t=Math.max(t,Je(r));return t}function Gn(e,t){const r=Math.min(1,Math.max(0,e)),c=Math.min(1,Math.max(0,t)),l=[["left",r],["right",1-r],["top",c],["bottom",1-c]];return l.sort((m,v)=>m[1]-v[1]),l[0][0]}function Qn(e,t,r){const c=e.axis==="x"?r.width:r.height;if(c<=0)return null;const l=Math.round(t/c),m=Math.min(e.maxDeltaCells,Math.max(e.minDeltaCells,l));return m===0?null:{deltaCells:m,targetSizeCells:e.edgeLeafSizeCells+m}}const it=150,Jn=200,Zn=15,er=46,tr=38,nr=12,rr=6;function ct(e){var t,r;return((t=e==null?void 0:e.customName)==null?void 0:t.trim())||((r=e==null?void 0:e.title)==null?void 0:r.trim())||"Pane"}function sr(e){var c,l;const t=(c=e==null?void 0:e.currentCommand)==null?void 0:c.trim();if(!t)return null;const r=(l=e==null?void 0:e.currentPath)==null?void 0:l.trim();return r?`${t}@${r}`:t}const or={left:"left-0 top-0 bottom-0 w-1/2",right:"right-0 top-0 bottom-0 w-1/2",top:"left-0 right-0 top-0 h-1/2",bottom:"left-0 right-0 bottom-0 h-1/2"};function ir({deviceId:e,window:t,focusedPaneId:r,theme:c,inputMode:l,deviceConnected:m,focusedTerminalRef:v,onUserSelectPane:b,onWindowResize:C}){var Q,ee,E;const F=n.useRef(null),z=n.useRef(new Map),[j,i]=n.useState(null),[y,ue]=n.useState(null),{t:U}=Pe(),M=O(a=>a.subscribePanes),ce=O(a=>a.fetchPaneHistory),ne=O(a=>a.resizePaneInWindow),me=O(a=>a.movePane),Z=O(a=>a.breakPane),d=O(a=>a.closePane),S=n.useMemo(()=>{const a=new Map;for(const h of t.panes)a.set(h.id,h);return a},[t.panes]),p=n.useMemo(()=>t.layout?vn(t.layout):null,[t.layout]),k=n.useMemo(()=>p?Kn(p.root,{width:1,height:1}):null,[p]),R=(p==null?void 0:p.root.width)??1,_=(p==null?void 0:p.root.height)??1,G=t.panes.map(a=>a.id).join(",");n.useEffect(()=>(M(e,G?G.split(","):[]),()=>{M(e,[])}),[e,G,M]);const u=n.useRef({key:"",fetched:new Set});n.useEffect(()=>{const a=`${e}:${t.id}`;u.current.key!==a&&(u.current={key:a,fetched:new Set});for(const h of G?G.split(","):[])u.current.fetched.has(h)||(u.current.fetched.add(h),h!==r&&ce(e,h))},[e,t.id,G,r,ce]),n.useEffect(()=>{var a;if(k)for(const h of k.panes)(a=z.current.get(h.paneId))==null||a.resize(h.cols,h.rows)},[k]),n.useEffect(()=>{var h,N;l!=="direct"||window.innerWidth<768||"ontouchstart"in window||(N=(h=z.current.get(r))==null?void 0:h.getTerminal())==null||N.focus()},[r,l]);const A=n.useCallback(()=>{var a;for(const h of[r,...z.current.keys()]){const N=(a=z.current.get(h))==null?void 0:a.getCellSize();if(N)return N}return null},[r]),Y=n.useMemo(()=>p?Qe(p.root):1,[p]),H=n.useMemo(()=>p?Je(p.root):1,[p]),D=n.useCallback(()=>{const a=F.current;if(!a)return!1;const h=a.getBoundingClientRect();if(h.width<1||h.height<1)return!1;const N=A();if(!N)return!1;const T=Math.max(0,h.height-Y*er),W=Math.max(0,h.width-H*nr),se=Math.max(2,Math.floor(W/N.width)),K=Math.max(2,Math.floor(T/N.height));return C(se,K),!0},[A,C,Y,H]),V=n.useRef(D);n.useEffect(()=>{V.current=D},[D]),n.useEffect(()=>{const a=F.current;if(!a)return;let h=null,N=null,T=0;const W=()=>{if(V.current()){T=0;return}T<Zn&&(T+=1,N=setTimeout(W,Jn))},se=new ResizeObserver(()=>{h&&clearTimeout(h),h=setTimeout(W,it)});return se.observe(a),()=>{se.disconnect(),h&&clearTimeout(h),N&&clearTimeout(N)}},[]),n.useEffect(()=>{const a=setTimeout(()=>{V.current()},it);return()=>clearTimeout(a)},[Y,H]);const de=n.useCallback((a,h,N)=>{N.preventDefault();const T=F.current;if(!T)return;const W=N.clientX,se=N.clientY,K=N.currentTarget;K.setPointerCapture(N.pointerId),i({gutterIndex:a,deltaPx:0});const f=P=>{const fe=h.axis==="x"?P.clientX-W:P.clientY-se;i({gutterIndex:a,deltaPx:fe})},x=(P,fe)=>{if(K.removeEventListener("pointermove",f),K.removeEventListener("pointerup",L),K.removeEventListener("pointercancel",$),i(null),!fe)return;const Ee=T.getBoundingClientRect(),be=h.axis==="x"?Ee.width/Math.max(1,R):Ee.height/Math.max(1,_),Se=h.axis==="x"?P.clientX-W:P.clientY-se,B=Qn(h,Se,{width:h.axis==="x"?be:1,height:h.axis==="y"?be:1});B&&ne(e,h.edgeLeafPaneId,h.axis==="x"?{cols:B.targetSizeCells}:{rows:B.targetSizeCells})},L=P=>x(P,!0),$=P=>x(P,!1);K.addEventListener("pointermove",f),K.addEventListener("pointerup",L),K.addEventListener("pointercancel",$)},[e,ne,R,_]),re=n.useCallback((a,h)=>{const N=F.current,T=k;if(!N||!T)return;h.preventDefault();const W=h.clientX,se=h.clientY,K=h.currentTarget;K.setPointerCapture(h.pointerId);let f=!1;const x=(B,oe)=>{const X=N.getBoundingClientRect();if(X.width<1||X.height<1)return null;const q=(B-X.left)/X.width*Math.max(1,R),xe=(oe-X.top)/X.height*Math.max(1,_);for(const ie of T.panes)if(q>=ie.rect.left&&q<=ie.rect.left+ie.rect.width&&xe>=ie.rect.top&&xe<=ie.rect.top+ie.rect.height){const he=(q-ie.rect.left)/Math.max(1e-6,ie.rect.width),pe=(xe-ie.rect.top)/Math.max(1e-6,ie.rect.height);return{paneId:ie.paneId,position:Gn(he,pe)}}return null},L=(B,oe,X)=>B>=X.left&&B<=X.right&&oe>=X.top&&oe<=X.bottom,$=(B,oe)=>{for(const X of Array.from(document.querySelectorAll('[data-testid^="window-item-"]'))){const q=X.getBoundingClientRect();if(q.width<1||!L(B,oe,q))continue;const xe=(X.getAttribute("data-testid")??"").replace("window-item-","");return!xe||xe===t.id?null:{type:"window",windowId:xe,rect:{left:q.left,top:q.top,width:q.width,height:q.height}}}for(const X of Array.from(document.querySelectorAll('[data-slot="sidebar"]'))){const q=X.getBoundingClientRect();if(!(q.width<1||!L(B,oe,q)))return{type:"break",rect:{left:q.left,top:q.top,width:q.width,height:q.height}}}return null},P=(B,oe)=>{const X=x(B,oe);return X?X.paneId===a?null:{type:"pane",...X}:$(B,oe)},fe=B=>{const oe=Math.hypot(B.clientX-W,B.clientY-se);!f&&oe<rr||(f=!0,ue({srcPaneId:a,active:!0,pointerX:B.clientX,pointerY:B.clientY,target:P(B.clientX,B.clientY)}))},Ee=(B,oe)=>{var q,xe;if(K.removeEventListener("pointermove",fe),K.removeEventListener("pointerup",be),K.removeEventListener("pointercancel",Se),ue(null),!oe||!f)return;const X=P(B.clientX,B.clientY);if(X){if(X.type==="pane"){me(e,a,X.paneId,X.position);return}if(X.type==="window"){const ie=(xe=(q=O.getState().snapshots[e])==null?void 0:q.session)==null?void 0:xe.windows,he=ie==null?void 0:ie.find(ye=>ye.id===X.windowId),pe=(he==null?void 0:he.panes.find(ye=>ye.active))??(he==null?void 0:he.panes[0]);pe&&me(e,a,pe.id,"right");return}Z(e,a)}},be=B=>Ee(B,!0),Se=B=>Ee(B,!1);K.addEventListener("pointermove",fe),K.addEventListener("pointerup",be),K.addEventListener("pointercancel",Se)},[e,k,me,Z,R,_,t.id]),we=n.useCallback(a=>h=>{h?z.current.set(a,h):z.current.delete(a),a===r&&v(h)},[r,v]);if(n.useEffect(()=>{v(z.current.get(r)??null)},[r,v]),!k)return null;const J=(a,h)=>`${a/Math.max(1,h)*100}%`;return o.jsxs("div",{ref:F,className:"relative h-full w-full min-h-0 min-w-0","data-testid":"split-terminal-area",children:[k.panes.map(a=>{var K;const h=a.paneId===r,N=S.get(a.paneId),T=sr(N),W=(y==null?void 0:y.active)&&y.srcPaneId===a.paneId,se=y!=null&&y.active&&((K=y.target)==null?void 0:K.type)==="pane"&&y.target.paneId===a.paneId?y.target.position:null;return o.jsxs("div",{className:`absolute flex flex-col ${W?"opacity-60":""}`,"data-testid":"split-pane","data-pane-id":a.paneId,"data-focused":h||void 0,style:{left:J(a.rect.left,R),top:J(a.rect.top,_),width:J(a.rect.width,R),height:J(a.rect.height,_)},onPointerDownCapture:()=>{h||b(t.id,a.paneId)},children:[o.jsx("div",{className:"shrink-0 px-1.5 pt-1.5 pb-2",style:{height:tr},children:o.jsxs("div",{"data-testid":"split-pane-titlebar","data-active":h||void 0,className:`flex h-6 cursor-grab touch-none select-none items-center gap-1.5 rounded-md px-2.5 transition-colors active:cursor-grabbing ${h?"bg-foreground/10":"bg-foreground/[0.04]"}`,onPointerDown:f=>re(a.paneId,f),children:[o.jsx("span",{className:`shrink-0 truncate font-mono text-[10.5px] leading-none ${h?"text-foreground/90":"text-foreground/50"}`,children:ct(N)}),T&&o.jsx("span",{className:`min-w-0 flex-1 truncate font-mono text-[10px] leading-none ${h?"text-muted-foreground":"text-muted-foreground/60"}`,children:T}),o.jsx("button",{type:"button","data-testid":`split-pane-close-${a.paneId}`,"aria-label":U("window.closePane"),title:U("window.closePane"),className:"ml-auto flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground/50 hover:bg-foreground/10 hover:text-foreground",onPointerDown:f=>f.stopPropagation(),onClick:f=>{f.stopPropagation(),d(e,a.paneId)},children:o.jsx("span",{className:"text-xs leading-none",children:"×"})})]})}),o.jsx("div",{className:"relative min-h-0 flex-1 px-1.5 pb-2",children:o.jsx(nt,{ref:we(a.paneId),deviceId:e,paneId:a.paneId,theme:c,inputMode:l,deviceConnected:m,isSelectionInvalid:!1,sizingMode:"follow",autoFocus:h,onResize:()=>{},onSync:()=>{}},`${e}:${a.paneId}`)}),se&&o.jsx("div",{"data-testid":"split-pane-drop-preview","data-position":se,className:`pointer-events-none absolute z-30 rounded-sm bg-primary/20 ring-1 ring-inset ring-primary/60 ${or[se]}`})]},a.paneId)}),(j!==null||(y==null?void 0:y.active))&&o.jsx("div",{"data-testid":"split-drag-shield",className:`absolute inset-0 z-30 ${j!==null?((Q=k.gutters[j.gutterIndex])==null?void 0:Q.axis)==="x"?"cursor-col-resize":"cursor-row-resize":"cursor-grabbing"}`}),(y==null?void 0:y.active)&&y.target&&y.target.type!=="pane"&&o.jsx("div",{"data-testid":"split-pane-sidebar-drop","data-drop-type":y.target.type,className:"pointer-events-none fixed z-40 rounded-lg bg-primary/15 ring-1 ring-inset ring-primary/50",style:{left:y.target.rect.left,top:y.target.rect.top,width:y.target.rect.width,height:y.target.rect.height}}),(y==null?void 0:y.active)&&o.jsxs("div",{className:"pointer-events-none fixed z-50 rounded border border-primary/40 bg-popover/95 px-2 py-1 font-mono text-[10.5px] text-popover-foreground shadow-md",style:{left:y.pointerX+12,top:y.pointerY+12},children:[o.jsx("div",{children:ct(S.get(y.srcPaneId))}),((ee=y.target)==null?void 0:ee.type)==="window"&&o.jsx("div",{className:"text-[9.5px] text-muted-foreground",children:U("window.moveToWindow")}),((E=y.target)==null?void 0:E.type)==="break"&&o.jsx("div",{className:"text-[9.5px] text-muted-foreground",children:U("window.breakToWindow")})]}),k.gutters.map((a,h)=>{const N=a.axis==="x",T=(j==null?void 0:j.gutterIndex)===h;return o.jsxs("div",{className:"absolute z-20",style:{left:J(a.rect.left,R),top:J(a.rect.top,_),width:J(N?1:a.rect.width,R),height:J(N?a.rect.height:1,_)},children:[o.jsx("div",{"data-testid":"split-gutter","data-axis":a.axis,className:`absolute touch-none select-none ${N?"-inset-x-1 inset-y-0 cursor-col-resize":"inset-x-0 -inset-y-1 cursor-row-resize"}`,onPointerDown:W=>de(h,a,W),children:o.jsx("div",{className:`absolute bg-foreground/[0.08] transition-colors hover:bg-primary/50 ${N?"inset-y-0 left-1/2 w-px -translate-x-1/2":"inset-x-0 top-1/2 h-px -translate-y-1/2"} ${T?"bg-primary":""}`})}),T&&j&&o.jsx("div",{className:"pointer-events-none absolute bg-primary/70",style:N?{top:0,bottom:0,width:2,left:`calc(50% + ${j.deltaPx}px)`}:{left:0,right:0,height:2,top:`calc(50% + ${j.deltaPx}px)`}})]},`${t.layout??""}:${h}`)})]})}const cr=1200,ar=2e3;function Ne(e,t){return!e||!t?!1:e.windowId===t.windowId&&e.paneId===t.paneId}function pt(e,t){const r=e.filter(c=>t-c.at<cr);return r.length===0?null:r.reduce((c,l)=>l.at>c.at?l:c)}function Fe(e,t=Date.now()){return!e||t-e.at>ar?null:e}function lr(e){const t=e.now??Date.now(),r=pt(e.recentSelectRequests,t),c=m=>!!(m&&m.paneId===e.activePaneFromEvent.paneId&&m.windowId!==e.activePaneFromEvent.windowId);if(r&&!Ne(r,e.activePaneFromEvent)&&!c(r)||Ne(e.currentRoute,e.activePaneFromEvent)||Ne(e.lastHandledActive,e.activePaneFromEvent))return!0;const l=Fe(e.pendingUserSelection,t);return!!(l&&!Ne(l,e.activePaneFromEvent)&&!c(l))}function ur(e){const t=e.now??Date.now(),r=pt(e.recentSelectRequests,t),c=Fe(e.pendingUserSelection,t);return!!(c&&!Ne(c,e.snapshotActive)||r&&!Ne(r,e.snapshotActive))}function dr(e){const t=e.now??Date.now(),r=Fe(e.pendingUserSelection,t);return!(r&&Ne(r,e.routeTarget)||e.snapshotActive&&Ne(e.snapshotActive,e.routeTarget))}const Ue=n.memo(function({onActivate:t,disabled:r}){const{data:c}=tt({queryKey:hn,queryFn:fn,staleTime:6e4}),l=(c==null?void 0:c.items)??[];return l.length===0?null:o.jsx("div",{className:"terminal-shortcuts-strip","data-testid":"terminal-shortcuts-strip",children:o.jsx(mn,{items:l,useIcons:(c==null?void 0:c.useIcons)??!1,onActivate:t,disabled:r,preventFocusSteal:!0,rowTestId:"terminal-shortcuts-row",idPrefix:"terminal-shortcut"})})});function gr(){var st;const{t:e}=Pe(),{deviceId:t,windowId:r,paneId:c}=Ze(),l=ut(),m=n.useRef(null),v=n.useRef(null),b=n.useRef(null),C=n.useRef(null),F=n.useRef(!1),z=n.useRef(!1),j=n.useRef(null),i=O(s=>s.selectPane),y=O(s=>s.focusPane),ue=O(s=>t?s.snapshots[t]:void 0),U=O(s=>{var g;return t?(g=s.deviceErrors)==null?void 0:g[t]:void 0}),M=O(s=>{var g;return t?((g=s.deviceConnected)==null?void 0:g[t])??!1:!1}),ne=!!O(s=>{var g;return t?(g=s.deviceReconnecting)==null?void 0:g[t]:void 0}),me=O(s=>t?s.connectedDevices.has(t):!1),Z=dt(s=>{var g;return((g=s.settings)==null?void 0:g.siteName)??"tmex"}),d=n.useMemo(()=>et(c),[c]),S=n.useMemo(()=>t&&d?`${t}:${d}`:null,[t,d]),[p,k]=n.useState(!1),[R,_]=n.useState(""),G=n.useRef(!1),u=!M||!d,[A,Y]=n.useState(!1),H=ge(s=>s.inputMode),D=ge(s=>s.theme),V=ge(s=>s.editorSendWithEnter),de=ge(s=>s.setEditorSendWithEnter),re=ge(s=>s.addEditorHistory),we=ge(s=>s.setEditorDraft),J=ge(s=>s.removeEditorDraft),Q=ge(s=>S?s.editorDrafts[S]??"":""),ee=n.useMemo(()=>$t(),[]),E=(st=ue==null?void 0:ue.session)==null?void 0:st.windows,a=D==="light"?lt:at,{data:h}=tt({queryKey:["devices"],queryFn:async()=>{const s=await fetch("/api/devices");if(!s.ok)throw new Error("Failed to fetch devices");return s.json()},throwOnError:!1}),N=n.useMemo(()=>{if(t)return h==null?void 0:h.devices.find(s=>s.id===t)},[t,h==null?void 0:h.devices]),T=n.useMemo(()=>{if(!(!r||!E))return E.find(s=>s.id===r)},[r,E]),W=n.useMemo(()=>{if(!(!d||!T))return T.panes.find(s=>s.id===d)},[d,T]),se=!!E,x=se&&!!r&&!T?e("terminal.windowClosed"):se&&!!r&&!!d&&!!T&&!W?e("terminal.paneClosed"):null,L=!!x,$=!!(M&&d&&!L),P=!!(!p&&T&&T.panes.length>1&&T.layout&&!L),fe=n.useRef(P);n.useEffect(()=>{fe.current=P},[P]);const Ee=n.useMemo(()=>{if(!T||!W)return null;const s=(N==null?void 0:N.name)??t;return ft({paneCustomName:W.customName,paneTitle:W.title,windowName:T.name,windowCustomName:T.customName,deviceName:s})},[N==null?void 0:N.name,t,W,T]),be=n.useMemo(()=>{if(!E||E.length===0)return null;const s=E.find(w=>w.active),g=s==null?void 0:s.panes.find(w=>w.active);return!s||!g?null:{windowId:s.id,paneId:g.id}},[E]),Se=p&&T&&T.panes.length>1?T.id:null,B=n.useRef(Se);n.useEffect(()=>{B.current=Se},[Se]);const oe=n.useCallback((s,g)=>{if(!t||!d)return;const w=B.current;if(w){O.getState().applyStackedLayout(t,w,s,g);return}O.getState().resizePane(t,d,s,g)},[t,d]),X=n.useCallback((s,g)=>{if(!t||!d)return;const w=B.current;if(w){O.getState().applyStackedLayout(t,w,s,g);return}O.getState().syncPaneSize(t,d,s,g)},[t,d]),q=n.useCallback((s,g)=>{var _e;const w=C.current;if(fe.current){const le=(_e=m.current)==null?void 0:_e.getBoundingClientRect(),ze=w==null?void 0:w.getCellSize();return le&&ze&&le.width>0&&le.height>0?{cols:Math.max(2,Math.floor(le.width/ze.width)),rows:Math.max(2,Math.floor(le.height/ze.height))}:void 0}if(s&&E){const le=E.find(ze=>ze.id===s);if(p&&le&&le.panes.length>1)return}const I=(w==null?void 0:w.calculateSizeFromContainer())??(w==null?void 0:w.getSize())??void 0;if(I)return I;if(!s||!g||!E)return;const te=E.find(le=>le.id===s),ve=te==null?void 0:te.panes.find(le=>le.id===g);if(!(!ve||ve.width<=1||ve.height<=1))return{cols:ve.width,rows:ve.height}},[p,E]),xe=n.useCallback((s,g)=>{t&&(j.current={windowId:s,paneId:g,at:Date.now()},l(`/devices/${t}/windows/${s}/panes/${Ce(g)}`,{replace:!0}))},[t,l]),ie=n.useCallback(s=>{C.current=s},[]);n.useEffect(()=>{const s=()=>{k(window.innerWidth<768||"ontouchstart"in window)};return s(),window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]),n.useEffect(()=>{if(!p||!ee||z.current)return;z.current=!0;const s=()=>{window.scrollTo(0,1)},g=window.requestAnimationFrame(s),w=window.setTimeout(s,120),I=window.setTimeout(s,420);return()=>{window.cancelAnimationFrame(g),window.clearTimeout(w),window.clearTimeout(I)}},[ee,p]),n.useEffect(()=>{t&&(F.current=!1,Ie.current=null,je.current=null,j.current=null,he.current=[])},[t]),n.useEffect(()=>{M||(F.current=!1)},[M]),n.useEffect(()=>{if(!t||!M||!r||!E)return;if(E.length===0){l("/devices",{replace:!0});return}const s=E.find(w=>w.id===r);if(!s)return;if(!d){const w=s.panes.find(I=>I.active)??s.panes[0];w&&l(`/devices/${t}/windows/${r}/panes/${Ce(w.id)}`,{replace:!0});return}if(!s.panes.find(w=>w.id===d)){const w=E.find(te=>te.panes.some(ve=>ve.id===d));if(w){l(`/devices/${t}/windows/${w.id}/panes/${Ce(d)}`,{replace:!0});return}const I=s.panes.find(te=>te.active)??s.panes[0];I&&l(`/devices/${t}/windows/${r}/panes/${Ce(I.id)}`,{replace:!0});return}},[t,M,E,r,d,l]),n.useEffect(()=>{if(!t||!M||!E||E.length===0||r&&d||F.current)return;const s=E.find(w=>w.active)??E[0],g=s.panes.find(w=>w.active)??s.panes[0];g&&(F.current=!0,l(`/devices/${t}/windows/${s.id}/panes/${Ce(g.id)}`,{replace:!0}))},[M,t,l,d,r,E]);const he=n.useRef([]),pe=n.useCallback((s,g)=>{const w=Date.now(),I=[...he.current.filter(te=>w-te.at<2e3),{windowId:s,paneId:g,at:w}];he.current=I.slice(-8)},[]),ye=n.useRef(null);n.useEffect(()=>{ye.current=null},[t,d]);const ke=n.useRef(null),Ae=n.useRef(P);n.useEffect(()=>{Ae.current!==P&&(Ae.current=P,ye.current=null,ke.current=null)},[P]),n.useEffect(()=>{if(!t||!r||!d||u||!M)return;const s=`${t}:${r}:${d}`;if(ye.current===s)return;ye.current=s;const g=P&&ke.current===`${t}:${r}`&&!!(T!=null&&T.panes.some(I=>I.id===d));if(pe(r,d),g){y(t,r,d);return}const w=q(r,d);i(t,r,d,w),ke.current=`${t}:${r}`},[M,t,y,q,u,P,pe,d,i,T,r]),n.useEffect(()=>{if(!t||!M||!r||!d)return;const s={windowId:r,paneId:d};dr({routeTarget:s,snapshotActive:be,pendingUserSelection:j.current})&&(j.current={windowId:s.windowId,paneId:s.paneId,at:Date.now()})},[M,t,d,be,r]);const ae=O(s=>t?s.activePaneFromEvent[t]:void 0),Ie=n.useRef(null);n.useEffect(()=>{if(!t||!M||!r||!d||!ae)return;const s=Date.now(),g=Fe(j.current,s);if(j.current=g,lr({now:s,pendingUserSelection:g,activePaneFromEvent:ae,currentRoute:{windowId:r,paneId:d},recentSelectRequests:he.current,lastHandledActive:Ie.current}))return;if(Ie.current={...ae},g&&g.windowId===ae.windowId&&g.paneId===ae.paneId&&(j.current=null),!(fe.current&&ae.windowId===r)){const I=q(ae.windowId,ae.paneId);pe(ae.windowId,ae.paneId),i(t,ae.windowId,ae.paneId,I)}l(`/devices/${t}/windows/${ae.windowId}/panes/${Ce(ae.paneId)}`,{replace:!0})},[t,M,r,d,ae,pe,q,i,l]);const je=n.useRef(null);n.useEffect(()=>{if(!t||!M||!E||E.length===0)return;const s=he.current,g=E.find(le=>le.active);if(!g)return;const w=g.panes.find(le=>le.active);if(!w)return;const I={windowId:g.id,paneId:w.id},te=Date.now(),ve=Fe(j.current,te);if(j.current=ve,ur({now:te,pendingUserSelection:ve,snapshotActive:I,recentSelectRequests:s})||je.current&&je.current.windowId===I.windowId&&je.current.paneId===I.paneId||(je.current={...I},ve&&ve.windowId===I.windowId&&ve.paneId===I.paneId&&(j.current=null),r===I.windowId&&d===I.paneId))return;if(!(fe.current&&I.windowId===r)){const le=q(I.windowId,I.paneId);pe(I.windowId,I.paneId),i(t,I.windowId,I.paneId,le)}l(`/devices/${t}/windows/${I.windowId}/panes/${Ce(I.paneId)}`,{replace:!0})},[t,M,E,r,d,pe,q,i,l]);const Le=O(s=>t?s.pendingCreateWindowAt[t]:void 0);n.useEffect(()=>{if(!t||!M||!Le)return;const s=5e3,g=Date.now()-Le;if(g>s){O.getState().clearPendingCreateWindow(t);return}if(!be){const te=window.setTimeout(()=>{O.getState().clearPendingCreateWindow(t)},s-g);return()=>window.clearTimeout(te)}const w=be;if(r===w.windowId&&d===w.paneId){const te=window.setTimeout(()=>{O.getState().clearPendingCreateWindow(t)},s-g);return()=>window.clearTimeout(te)}j.current={windowId:w.windowId,paneId:w.paneId,at:Date.now()};const I=q(w.windowId,w.paneId);pe(w.windowId,w.paneId),i(t,w.windowId,w.paneId,I),l(`/devices/${t}/windows/${w.windowId}/panes/${Ce(w.paneId)}`,{replace:!0}),O.getState().clearPendingCreateWindow(t)},[t,M,Le,be,r,d,pe,q,i,l]),n.useEffect(()=>{if(P||!$||!W||u)return;const s=C.current,g=s==null?void 0:s.getTerminal();if(!g)return;const w=Math.max(2,Math.floor(W.width||0)),I=Math.max(2,Math.floor(W.height||0));if(!w||!I)return;const te=Date.now(),ve={cols:w,rows:I},_e=(s==null?void 0:s.getPendingLocalSize())??null;$n({now:te,remoteSize:ve,pendingLocalSize:_e})&&(g.cols===w&&g.rows===I||g.resize(w,I))},[$,u,P,W]),n.useEffect(()=>{const s=window.requestAnimationFrame(()=>{var w;(w=C.current)==null||w.scrollToBottom()}),g=window.setTimeout(()=>{var w;(w=C.current)==null||w.scrollToBottom()},120);return()=>{window.cancelAnimationFrame(s),window.clearTimeout(g)}},[H]),n.useEffect(()=>{U!=null&&U.message&&Me.error(U.message)},[U==null?void 0:U.message]),n.useEffect(()=>(document.title=Bt(Ee),()=>{document.title=Z}),[Z,Ee]),n.useEffect(()=>{const s=()=>{var g;(g=C.current)==null||g.scrollToBottom()};return window.addEventListener("tmex:jump-to-latest",s),()=>{window.removeEventListener("tmex:jump-to-latest",s)}},[]),n.useEffect(()=>{const s=g=>{const{deviceId:w,windowId:I,paneId:te}=g.detail;w===t&&(j.current={windowId:I,paneId:te,at:Date.now()})};return window.addEventListener("tmex:user-initiated-selection",s),()=>{window.removeEventListener("tmex:user-initiated-selection",s)}},[t]),n.useEffect(()=>{_(Q)},[Q]);const Te=n.useCallback(s=>{if(!t||!d||!$)return;O.getState().sendInput(t,d,s,!1)},[$,t,d]),De=n.useCallback(s=>{var g,w;if(s.type==="action"){if(s.action==="toggleKeyboard"){ge.getState().setInputMode(H==="direct"?"editor":"direct");return}if(s.action==="scrollToBottom"){(g=C.current)==null||g.scrollToBottom();return}}if(s.type==="send"){s.payload&&Te(s.payload);return}if(!(!t||!d||!$))switch(s.action){case"paste":{((w=navigator.clipboard)!=null&&w.readText?navigator.clipboard.readText():Promise.reject(new Error("clipboard unavailable"))).then(te=>{te&&O.getState().paste(t,d,te)}).catch(()=>Me.error(e("terminal.pasteFailed")));break}case"newAgentSession":Ft.getState().startDraft(t,d,null),ge.getState().setSidebarCollapsed(!1),ge.getState().setSidebarTab("agent");break}},[$,t,Te,H,d,e]),gt=n.useCallback(()=>{if(!$){Me.error(e("wsError.checkGateway"));return}if(!t||!d||!R.trim())return;Y(!0),window.setTimeout(()=>Y(!1),150);const s=V?`${R}\r`:R;O.getState().sendInput(t,d,s,!1),re(R),S&&J(S),_("")},[re,$,t,S,V,R,J,d,e]),xt=n.useCallback(()=>{if(!$){Me.error(e("wsError.checkGateway"));return}if(!t||!d||!R.trim())return;Y(!0),window.setTimeout(()=>Y(!1),150);const s=R.split(/\r?\n/),g=O.getState();for(const w of s)w.trim()&&g.sendInput(t,d,`${w}\r`,!1);re(R),S&&J(S),_("")},[re,$,t,S,R,J,d,e]),vt=n.useCallback(()=>{var s;(s=b.current)==null||s.focus({preventScroll:!0})},[]);if(!t)return o.jsx("div",{className:"flex h-full items-center justify-center p-4",children:o.jsx("div",{className:"rounded-lg border border-dashed border-border px-4 py-3 text-sm text-muted-foreground",children:e("device.noDevices")})});const bt=!!d&&!L&&(M||ne),St=M&&!!d&&!L&&!W,yt=me&&!M&&!U&&!ne,rt=o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx(qe,{className:"h-6 w-6 text-muted-foreground animate-spin"})}),o.jsx("h3",{className:"text-lg font-medium",children:e("terminal.connecting")})]});return o.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-background","data-testid":"device-page",children:[o.jsx("div",{className:`flex-1 relative overflow-hidden min-h-0 min-w-0 ${p&&H==="editor"?"pb-1":""}`,children:o.jsxs("div",{className:"h-full px-3 py-1 min-h-0 min-w-0 w-full relative flex rounded-xl",style:{backgroundColor:a.background},children:[L?o.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:o.jsxs("div",{className:"max-w-sm space-y-4",children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx(En,{className:"h-6 w-6 text-muted-foreground"})}),o.jsx("p",{className:"text-sm text-muted-foreground","data-testid":"terminal-selection-invalid",children:x})]})}):bt&&d?P&&T?o.jsxs("div",{className:"flex h-full min-h-0 w-full flex-1 flex-col","data-virtual-keyboard-avoid":!0,children:[o.jsx("div",{ref:m,className:"relative min-h-0 flex-1",children:o.jsx(ir,{deviceId:t,window:T,focusedPaneId:d,theme:D,inputMode:H,deviceConnected:M,focusedTerminalRef:ie,onUserSelectPane:xe,onWindowResize:oe},`${t}:${T.id}`)}),H==="direct"&&o.jsx("div",{className:"kb-floating-shortcuts",style:{backgroundColor:a.background},children:o.jsx(Ue,{onActivate:De,disabled:!$})})]}):o.jsx("div",{ref:m,className:"flex-1 h-full min-h-0 w-full","data-virtual-keyboard-avoid":!0,children:o.jsx(nt,{ref:C,deviceId:t,paneId:d,theme:D,inputMode:H,deviceConnected:M,isSelectionInvalid:L,onResize:oe,onSync:X,children:H==="direct"&&o.jsx("div",{className:"kb-floating-shortcuts",style:{backgroundColor:a.background},children:o.jsx(Ue,{onActivate:De,disabled:!$})})},`${t}:${d}`)}):o.jsx("div",{className:"absolute inset-0 flex flex-col items-center justify-center p-8 text-center",children:o.jsx("div",{className:"max-w-sm space-y-4",children:yt?rt:!M&&!ne?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx("span",{className:"text-2xl text-muted-foreground",children:"🔌"})}),o.jsx("h3",{className:"text-lg font-medium",children:e("device.disconnected")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e("device.connectToStart")})]}):r?rt:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center mx-auto",children:o.jsx("span",{className:"text-2xl text-muted-foreground",children:"📋"})}),o.jsx("h3",{className:"text-lg font-medium",children:e("window.noWindowSelected")}),o.jsx("p",{className:"text-sm text-muted-foreground",children:e("window.selectWindowToStart")})]})})}),ne&&o.jsx("div",{className:"pointer-events-none absolute inset-x-0 top-2 z-10 flex justify-center","data-testid":"terminal-reconnecting-indicator",children:o.jsx(Ht,{deviceId:t,className:"shadow-sm"})}),St&&o.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-background/85 backdrop-blur-sm","data-testid":"terminal-status-overlay",children:o.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:[o.jsx("div",{className:"h-7 w-7 rounded-full border-2 border-primary border-t-transparent animate-spin"}),o.jsx("span",{className:"text-xs text-muted-foreground","data-testid":"terminal-status-text",children:e("terminal.connecting")})]})})]})}),H==="editor"&&o.jsxs("div",{ref:v,"data-virtual-keyboard-avoid":!0,className:"editor-mode-input bg-card/85 backdrop-blur-sm",children:[p&&o.jsx(Ue,{onActivate:s=>{De(s),s.type==="send"&&vt()},disabled:!$}),o.jsx("textarea",{ref:b,"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:R,onChange:s=>{const g=s.target.value;if(_(g),!!S){if(g){we(S,g);return}J(S)}},placeholder:e("terminal.inputPlaceholder"),onCompositionStart:()=>{G.current=!0},onCompositionEnd:()=>{G.current=!1}}),o.jsx("div",{className:"actions mt-2",children:o.jsxs("div",{className:"send-row flex flex-wrap items-center justify-end gap-2","data-testid":"editor-send-row",children:[o.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:[o.jsx(Wt,{size:"sm",checked:V,onCheckedChange:s=>de(!!s)}),o.jsx("span",{children:e("terminal.editorSendWithEnter")})]}),o.jsxs(Re,{variant:"outline",size:"sm","data-testid":"editor-clear",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s;_(""),S&&J(S),p&&H==="editor"&&((s=b.current)==null||s.focus({preventScroll:!0}))},title:e("terminal.clear"),children:[o.jsx(Ot,{className:"h-4 w-4"}),e("terminal.clear")]}),o.jsxs(Re,{variant:"secondary",size:"sm","data-testid":"editor-send-line-by-line",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s;xt(),p&&H==="editor"&&((s=b.current)==null||s.focus({preventScroll:!0}))},disabled:!$||A,children:[A?o.jsx(qe,{className:"h-4 w-4 animate-spin"}):o.jsx(ot,{className:"h-4 w-4"}),e("terminal.editorSendLineByLine")]}),o.jsxs(Re,{variant:"default",size:"sm","data-testid":"editor-send",onMouseDown:s=>s.preventDefault(),onClick:()=>{var s;gt(),p&&H==="editor"&&((s=b.current)==null||s.focus({preventScroll:!0}))},disabled:!$||A,children:[A?o.jsx(qe,{className:"h-4 w-4 animate-spin"}):o.jsx(ot,{className:"h-4 w-4"}),e("common.send")]})]})})]})]})}function xr(){const{deviceId:e,windowId:t,paneId:r}=Ze(),c=r?et(r):void 0,l=O(z=>z.snapshots),m=dt(z=>{var j;return((j=z.settings)==null?void 0:j.siteName)??"tmex"}),v=e?l[e]:void 0,b=n.useMemo(()=>{var z;if(!(!t||!((z=v==null?void 0:v.session)!=null&&z.windows)))return v.session.windows.find(j=>j.id===t)},[t,v]),C=n.useMemo(()=>{if(!(!c||!b))return b.panes.find(z=>z.id===c)},[c,b]),F=n.useMemo(()=>b&&C?ft({paneCustomName:C.customName,paneTitle:C.title,windowName:b.name,windowCustomName:b.customName,deviceName:m}):e??"",[b,C,m,e]);return o.jsx(o.Fragment,{children:F})}function vr(){const{t:e}=Pe(),{deviceId:t,windowId:r,paneId:c}=Ze(),l=ut(),m=Xt(),v=c?et(c):void 0,b=ge(u=>u.inputMode),C=ge(u=>u.setInputMode),F=O(u=>{var A;return t?((A=u.deviceConnected)==null?void 0:A[t])??!1:!1}),z=O(u=>t?u.snapshots[t]:void 0),j=n.useMemo(()=>{var u;if(!(!r||!((u=z==null?void 0:z.session)!=null&&u.windows)))return z.session.windows.find(A=>A.id===r)},[r,z]),i=n.useCallback(u=>{!t||!r||l(`/devices/${t}/windows/${r}/panes/${Ce(u)}`,{replace:!0})},[t,r,l]),y=n.useMemo(()=>{if(!(!v||!j))return j.panes.find(u=>u.id===v)},[v,j]),ue=n.useCallback(u=>{!t||!v||O.getState().splitPane(t,v,u,y==null?void 0:y.currentPath)},[t,v,y==null?void 0:y.currentPath]),[U,M]=n.useState(!1),[ce,ne]=n.useState(!1),[me,Z]=n.useState(!1),d=!!(v&&F),p=(tt({queryKey:Yt(t??"",v??""),queryFn:()=>qt(t??"",v??""),enabled:!!(t&&v),throwOnError:!1}).data??[]).some(u=>u.enabled),k=()=>{C(b==="direct"?"editor":"direct")},R=()=>{window.dispatchEvent(new CustomEvent("tmex:jump-to-latest"))},_=()=>{M(!0)},G=()=>{window.location.reload()};return o.jsxs(o.Fragment,{children:[m&&v&&j&&j.panes.length>1&&o.jsx(Vn,{window:j,currentPaneId:v,onSelectPane:i}),!m&&o.jsxs(o.Fragment,{children:[o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:()=>ue("right"),disabled:!d,"data-testid":"split-right-button","aria-label":e("window.splitRight"),title:e("window.splitRight"),children:o.jsx(Ut,{className:"h-4 w-4"})}),o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:()=>ue("down"),disabled:!d,"data-testid":"split-down-button","aria-label":e("window.splitDown"),title:e("window.splitDown"),children:o.jsx(Vt,{className:"h-4 w-4"})})]}),o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:_,"aria-label":e("nav.refreshPage"),title:e("nav.refreshPage"),children:o.jsx(un,{className:"h-4 w-4"})}),o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:k,disabled:!d,"data-testid":"terminal-input-mode-toggle","aria-label":e(b==="direct"?"nav.switchToEditor":"nav.switchToDirect"),title:e(b==="direct"?"nav.switchToEditor":"nav.switchToDirect"),children:b==="direct"?o.jsx(gn,{className:"h-4 w-4"}):o.jsx(jn,{className:"h-4 w-4"})}),o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:R,disabled:!d,"aria-label":e("nav.jumpToLatest"),title:e("nav.jumpToLatest"),children:o.jsx(dn,{className:"h-4 w-4"})}),o.jsxs(Re,{variant:"ghost",size:"icon-sm",className:"relative",onClick:()=>ne(!0),disabled:!v,"data-testid":"watch-open-button","aria-label":e("watch.title"),title:e("watch.title"),children:[o.jsx(Kt,{className:"h-4 w-4"}),p&&o.jsx("span",{className:"absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-primary","data-testid":"watch-active-indicator"})]}),o.jsx(Re,{variant:"ghost",size:"icon-sm",onClick:()=>Z(!0),"data-testid":"keyboard-behavior-open-button","aria-label":e("settings.terminal.title"),title:e("settings.terminal.title"),children:o.jsx(Tn,{className:"h-4 w-4"})}),o.jsx(Nn,{open:me,onOpenChange:Z}),t&&v&&o.jsx(Gt,{open:ce,onOpenChange:ne,deviceId:t,paneId:v}),o.jsx(Qt,{open:U,onOpenChange:M,children:o.jsxs(Jt,{children:[o.jsxs(Zt,{children:[o.jsx(en,{children:e("nav.refreshPage")}),o.jsx(tn,{children:e("nav.refreshPageConfirm")})]}),o.jsxs(nn,{children:[o.jsx(rn,{onClick:()=>M(!1),children:e("common.cancel")}),o.jsx(sn,{onClick:G,children:e("common.confirm")})]})]})})]})}export{vr as PageActions,xr as PageTitle,gr as default};
@@ -1 +0,0 @@
1
- import{ai as o,aj as n}from"./mermaid.core-CXD-Pc2r.js";const t=(a,r)=>o.lang.round(n.parse(a)[r]);export{t as c};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-DEa9FPer.js";import{_ as i}from"./mermaid.core-CXD-Pc2r.js";import"./chunk-FMBD7UC4-DLcIMhi1.js";import"./chunk-ND2GUHAM-Cu1P2Ot8.js";import"./chunk-55IACEB6-BmFdQL7n.js";import"./chunk-2J33WTMH-DqycjO3G.js";import"./index-BK6c5W5S.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1 +0,0 @@
1
- import{s as a,c as s,a as e,C as t}from"./chunk-727SXJPM-DEa9FPer.js";import{_ as i}from"./mermaid.core-CXD-Pc2r.js";import"./chunk-FMBD7UC4-DLcIMhi1.js";import"./chunk-ND2GUHAM-Cu1P2Ot8.js";import"./chunk-55IACEB6-BmFdQL7n.js";import"./chunk-2J33WTMH-DqycjO3G.js";import"./index-BK6c5W5S.js";var n={parser:e,get db(){return new t},renderer:s,styles:a,init:i(r=>{r.class||(r.class={}),r.class.arrowMarkerAbsolute=r.arrowMarkerAbsolute},"init")};export{n as diagram};
@@ -1 +0,0 @@
1
- import{s as e,b as r,a,S as s}from"./chunk-AQP2D5EJ-DiZ9AoB9.js";import{_ as i}from"./mermaid.core-CXD-Pc2r.js";import"./chunk-55IACEB6-BmFdQL7n.js";import"./chunk-2J33WTMH-DqycjO3G.js";import"./index-BK6c5W5S.js";var p={parser:a,get db(){return new s(2)},renderer:r,styles:e,init:i(t=>{t.state||(t.state={}),t.state.arrowMarkerAbsolute=t.arrowMarkerAbsolute},"init")};export{p as diagram};
@@ -1,25 +0,0 @@
1
- var oe=Object.defineProperty;var re=(e,t,n)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var h=(e,t,n)=>re(e,typeof t!="symbol"?t+"":t,n);import{Y as P,u as N,j as a,$ as st,B as M,X as A,a as le,c as ae,r as w,a0 as ce,a1 as V,e as de,o as mt,a2 as he,a3 as ue,a4 as me,a5 as fe,a6 as pe,K as _,P as ge,a7 as ye,a8 as xe,a9 as Se,aa as be,ab as Ce,ac as we,ad as Te,T as Ee,ae as Re,af as E,ag as ve,ah as ft,ai as pt,aj as Me,N as _e,O as Ae,Q as De,ak as He,R as ke,al as Ne,U as Ie,am as Be}from"./index-BK6c5W5S.js";import{g as Le,h as gt,i as Oe,w as Fe,a as $e,b as Ke,c as yt,d as je,k as Ft}from"./selection-clipboard-D3gUQQ7L.js";import{K as $t}from"./send-BVxB0Ywb.js";const Ye=[{id:"paste",type:"action",action:"paste",label:""},{id:"enter",type:"send",label:"Enter",payload:"\r"},{id:"shift-tab",type:"send",label:"SHIFT-TAB",payload:"\x1B[Z"},{id:"esc",type:"send",label:"ESC",payload:"\x1B"},{id:"ctrl-c",type:"send",label:"CTRL-C",payload:""},{id:"ctrl-d",type:"send",label:"CTRL-D",payload:""},{id:"arrow-up",type:"send",label:"↑",payload:"\x1B[A"},{id:"arrow-down",type:"send",label:"↓",payload:"\x1B[B"},{id:"arrow-left",type:"send",label:"←",payload:"\x1B[D"},{id:"arrow-right",type:"send",label:"→",payload:"\x1B[C"},{id:"shift-enter",type:"send",label:"SHIFT-Enter",payload:"\x1B[13;2u"},{id:"backspace",type:"send",label:"Backspace",payload:"\b"}];/**
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 Pe=[["path",{d:"M12 17V3",key:"1cwfxf"}],["path",{d:"m6 11 6 6 6-6",key:"12ii2o"}],["path",{d:"M19 21H5",key:"150jfl"}]],Kt=P("arrow-down-to-line",Pe);/**
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 Ue=[["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"}]],jt=P("clipboard-paste",Ue);/**
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 Ge=[["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"}]],_i=P("refresh-cw",Ge);/**
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 Ve=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],ze=P("rotate-ccw",Ve);function We(e){return`rgb(${e.r} ${e.g} ${e.b})`}const Xe=new Map([[9622,4],[9623,8],[9624,1],[9625,13],[9626,9],[9627,7],[9628,11],[9629,2],[9630,6],[9631,14]]),qe=new Map([[9617,.25],[9618,.5],[9619,.75]]);function Qe(e){return e>=9600&&e<=9631}function z(e){const t=e.getContext("2d");if(!t)throw new Error("2d canvas context unavailable");return t}class Ze{constructor(t){h(this,"kind","canvas");h(this,"mainCanvas");h(this,"selectionCanvas");h(this,"cursorCanvas");h(this,"mainContext");h(this,"selectionContext");h(this,"cursorContext");h(this,"theme");h(this,"fontFamily");h(this,"fontSize");h(this,"cellDimensions",{width:9,height:17});h(this,"deviceCellWidth",9);h(this,"deviceCellHeight",17);h(this,"deviceFontSize",13);h(this,"textTopGap",0);h(this,"textBaselineY",0);h(this,"glyphBoxHeight",0);h(this,"dpr",1);h(this,"cols",0);h(this,"rows",0);h(this,"lastCursor",null);h(this,"frameCount",0);h(this,"lastDrawnRows",[]);h(this,"colorCache",new Map);h(this,"fontCache",new Map);h(this,"cursorBlinkVisible",!0);h(this,"cursorBlinkTimer",null);this.theme=t.theme,this.fontFamily=t.fontFamily,this.fontSize=t.fontSize,t.screenElement.style.position="relative",t.screenElement.style.overflow="hidden",this.mainCanvas=document.createElement("canvas"),this.selectionCanvas=document.createElement("canvas"),this.cursorCanvas=document.createElement("canvas");for(const[n,i]of[[this.mainCanvas,"main"],[this.selectionCanvas,"selection"],[this.cursorCanvas,"cursor"]])n.dataset.layer=i,n.style.position="absolute",n.style.inset="0",n.style.width="100%",n.style.height="100%",n.style.pointerEvents="none",t.screenElement.appendChild(n);this.mainContext=z(this.mainCanvas),this.selectionContext=z(this.selectionCanvas),this.cursorContext=z(this.cursorCanvas)}setTheme(t){this.theme=t,this.colorCache.clear()}render(t){if(this.frameCount+=1,this.lastDrawnRows=[],this.cellDimensions=t.cellDimensions,this.resize(t.meta.cols,t.meta.rows),this.drawSelection(t.selectionRects??[],t.selectionColor??this.theme.selectionBackground),t.meta.dirty==="clean"){this.drawCursor(t.meta);return}const n=t.meta.dirty==="full",i=n?t.rows:t.rows.filter(s=>s.dirty);let o;if(n)o=t.rows;else{const s=new Set;for(const r of i)s.add(r.y-1),s.add(r.y),s.add(r.y+1);o=t.rows.filter(r=>s.has(r.y))}for(const s of o)this.drawRowBackground(s,t.meta.colors);for(const s of o)this.drawRowForeground(s,t.meta.colors);for(const s of i)this.lastDrawnRows.push(s.y);this.drawCursor(t.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(t,n){const i=Math.max(1,t),o=Math.max(1,n),s=Math.max(1,globalThis.devicePixelRatio??1),r=Math.max(1,Math.round(this.cellDimensions.width*s)),l=Math.max(1,Math.round(this.cellDimensions.height*s));if(this.cols===i&&this.rows===o&&this.dpr===s&&this.deviceCellWidth===r&&this.deviceCellHeight===l)return;this.cols=i,this.rows=o,this.dpr=s,this.deviceCellWidth=r,this.deviceCellHeight=l,this.deviceFontSize=this.fontSize*s,this.mainContext.font=`${this.deviceFontSize}px ${this.fontFamily}`;const c=this.mainContext.measureText("Mg|qyÅ");let d=c.fontBoundingBoxAscent,m=c.fontBoundingBoxDescent;Number.isFinite(d)&&Number.isFinite(m)&&d>0||(d=this.deviceFontSize*.8,m=this.deviceFontSize*.2),this.glyphBoxHeight=d+m,this.textTopGap=Math.round((l-this.glyphBoxHeight)/2),this.textBaselineY=Math.round(this.textTopGap+d);const g=i*r,S=o*l;for(const y of[this.mainCanvas,this.selectionCanvas,this.cursorCanvas])y.width=g,y.height=S,y.style.width=`${g/s}px`,y.style.height=`${S/s}px`;for(const y of[this.mainContext,this.selectionContext,this.cursorContext])y.setTransform(1,0,0,1,0,0),y.textBaseline="alphabetic",y.imageSmoothingEnabled=!1}drawSelection(t,n){if(this.selectionContext.clearRect(0,0,this.selectionCanvas.width,this.selectionCanvas.height),t.length!==0){this.selectionContext.fillStyle=n;for(const i of t)this.selectionContext.fillRect(i.x*this.deviceCellWidth,i.row*this.deviceCellHeight,i.width*this.deviceCellWidth,this.deviceCellHeight)}}drawRowBackground(t,n){const i=t.y*this.deviceCellHeight,o=this.cols*this.deviceCellWidth,s=this.toCss(n.background);this.mainContext.clearRect(0,i,o,this.deviceCellHeight),this.mainContext.fillStyle=s,this.mainContext.fillRect(0,i,o,this.deviceCellHeight);for(const r of t.cells){if(r.widthKind==="spacer-tail"||r.widthKind==="spacer-head")continue;const l=r.style.inverse?r.fgColor??n.foreground:r.bgColor??n.background;if(l.r!==n.background.r||l.g!==n.background.g||l.b!==n.background.b){const c=r.x*this.deviceCellWidth,d=r.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l),this.mainContext.fillRect(c,i,d,this.deviceCellHeight)}}}drawRowForeground(t,n){const i=t.y*this.deviceCellHeight,o=Math.max(1,Math.round(this.dpr));for(const s of t.cells){if(s.widthKind==="spacer-tail"||s.widthKind==="spacer-head"||!s.text||s.style.invisible)continue;const r=s.x*this.deviceCellWidth,l=s.style.inverse?s.bgColor??n.background:s.fgColor??n.foreground,c=s.widthKind==="wide"?this.deviceCellWidth*2:this.deviceCellWidth;this.mainContext.fillStyle=this.toCss(l);const d=s.codepoints.length===1&&Qe(s.codepoints[0])?s.codepoints[0]:null;d!==null?this.drawBlockElement(d,r,i,c,this.deviceCellHeight):(this.mainContext.font=this.resolveFont(s.style),this.mainContext.fillText(s.text,r,i+this.textBaselineY));const m=i+this.textTopGap,g=i+this.textTopGap+this.glyphBoxHeight;s.style.underline>0&&this.mainContext.fillRect(r,Math.min(Math.round(g-o),i+this.deviceCellHeight-o),Math.max(c-o,o),o),s.style.strikethrough&&this.mainContext.fillRect(r,Math.round(i+this.textTopGap+this.glyphBoxHeight/2),Math.max(c-o,o),o),s.style.overline&&this.mainContext.fillRect(r,Math.max(i,Math.round(m)),Math.max(c-o,o),o)}}drawBlockElement(t,n,i,o,s){const r=this.mainContext,l=C=>Math.round(o*C/8),c=C=>Math.round(s*C/8),d=(C,p,x,I)=>{r.fillRect(n+C,i+p,x-C,I-p)};if(t===9600){d(0,0,o,c(4));return}if(t>=9601&&t<=9608){d(0,c(8-(t-9600)),o,s);return}if(t>=9609&&t<=9615){d(0,0,l(9616-t),s);return}if(t===9616){d(l(4),0,o,s);return}const m=qe.get(t);if(m!==void 0){const C=r.globalAlpha;r.globalAlpha=C*m,d(0,0,o,s),r.globalAlpha=C;return}if(t===9620){d(0,0,o,c(1));return}if(t===9621){d(l(7),0,o,s);return}const g=Xe.get(t)??0,S=l(4),y=c(4);g&1&&d(0,0,S,y),g&2&&d(S,0,o,y),g&4&&d(0,y,S,s),g&8&&d(S,y,o,s)}drawCursor(t){const n=t.colors,i=t.cursor,o=this.lastCursor;if(this.cursorContext.clearRect(0,0,this.cursorCanvas.width,this.cursorCanvas.height),!i.visible||i.x===null||i.y===null){this.lastCursor=null,this.stopCursorBlink();return}const s=i.x*this.deviceCellWidth,r=i.y*this.deviceCellHeight,l=i.wideTail?this.deviceCellWidth*2:this.deviceCellWidth,c=Math.max(1,Math.round(this.dpr)),d=n.cursor??n.foreground,m=this.toCss(d);this.cursorContext.fillStyle=m,this.cursorContext.strokeStyle=m,this.cursorContext.globalAlpha=.7,this.cursorContext.fillRect(s,r+this.deviceCellHeight-2*c,Math.max(l-c,c),2*c),this.cursorContext.globalAlpha=1,this.startCursorBlink(),this.lastCursor={x:i.x,y:i.y,style:i.style},o&&(o.x!==this.lastCursor.x||o.y!==this.lastCursor.y||o.style!==this.lastCursor.style)&&this.lastDrawnRows.push(o.y)}resolveFont(t){const n=this.deviceFontSize,i=[t.italic?"italic":"normal",t.bold?"700":"400",`${n}px`,this.fontFamily].join("|"),o=this.fontCache.get(i);if(o)return o;const s=`${t.italic?"italic ":""}${t.bold?"700 ":""}${n}px ${this.fontFamily}`;return this.fontCache.set(i,s),s}toCss(t){const n=`${t.r},${t.g},${t.b}`,i=this.colorCache.get(n);if(i)return i;const o=We(t);return this.colorCache.set(n,o),o}}const W=/https?:\/\/[^\s"'`<>()[\]{}]+/g,Je=/[.,;:!?]+$/;function tn(e){let t="";const n=[],i=e.colChars.length;for(let o=0;o<i;o+=1){const s=e.colChars[o];if(!(s===null||s===""))for(let r=0;r<s.length;r+=1)t+=s[r],n.push(o)}return{text:t,colOf:n}}function en(e){let t="";const n=[],i=[];for(let r=0;r<e.length;r+=1){const l=tn(e[r]);for(let c=0;c<l.text.length;c+=1)t+=l.text[c],n.push(r),i.push(l.colOf[c])}const o=[];W.lastIndex=0;let s=W.exec(t);for(;s!==null;){const r=s[0].replace(Je,"");if(r.length>0){const l=s.index,c=l+r.length-1;let d=l;for(let m=l;m<=c;m+=1)(m===c||n[m+1]!==n[m])&&(o.push({lineIndex:n[d],startCol:i[d],endCol:i[m],url:r}),d=m+1)}s=W.exec(t)}return o}const D=0,nn=-2,sn=1,on=2,rn=3,ln=10,an=11,cn=12,dn=13,hn=14,un=15,mn=16,fn=17,pn=1,gn=2,yn=1,xn=2,Sn=3,bn=4,Cn=5,wn=6,Tn=1,En=2,Rn=3,vn=4;function ot(e){if(e.disposed||e.renderStateHandle===0)throw new Error("render state resources already disposed")}function Mn(e){switch(e){case 2:return"full";case 1:return"partial";default:return"clean"}}function _n(e){switch(e){case 0:return"bar";case 2:return"underline";case 3:return"block-hollow";default:return"block"}}function An(e){switch(e){case 1:return"wide";case 2:return"spacer-tail";case 3:return"spacer-head";default:return"narrow"}}function H(e,t){return{r:e.view().getUint8(t),g:e.view().getUint8(t+1),b:e.view().getUint8(t+2)}}function xt(e,t){const n=e.bindings.allocStruct("GhosttyColorRgb");try{const i=t(n.ptr);if(i===nn)return null;if(i!==D)throw new Error(`ghostty optional color read failed with result ${i}`);return H(e.bindings,n.ptr)}finally{n.free()}}function v(e,t){const n=e.bindings.allocU8();try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty bool read failed with result ${i}`);return e.bindings.readU8(n)!==0}finally{e.bindings.freeU8(n)}}function B(e,t){const n=e.bindings.allocBytes(2);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u16 read failed with result ${i}`);return e.bindings.view().getUint16(n,!0)}finally{e.bindings.freeBytes(n,2)}}function Dn(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u32 read failed with result ${i}`);return e.bindings.view().getUint32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function et(e,t){const n=e.bindings.allocBytes(4);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty enum read failed with result ${i}`);return e.bindings.view().getInt32(n,!0)}finally{e.bindings.freeBytes(n,4)}}function St(e,t){const n=e.bindings.allocBytes(8);try{const i=t(n);if(typeof i=="number"&&i!==D)throw new Error(`ghostty u64 read failed with result ${i}`);return e.bindings.readU64(n)}finally{e.bindings.freeBytes(n,8)}}function Hn(e){const t=e.bindings.allocStruct("GhosttyStyle");try{e.bindings.setField(t.view,"GhosttyStyle","size",e.bindings.typeSize("GhosttyStyle")),e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,xn,t.ptr);const n=i=>e.bindings.field("GhosttyStyle",i).offset;return{bold:t.view.getUint8(n("bold"))!==0,italic:t.view.getUint8(n("italic"))!==0,faint:t.view.getUint8(n("faint"))!==0,blink:t.view.getUint8(n("blink"))!==0,inverse:t.view.getUint8(n("inverse"))!==0,invisible:t.view.getUint8(n("invisible"))!==0,strikethrough:t.view.getUint8(n("strikethrough"))!==0,overline:t.view.getUint8(n("overline"))!==0,underline:t.view.getInt32(n("underline"),!0)}}finally{t.free()}}function kn(e){const t=Dn(e,i=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Sn,i));if(t===0)return[];const n=e.bindings.allocBytes(t*4);try{e.bindings.getRenderStateRowCellValue(e.rowCellsHandle,bn,n);const i=[];for(let o=0;o<t;o+=1)i.push(e.bindings.view().getUint32(n+o*4,!0));return i}finally{e.bindings.freeBytes(n,t*4)}}function Nn(e){if(e.length===0)return"";try{return String.fromCodePoint(...e)}catch{return""}}function In(e){let t="";for(const n of e)if(!(n.widthKind==="spacer-tail"||n.widthKind==="spacer-head")){if(n.text){t+=n.text;continue}n.widthKind==="narrow"&&(t+=" ")}return t}function Bn(e){const t=e.bindings.allocStruct("GhosttyRenderStateColors");try{e.bindings.setField(t.view,"GhosttyRenderStateColors","size",e.bindings.typeSize("GhosttyRenderStateColors")),e.bindings.getRenderStateColors(e.renderStateHandle,t.ptr);const n=e.bindings.field("GhosttyRenderStateColors","palette").offset,i=[];for(let r=0;r<256;r+=1){const l=t.ptr+n+r*3;i.push(H(e.bindings,l))}const o=t.view.getUint8(e.bindings.field("GhosttyRenderStateColors","cursor_has_value").offset)!==0,s=v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,hn,r));return{cols:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,sn,r)),rows:B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,on,r)),dirty:Mn(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,rn,r))),colors:{background:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","background").offset),foreground:H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","foreground").offset),cursor:o?H(e.bindings,t.ptr+e.bindings.field("GhosttyRenderStateColors","cursor").offset):null,palette:i},cursor:{style:_n(et(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,ln,r))),visible:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,an,r)),blinking:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,cn,r)),passwordInput:v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,dn,r)),x:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,un,r)):null,y:s?B(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,mn,r)):null,wideTail:s?v(e,r=>e.bindings.getRenderStateValueResult(e.renderStateHandle,fn,r)):!1}}}finally{t.free()}}function Ln(e,t){const n=St(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,gn,s));e.bindings.bindRenderStateRowCells(e.rowIteratorHandle,e.rowCellsHandle);const i=[];let o=0;for(;e.bindings.nextRenderStateRowCell(e.rowCellsHandle);){const s=St(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,yn,d)),r=kn(e),l=An(et(e,d=>e.bindings.getRawCellValueResult(s,Rn,d))),c={x:o,text:Nn(r),codepoints:r,widthKind:l,hasText:v(e,d=>e.bindings.getRawCellValueResult(s,vn,d)),style:Hn(e),fgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,wn,d)),bgColor:xt(e,d=>e.bindings.getRenderStateRowCellValueResult(e.rowCellsHandle,Cn,d))};i.push(c),o+=1}return{y:t,dirty:v(e,s=>e.bindings.getRenderStateRowValueResult(e.rowIteratorHandle,pn,s)),wrap:v(e,s=>e.bindings.getRawRowValueResult(n,Tn,s)),wrapContinuation:v(e,s=>e.bindings.getRawRowValueResult(n,En,s)),text:In(i),cells:i}}function bt(e){return{bindings:e,renderStateHandle:e.createRenderState(),rowIteratorHandle:e.createRenderStateRowIterator(),rowCellsHandle:e.createRenderStateRowCells(),snapshotVersion:0,disposed:!1,cachedMeta:null}}function Ct(e,t){ot(e),e.bindings.updateRenderState(e.renderStateHandle,t),e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle),e.snapshotVersion+=1,e.cachedMeta=null}function nt(e){return ot(e),e.cachedMeta||(e.cachedMeta=Bn(e)),e.cachedMeta}function*On(e){ot(e);const t=nt(e);e.bindings.bindRenderStateRowIterator(e.renderStateHandle,e.rowIteratorHandle);let n=0;for(;n<t.rows&&e.bindings.nextRenderStateRowIterator(e.rowIteratorHandle);)yield Ln(e,n),n+=1}function X(e){e.disposed||(e.disposed=!0,e.rowCellsHandle!==0&&(e.bindings.freeRenderStateRowCells(e.rowCellsHandle),e.rowCellsHandle=0),e.rowIteratorHandle!==0&&(e.bindings.freeRenderStateRowIterator(e.rowIteratorHandle),e.rowIteratorHandle=0),e.renderStateHandle!==0&&(e.bindings.freeRenderState(e.renderStateHandle),e.renderStateHandle=0),e.cachedMeta=null)}const Fn={colChars:[],contentCols:0,wrappedToNext:!1};function $n(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n!==null&&n!==""&&n!==" ")return t+1}return 0}function wt(e,t=!1){const n=[];for(const i of e){if(i.widthKind==="spacer-tail"){n.push(null);continue}if(i.widthKind==="spacer-head"){n.push("");continue}n.push(i.text||" ")}return{colChars:n,contentCols:$n(n),wrappedToNext:t}}function Kn(e,t){return Math.max(0,Math.min(Math.max(e.colChars.length-1,0),Math.floor(t)))}function rt(e,t){let n=Kn(e,t);for(;n>0&&e.colChars[n]===null;)n-=1;return n}function q(e,t){let n=t;for(;n>0&&e.colChars[n]===null;)n-=1;return e.colChars[n]||""}function Tt(e,t){let n=t;for(;n+1<e.colChars.length&&e.colChars[n+1]===null;)n+=1;return n}function jn(e,t){return e.line<t.line?{start:e,end:t}:e.line>t.line?{start:t,end:e}:e.col<=t.col?{start:e,end:t}:{start:t,end:e}}function Yn(e,t,n){if(n.colChars.length===0)return{start:{line:e,col:0},end:{line:e,col:0}};const i=rt(n,t),o=l=>/[\p{L}\p{N}_-]/u.test(l);if(!o(q(n,i)))return{start:{line:e,col:i},end:{line:e,col:i}};let s=i,r=i;for(;s>0&&o(q(n,s-1));)s-=1;for(;r+1<n.colChars.length&&o(q(n,r+1));)r+=1;return{start:{line:e,col:s},end:{line:e,col:r}}}function Yt(e,t){const n=Math.max(t.contentCols-1,0);return{start:{line:e,col:0},end:{line:e,col:n}}}function Pt(e,t,n){const i=n(e.line);switch(t){case"word":return Yn(e.line,e.col,i);case"line":return Yt(e.line,i);default:{const o=rt(i,e.col);return{start:{line:e.line,col:o},end:{line:e.line,col:o}}}}}function Ut(){return{anchor:null,focus:null,mode:"character"}}function Et(e){return!!(e.anchor&&e.focus)}function Pn(){return Ut()}function Un(e,t,n){const i=Pt(t,t.mode,n);return{anchor:i.start,focus:i.end,mode:t.mode}}function Rt(e,t,n){return e.anchor?e.mode==="line"?{...e,focus:Yt(t.line,n(t.line)).end}:e.mode==="word"?{...e,focus:Pt(t,"word",n).end}:{...e,focus:{line:t.line,col:rt(n(t.line),t.col)}}:e}function Gt(e){return!e.anchor||!e.focus?null:jn(e.anchor,e.focus)}function Gn(e,t,n){const i=e.wrappedToNext?e.colChars.length-1:e.contentCols-1,o=Math.min(n,i);let s=Math.max(0,t);for(;s>0&&e.colChars[s]===null;)s-=1;if(s>o)return"";let r="";for(let l=s;l<=o;l+=1)r+=e.colChars[l]??"";return r}function Vn(e,t){const n=Gt(e);if(!n)return null;let i="";for(let o=n.start.line;o<=n.end.line;o+=1){const s=t(o),r=o===n.start.line?n.start.col:0,l=o===n.end.line?n.end.col:s.colChars.length-1;i+=Gn(s,r,l),o<n.end.line&&!s.wrappedToNext&&(i+=`
22
- `)}return i}function zn(e,t,n,i){const o=Gt(e);if(!o)return[];const s=t+n-1,r=[];for(let l=Math.max(o.start.line,t);l<=Math.min(o.end.line,s);l+=1){const c=l-t;if(l===o.start.line&&l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:o.start.col,width:g-o.start.col+1});continue}if(l===o.start.line){const m=i?Math.max(i(l).colChars.length-o.start.col,0):Number.MAX_SAFE_INTEGER;r.push({row:c,x:o.start.col,width:m});continue}if(l===o.end.line){const m=i==null?void 0:i(l),g=m?Tt(m,o.end.col):o.end.col;r.push({row:c,x:0,width:g+1});continue}const d=i?i(l).colChars.length:Number.MAX_SAFE_INTEGER;r.push({row:c,x:0,width:d})}return r}const vt=80,k=24,Q=9,Z=17,Mt=1.2,Wn=48,Ai="ghostty-official",$=9,K=1e3,j=1002,Y=1003,J=1007,L=1047,O=1049,Xn=[$,K,j,Y],_t=1,At=3,Dt=2,qn=4,Qn=5;class Zn{constructor(t){this.content=t}translateToString(t){return t?this.content.replace(/\s+$/u,""):this.content}}class Jn{constructor(){h(this,"active",{baseY:0,viewportY:0,length:k,getLine:t=>{const n=t-this.active.viewportY,i=this.visibleLines[n];return typeof i=="string"?new Zn(i):null}});h(this,"visibleLines",Array.from({length:k},()=>""))}setViewport(t,n,i,o){this.active.viewportY=t,this.active.baseY=n,this.active.length=i,this.visibleLines=o}}const ti={deleteContentBackward:"Backspace",deleteContentForward:"Delete",insertLineBreak:"Enter",insertParagraph:"Enter"};function ei(e){return!(e.key.length===1&&!e.ctrlKey&&!e.altKey&&!e.metaKey)}function ni(e,t){const n=e.slice(0,t).map(i=>i.text);for(;n.length<t;)n.push("");return n}function F(e){return Ft({shiftKey:!!e.shiftKey,ctrlKey:!!e.ctrlKey,altKey:!!e.altKey,metaKey:!!e.metaKey,getModifierState:()=>!1})}class ii{constructor(){h(this,"terminal",null)}activate(t){this.terminal=t instanceof U?t:null}fit(){const t=this.proposeDimensions();!this.terminal||!t||this.terminal.resize(t.cols,t.rows)}proposeDimensions(){var t;return((t=this.terminal)==null?void 0:t.measureSizeFromElement())??null}dispose(){this.terminal=null}}class U{constructor(t,n,i,o,s,r){h(this,"buffer",new Jn);h(this,"_core",{_renderService:{dimensions:{css:{cell:{width:Q,height:Z}}}}});h(this,"options");h(this,"element",null);h(this,"textarea",null);h(this,"cols",vt);h(this,"rows",k);h(this,"bindings");h(this,"terminalHandle");h(this,"keyEncoderHandle");h(this,"mouseEncoderHandle");h(this,"renderState");h(this,"dataListeners",new Set);h(this,"selectionListeners",new Set);h(this,"linkListeners",new Set);h(this,"linkCursorActive",!1);h(this,"lastNotifiedSelectionText",null);h(this,"addons",new Set);h(this,"screenElement",null);h(this,"renderer",null);h(this,"renderRaf",null);h(this,"lastCursor",null);h(this,"disposed",!1);h(this,"disableStdin");h(this,"customKeyEventHandler",()=>!0);h(this,"imeIsComposing",!1);h(this,"lastCompositionCommit",null);h(this,"selectionState",Ut());h(this,"lineCache",new Map);h(this,"lastViewportOffset",0);h(this,"lastViewportRows",k);h(this,"lastRenderedRows",[]);h(this,"pointerDrag",{active:!1,moved:!1,mode:"character",lastClientX:null,lastClientY:null});h(this,"autoScrollTimer",null);h(this,"domEventDisposers",[]);h(this,"copyShortcutSuppressed",!1);h(this,"scrollbarThumb",null);h(this,"scrollbarFadeTimer",null);h(this,"pressedMouseButtons",new Set);h(this,"wheelPixelDelta",0);h(this,"mouseDragActive",!1);this.bindings=t,this.terminalHandle=n,this.keyEncoderHandle=i,this.mouseEncoderHandle=o,this.renderState=s,this.options=r,this.disableStdin=!!r.disableStdin}static async create(t){const n=await Le(),i=n.createTerminal(vt,k,t.scrollback);let o=0,s=0,r=null;try{return n.setTerminalTheme(i,t.theme),o=n.createKeyEncoder(),s=n.createMouseEncoder(),r=bt(n),new U(n,i,o,s,r,t)}catch(l){throw r&&X(r),o!==0&&n.freeKeyEncoder(o),s!==0&&n.freeMouseEncoder(s),n.freeTerminal(i),l}}open(t){if(this.disposed||this.element)return;const n=document.createElement("div");n.className="xterm",n.style.position="absolute",n.style.inset="0",n.style.overflow="hidden",n.style.width="100%",n.style.height="100%",n.style.backgroundColor=this.options.theme.background,n.style.color=this.options.theme.foreground,n.style.fontFamily=this.options.fontFamily,n.style.fontSize=`${this.options.fontSize}px`,n.style.lineHeight=String(this.options.lineHeight??Mt);const i=document.createElement("div");i.className="xterm-viewport",i.style.width="100%",i.style.height="100%",i.style.overflow="hidden",i.style.position="relative";const o=document.createElement("div");o.className="xterm-screen",o.style.width="100%",o.style.height="100%",o.style.position="relative",o.style.userSelect="none",o.style.webkitUserSelect="none",o.style.backgroundColor=this.options.theme.background;const s=document.createElement("div");s.className="xterm-helper-textarea",s.setAttribute("aria-label","Terminal Input"),s.setAttribute("role","textbox"),s.setAttribute("contenteditable","true"),s.setAttribute("autocorrect","off"),s.setAttribute("autocapitalize","off"),s.setAttribute("spellcheck","false"),s.style.position="absolute",s.style.opacity="1",s.style.pointerEvents="none",s.style.left="0",s.style.top="0",s.style.minWidth="1px",s.style.minHeight="1px",s.style.whiteSpace="pre",s.style.border="0",s.style.padding="0",s.style.margin="0",s.style.color=this.options.theme.foreground,s.style.backgroundColor="transparent",s.style.caretColor="transparent",s.style.overflow="visible",s.style.outline="none",s.style.boxShadow="none",s.style.fontFamily=this.options.fontFamily,s.style.fontSize=`${this.options.fontSize}px`,s.style.userSelect="text",s.style.webkitUserSelect="text";const r=document.createElement("div");r.className="xterm-scrollbar-track",r.style.position="absolute",r.style.top="0",r.style.right="0",r.style.width="8px",r.style.height="100%",r.style.backgroundColor="transparent",r.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",r.appendChild(l),i.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(r),t.appendChild(n),this.element=n,this.screenElement=o,this.textarea=s,this.scrollbarThumb=l,this.renderer=new Ze({screenElement:o,theme:this.options.theme,fontFamily:this.options.fontFamily,fontSize:this.options.fontSize}),this.syncInputState(),this.bindDomEvents(),this.updateCellDimensions();const c=this.measureSizeFromElement();c?this.resize(c.cols,c.rows):this.render()}loadAddon(t){t.activate(this),this.addons.add(t)}onData(t){return this.dataListeners.add(t),{dispose:()=>{this.dataListeners.delete(t)}}}attachCustomKeyEventHandler(t){this.customKeyEventHandler=t}onSelectionChange(t){return this.selectionListeners.add(t),{dispose:()=>{this.selectionListeners.delete(t)}}}onLinkActivated(t){return this.linkListeners.add(t),{dispose:()=>{this.linkListeners.delete(t)}}}hasSelection(){return Et(this.selectionState)}getSelection(){return this.getSelectionText()??""}clearSelection(){this.disposed||this.clearSelectionState()}startTouchSelection(t,n,i="word"){return this.disposed?!1:this.beginSelectionAt(t,n,i)}updateTouchSelection(t,n){this.disposed||this.updateSelectionDrag(t,n)}endTouchSelection(){this.disposed||!this.pointerDrag.active||(this.stopAutoScroll(),this.pointerDrag.active=!1,this.render())}write(t){if(this.disposed)return;const n=this.isAltScreenActive();this.bindings.writeVt(this.terminalHandle,t);const i=this.isAltScreenActive();n&&!i&&this.clearMouseTrackingModes(),this.scheduleRender()}clearMouseTrackingModes(){if(!this.disposed){for(const t of Xn)this.bindings.setTerminalMode(this.terminalHandle,t,!1);this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.pressedMouseButtons.clear(),this.mouseDragActive=!1}}isAltScreenActive(){return this.isModeEnabled(L)||this.isModeEnabled(O)}reset(){this.disposed||(this.lineCache.clear(),this.clearSelectionState(!1),this.bindings.resetTerminal(this.terminalHandle),this.scheduleRender())}refresh(){this.disposed||this.render()}resize(t,n){if(this.disposed)return;const i=Math.max(2,Math.floor(t)),o=Math.max(2,Math.floor(n));this.cols=i,this.rows=o,this.clearSelectionState(!1),this.bindings.resizeTerminal(this.terminalHandle,i,o,this.cellDimensions()),this.bindings.resetMouseEncoder(this.mouseEncoderHandle),this.scheduleRender()}scrollLines(t){this.disposed||t===0||(this.bindings.scrollViewportDelta(this.terminalHandle,t),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($),mouseNormal:this.isModeEnabled(K),mouseButton:this.isModeEnabled(j),mouseAny:this.isModeEnabled(Y),mouseUtf8:this.isModeEnabled(1005),mouseSgr:this.isModeEnabled(1006),mouseSgrPixels:this.isModeEnabled(1016),mouseUrxvt:this.isModeEnabled(1015),altScroll:this.isModeEnabled(J),altScreen1047:this.isModeEnabled(L),altScreen1049:this.isModeEnabled(O)}}restoreModeSnapshot(t){this.bindings.setTerminalMode(this.terminalHandle,$,t.mouseX10),this.bindings.setTerminalMode(this.terminalHandle,K,t.mouseNormal),this.bindings.setTerminalMode(this.terminalHandle,j,t.mouseButton),this.bindings.setTerminalMode(this.terminalHandle,Y,t.mouseAny),this.bindings.setTerminalMode(this.terminalHandle,1005,t.mouseUtf8),this.bindings.setTerminalMode(this.terminalHandle,1006,t.mouseSgr),this.bindings.setTerminalMode(this.terminalHandle,1016,t.mouseSgrPixels),this.bindings.setTerminalMode(this.terminalHandle,1015,t.mouseUrxvt),this.bindings.setTerminalMode(this.terminalHandle,J,t.altScroll),this.bindings.setTerminalMode(this.terminalHandle,L,t.altScreen1047),this.bindings.setTerminalMode(this.terminalHandle,O,t.altScreen1049),this.bindings.resetMouseEncoder(this.mouseEncoderHandle)}handleViewportGesture(t){if(this.disposed||t.deltaY===0)return!1;const n=this.gestureToLines(t);if(n===0)return!1;const i=this.getInputRoutingState();if(i.mouseReporting){const o=n<0?qn:Qn;let s=!1;for(let r=0;r<Math.abs(n);r+=1)s=this.emitMouseInput({action:"press",button:o,clientX:t.clientX,clientY:t.clientY,mods:F(t),anyButtonPressed:this.pressedMouseButtons.size>0})||s;return s}return i.altScroll?this.emitAltScrollInput(n):(this.scrollLines(n),!0)}paste(t){if(this.disposed||this.disableStdin||!t)return;const n=this.bindings.encodePaste(this.terminalHandle,t);n&&this.emitData(n)}focus(){var t;(t=this.textarea)==null||t.focus({preventScroll:!0})}getCursorViewportRect(){if(this.disposed)return null;const t=this.screenElement,n=this.lastCursor;if(!t||!n||!n.visible||n.y===null||this.textarea===null||document.activeElement!==this.textarea)return null;const{height:i}=this.cellDimensions();if(i<=0)return null;const o=t.getBoundingClientRect().top+n.y*i;return{top:o,bottom:o+i}}getRendererKind(){var t;return((t=this.renderer)==null?void 0:t.kind)??"unknown"}setTheme(t){var n;this.bindings.setTerminalTheme(this.terminalHandle,t),this.options.theme=t,this.element&&(this.element.style.backgroundColor=t.background,this.element.style.color=t.foreground),this.screenElement&&(this.screenElement.style.backgroundColor=t.background),(n=this.renderer)==null||n.setTheme(t),this.scheduleRender()}setDisableStdin(t){this.disableStdin=t,this.syncInputState()}measureSizeFromElement(){const t=this.element;if(!t)return null;const n=t.getBoundingClientRect(),{width:i,height:o}=this.cellDimensions();return n.width===0||n.height===0||i<=0||o<=0?null:{cols:Math.max(2,Math.floor(n.width/i)),rows:Math.max(2,Math.floor(n.height/o))}}dispose(){var t,n;if(!this.disposed){this.disposed=!0,this.renderRaf!==null&&(cancelAnimationFrame(this.renderRaf),this.renderRaf=null),this.stopAutoScroll(),this.updateSelectionTextProbe(null),this.clearDomEventListeners(),this.scrollbarFadeTimer&&(clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=null);for(const i of this.addons)i.dispose();this.addons.clear(),(t=this.renderer)==null||t.dispose(),this.renderer=null,(n=this.element)==null||n.remove(),this.element=null,this.screenElement=null,this.textarea=null,this.scrollbarThumb=null,X(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 t=this.element,n=this.textarea;if(!t||!n)return;t.addEventListener("click",()=>{this.disableStdin||this.focus()});const i=this.screenElement??t;i.addEventListener("mousedown",s=>{if(s instanceof MouseEvent){if(this.disableStdin||this.focus(),this.getInputRoutingState().mouseReporting){const r=this.mouseButtonFromEvent(s);if(r===null)return;this.clearSelectionState(),this.pressedMouseButtons.add(r),this.mouseDragActive=!0,this.emitMouseInput({action:"press",button:r,clientX:s.clientX,clientY:s.clientY,mods:F(s),anyButtonPressed:!0}),s.preventDefault();return}if(s.button===0&&gt(s)){const r=this.linkAtClient(s.clientX,s.clientY);if(r){this.emitLinkActivated(r),s.preventDefault();return}}s.button===0&&(this.mouseDragActive=!0,this.beginPointerSelection(s),s.preventDefault())}}),i.addEventListener("mousemove",s=>{if(!(!(s instanceof MouseEvent)||this.mouseDragActive)){if(this.getInputRoutingState().mouseReporting){this.setLinkCursor(!1);return}this.setLinkCursor(gt(s)&&this.linkAtClient(s.clientX,s.clientY)!==null)}}),i.addEventListener("mouseleave",()=>{this.setLinkCursor(!1)}),t.addEventListener("wheel",s=>{this.handleViewportGesture({source:"wheel",deltaY:s.deltaY,deltaMode:s.deltaMode,clientX:s.clientX,clientY:s.clientY,shiftKey:s.shiftKey,ctrlKey:s.ctrlKey,altKey:s.altKey,metaKey:s.metaKey})&&s.preventDefault()},{passive:!1});const o=typeof window<"u"&&typeof window.addEventListener=="function"?window:null;if(o){const s=l=>{if(this.mouseDragActive){if(this.getInputRoutingState().mouseReporting){this.emitMouseInput({action:"motion",button:this.mouseButtonFromButtons(l.buttons),clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0||l.buttons>0});return}this.updatePointerSelection(l)}},r=l=>{if(this.mouseDragActive){if(this.mouseDragActive=!1,this.getInputRoutingState().mouseReporting){const c=this.mouseButtonFromEvent(l);c!==null&&this.pressedMouseButtons.delete(c),this.emitMouseInput({action:"release",button:c,clientX:l.clientX,clientY:l.clientY,mods:F(l),anyButtonPressed:this.pressedMouseButtons.size>0});return}this.finishPointerSelection(l)}};o.addEventListener("mousemove",s),o.addEventListener("mouseup",r),this.domEventDisposers.push(()=>{o.removeEventListener("mousemove",s),o.removeEventListener("mouseup",r)})}n.addEventListener("keydown",s=>{const r=this.getSelectionText();if(r&&Oe(s)){s.preventDefault(),Fe(r).catch(()=>{}),this.clearSelectionState(),this.copyShortcutSuppressed=!0,this.clearTextarea();return}if(!this.customKeyEventHandler(s)||this.disableStdin||this.imeIsComposing||s.keyCode===229||$e(s)||!ei(s))return;const l=this.encodeKeyboardEvent(s,s.repeat?"repeat":"press");l&&(s.preventDefault(),this.emitData(l),this.clearTextarea())}),n.addEventListener("keyup",s=>{if(this.copyShortcutSuppressed){const l=s.key.toLowerCase();if(l==="c"){s.preventDefault();return}if(l==="control"||l==="meta"||l==="os"){this.copyShortcutSuppressed=!1,s.preventDefault();return}}if(this.disableStdin||this.imeIsComposing)return;const r=this.encodeKeyboardEvent(s,"release");r&&(s.preventDefault(),this.emitData(r),this.clearTextarea())}),n.addEventListener("compositionstart",()=>{this.imeIsComposing=!0,this.lastCompositionCommit=null,this.syncTextareaPositionToCursor()}),n.addEventListener("compositionupdate",()=>{this.syncTextareaPositionToCursor()}),n.addEventListener("compositionend",s=>{this.imeIsComposing=!1;const r=s.data??"";r&&(this.lastCompositionCommit={data:r,at:Date.now()},this.emitData(r),this.clearTextarea())}),n.addEventListener("beforeinput",s=>{if(this.disableStdin||s.inputType==="insertFromPaste"||s.isComposing||this.imeIsComposing)return;const r=ti[s.inputType??""];if(r){s.preventDefault();const d=this.encodeSyntheticKey(r);d&&this.emitData(d),this.clearTextarea();return}const l=s.data??"";if(!l)return;const c=this.lastCompositionCommit;if(c&&c.data===l&&Date.now()-c.at<40){this.lastCompositionCommit=null,s.preventDefault(),this.clearTextarea();return}this.lastCompositionCommit=null,s.preventDefault(),this.emitData(l),this.clearTextarea()}),n.addEventListener("paste",s=>{var l;if(this.disableStdin)return;const r=((l=s.clipboardData)==null?void 0:l.getData("text/plain"))??"";r&&(s.preventDefault(),this.paste(r),this.clearTextarea())}),n.addEventListener("copy",s=>{const r=this.getSelectionText();r&&Ke(s,r)}),n.addEventListener("input",()=>{if(this.disableStdin||this.imeIsComposing)return;const s=n.textContent??"";if(!s){this.clearTextarea();return}const r=this.lastCompositionCommit;if(r&&r.data===s&&Date.now()-r.at<40){this.lastCompositionCommit=null,this.clearTextarea();return}this.lastCompositionCommit=null,this.emitData(s),this.clearTextarea()})}encodeKeyboardEvent(t,n){const i=yt(t.code);if(i===0)return null;const o=t.key.length===1&&!t.ctrlKey&&!t.metaKey?t.key:null;return this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:n,keyCode:i,mods:Ft(t),composing:t.isComposing,utf8:o,unshiftedCodepoint:je(t.code)})}encodeSyntheticKey(t){const n={code:t,key:t,shiftKey:!1,ctrlKey:!1,altKey:!1,metaKey:!1,repeat:!1,isComposing:!1,getModifierState:()=>!1};return this.encodeKeyboardEvent(n,"press")}getInputRoutingState(){const t=this.isModeEnabled($)||this.isModeEnabled(K)||this.isModeEnabled(j)||this.isModeEnabled(Y),n=this.isModeEnabled(L)||this.isModeEnabled(O);return{mouseReporting:t,altScroll:!t&&n&&this.isModeEnabled(J)}}gestureToLines(t){const n=this.cellDimensions().height||Z;if(t.source==="wheel"){if(t.deltaMode===1)return this.wheelPixelDelta=0,t.deltaY>0?Math.ceil(t.deltaY):Math.floor(t.deltaY);if(t.deltaMode===2){this.wheelPixelDelta=0;const o=Math.max(1,this.rows),s=t.deltaY*o;return s>0?Math.ceil(s):Math.floor(s)}this.wheelPixelDelta+=t.deltaY;const i=this.wheelPixelDelta>0?Math.floor(this.wheelPixelDelta/n):Math.ceil(this.wheelPixelDelta/n);return i!==0&&(this.wheelPixelDelta-=i*n),i}return t.deltaY>0?Math.ceil(t.deltaY/n):Math.floor(t.deltaY/n)}isModeEnabled(t){return this.bindings.isTerminalModeEnabled(this.terminalHandle,t)}mouseButtonFromEvent(t){switch(t.button){case 0:return _t;case 1:return At;case 2:return Dt;default:return null}}mouseButtonFromButtons(t){return t&1?_t:t&4?At:t&2?Dt:null}pointerPositionFromClient(t,n){var r;const i=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!i)return null;const o=Math.max(1,i.width),s=Math.max(1,i.height);return{x:Math.max(0,Math.min(o-1,t-i.left)),y:Math.max(0,Math.min(s-1,n-i.top))}}emitMouseInput(t){var r;if(this.disableStdin)return!1;const n=this.pointerPositionFromClient(t.clientX,t.clientY);if(!n)return!1;const i=this.cellDimensions(),o=(r=this.screenElement)==null?void 0:r.getBoundingClientRect();if(!o)return!1;const s=this.bindings.encodeMouseEvent(this.mouseEncoderHandle,this.terminalHandle,{action:t.action,button:t.button,mods:t.mods,x:n.x,y:n.y,anyButtonPressed:t.anyButtonPressed,screenWidth:Math.max(1,Math.round(o.width)),screenHeight:Math.max(1,Math.round(o.height)),cellWidth:Math.max(1,Math.round(i.width||Q)),cellHeight:Math.max(1,Math.round(i.height||Z))});return s?(this.emitData(s),!0):!1}emitAltScrollInput(t){const n=yt(t<0?"ArrowUp":"ArrowDown");if(n===0)return!1;let i=!1;for(let o=0;o<Math.abs(t);o+=1){const s=this.bindings.encodeKeyEvent(this.keyEncoderHandle,this.terminalHandle,{action:"press",keyCode:n,mods:0,composing:!1,utf8:null,unshiftedCodepoint:null});s&&(this.emitData(s),i=!0)}return i}emitData(t){for(const n of this.dataListeners)n(t)}clearTextarea(){this.textarea&&(this.textarea.textContent="")}syncTextareaPositionToCursor(){const t=this.textarea,n=this.screenElement;if(!t||!n)return;const{width:i,height:o}=this.cellDimensions();if(i<=0||o<=0)return;const s=bt(this.bindings);let r=0,l=0;try{Ct(s,this.terminalHandle);const m=nt(s);m.cursor.x!==null&&m.cursor.y!==null&&(r=m.cursor.x,l=m.cursor.y)}finally{X(s)}const c=r*i,d=l*o;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.width=`${Math.max(1,i)}px`,t.style.height=`${Math.max(1,o)}px`,t.style.lineHeight=`${o}px`,t.style.fontFamily=this.options.fontFamily,t.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 t=this.bindings.readScrollbar(this.terminalHandle),n=Math.max(1,t.len||this.rows);Ct(this.renderState,this.terminalHandle);const i=nt(this.renderState),o=Array.from(On(this.renderState));this.lastCursor=i.cursor,this.cols=Math.max(2,i.cols),this.rows=Math.max(2,i.rows||n),this.lastViewportOffset=t.offset,this.lastViewportRows=this.rows,this.lastRenderedRows=o;for(const d of o)this.lineCache.set(t.offset+d.y,wt(d.cells,d.wrap));const s=zn(this.selectionState,this.lastViewportOffset,this.lastViewportRows,d=>this.getLineModel(d)),r=this.getSelectionText();this.renderer.render({meta:i,rows:o,cellDimensions:this.cellDimensions(),selectionRects:s,selectionColor:this.options.theme.selectionBackground});const l=ni(o,this.rows),c=Math.max(0,t.total-t.len);this.buffer.setViewport(t.offset,c,t.total,l),this.updateSelectionTextProbe(r),this.updateScrollbar(t)}updateScrollbar(t){var c;const n=this.scrollbarThumb;if(!n)return;const i=((c=this.screenElement)==null?void 0:c.clientHeight)??0;if(i===0||t.total<=t.len){n.style.opacity="0";return}const o=t.len/t.total,s=Math.max(20,o*i),l=t.offset/Math.max(1,t.total-t.len)*(i-s);n.style.height=`${s}px`,n.style.transform=`translateY(${l}px)`,n.style.opacity="1",this.scrollbarFadeTimer&&clearTimeout(this.scrollbarFadeTimer),this.scrollbarFadeTimer=setTimeout(()=>{n.style.opacity="0"},800)}updateCellDimensions(){if(!this.element)return;const t=document.createElement("span");t.textContent="WWWWWWWWWW",t.style.position="absolute",t.style.visibility="hidden",t.style.whiteSpace="pre",t.style.fontFamily=this.options.fontFamily,t.style.fontSize=`${this.options.fontSize}px`,this.element.appendChild(t);const n=t.getBoundingClientRect();t.remove();const i=Math.max(1,globalThis.devicePixelRatio??1),o=n.width>0?n.width/10:Q,s=this.options.fontSize*(this.options.lineHeight??Mt);this._core._renderService.dimensions.css.cell.width=Math.max(1,Math.round(o*i))/i,this._core._renderService.dimensions.css.cell.height=Math.max(1,Math.round(s*i))/i}clearSelectionState(t=!0){this.selectionState=Pn(),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),t&&this.screenElement&&this.renderer&&this.render()}beginSelectionAt(t,n,i){const o=this.hitTest(t,n);return o?(this.pointerDrag={active:!0,moved:!1,mode:i,lastClientX:t,lastClientY:n},this.selectionState=Un(this.selectionState,{...o,mode:i},s=>this.getLineModel(s)),this.updateAutoScroll(),this.render(),!0):!1}updateSelectionDrag(t,n){if(!this.pointerDrag.active)return;const i=this.hitTest(t,n);this.pointerDrag.lastClientX=t,this.pointerDrag.lastClientY=n,i&&(this.pointerDrag.moved=!0,this.selectionState=Rt(this.selectionState,i,o=>this.getLineModel(o)),this.render()),this.updateAutoScroll()}beginPointerSelection(t){this.beginSelectionAt(t.clientX,t.clientY,this.selectionModeFromClickDetail(t.detail))}updatePointerSelection(t){this.updateSelectionDrag(t.clientX,t.clientY)}finishPointerSelection(t){var i,o,s,r;if(!this.pointerDrag.active||t.button!==0)return;this.pointerDrag.lastClientX=t.clientX,this.pointerDrag.lastClientY=t.clientY,this.stopAutoScroll();const n=this.pointerDrag.mode==="character"&&!this.pointerDrag.moved&&((i=this.selectionState.anchor)==null?void 0:i.line)===((o=this.selectionState.focus)==null?void 0:o.line)&&((s=this.selectionState.anchor)==null?void 0:s.col)===((r=this.selectionState.focus)==null?void 0:r.col);if(this.pointerDrag.active=!1,n){this.clearSelectionState();return}this.render()}selectionModeFromClickDetail(t){return t>=3?"line":t===2?"word":"character"}hitTest(t,n){var S;const i=(S=this.screenElement)==null?void 0:S.getBoundingClientRect();if(!i)return null;const{width:o,height:s}=this.cellDimensions();if(o<=0||s<=0)return null;const r=t-i.left,l=n-i.top,c=Math.max(this.cols-1,0),d=Math.max(this.lastViewportRows-1,0),m=Math.max(0,Math.min(c,Math.floor(r/o))),g=Math.max(0,Math.min(d,Math.floor(l/s)));return{line:this.lastViewportOffset+g,col:m}}getLineModel(t){const n=this.lineCache.get(t);if(n)return n;const i=t-this.lastViewportOffset,o=this.lastRenderedRows[i];return o?wt(o.cells,o.wrap):Fn}emitLinkActivated(t){for(const n of this.linkListeners)n(t)}setLinkCursor(t){this.linkCursorActive!==t&&(this.linkCursorActive=t,this.screenElement&&(this.screenElement.style.cursor=t?"pointer":""))}linkAtClient(t,n){const i=this.hitTest(t,n);return i?this.linkAtPoint(i.line,i.col):null}linkAtPoint(t,n){if(this.getLineModel(t).colChars.length===0)return null;let i=t;for(;this.getLineModel(i-1).wrappedToNext;)i-=1;let o=t;for(;this.getLineModel(o).wrappedToNext;)o+=1;const s=[];for(let l=i;l<=o;l+=1)s.push(this.getLineModel(l));const r=t-i;for(const l of en(s))if(l.lineIndex===r&&n>=l.startCol&&n<=l.endCol)return l.url;return null}getSelectionText(){return Et(this.selectionState)?Vn(this.selectionState,t=>this.getLineModel(t)):null}updateSelectionTextProbe(t){if(globalThis.__tmexE2eTerminalSelectionText=t,t!==this.lastNotifiedSelectionText){this.lastNotifiedSelectionText=t;for(const n of this.selectionListeners)n(t)}}updateAutoScroll(){var i;if(!this.pointerDrag.active||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(i=this.screenElement)==null?void 0:i.getBoundingClientRect();if(!t){this.stopAutoScroll();return}if(!(this.pointerDrag.lastClientY<t.top||this.pointerDrag.lastClientY>t.bottom)){this.stopAutoScroll();return}this.autoScrollTimer===null&&(this.autoScrollTimer=setInterval(()=>{this.stepAutoScroll()},Wn))}stepAutoScroll(){var o;if(!this.pointerDrag.active||this.pointerDrag.lastClientX===null||this.pointerDrag.lastClientY===null){this.stopAutoScroll();return}const t=(o=this.screenElement)==null?void 0:o.getBoundingClientRect();if(!t){this.stopAutoScroll();return}let n=0;if(this.pointerDrag.lastClientY<t.top?n=-1:this.pointerDrag.lastClientY>t.bottom&&(n=1),n===0){this.stopAutoScroll();return}this.bindings.scrollViewportDelta(this.terminalHandle,n),this.render();const i=this.hitTest(this.pointerDrag.lastClientX,this.pointerDrag.lastClientY);i&&(this.selectionState=Rt(this.selectionState,i,s=>this.getLineModel(s)),this.pointerDrag.moved=!0,this.render())}stopAutoScroll(){this.autoScrollTimer!==null&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null)}clearDomEventListeners(){for(;this.domEventDisposers.length>0;){const t=this.domEventDisposers.pop();t==null||t()}}}async function si(e){return U.create(e)}const oi=new Set(["Control","Shift","Alt","Meta","CapsLock","NumLock","ScrollLock","Dead","Unidentified","OS","ContextMenu","Fn","FnLock","Hyper","Super"]),ri={Enter:{label:"Enter",raw:"\r"},Tab:{label:"Tab",raw:" "},Escape:{label:"ESC",raw:"\x1B"},Backspace:{label:"Backspace",raw:"\b"}," ":{label:"Space",raw:" "},ArrowUp:{label:"↑",csiFinal:"A"},ArrowDown:{label:"↓",csiFinal:"B"},ArrowRight:{label:"→",csiFinal:"C"},ArrowLeft:{label:"←",csiFinal:"D"},Home:{label:"Home",csiFinal:"H"},End:{label:"End",csiFinal:"F"},Delete:{label:"Delete",csiNum:3},Insert:{label:"Insert",csiNum:2},PageUp:{label:"PgUp",csiNum:5},PageDown:{label:"PgDn",csiNum:6}},li={F1:"\x1BOP",F2:"\x1BOQ",F3:"\x1BOR",F4:"\x1BOS",F5:"\x1B[15~",F6:"\x1B[17~",F7:"\x1B[18~",F8:"\x1B[19~",F9:"\x1B[20~",F10:"\x1B[21~",F11:"\x1B[23~",F12:"\x1B[24~"},ai={"[":"\x1B","\\":"","]":"","^":"",_:"","@":"\0","?":""};function ci(e){return 1+(e.shiftKey?1:0)+(e.altKey?2:0)+(e.ctrlKey?4:0)+(e.metaKey?8:0)}function di(e){const t=[];return e.ctrlKey&&t.push("CTRL"),e.altKey&&t.push("ALT"),e.metaKey&&t.push("CMD"),e.shiftKey&&t.push("SHIFT"),t.length?`${t.join("-")}-`:""}function hi(e){const t=e.key;if(!t||oi.has(t))return null;const n=ci(e),i=n!==1,o=di(e);if(t==="Tab"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Tab",payload:"\x1B[Z"};if(t==="Enter"&&e.shiftKey&&!e.ctrlKey&&!e.altKey&&!e.metaKey)return{label:"SHIFT-Enter",payload:"\x1B[13;2u"};if(e.ctrlKey&&!e.altKey&&!e.metaKey&&/^[a-zA-Z]$/.test(t)){const l=t.toUpperCase();return{label:`CTRL-${l}`,payload:String.fromCharCode(l.charCodeAt(0)-64)}}const s=li[t];if(s)return{label:o+t,payload:s};const r=ri[t];if(r){if("raw"in r){const c=e.altKey?`\x1B${r.raw}`:r.raw;return{label:o+r.label,payload:c}}if("csiFinal"in r){const c=i?`\x1B[1;${n}${r.csiFinal}`:`\x1B[${r.csiFinal}`;return{label:o+r.label,payload:c}}const l=i?`\x1B[${r.csiNum};${n}~`:`\x1B[${r.csiNum}~`;return{label:o+r.label,payload:l}}if(t.length===1){if(e.altKey&&!e.ctrlKey&&!e.metaKey)return{label:`ALT-${t.toUpperCase()}`,payload:`\x1B${t}`};if(e.ctrlKey){const l=ai[t];return l!==void 0?{label:o+t,payload:l}:null}return{label:t,payload:t}}return null}function Vt(e){return e.replace(/\\(x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|.)/g,(t,n)=>{if(n[0]==="x"&&n.length===3||n[0]==="u"&&n.length===5)return String.fromCharCode(Number.parseInt(n.slice(1),16));switch(n){case"r":return"\r";case"n":return`
23
- `;case"t":return" ";case"e":return"\x1B";case"0":return"\0";case"a":return"\x07";case"b":return"\b";case"f":return"\f";case"v":return"\v";case"\\":return"\\";default:return n}})}function it(e){let t="";for(const n of e){const i=n.codePointAt(0)??0;n==="\\"?t+="\\\\":n==="\r"?t+="\\r":n===`
24
- `?t+="\\n":n===" "?t+="\\t":n==="\x1B"?t+="\\e":i<32||i>=127&&i<=159?t+=`\\x${i.toString(16).padStart(2,"0")}`:t+=n}return t}const ui={CTRL:"⌃",CONTROL:"⌃",SHIFT:"⇧",ALT:"⌥",OPTION:"⌥",OPT:"⌥",CMD:"⌘",META:"⌘",SUPER:"⌘",WIN:"⌘",ENTER:"⏎",RETURN:"⏎",CR:"⏎",ESC:"⎋",ESCAPE:"⎋",TAB:"⇥",BACKSPACE:"⌫",BS:"⌫",DELETE:"⌦",DEL:"⌦",SPACE:"␣",UP:"↑",DOWN:"↓",LEFT:"←",RIGHT:"→"};function mi(e){return e&&e.split(/[-+]/).map(n=>{const i=n.trim().toUpperCase();return ui[i]??n}).join("")}const fi={paste:jt,toggleKeyboard:$t,newAgentSession:st,scrollToBottom:Kt};function pi({items:e,useIcons:t,onActivate:n,disabled:i=!1,preventFocusSteal:o=!1,className:s,rowTestId:r="editor-shortcuts-row",idPrefix:l="editor-shortcut"}){const{t:c}=N();return a.jsx("div",{className:A("shortcut-row flex items-center gap-1.5 py-2 overflow-x-auto scrollbar-thin",s),"data-testid":r,children:e.map(d=>{const m=d.type==="action",g=m&&d.action?fi[d.action]:null,S=m&&d.action?c(`settings.terminal.shortcuts.action.${d.action}`):"",y=d.label||it(d.payload??""),C=t?mi(y):y,p=m?d.label.trim()||S:y;return a.jsx(M,{type:"button",variant:"ghost",size:"sm",className:"terminal-shortcut-btn h-8 min-w-9 px-2.5 rounded-full font-mono text-[13px] 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:p,"aria-label":p,"data-testid":`${l}-${d.id}`,onMouseDown:o?x=>x.preventDefault():void 0,onClick:n?()=>n(d):void 0,disabled:i,children:g?a.jsx(g,{className:"h-4 w-4"}):a.jsx("span",{children:C})},d.id)})})}const Ht=["terminal-shortcuts"];async function zt(e,t){try{return(await e.json()).error??t}catch{return t}}async function gi(){const e=await fetch("/api/settings/terminal-shortcuts");if(!e.ok)throw new Error(await zt(e,"Failed to load terminal shortcuts"));return(await e.json()).settings}async function yi(e){const t=await fetch("/api/settings/terminal-shortcuts",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!t.ok)throw new Error(await zt(t,"Failed to save terminal shortcuts"));return(await t.json()).settings}const Wt=[{action:"paste",icon:jt},{action:"toggleKeyboard",icon:$t},{action:"newAgentSession",icon:st},{action:"scrollToBottom",icon:Kt}];function kt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`sc-${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function Nt(e){return JSON.stringify([e.id,e.type,e.label,e.payload??null,e.action??null])}function tt(e,t){return e.length!==t.length?!1:e.every((n,i)=>Nt(n)===Nt(t[i]))}function xi({action:e}){var i;const{t}=N(),n=((i=Wt.find(o=>o.action===e))==null?void 0:i.icon)??st;return a.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1 whitespace-nowrap rounded bg-muted px-1.5 py-0.5 text-muted-foreground text-xs",children:[a.jsx(n,{className:"h-3.5 w-3.5"}),t(`settings.terminal.shortcuts.action.${e}`)]})}function Si({item:e,onLabelChange:t,onPayloadChange:n,onRemove:i}){const{t:o}=N(),{attributes:s,listeners:r,setNodeRef:l,setActivatorNodeRef:c,transform:d,transition:m,isDragging:g}=we({id:e.id}),S=e.type==="action",[y,C]=w.useState(()=>it(e.payload??""));return w.useEffect(()=>{C(it(e.payload??""))},[e.payload]),a.jsxs("div",{ref:l,style:{transform:Re.Translate.toString(d),transition:m},className:A("flex items-center gap-2 rounded-lg border border-border bg-background p-2.5",g&&"opacity-60 shadow-sm"),"data-testid":`shortcut-editor-row-${e.id}`,children:[a.jsx("button",{type:"button",ref:c,...s,...r,"aria-label":o("settings.terminal.shortcuts.dragHandle"),className:"shrink-0 cursor-grab touch-none text-muted-foreground hover:text-foreground",children:a.jsx(Te,{className:"h-4 w-4"})}),S&&e.action?a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(xi,{action:e.action}),a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o(`settings.terminal.shortcuts.action.${e.action}`),className:"h-9 min-w-0 flex-1","data-testid":`shortcut-editor-label-${e.id}`})]}):a.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[a.jsx(_,{value:e.label,onChange:p=>t(e.id,p.target.value),placeholder:o("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":`shortcut-editor-label-${e.id}`}),a.jsx(_,{value:y,onChange:p=>C(p.target.value),onBlur:()=>n(e.id,Vt(y)),placeholder:o("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":`shortcut-editor-payload-${e.id}`})]}),a.jsx(M,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>i(e.id),"aria-label":o("settings.terminal.shortcuts.delete"),"data-testid":`shortcut-editor-remove-${e.id}`,children:a.jsx(Ee,{className:"h-4 w-4"})})]})}function bi(){const{t:e}=N(),t=le(),{data:n,isLoading:i,isError:o,refetch:s}=ae({queryKey:Ht,queryFn:gi}),[r,l]=w.useState([]),[c,d]=w.useState(!1),[m,g]=w.useState(null),[S,y]=w.useState(!1),[C,p]=w.useState(!1),[x,I]=w.useState(""),[lt,at]=w.useState("");w.useEffect(()=>{if(!n)return;if(m===null){l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons});return}if(tt(m.items,n.items)&&m.useIcons===n.useIcons)return;tt(r,m.items)&&c===m.useIcons&&(l(n.items),d(n.useIcons),g({items:n.items,useIcons:n.useIcons}))},[n,m,r,c]);const Xt=w.useMemo(()=>m?!tt(r,m.items)||c!==m.useIcons:!1,[r,c,m]),qt=ce(V(Ce,{activationConstraint:{distance:8}}),V(be,{activationConstraint:{delay:250,tolerance:5}}),V(Se,{coordinateGetter:xe})),ct=de({mutationFn:()=>yi({items:r,useIcons:c}),onSuccess:f=>{t.setQueryData(Ht,f),l(f.items),d(f.useIcons),g({items:f.items,useIcons:f.useIcons}),mt.success(e("settings.terminal.shortcuts.saved"))},onError:f=>{mt.error(f instanceof Error?f.message:e("settings.terminal.shortcuts.saveFailed"))}}),Qt=f=>{const{active:b,over:R}=f;!R||b.id===R.id||l(T=>{const ht=T.findIndex(G=>G.id===b.id),ut=T.findIndex(G=>G.id===R.id);return ht<0||ut<0?T:ye(T,ht,ut)})},Zt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,label:b}:T)),Jt=(f,b)=>l(R=>R.map(T=>T.id===f?{...T,payload:b}:T)),te=f=>l(b=>b.filter(R=>R.id!==f)),dt=(f,b)=>{b&&l(R=>[...R,{id:kt(),type:"send",label:f||b,payload:b}])},ee=f=>l(b=>[...b,{id:kt(),type:"action",action:f,label:""}]),ne=()=>{l(Ye.map(f=>({...f}))),d(!1)},ie=f=>{f.preventDefault(),f.stopPropagation();const b=hi({key:f.key,ctrlKey:f.ctrlKey,shiftKey:f.shiftKey,altKey:f.altKey,metaKey:f.metaKey});b&&(dt(b.label,b.payload),y(!1))},se=()=>{const f=Vt(lt);f&&(dt(x.trim(),f),I(""),at(""))};return o&&!m?a.jsxs("div",{className:"space-y-2","data-testid":"terminal-shortcuts-error",children:[a.jsx("p",{className:"text-destructive text-sm",children:e("settings.terminal.shortcuts.loadFailed")}),a.jsx(M,{type:"button",variant:"outline",size:"sm",onClick:()=>s(),children:e("settings.terminal.shortcuts.retry")})]}):i&&!m?a.jsx("p",{className:"text-muted-foreground text-sm",children:e("settings.terminal.shortcuts.loading")}):a.jsxs("div",{className:"space-y-5","data-testid":"terminal-shortcuts-editor",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.preview")}),a.jsx("div",{className:"rounded-lg border border-border bg-muted/30 px-3","data-testid":"shortcut-preview",children:a.jsx(pi,{items:r,useIcons:c})})]}),a.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-border p-3",children:[a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"font-medium text-sm",children:e("settings.terminal.shortcuts.useIcons")}),a.jsx("span",{className:"text-muted-foreground text-xs",children:e("settings.terminal.shortcuts.useIconsDesc")})]}),a.jsx(he,{checked:c,onCheckedChange:f=>d(f),"aria-label":e("settings.terminal.shortcuts.useIcons"),"data-testid":"shortcut-use-icons"})]}),a.jsx(ue,{sensors:qt,collisionDetection:me,onDragEnd:Qt,children:a.jsx(fe,{items:r.map(f=>f.id),strategy:pe,children:a.jsx("div",{className:"space-y-2","data-testid":"shortcut-editor-list",children:r.map(f=>a.jsx(Si,{item:f,onLabelChange:Zt,onPayloadChange:Jt,onRemove:te},f.id))})})}),a.jsxs("div",{className:"space-y-3 rounded-lg border border-dashed border-border p-4",children:[a.jsx("span",{className:"block font-medium text-sm",children:e("settings.terminal.shortcuts.addShortcut")}),a.jsx("button",{type:"button",onKeyDown:ie,onFocus:()=>y(!0),onBlur:()=>y(!1),className:A("w-full rounded-lg border px-3 py-2.5 text-center text-sm outline-none transition-colors",S?"border-primary bg-primary/5 text-foreground":"border-border text-muted-foreground"),"data-testid":"shortcut-capture-input",children:e(S?"settings.terminal.shortcuts.capturePrompt":"settings.terminal.shortcuts.captureHint")}),a.jsx("div",{className:"flex flex-wrap gap-1.5",children:Wt.map(({action:f,icon:b})=>a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:()=>ee(f),"data-testid":`shortcut-add-action-${f}`,children:[a.jsx(b,{className:"h-3.5 w-3.5"}),e(`settings.terminal.shortcuts.action.${f}`)]},f))}),a.jsx("button",{type:"button",className:"text-muted-foreground text-xs underline underline-offset-2",onClick:()=>p(f=>!f),children:e("settings.terminal.shortcuts.advanced")}),C&&a.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[a.jsx(_,{value:x,onChange:f=>I(f.target.value),placeholder:e("settings.terminal.shortcuts.labelPlaceholder"),className:"h-9 w-24 font-mono","data-testid":"shortcut-manual-label"}),a.jsx(_,{value:lt,onChange:f=>at(f.target.value),placeholder:e("settings.terminal.shortcuts.payloadPlaceholder"),spellCheck:!1,className:"h-9 min-w-0 flex-1 font-mono text-xs","data-testid":"shortcut-manual-payload"}),a.jsxs(M,{type:"button",variant:"outline",size:"sm",onClick:se,"data-testid":"shortcut-manual-add",children:[a.jsx(ge,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.add")]})]})]}),a.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1",children:[a.jsxs(M,{type:"button",variant:"ghost",size:"sm",onClick:ne,"data-testid":"shortcut-reset",children:[a.jsx(ze,{className:"h-3.5 w-3.5"}),e("settings.terminal.shortcuts.reset")]}),a.jsx(M,{type:"button",variant:"default",size:"default",onClick:()=>ct.mutate(),disabled:!Xt||ct.isPending,"data-testid":"shortcut-save",children:e("settings.terminal.shortcuts.save")})]})]})}const u="\x1B",Ci=[`${u}[1;32m  feat/terminal-font${u}[0m ${u}[39m~/projects/tmex${u}[0m`,`${u}[39m// 渲染中文与彩色代码块:字号 / 字体 / 行高 实时预览${u}[0m`,`${u}[35mexport const${u}[0m ${u}[36mgreeting${u}[0m = ${u}[33m"你好,世界 🌏"${u}[0m;`,`${u}[35mfunction${u}[0m ${u}[34mfib${u}[0m(${u}[36mn${u}[0m: ${u}[32mnumber${u}[0m) {`,` ${u}[35mreturn${u}[0m n ${u}[31m<${u}[0m ${u}[33m2${u}[0m ${u}[31m?${u}[0m n ${u}[31m:${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m1${u}[0m) ${u}[31m+${u}[0m ${u}[34mfib${u}[0m(n${u}[31m-${u}[0m${u}[33m2${u}[0m);`,"}",`${u}[32m+ 新增${u}[0m ${u}[31m- 删除${u}[0m ${u}[33m~ 修改${u}[0m ${u}[36m通过测试 ✓${u}[0m`,`${u}[1;34m dir/${u}[0m ${u}[32m file.ts${u}[0m ${u}[33m README.md${u}[0m ${u}[35m config${u}[0m`,`${u}[39m$${u}[0m bun run ${u}[36mbuild:fonts${u}[0m ${u}[32m✓${u}[0m ${u}[39m14MB${u}[0m`,`${u}[7m NORMAL ${u}[0m ${u}[39m UTF-8 LF TypeScript${u}[0m`].join(`\r
25
- `);function wi({className:e}){const t=E(c=>c.terminalFontId),n=E(c=>c.terminalFontSize),i=E(c=>c.terminalLineHeight),o=E(c=>c.theme),s=w.useRef(null),r=w.useRef(null);w.useEffect(()=>{let c=!1,d=null;return(async()=>{await ve(t,n);const m=s.current;if(c||!m)return;if(d=await si({fontFamily:Me(t),fontSize:n,lineHeight:i,scrollback:100,theme:o==="light"?ft:pt,disableStdin:!0}),c){d.dispose();return}d.open(m);const g=new ii;d.loadAddon(g),r.current=g,g.fit(),d.write(Ci)})(),()=>{c=!0,r.current=null,d==null||d.dispose()}},[t,n,i,o]),w.useEffect(()=>{const c=s.current;if(!c)return;const d=new ResizeObserver(()=>{var m;return(m=r.current)==null?void 0:m.fit()});return d.observe(c),()=>d.disconnect()},[]);const l=Math.ceil(n*i*12);return a.jsx("div",{className:A("relative w-full overflow-hidden rounded-md border",e),style:{height:`${l}px`,backgroundColor:o==="light"?ft.background:pt.background},children:a.jsx("div",{ref:s,className:"absolute inset-0"})})}const It=8,Bt=28,Lt=1,Ot=2,Ti=[{value:"lift",labelKey:"terminal.keyboardBehavior.modeLift",descKey:"terminal.keyboardBehavior.modeLiftDesc"},{value:"resize",labelKey:"terminal.keyboardBehavior.modeResize",descKey:"terminal.keyboardBehavior.modeResizeDesc"},{value:"follow",labelKey:"terminal.keyboardBehavior.modeFollow",descKey:"terminal.keyboardBehavior.modeFollowDesc"}];function Di({showPreview:e=!0,showShortcuts:t=!0}){const{t:n}=N(),i=E(p=>p.terminalFontSize),o=E(p=>p.setTerminalFontSize),s=E(p=>p.terminalLineHeight),r=E(p=>p.setTerminalLineHeight),l=E(p=>p.terminalFontId),c=E(p=>p.setTerminalFontId),d=E(p=>p.keyboardBehaviorMode),m=E(p=>p.setKeyboardBehaviorMode),[g,S]=w.useState(String(i)),[y,C]=w.useState(String(s));return w.useEffect(()=>{S(String(i))},[i]),w.useEffect(()=>{C(String(s))},[s]),a.jsxs("div",{className:"space-y-6",children:[a.jsx("p",{className:"text-muted-foreground text-sm",children:n("settings.terminal.description")}),e&&a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("settings.terminal.preview")}),a.jsx(wi,{})]}),a.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-font-size",children:n("settings.terminal.fontSize")}),a.jsx(_,{id:"terminal-font-size","data-testid":"terminal-font-size",type:"number",min:It,max:Bt,step:1,value:g,onChange:p=>{S(p.target.value);const x=Number(p.target.value);Number.isFinite(x)&&x>=It&&x<=Bt&&o(x)},className:"min-h-10"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-line-height",children:n("settings.terminal.lineHeight")}),a.jsx(_,{id:"terminal-line-height","data-testid":"terminal-line-height",type:"number",min:Lt,max:Ot,step:.1,value:y,onChange:p=>{C(p.target.value);const x=Number(p.target.value);Number.isFinite(x)&&x>=Lt&&x<=Ot&&r(x)},className:"min-h-10"})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("label",{className:"block text-sm font-medium",htmlFor:"terminal-font-family",children:n("settings.terminal.fontFamily")}),a.jsxs(_e,{value:l,onValueChange:p=>{p&&c(p)},children:[a.jsx(Ae,{id:"terminal-font-family","data-testid":"terminal-font-family",className:"min-h-10 w-full",children:a.jsx(De,{children:He(l).displayName})}),a.jsx(ke,{children:Ne.map(p=>a.jsx(Ie,{value:p.id,children:p.displayName},p.id))})]})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block text-sm font-medium",children:n("terminal.keyboardBehavior.title")}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("terminal.keyboardBehavior.description")}),a.jsx("div",{className:"flex flex-col gap-2",children:Ti.map(p=>{const x=d===p.value;return a.jsxs("button",{type:"button",onClick:()=>m(p.value),"aria-pressed":x,"data-testid":`keyboard-behavior-option-${p.value}`,className:A("flex items-start gap-3 rounded-lg border p-3 text-left transition-colors",x?"border-primary bg-primary/5":"border-border hover:bg-muted/50"),children:[a.jsx("span",{className:A("mt-0.5 flex h-5 w-5 shrink-0 items-center justify-center rounded-full border",x?"border-primary bg-primary text-primary-foreground":"border-muted-foreground/40"),children:x&&a.jsx(Be,{className:"h-3.5 w-3.5"})}),a.jsxs("span",{className:"flex min-w-0 flex-col gap-0.5",children:[a.jsx("span",{className:"text-sm font-medium",children:n(p.labelKey)}),a.jsx("span",{className:"text-muted-foreground text-xs leading-snug",children:n(p.descKey)})]})]},p.value)})})]}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("settings.terminal.savedInBrowser")}),t&&a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"h-px bg-border"}),a.jsxs("div",{className:"space-y-2",children:[a.jsx("span",{className:"block font-medium text-sm",children:n("settings.terminal.shortcuts.title")}),a.jsx("p",{className:"text-muted-foreground text-xs",children:n("settings.terminal.shortcuts.savedOnServer")}),a.jsx(bi,{})]})]})]})}export{Kt as A,jt as C,ii as F,_i as R,pi as S,Di as T,Ai as a,bi as b,si as c,ze as d,gi as f,Ht as t};