tmux-tui 1.6.0 → 1.7.0

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 (2) hide show
  1. package/dist/tmuxtui.js +2 -2
  2. package/package.json +1 -1
package/dist/tmuxtui.js CHANGED
@@ -288,7 +288,7 @@ Read about how to prevent this error on https://github.com/vadimdemedes/ink/#isr
288
288
  `)E.name="enter";else if(n===" ")E.name="tab";else if(n==="\b"||n==="\x1B\b")E.name="backspace",E.meta=n.charAt(0)==="\x1B";else if(n==="\x7F"||n==="\x1B\x7F")E.name="delete",E.meta=n.charAt(0)==="\x1B";else if(n==="\x1B"||n==="\x1B\x1B")E.name="escape",E.meta=n.length===2;else if(n===" "||n==="\x1B ")E.name="space",E.meta=n.length===2;else if(n.length===1&&n<="")E.name=String.fromCharCode(n.charCodeAt(0)+97-1),E.ctrl=!0;else if(n.length===1&&n>="0"&&n<="9")E.name="number";else if(n.length===1&&n>="a"&&n<="z")E.name=n;else if(n.length===1&&n>="A"&&n<="Z")E.name=n.toLowerCase(),E.shift=!0;else if(u=z_.exec(n))E.meta=!0,E.shift=/^[A-Z]$/.test(u[1]);else if(u=J_.exec(n)){let p=[...n];p[0]==="\x1B"&&p[1]==="\x1B"&&(E.option=!0);let I=[u[1],u[2],u[4],u[6]].filter(Boolean).join(""),S=(u[3]||u[5]||1)-1;E.ctrl=!!(S&4),E.meta=!!(S&10),E.shift=!!(S&1),E.code=I,E.name=Q2[I],E.shift=Y_(I)||E.shift,E.ctrl=K_(I)||E.ctrl}return E},N2=k_;var x2=ae(nA(),1);var W_=()=>(0,x2.useContext)(bm),Ym=W_;var P_=(n,u={})=>{let{stdin:s,setRawMode:c,internal_exitOnCtrlC:E,internal_eventEmitter:p}=Ym();(0,lQ.useEffect)(()=>{if(u.isActive!==!1)return c(!0),()=>{c(!1)}},[u.isActive,c]),(0,lQ.useEffect)(()=>{if(u.isActive===!1)return;let I=S=>{let R=N2(S),_={upArrow:R.name==="up",downArrow:R.name==="down",leftArrow:R.name==="left",rightArrow:R.name==="right",pageDown:R.name==="pagedown",pageUp:R.name==="pageup",home:R.name==="home",end:R.name==="end",return:R.name==="return",escape:R.name==="escape",ctrl:R.ctrl,shift:R.shift,tab:R.name==="tab",backspace:R.name==="backspace",delete:R.name==="delete",meta:R.meta||R.name==="escape"||R.option,super:R.super??!1,hyper:R.hyper??!1,capsLock:R.capsLock??!1,numLock:R.numLock??!1,eventType:R.eventType},F;R.isKittyProtocol?R.isPrintable?F=R.text??R.name:R.ctrl&&R.name.length===1?F=R.name:F="":R.ctrl?F=R.name:F=R.sequence,!R.isKittyProtocol&&D2.includes(R.name)&&(F=""),F.startsWith("\x1B")&&(F=F.slice(1)),F.length===1&&typeof F[0]=="string"&&/[A-Z]/.test(F[0])&&(_.shift=!0),(!(F==="c"&&_.ctrl)||!E)&&mu.batchedUpdates(()=>{n(F,_)})};return p?.on("input",I),()=>{p?.removeListener("input",I)}},[u.isActive,s,E,n])},uQ=P_;var T2=ae(nA(),1);var $_=()=>(0,T2.useContext)(Fm),iQ=$_;var _2=ae(nA(),1);var tF=()=>(0,_2.useContext)(Um),oQ=tF;var eF=ae(nA(),1);var sQ=ae(nA(),1);var AF=ae(nA(),1);var nF=ae(nA(),1);var Km=ae(nA(),1);import{execSync as pQ}from"child_process";import{basename as $2}from"path";var xA=ae(nA(),1);import{execSync as Jn}from"child_process";import{existsSync as Ir}from"fs";import{join as hr}from"path";function Qr(){let n="#{session_name} #{session_windows} #{session_created} #{session_attached} #{session_id} #{session_path} #{session_last_attached}";try{let u=Jn(`tmux list-sessions -F '${n}'`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();return u?u.split(`
289
289
  `).map(c=>{let[E,p,I,S,R,_,F]=c.split(" ");return{name:E,windows:parseInt(p,10),created:parseInt(I,10),attached:S==="1",sessionId:R,path:_||"",lastAttached:parseInt(F,10)||0}}):[]}catch{return[]}}function cQ(n,u){let s=n.replace(/'/g,"'\\''"),c=u.replace(/'/g,"'\\''"),E=u?`tmux new-session -d -s '${s}' -c '${c}'`:`tmux new-session -d -s '${s}'`;Jn(E,{stdio:"pipe"})}function F2(n){let u=n.replace(/'/g,"'\\''");Jn(`tmux kill-session -t '${u}'`,{stdio:"pipe"})}function b2(n,u){let s=n.replace(/'/g,"'\\''"),c=u.replace(/'/g,"'\\''");Jn(`tmux rename-session -t '${s}' '${c}'`,{stdio:"pipe"})}function U2(n){let u=n.replace(/'/g,"'\\''");Jn(`tmux detach-client -s '${u}'`,{stdio:"pipe"})}function qm(n){let u="#{window_name} #{window_index} #{window_panes} #{window_active}",s=n.replace(/'/g,"'\\''");try{let c=Jn(`tmux list-windows -t '${s}' -F '${u}'`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();return c?c.split(`
290
290
  `).map(E=>{let[p,I,S,R]=E.split(" ");return{name:p,index:parseInt(I,10),panes:parseInt(S,10),active:R==="1"}}):[]}catch{return[]}}function M2(n,u,s){let c=n.replace(/'/g,"'\\''"),E=u.replace(/'/g,"'\\''"),p=s?s.replace(/'/g,"'\\''"):"",I=p?`tmux new-window -d -t '${c}' -n '${E}' -c '${p}'`:`tmux new-window -d -t '${c}' -n '${E}'`;Jn(I,{stdio:"pipe"})}function H2(n,u,s){let c=n.replace(/'/g,"'\\''"),E=s.replace(/'/g,"'\\''");Jn(`tmux rename-window -t '${c}':${u} '${E}'`,{stdio:"pipe"})}function O2(n,u){let s=n.replace(/'/g,"'\\''");Jn(`tmux kill-window -t '${s}':${u}`,{stdio:"pipe"})}var Gs=[{id:1,name:"Single",panes:1,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[]},{id:2,name:"H-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u252C\u2500\u2500\u2500\u2510","\u2502 1 \u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2534\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50}]},{id:3,name:"V-Split",panes:2,preview:["\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 1 \u2502","\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524","\u2502 2 \u2502","\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!1,percentage:50}]},{id:4,name:"IDE",panes:2,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u25021 \u2502 2 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75}]},{id:5,name:"IDE+Term",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u2500\u2500\u2524","\u2502 \u2502 3 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:50}]},{id:6,name:"Triple",panes:3,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u25023 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:66},{pane:1,horizontal:!0,percentage:50}]},{id:7,name:"IDE+Side",panes:3,preview:["\u250C\u2500\u252C\u2500\u2500\u252C\u2500\u2510","\u25021\u25022 \u25023\u2502","\u2514\u2500\u2534\u2500\u2500\u2534\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:80},{pane:1,horizontal:!0,percentage:25}]},{id:8,name:"Quad",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2510","\u25021 \u25022 \u2502","\u251C\u2500\u2500\u253C\u2500\u2500\u2524","\u25023 \u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:50},{pane:0,horizontal:!1,percentage:50},{pane:1,horizontal:!1,percentage:50}]},{id:9,name:"IDE Pro",panes:4,preview:["\u250C\u2500\u2500\u252C\u2500\u2500\u2500\u2500\u2500\u2510","\u2502 \u2502 2 \u2502","\u25021 \u251C\u2500\u2500\u252C\u2500\u2500\u2524","\u2502 \u2502 3\u25024 \u2502","\u2514\u2500\u2500\u2534\u2500\u2500\u2534\u2500\u2500\u2518"],splits:[{pane:0,horizontal:!0,percentage:75},{pane:1,horizontal:!1,percentage:40},{pane:2,horizontal:!0,percentage:50}]}];function G2(n,u,s,c){let E=Gs.find(_=>_.id===s);if(!E||E.splits.length===0)return;let I=`'${n.replace(/'/g,"'\\''")}':${u}`,S=c?` -c '${c.replace(/'/g,"'\\''")}'`:"",R=0;try{let _=Jn("tmux show-option -g pane-base-index",{encoding:"utf-8"}).trim();R=parseInt(_.split(" ").pop()||"0",10)}catch{}for(let _ of E.splits){let F=_.horizontal?"-h":"-v",X=`${I}.${R+_.pane}`;Jn(`tmux split-window -t ${X} ${F} -p ${_.percentage}${S}`,{stdio:"pipe"})}}function aF(n,u){let s="#{pane_index} #{pane_title} #{pane_current_command} #{pane_current_path} #{pane_active}",c=n.replace(/'/g,"'\\''");try{let E=Jn(`tmux list-panes -t '${c}':${u} -F '${s}'`,{encoding:"utf-8",stdio:["pipe","pipe","pipe"]}).trim();return E?E.split(`
291
- `).map(p=>{let[I,S,R,_,F]=p.split(" ");return{index:parseInt(I,10),title:S,currentCommand:R,currentPath:_,active:F==="1"}}):[]}catch{return[]}}function w2(n){return qm(n).map(s=>({...s,paneList:aF(n,s.index)}))}function L2(n,u,s){let c=n.replace(/'/g,"'\\''"),E=s.replace(/'/g,"'\\''");Jn(`tmux move-window -s '${c}':${u} -t '${E}':`,{stdio:"pipe"})}function lF(){try{return Jn("tmux info",{stdio:"ignore"}),!0}catch{return!1}}function uF(n){return Ir(hr(n,"tmux-resurrect"))||Ir(hr(n,"tmux-continuum"))}function z2(n){return{resurrect:Ir(hr(n,"tmux-resurrect")),continuum:Ir(hr(n,"tmux-continuum")),tpm:Ir(hr(n,"tpm"))}}function rQ(n){let u=hr(n,"tmux-resurrect/scripts/save.sh");if(Ir(u))try{Jn(`tmux run-shell '${u}'`,{stdio:"ignore"})}catch{}}function J2(n){if(lF()||!uF(n))return;let u=hr(n,"tmux-resurrect/scripts/restore.sh");if(!Ir(u))return;let s="__tmuxtui_warmup__";try{Jn(`tmux new-session -d -s '${s}'`,{stdio:"ignore"}),Jn(`tmux run-shell '${u}'`,{stdio:"ignore"}),Jn("sleep 1",{stdio:"ignore"})}catch{}finally{try{Jn(`tmux kill-session -t '${s}'`,{stdio:"ignore"})}catch{}}}function fQ(n){if(!n)return"\u2014";let u=new Date(n*1e3),s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=u.getHours().toString().padStart(2,"0"),E=u.getMinutes().toString().padStart(2,"0");return`${s[u.getMonth()]} ${u.getDate()} ${c}:${E}`}import{readFileSync as iF,writeFileSync as oF,mkdirSync as sF}from"fs";import{join as Y2}from"path";import{homedir as cF}from"os";var K2=Y2(cF(),".config","tmuxtui"),q2=Y2(K2,"favorites.json");function j2(){try{let n=JSON.parse(iF(q2,"utf-8"));return new Set(n.favorites||[])}catch{return new Set}}function rF(n){sF(K2,{recursive:!0}),oF(q2,JSON.stringify({favorites:[...n]},null,2))}function X2(n,u){let s=new Set(u);return s.has(n)?s.delete(n):s.add(n),rF(s),s}import{readFileSync as fF,writeFileSync as DG,mkdirSync as yG}from"fs";import{join as jm}from"path";import{homedir as gQ}from"os";var gF=jm(gQ(),".config","tmuxtui"),EF=jm(gF,"config.json"),EQ={"select-up":"up","select-down":"down",attach:"return",new:"n",rename:"r",kill:"d",detach:"x",search:"/",favorite:"s","favorites-filter":"f",refresh:"R",help:"h",quit:"q","batch-mark":"tab","batch-detach":"X","batch-kill":"D",detail:"i",config:"c"},ws={defaultSort:"lastAttached",confirmBeforeKill:!0,autoAttachOnCreate:!1,refreshInterval:0,pluginsDir:jm(gQ(),".tmux","plugins"),keybindings:EQ,ui:{showPath:!0,showSessionId:!1,sessionNameWidth:20}},CF=new Set(["lastAttached","name","created"]);function BF(n){if(typeof n!="object"||n===null||Array.isArray(n))return{};let u=n,s={};if(CF.has(u.defaultSort)&&(s.defaultSort=u.defaultSort),typeof u.confirmBeforeKill=="boolean"&&(s.confirmBeforeKill=u.confirmBeforeKill),typeof u.autoAttachOnCreate=="boolean"&&(s.autoAttachOnCreate=u.autoAttachOnCreate),typeof u.refreshInterval=="number"&&u.refreshInterval>=0&&(s.refreshInterval=Math.min(u.refreshInterval,300)),typeof u.pluginsDir=="string"&&u.pluginsDir.trim()!==""&&(s.pluginsDir=u.pluginsDir.startsWith("~")?jm(gQ(),u.pluginsDir.slice(1)):u.pluginsDir),typeof u.keybindings=="object"&&u.keybindings!==null&&!Array.isArray(u.keybindings)){let c={};for(let[E,p]of Object.entries(u.keybindings))typeof p=="string"&&(c[E]=p);s.keybindings=c}if(typeof u.ui=="object"&&u.ui!==null&&!Array.isArray(u.ui)){let c=u.ui,E={};typeof c.showPath=="boolean"&&(E.showPath=c.showPath),typeof c.showSessionId=="boolean"&&(E.showSessionId=c.showSessionId),typeof c.sessionNameWidth=="number"&&(E.sessionNameWidth=Math.max(10,Math.min(60,Math.round(c.sessionNameWidth)))),s.ui=E}return s}function dF(n){return{defaultSort:n.defaultSort??ws.defaultSort,confirmBeforeKill:n.confirmBeforeKill??ws.confirmBeforeKill,autoAttachOnCreate:n.autoAttachOnCreate??ws.autoAttachOnCreate,refreshInterval:n.refreshInterval??ws.refreshInterval,pluginsDir:n.pluginsDir??ws.pluginsDir,keybindings:{...EQ,...n.keybindings??{}},ui:{...ws.ui,...n.ui??{}}}}function Xm(){try{let n=JSON.parse(fF(EF,"utf-8")),u=BF(n);return dF(u)}catch{return{...ws,keybindings:{...EQ},ui:{...ws.ui}}}}var pF={up:"upArrow",down:"downArrow",return:"return",escape:"escape",tab:"tab",backspace:"backspace",delete:"delete"};function Yn(n,u,s){let c=pF[n];return c?!!s[c]:u===n}function HB(n,u){return[...n].sort((s,c)=>{if(s.attached!==c.attached)return s.attached?-1:1;switch(u){case"name":return s.name.localeCompare(c.name);case"created":return c.created-s.created;default:return c.lastAttached-s.lastAttached}})}var v=ae(BQ(),1);function hF({interactive:n,config:u,favoritesOnly:s,onSelect:c,onCreate:E,onKill:p,onRename:I,onDetach:S}){let{exit:R}=iQ(),{stdout:_}=oQ(),F=u,[X]=(0,xA.useState)(()=>z2(F.pluginsDir));function T(ut,tt){let Dt=ut.toLowerCase(),ht=tt.toLowerCase(),Mt=0;for(let h=0;h<ht.length&&Mt<Dt.length;h++)ht[h]===Dt[Mt]&&Mt++;return Mt===Dt.length}let[Y,et]=(0,xA.useState)(()=>HB(Qr(),F.defaultSort)),[q,K]=(0,xA.useState)(0),[vt,ce]=(0,xA.useState)(0),[Ht,yt]=(0,xA.useState)("list"),[Wt,Pt]=(0,xA.useState)(""),[re,Gt]=(0,xA.useState)(""),[It,qt]=(0,xA.useState)("name"),[ne,Ct]=(0,xA.useState)(""),[Me,Pe]=(0,xA.useState)(null),[st,bt]=(0,xA.useState)([]),[xt,wt]=(0,xA.useState)(0),[jt,me]=(0,xA.useState)("list"),[at,Ot]=(0,xA.useState)(0),[le,Ee]=(0,xA.useState)(""),[je,gn]=(0,xA.useState)(null),[Ie,Le]=(0,xA.useState)([]),[te,he]=(0,xA.useState)(0),[Rt,ee]=(0,xA.useState)([]),[Be,zt]=(0,xA.useState)(0),[Qe,BA]=(0,xA.useState)(j2),[hA,Jt]=(0,xA.useState)(s??!1),[cA,MA]=(0,xA.useState)(new Set),Ve=()=>{let ut=HB(Qr(),F.defaultSort);et(ut),K(tt=>Math.min(tt,Math.max(0,ut.length-1)))},Xt=hA?Y.filter(ut=>Qe.has(ut.name)):Y,na=_?.rows||24,fl=F.ui.showPath?3:2,aa=Math.max(1,Math.floor((na-8)/fl));(0,xA.useEffect)(()=>{let ut=Xt.length,tt=Math.min(q,Math.max(0,ut-1));ce(Dt=>{let ht=Dt;return tt<ht?ht=tt:tt>=ht+aa&&(ht=tt-aa+1),Math.max(0,Math.min(ht,Math.max(0,ut-aa)))})},[q,aa,Xt.length]);let En=()=>{if(!Me)return;let ut=qm(Me.name);bt(ut),wt(tt=>Math.min(tt,Math.max(0,ut.length-1)))};if(n&&uQ((ut,tt)=>{if(Ht==="new"){if(tt.escape){yt("list"),Pt(""),Gt(""),Ct("");return}if(tt.tab){qt(ht=>ht==="name"?"path":"name");return}if(tt.return){if(!Wt.trim()){Ct("Session name is required");return}let ht=(re||process.cwd()).replace(/^~/,process.env.HOME||"~");E?.(Wt.trim(),ht),F.autoAttachOnCreate?R():(Ve(),yt("list"),Pt(""),Gt(""),Ct(""));return}if(tt.backspace||tt.delete){It==="name"?Pt(ht=>ht.slice(0,-1)):Gt(ht=>ht.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(It==="name"?Pt(ht=>ht+ut):Gt(ht=>ht+ut),Ct(""));return}if(Ht==="rename"){if(tt.escape){yt("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Name cannot be empty");return}I?.(Y[q].name,Wt.trim()),Ve(),yt("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(ht=>ht.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(ht=>ht+ut),Ct(""));return}if(Ht==="confirm-kill"){if(tt.escape||ut==="n"){yt("list");return}(ut==="y"||tt.return)&&(p?.(Xt[q].name),Ve(),yt("list"));return}if(Ht==="confirm-batch-kill"){if(tt.escape||ut==="n"){yt("list");return}if(ut==="y"||tt.return){for(let ht of cA)p?.(ht);MA(new Set),Ve(),yt("list")}return}if(Ht==="search"){if(tt.escape){yt("list"),Ee("");return}if(tt.return){let ht=Y.filter(Mt=>T(le,Mt.name));ht.length>0&&(c?.(ht[q]),R());return}if(tt.backspace||tt.delete){Ee(ht=>ht.slice(0,-1));return}if(tt.upArrow||tt.downArrow){let ht=Y.filter(Mt=>T(le,Mt.name));tt.upArrow?K(Mt=>(Mt-1+ht.length)%ht.length):K(Mt=>(Mt+1)%ht.length);return}ut&&!tt.ctrl&&!tt.meta&&(Ee(ht=>ht+ut),K(0));return}if(Ht==="detail"){if(tt.escape){yt("list"),gn(null),Le([]);return}tt.upArrow?he(ht=>(ht-1+Ie.length)%Ie.length):tt.downArrow&&he(ht=>(ht+1)%Ie.length);return}if(Ht==="help"){if(tt.escape||ut==="q"||ut==="h"){yt("list");return}return}if(Ht==="config"){if(jt==="new"){if(tt.escape){me("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Window name is required");return}try{M2(Me.name,Wt.trim(),Me.path)}catch(Mt){Ct(Mt.message);return}En(),me("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(Mt=>Mt.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(Mt=>Mt+ut),Ct(""));return}if(jt==="rename"){if(tt.escape){me("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Name cannot be empty");return}try{H2(Me.name,st[xt].index,Wt.trim())}catch(Mt){Ct(Mt.message);return}En(),me("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(Mt=>Mt.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(Mt=>Mt+ut),Ct(""));return}if(jt==="confirm-delete"){if(tt.escape||ut==="n"){me("list");return}if(ut==="y"||tt.return){try{O2(Me.name,st[xt].index)}catch(Mt){Ct(Mt.message),me("list");return}En(),me("list")}return}if(jt==="init-panes"){if(tt.escape){me("list"),Ct("");return}if(tt.return){try{G2(Me.name,st[xt].index,Gs[at].id,Me.path)}catch(Mt){Ct(Mt.message);return}En(),me("list");return}tt.upArrow?Ot(Mt=>(Mt-1+Gs.length)%Gs.length):tt.downArrow&&Ot(Mt=>(Mt+1)%Gs.length);return}if(jt==="move"){if(tt.escape){me("list"),ee([]);return}if(tt.return&&Rt.length>0){try{L2(Me.name,st[xt].index,Rt[Be].name)}catch(Mt){Ct(Mt.message),me("list"),ee([]);return}En(),me("list"),ee([]);return}tt.upArrow?zt(Mt=>(Mt-1+Rt.length)%Rt.length):tt.downArrow&&zt(Mt=>(Mt+1)%Rt.length);return}if(tt.escape){Ve(),yt("list"),Pe(null);return}if(ut==="n"){me("new"),Pt(""),Ct("");return}if(ut==="r"&&st.length>0){me("rename"),Pt(st[xt].name),Ct("");return}if(ut==="d"&&st.length>0){me("confirm-delete");return}let ht=st.length>0&&st[xt].panes===1;if(ut==="i"&&ht){Ot(0),me("init-panes"),Ct("");return}if(ut==="m"&&st.length>0){let Mt=Qr().filter(h=>h.name!==Me.name);if(Mt.length===0){Ct("No other sessions to move to");return}ee(Mt),zt(0),me("move"),Ct("");return}tt.upArrow?wt(Mt=>(Mt-1+st.length)%st.length):tt.downArrow&&wt(Mt=>(Mt+1)%st.length);return}let Dt=F.keybindings;if(Yn(Dt.quit,ut,tt)){R();return}if(Yn(Dt.refresh,ut,tt)){Ve();return}if(Yn(Dt.favorite,ut,tt)&&Xt.length>0){BA(X2(Xt[q].name,Qe));return}if(Yn(Dt["favorites-filter"],ut,tt)){Jt(ht=>!ht),K(0);return}if(Yn(Dt["batch-mark"],ut,tt)&&Xt.length>0){MA(ht=>{let Mt=new Set(ht),h=Xt[q].name;return Mt.has(h)?Mt.delete(h):Mt.add(h),Mt}),K(ht=>(ht+1)%Xt.length);return}if(Yn(Dt["batch-detach"],ut,tt)&&cA.size>0){for(let ht of cA)S?.(ht);MA(new Set),Ve();return}if(Yn(Dt["batch-kill"],ut,tt)&&cA.size>0){if(F.confirmBeforeKill)yt("confirm-batch-kill");else{for(let ht of cA)p?.(ht);MA(new Set),Ve()}return}if(Yn(Dt.search,ut,tt)){yt("search"),Ee(""),K(0);return}if(Yn(Dt.detail,ut,tt)&&Xt.length>0){let ht=Xt[q];gn(ht),Le(w2(ht.name)),he(0),yt("detail");return}if(Yn(Dt.help,ut,tt)){yt("help");return}if(Yn(Dt.new,ut,tt)){yt("new"),qt("name"),Pt(""),Gt(""),Ct("");return}if(Yn(Dt.rename,ut,tt)&&Xt.length>0){yt("rename"),Pt(Xt[q].name),Ct("");return}if(Yn(Dt.detach,ut,tt)&&Xt.length>0){S?.(Xt[q].name),Ve();return}if(Yn(Dt.kill,ut,tt)&&Xt.length>0){F.confirmBeforeKill?yt("confirm-kill"):(p?.(Xt[q].name),Ve());return}if(Yn(Dt.config,ut,tt)&&Xt.length>0){let ht=Xt[q];Pe(ht),bt(qm(ht.name)),wt(0),me("list"),Ct(""),yt("config");return}Yn(Dt["select-up"],ut,tt)?K(ht=>(ht-1+Xt.length)%Xt.length):Yn(Dt["select-down"],ut,tt)?K(ht=>(ht+1)%Xt.length):Yn(Dt.attach,ut,tt)&&Xt.length>0&&(c?.(Xt[q]),R())}),Ht==="new")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{children:[" ","new session"]})]}),(0,v.jsxs)(Et,{marginBottom:1,flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:It==="name"?"cyan":"white",bold:It==="name",children:"Name: "}),(0,v.jsx)(x,{color:It==="name"?"cyan":"white",children:Wt}),It==="name"&&(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:It==="path"?"cyan":"white",bold:It==="path",children:"Path: "}),(0,v.jsx)(x,{color:It==="path"?"cyan":"white",children:re}),It==="path"&&(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"tab switch | \u21B5 create | esc cancel"})})]});if(Ht==="rename")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{children:[" ","rename session"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"New name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(Ht==="confirm-kill"&&Xt.length>0){let ut=Xt[q];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Kill session "}),(0,v.jsx)(x,{bold:!0,color:"red",children:ut.name}),(0,v.jsx)(x,{children:"?"})]}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(Ht==="confirm-batch-kill"&&cA.size>0)return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 batch delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Kill "}),(0,v.jsx)(x,{bold:!0,color:"red",children:cA.size}),(0,v.jsx)(x,{children:" sessions?"})]}),[...cA].map(ut=>(0,v.jsx)(Et,{marginLeft:2,children:(0,v.jsxs)(x,{color:"red",children:["- ",ut]})},ut)),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]});if(Ht==="search"){let ut=Y.filter(Dt=>T(le,Dt.name)),tt=Math.min(q,Math.max(0,ut.length-1));return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{color:"cyan",children:"/"}),(0,v.jsx)(x,{color:"cyan",children:le}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "}),(0,v.jsx)(x,{dimColor:!0,children:` ${ut.length}/${Y.length}`})]}),ut.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No matching sessions"}):(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{dimColor:!0,children:"NAME".padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:"WINS".padEnd(7)}),(0,v.jsx)(x,{dimColor:!0,children:"STATUS".padEnd(8)}),(0,v.jsx)(x,{dimColor:!0,children:" LAST USED"})]}),ut.map((Dt,ht)=>(0,v.jsx)(Et,{flexDirection:"column",marginBottom:1,children:(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:ht===tt?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:ht===tt?"cyan":Dt.attached?"green":"white",children:(Dt.name.length>F.ui.sessionNameWidth?Dt.name.slice(0,F.ui.sessionNameWidth-3)+"...":Dt.name).padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:`${Dt.windows} win${Dt.windows!==1?"s":""}`.padEnd(7)}),(0,v.jsx)(x,{color:"yellow",children:Dt.attached?"attached":" "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",fQ(Dt.lastAttached)]})]})},Dt.sessionId))]}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 attach | esc cancel"})})]})}if(Ht==="detail"&&je){let ut=te;return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:je.name}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",je.path.replace(process.env.HOME||"","~")]})]}),Ie.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No windows found"}):Ie.map((tt,Dt)=>(0,v.jsxs)(Et,{flexDirection:"column",marginBottom:1,children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===ut?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===ut?"cyan":tt.active?"green":"white",children:tt.name}),(0,v.jsx)(x,{dimColor:!0,children:` ${tt.panes} pane${tt.panes!==1?"s":""}`}),(0,v.jsx)(x,{color:"yellow",children:tt.active?" active":""})]}),Dt===ut&&tt.paneList&&tt.paneList.map(ht=>(0,v.jsxs)(Et,{marginLeft:3,children:[(0,v.jsx)(x,{dimColor:!0,children:`[${ht.index}] `}),(0,v.jsx)(x,{color:ht.active?"green":"white",children:ht.currentCommand}),ht.currentPath&&(0,v.jsx)(x,{dimColor:!0,children:` ${ht.currentPath.replace(process.env.HOME||"","~")}`})]},ht.index))]},tt.index)),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | esc back"})})]})}if(Ht==="help"){let ut=F.keybindings;return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:"Help"}),(0,v.jsx)(x,{dimColor:!0,children:" All available commands"})]}),(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsx)(x,{bold:!0,color:"white",children:"NAVIGATION"}),(0,v.jsxs)(x,{children:[" ",(0,v.jsxs)(x,{bold:!0,children:[ut["select-up"],"/",ut["select-down"]]}),(0,v.jsx)(x,{dimColor:!0,children:" Select session"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"SESSION MANAGEMENT"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.attach}),(0,v.jsx)(x,{dimColor:!0,children:" Attach to selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"green",bold:!0,children:ut.new}),(0,v.jsx)(x,{dimColor:!0,children:" Create new session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"yellow",bold:!0,children:ut.rename}),(0,v.jsx)(x,{dimColor:!0,children:" Rename selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"blue",bold:!0,children:ut.detach}),(0,v.jsx)(x,{dimColor:!0,children:" Detach selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"red",bold:!0,children:ut.kill}),(0,v.jsx)(x,{dimColor:!0,children:" Delete selected session"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"SEARCH & FILTER"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"cyan",bold:!0,children:ut.search}),(0,v.jsx)(x,{dimColor:!0,children:" Search sessions by name"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"yellow",bold:!0,children:ut.favorite}),(0,v.jsx)(x,{dimColor:!0,children:" Toggle favorite on selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"cyan",bold:!0,children:ut["favorites-filter"]}),(0,v.jsx)(x,{dimColor:!0,children:" Filter list to favorites only"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"ADVANCED"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"magenta",bold:!0,children:ut.config}),(0,v.jsx)(x,{dimColor:!0,children:" Config \u2014 manage windows for selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut.detail}),(0,v.jsx)(x,{dimColor:!0,children:" Show session details (windows & panes)"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut.refresh}),(0,v.jsx)(x,{dimColor:!0,children:" Refresh session list"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"BATCH OPERATIONS"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut["batch-mark"]}),(0,v.jsx)(x,{dimColor:!0,children:" Mark / unmark session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"blue",bold:!0,children:ut["batch-detach"]}),(0,v.jsx)(x,{dimColor:!0,children:" Batch detach all marked sessions"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"red",bold:!0,children:ut["batch-kill"]}),(0,v.jsx)(x,{dimColor:!0,children:" Batch delete all marked sessions"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"OTHER"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.quit}),(0,v.jsx)(x,{dimColor:!0,children:" Quit tmuxtui"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.help}),(0,v.jsx)(x,{dimColor:!0,children:" Show this help screen"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"PERSISTENCE"})}),(0,v.jsx)(x,{dimColor:!0,children:" Sessions live in tmux server memory and do NOT survive reboots."}),(0,v.jsx)(x,{dimColor:!0,children:" Install tmux-resurrect + tmux-continuum to save/restore across restarts."}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"PLUGINS"})}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",F.pluginsDir]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.resurrect?"green":"red",children:X.resurrect?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tmux-resurrect"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.continuum?"green":"red",children:X.continuum?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tmux-continuum"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.tpm?"green":"red",children:X.tpm?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tpm"})]})]}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"esc back to sessions"})})]})}if(Ht==="config"&&Me){if(jt==="new")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","new window"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 create | esc cancel"})})]});if(jt==="rename")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","rename window"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"New name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(jt==="confirm-delete"&&st.length>0){let tt=st[xt];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Delete window "}),(0,v.jsx)(x,{bold:!0,color:"red",children:tt.name}),(0,v.jsx)(x,{children:"?"})]}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(jt==="list")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ",Me.name]}),(0,v.jsxs)(x,{dimColor:!0,children:[" windows (",st.length,")"]})]}),st.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No windows found"}):st.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===xt?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===xt?"cyan":tt.active?"green":"white",children:tt.name.padEnd(20)}),(0,v.jsxs)(x,{dimColor:!0,children:[tt.panes," pane",tt.panes!==1?"s":""]}),(0,v.jsx)(x,{color:"yellow",children:tt.active?" active":""})]},tt.index)),n&&(0,v.jsxs)(Et,{marginTop:1,children:[(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | "}),(0,v.jsx)(x,{color:"green",bold:!0,children:"n"}),(0,v.jsx)(x,{dimColor:!0,children:" new | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:"r"}),(0,v.jsx)(x,{dimColor:!0,children:" rename | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:"d"}),(0,v.jsx)(x,{dimColor:!0,children:" delete | "}),st.length>0&&st[xt].panes===1&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(x,{color:"cyan",bold:!0,children:"i"}),(0,v.jsx)(x,{dimColor:!0,children:" init panes | "})]}),st.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(x,{color:"blue",bold:!0,children:"m"}),(0,v.jsx)(x,{dimColor:!0,children:" move | "})]}),(0,v.jsx)(x,{dimColor:!0,children:"esc back"})]})]});if(jt==="move")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","move window "]}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:st[xt]?.name}),(0,v.jsx)(x,{children:" to:"})]}),Rt.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===Be?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===Be?"cyan":"white",children:tt.name}),(0,v.jsx)(x,{dimColor:!0,children:` ${tt.windows} win${tt.windows!==1?"s":""}`}),(0,v.jsx)(x,{color:"yellow",children:tt.attached?" attached":""})]},tt.sessionId)),ne&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 move | esc cancel"})})]});let ut=Gs[at];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ",st[xt]?.name]}),(0,v.jsx)(x,{dimColor:!0,children:" init panes"})]}),Gs.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===at?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===at?"cyan":"white",children:`${tt.id}. ${tt.name.padEnd(12)}`}),(0,v.jsx)(x,{dimColor:!0,children:`${tt.panes} pane${tt.panes!==1?"s":""}`})]},tt.id)),(0,v.jsxs)(Et,{marginTop:1,flexDirection:"column",children:[(0,v.jsx)(x,{dimColor:!0,children:"Preview:"}),ut.preview.map((tt,Dt)=>(0,v.jsx)(x,{color:"cyan",children:tt},Dt))]}),ne&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 apply | esc cancel"})})]})}let Ta=Math.min(q,Math.max(0,Xt.length-1)),hn=Xt.slice(vt,vt+aa),Kn=vt,la=Math.max(0,Xt.length-vt-aa);return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ","tmux sessions (",Xt.length,hA?" \u2605":"","/",Y.length,")"]})]}),Xt.length===0?(0,v.jsx)(x,{dimColor:!0,children:hA?"No favorite sessions":"No tmux sessions found"}):(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{dimColor:!0,children:"NAME".padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:"WINS".padEnd(7)}),(0,v.jsx)(x,{dimColor:!0,children:"STATUS".padEnd(8)}),(0,v.jsx)(x,{dimColor:!0,children:" LAST USED"})]}),Kn>0&&(0,v.jsx)(x,{dimColor:!0,children:` \u25B2 ${Kn} more above`}),hn.map((ut,tt)=>{let Dt=vt+tt;return(0,v.jsxs)(Et,{flexDirection:"column",marginBottom:1,children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:cA.has(ut.name)?"\u2611":"\u2610"}),(0,v.jsx)(x,{children:Qe.has(ut.name)?"\u2605":" "}),(0,v.jsx)(x,{children:Dt===Ta?"\u25B8":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===Ta?"cyan":ut.attached?"green":"white",children:(ut.name.length>F.ui.sessionNameWidth?ut.name.slice(0,F.ui.sessionNameWidth-3)+"...":ut.name).padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:`${ut.windows} win${ut.windows!==1?"s":""}`.padEnd(7)}),(0,v.jsx)(x,{color:"yellow",children:ut.attached?"attached":" "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",fQ(ut.lastAttached)]}),F.ui.showSessionId&&(0,v.jsxs)(x,{dimColor:!0,children:[" ",ut.sessionId]})]}),ut.path&&F.ui.showPath&&(0,v.jsxs)(x,{dimColor:!0,children:[" ",ut.path.replace(process.env.HOME||"","~")]})]},ut.sessionId)}),la>0&&(0,v.jsx)(x,{dimColor:!0,children:` \u25BC ${la} more below`})]}),n&&(0,v.jsxs)(Et,{marginTop:1,flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsxs)(x,{dimColor:!0,children:[F.keybindings["select-up"],"/",F.keybindings["select-down"]," select | ",F.keybindings.attach," attach | "]}),(0,v.jsx)(x,{color:"green",bold:!0,children:F.keybindings.new}),(0,v.jsx)(x,{dimColor:!0,children:" new | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:F.keybindings.rename}),(0,v.jsx)(x,{dimColor:!0,children:" rename | "}),(0,v.jsx)(x,{color:"magenta",bold:!0,children:F.keybindings.config}),(0,v.jsx)(x,{dimColor:!0,children:" config | "}),(0,v.jsxs)(x,{dimColor:!0,children:[F.keybindings.quit," quit | "]}),(0,v.jsx)(x,{bold:!0,children:F.keybindings.help}),(0,v.jsx)(x,{dimColor:!0,children:" help"})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:"cyan",bold:!0,children:F.keybindings.search}),(0,v.jsx)(x,{dimColor:!0,children:" search | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:F.keybindings.favorite}),(0,v.jsx)(x,{dimColor:!0,children:" star | "}),(0,v.jsx)(x,{color:"cyan",bold:!0,children:F.keybindings["favorites-filter"]}),(0,v.jsx)(x,{dimColor:!0,children:" filter | "}),(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings.refresh}),(0,v.jsx)(x,{dimColor:!0,children:" refresh | "}),(0,v.jsx)(x,{color:"blue",bold:!0,children:F.keybindings.detach}),(0,v.jsx)(x,{dimColor:!0,children:" detach | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:F.keybindings.kill}),(0,v.jsx)(x,{dimColor:!0,children:" delete | "}),(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings.detail}),(0,v.jsx)(x,{dimColor:!0,children:" info"})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings["batch-mark"]}),(0,v.jsx)(x,{dimColor:!0,children:" mark | "}),(0,v.jsx)(x,{color:"blue",bold:!0,children:F.keybindings["batch-detach"]}),(0,v.jsx)(x,{dimColor:!0,children:" batch detach | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:F.keybindings["batch-kill"]}),(0,v.jsx)(x,{dimColor:!0,children:" batch kill"})]})]})]})}function dQ({onSelect:n,onCreate:u,onKill:s,onRename:c,onDetach:E,favoritesOnly:p,config:I}){let S=I??Xm();return(0,v.jsx)(hF,{interactive:!!process.stdin.isTTY,config:S,favoritesOnly:p,onSelect:n,onCreate:u,onKill:s,onRename:c,onDetach:E})}function km(n){process.stdout.write(`\x1B]0;[tmux] ${n}\x07`);let u=`'${n.replace(/'/g,"'\\''")}'`,s=process.env.TMUX?`tmux switch-client -t ${u}`:`tmux attach-session -t ${u}`;pQ(s,{stdio:"inherit"})}var Ja=process.argv.slice(2),lE=Xm();function QF(){console.log(`
291
+ `).map(p=>{let[I,S,R,_,F]=p.split(" ");return{index:parseInt(I,10),title:S,currentCommand:R,currentPath:_,active:F==="1"}}):[]}catch{return[]}}function w2(n){return qm(n).map(s=>({...s,paneList:aF(n,s.index)}))}function L2(n,u,s){let c=n.replace(/'/g,"'\\''"),E=s.replace(/'/g,"'\\''");Jn(`tmux move-window -s '${c}':${u} -t '${E}':`,{stdio:"pipe"})}function lF(){try{return Jn("tmux info",{stdio:"ignore"}),!0}catch{return!1}}function uF(n){return Ir(hr(n,"tmux-resurrect"))||Ir(hr(n,"tmux-continuum"))}function z2(n){return{resurrect:Ir(hr(n,"tmux-resurrect")),continuum:Ir(hr(n,"tmux-continuum")),tpm:Ir(hr(n,"tpm"))}}function rQ(n){let u=hr(n,"tmux-resurrect/scripts/save.sh");if(!Ir(u))return!1;try{return Jn(`tmux run-shell -b '${u}'`,{stdio:"ignore"}),!0}catch{return!1}}function J2(n){if(lF()||!uF(n))return;let u=hr(n,"tmux-resurrect/scripts/restore.sh");if(!Ir(u))return;let s="__tmuxtui_warmup__";try{Jn(`tmux new-session -d -s '${s}'`,{stdio:"ignore"}),Jn(`tmux run-shell '${u}'`,{stdio:"ignore"}),Jn("sleep 1",{stdio:"ignore"})}catch{}finally{try{Jn(`tmux kill-session -t '${s}'`,{stdio:"ignore"})}catch{}}}function fQ(n){if(!n)return"\u2014";let u=new Date(n*1e3),s=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=u.getHours().toString().padStart(2,"0"),E=u.getMinutes().toString().padStart(2,"0");return`${s[u.getMonth()]} ${u.getDate()} ${c}:${E}`}import{readFileSync as iF,writeFileSync as oF,mkdirSync as sF}from"fs";import{join as Y2}from"path";import{homedir as cF}from"os";var K2=Y2(cF(),".config","tmuxtui"),q2=Y2(K2,"favorites.json");function j2(){try{let n=JSON.parse(iF(q2,"utf-8"));return new Set(n.favorites||[])}catch{return new Set}}function rF(n){sF(K2,{recursive:!0}),oF(q2,JSON.stringify({favorites:[...n]},null,2))}function X2(n,u){let s=new Set(u);return s.has(n)?s.delete(n):s.add(n),rF(s),s}import{readFileSync as fF,writeFileSync as DG,mkdirSync as yG}from"fs";import{join as jm}from"path";import{homedir as gQ}from"os";var gF=jm(gQ(),".config","tmuxtui"),EF=jm(gF,"config.json"),EQ={"select-up":"up","select-down":"down",attach:"return",new:"n",rename:"r",kill:"d",detach:"x",search:"/",favorite:"s","favorites-filter":"f",refresh:"R",help:"h",quit:"q","batch-mark":"tab","batch-detach":"X","batch-kill":"D",detail:"i",config:"c"},ws={defaultSort:"lastAttached",confirmBeforeKill:!0,autoAttachOnCreate:!1,refreshInterval:0,pluginsDir:jm(gQ(),".tmux","plugins"),keybindings:EQ,ui:{showPath:!0,showSessionId:!1,sessionNameWidth:20}},CF=new Set(["lastAttached","name","created"]);function BF(n){if(typeof n!="object"||n===null||Array.isArray(n))return{};let u=n,s={};if(CF.has(u.defaultSort)&&(s.defaultSort=u.defaultSort),typeof u.confirmBeforeKill=="boolean"&&(s.confirmBeforeKill=u.confirmBeforeKill),typeof u.autoAttachOnCreate=="boolean"&&(s.autoAttachOnCreate=u.autoAttachOnCreate),typeof u.refreshInterval=="number"&&u.refreshInterval>=0&&(s.refreshInterval=Math.min(u.refreshInterval,300)),typeof u.pluginsDir=="string"&&u.pluginsDir.trim()!==""&&(s.pluginsDir=u.pluginsDir.startsWith("~")?jm(gQ(),u.pluginsDir.slice(1)):u.pluginsDir),typeof u.keybindings=="object"&&u.keybindings!==null&&!Array.isArray(u.keybindings)){let c={};for(let[E,p]of Object.entries(u.keybindings))typeof p=="string"&&(c[E]=p);s.keybindings=c}if(typeof u.ui=="object"&&u.ui!==null&&!Array.isArray(u.ui)){let c=u.ui,E={};typeof c.showPath=="boolean"&&(E.showPath=c.showPath),typeof c.showSessionId=="boolean"&&(E.showSessionId=c.showSessionId),typeof c.sessionNameWidth=="number"&&(E.sessionNameWidth=Math.max(10,Math.min(60,Math.round(c.sessionNameWidth)))),s.ui=E}return s}function dF(n){return{defaultSort:n.defaultSort??ws.defaultSort,confirmBeforeKill:n.confirmBeforeKill??ws.confirmBeforeKill,autoAttachOnCreate:n.autoAttachOnCreate??ws.autoAttachOnCreate,refreshInterval:n.refreshInterval??ws.refreshInterval,pluginsDir:n.pluginsDir??ws.pluginsDir,keybindings:{...EQ,...n.keybindings??{}},ui:{...ws.ui,...n.ui??{}}}}function Xm(){try{let n=JSON.parse(fF(EF,"utf-8")),u=BF(n);return dF(u)}catch{return{...ws,keybindings:{...EQ},ui:{...ws.ui}}}}var pF={up:"upArrow",down:"downArrow",return:"return",escape:"escape",tab:"tab",backspace:"backspace",delete:"delete"};function Yn(n,u,s){let c=pF[n];return c?!!s[c]:u===n}function HB(n,u){return[...n].sort((s,c)=>{if(s.attached!==c.attached)return s.attached?-1:1;switch(u){case"name":return s.name.localeCompare(c.name);case"created":return c.created-s.created;default:return c.lastAttached-s.lastAttached}})}var v=ae(BQ(),1);function hF({interactive:n,config:u,favoritesOnly:s,onSelect:c,onCreate:E,onKill:p,onRename:I,onDetach:S}){let{exit:R}=iQ(),{stdout:_}=oQ(),F=u,[X]=(0,xA.useState)(()=>z2(F.pluginsDir));function T(ut,tt){let Dt=ut.toLowerCase(),ht=tt.toLowerCase(),Mt=0;for(let h=0;h<ht.length&&Mt<Dt.length;h++)ht[h]===Dt[Mt]&&Mt++;return Mt===Dt.length}let[Y,et]=(0,xA.useState)(()=>HB(Qr(),F.defaultSort)),[q,K]=(0,xA.useState)(0),[vt,ce]=(0,xA.useState)(0),[Ht,yt]=(0,xA.useState)("list"),[Wt,Pt]=(0,xA.useState)(""),[re,Gt]=(0,xA.useState)(""),[It,qt]=(0,xA.useState)("name"),[ne,Ct]=(0,xA.useState)(""),[Me,Pe]=(0,xA.useState)(null),[st,bt]=(0,xA.useState)([]),[xt,wt]=(0,xA.useState)(0),[jt,me]=(0,xA.useState)("list"),[at,Ot]=(0,xA.useState)(0),[le,Ee]=(0,xA.useState)(""),[je,gn]=(0,xA.useState)(null),[Ie,Le]=(0,xA.useState)([]),[te,he]=(0,xA.useState)(0),[Rt,ee]=(0,xA.useState)([]),[Be,zt]=(0,xA.useState)(0),[Qe,BA]=(0,xA.useState)(j2),[hA,Jt]=(0,xA.useState)(s??!1),[cA,MA]=(0,xA.useState)(new Set),Ve=()=>{let ut=HB(Qr(),F.defaultSort);et(ut),K(tt=>Math.min(tt,Math.max(0,ut.length-1)))},Xt=hA?Y.filter(ut=>Qe.has(ut.name)):Y,na=_?.rows||24,fl=F.ui.showPath?3:2,aa=Math.max(1,Math.floor((na-8)/fl));(0,xA.useEffect)(()=>{let ut=Xt.length,tt=Math.min(q,Math.max(0,ut-1));ce(Dt=>{let ht=Dt;return tt<ht?ht=tt:tt>=ht+aa&&(ht=tt-aa+1),Math.max(0,Math.min(ht,Math.max(0,ut-aa)))})},[q,aa,Xt.length]);let En=()=>{if(!Me)return;let ut=qm(Me.name);bt(ut),wt(tt=>Math.min(tt,Math.max(0,ut.length-1)))};if(n&&uQ((ut,tt)=>{if(Ht==="new"){if(tt.escape){yt("list"),Pt(""),Gt(""),Ct("");return}if(tt.tab){qt(ht=>ht==="name"?"path":"name");return}if(tt.return){if(!Wt.trim()){Ct("Session name is required");return}let ht=(re||process.cwd()).replace(/^~/,process.env.HOME||"~");E?.(Wt.trim(),ht),F.autoAttachOnCreate?R():(Ve(),yt("list"),Pt(""),Gt(""),Ct(""));return}if(tt.backspace||tt.delete){It==="name"?Pt(ht=>ht.slice(0,-1)):Gt(ht=>ht.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(It==="name"?Pt(ht=>ht+ut):Gt(ht=>ht+ut),Ct(""));return}if(Ht==="rename"){if(tt.escape){yt("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Name cannot be empty");return}I?.(Y[q].name,Wt.trim()),Ve(),yt("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(ht=>ht.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(ht=>ht+ut),Ct(""));return}if(Ht==="confirm-kill"){if(tt.escape||ut==="n"){yt("list");return}(ut==="y"||tt.return)&&(p?.(Xt[q].name),Ve(),yt("list"));return}if(Ht==="confirm-batch-kill"){if(tt.escape||ut==="n"){yt("list");return}if(ut==="y"||tt.return){for(let ht of cA)p?.(ht);MA(new Set),Ve(),yt("list")}return}if(Ht==="search"){if(tt.escape){yt("list"),Ee("");return}if(tt.return){let ht=Y.filter(Mt=>T(le,Mt.name));ht.length>0&&(c?.(ht[q]),R());return}if(tt.backspace||tt.delete){Ee(ht=>ht.slice(0,-1));return}if(tt.upArrow||tt.downArrow){let ht=Y.filter(Mt=>T(le,Mt.name));tt.upArrow?K(Mt=>(Mt-1+ht.length)%ht.length):K(Mt=>(Mt+1)%ht.length);return}ut&&!tt.ctrl&&!tt.meta&&(Ee(ht=>ht+ut),K(0));return}if(Ht==="detail"){if(tt.escape){yt("list"),gn(null),Le([]);return}tt.upArrow?he(ht=>(ht-1+Ie.length)%Ie.length):tt.downArrow&&he(ht=>(ht+1)%Ie.length);return}if(Ht==="help"){if(tt.escape||ut==="q"||ut==="h"){yt("list");return}return}if(Ht==="config"){if(jt==="new"){if(tt.escape){me("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Window name is required");return}try{M2(Me.name,Wt.trim(),Me.path)}catch(Mt){Ct(Mt.message);return}En(),me("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(Mt=>Mt.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(Mt=>Mt+ut),Ct(""));return}if(jt==="rename"){if(tt.escape){me("list"),Pt(""),Ct("");return}if(tt.return){if(!Wt.trim()){Ct("Name cannot be empty");return}try{H2(Me.name,st[xt].index,Wt.trim())}catch(Mt){Ct(Mt.message);return}En(),me("list"),Pt(""),Ct("");return}if(tt.backspace||tt.delete){Pt(Mt=>Mt.slice(0,-1)),Ct("");return}ut&&!tt.ctrl&&!tt.meta&&(Pt(Mt=>Mt+ut),Ct(""));return}if(jt==="confirm-delete"){if(tt.escape||ut==="n"){me("list");return}if(ut==="y"||tt.return){try{O2(Me.name,st[xt].index)}catch(Mt){Ct(Mt.message),me("list");return}En(),me("list")}return}if(jt==="init-panes"){if(tt.escape){me("list"),Ct("");return}if(tt.return){try{G2(Me.name,st[xt].index,Gs[at].id,Me.path)}catch(Mt){Ct(Mt.message);return}En(),me("list");return}tt.upArrow?Ot(Mt=>(Mt-1+Gs.length)%Gs.length):tt.downArrow&&Ot(Mt=>(Mt+1)%Gs.length);return}if(jt==="move"){if(tt.escape){me("list"),ee([]);return}if(tt.return&&Rt.length>0){try{L2(Me.name,st[xt].index,Rt[Be].name)}catch(Mt){Ct(Mt.message),me("list"),ee([]);return}En(),me("list"),ee([]);return}tt.upArrow?zt(Mt=>(Mt-1+Rt.length)%Rt.length):tt.downArrow&&zt(Mt=>(Mt+1)%Rt.length);return}if(tt.escape){Ve(),yt("list"),Pe(null);return}if(ut==="n"){me("new"),Pt(""),Ct("");return}if(ut==="r"&&st.length>0){me("rename"),Pt(st[xt].name),Ct("");return}if(ut==="d"&&st.length>0){me("confirm-delete");return}let ht=st.length>0&&st[xt].panes===1;if(ut==="i"&&ht){Ot(0),me("init-panes"),Ct("");return}if(ut==="m"&&st.length>0){let Mt=Qr().filter(h=>h.name!==Me.name);if(Mt.length===0){Ct("No other sessions to move to");return}ee(Mt),zt(0),me("move"),Ct("");return}tt.upArrow?wt(Mt=>(Mt-1+st.length)%st.length):tt.downArrow&&wt(Mt=>(Mt+1)%st.length);return}let Dt=F.keybindings;if(Yn(Dt.quit,ut,tt)){R();return}if(Yn(Dt.refresh,ut,tt)){Ve();return}if(Yn(Dt.favorite,ut,tt)&&Xt.length>0){BA(X2(Xt[q].name,Qe));return}if(Yn(Dt["favorites-filter"],ut,tt)){Jt(ht=>!ht),K(0);return}if(Yn(Dt["batch-mark"],ut,tt)&&Xt.length>0){MA(ht=>{let Mt=new Set(ht),h=Xt[q].name;return Mt.has(h)?Mt.delete(h):Mt.add(h),Mt}),K(ht=>(ht+1)%Xt.length);return}if(Yn(Dt["batch-detach"],ut,tt)&&cA.size>0){for(let ht of cA)S?.(ht);MA(new Set),Ve();return}if(Yn(Dt["batch-kill"],ut,tt)&&cA.size>0){if(F.confirmBeforeKill)yt("confirm-batch-kill");else{for(let ht of cA)p?.(ht);MA(new Set),Ve()}return}if(Yn(Dt.search,ut,tt)){yt("search"),Ee(""),K(0);return}if(Yn(Dt.detail,ut,tt)&&Xt.length>0){let ht=Xt[q];gn(ht),Le(w2(ht.name)),he(0),yt("detail");return}if(Yn(Dt.help,ut,tt)){yt("help");return}if(Yn(Dt.new,ut,tt)){yt("new"),qt("name"),Pt(""),Gt(""),Ct("");return}if(Yn(Dt.rename,ut,tt)&&Xt.length>0){yt("rename"),Pt(Xt[q].name),Ct("");return}if(Yn(Dt.detach,ut,tt)&&Xt.length>0){S?.(Xt[q].name),Ve();return}if(Yn(Dt.kill,ut,tt)&&Xt.length>0){F.confirmBeforeKill?yt("confirm-kill"):(p?.(Xt[q].name),Ve());return}if(Yn(Dt.config,ut,tt)&&Xt.length>0){let ht=Xt[q];Pe(ht),bt(qm(ht.name)),wt(0),me("list"),Ct(""),yt("config");return}Yn(Dt["select-up"],ut,tt)?K(ht=>(ht-1+Xt.length)%Xt.length):Yn(Dt["select-down"],ut,tt)?K(ht=>(ht+1)%Xt.length):Yn(Dt.attach,ut,tt)&&Xt.length>0&&(c?.(Xt[q]),R())}),Ht==="new")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{children:[" ","new session"]})]}),(0,v.jsxs)(Et,{marginBottom:1,flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:It==="name"?"cyan":"white",bold:It==="name",children:"Name: "}),(0,v.jsx)(x,{color:It==="name"?"cyan":"white",children:Wt}),It==="name"&&(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:It==="path"?"cyan":"white",bold:It==="path",children:"Path: "}),(0,v.jsx)(x,{color:It==="path"?"cyan":"white",children:re}),It==="path"&&(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"tab switch | \u21B5 create | esc cancel"})})]});if(Ht==="rename")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{children:[" ","rename session"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"New name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(Ht==="confirm-kill"&&Xt.length>0){let ut=Xt[q];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Kill session "}),(0,v.jsx)(x,{bold:!0,color:"red",children:ut.name}),(0,v.jsx)(x,{children:"?"})]}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(Ht==="confirm-batch-kill"&&cA.size>0)return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 batch delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Kill "}),(0,v.jsx)(x,{bold:!0,color:"red",children:cA.size}),(0,v.jsx)(x,{children:" sessions?"})]}),[...cA].map(ut=>(0,v.jsx)(Et,{marginLeft:2,children:(0,v.jsxs)(x,{color:"red",children:["- ",ut]})},ut)),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]});if(Ht==="search"){let ut=Y.filter(Dt=>T(le,Dt.name)),tt=Math.min(q,Math.max(0,ut.length-1));return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{color:"cyan",children:"/"}),(0,v.jsx)(x,{color:"cyan",children:le}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "}),(0,v.jsx)(x,{dimColor:!0,children:` ${ut.length}/${Y.length}`})]}),ut.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No matching sessions"}):(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{dimColor:!0,children:"NAME".padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:"WINS".padEnd(7)}),(0,v.jsx)(x,{dimColor:!0,children:"STATUS".padEnd(8)}),(0,v.jsx)(x,{dimColor:!0,children:" LAST USED"})]}),ut.map((Dt,ht)=>(0,v.jsx)(Et,{flexDirection:"column",marginBottom:1,children:(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:ht===tt?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:ht===tt?"cyan":Dt.attached?"green":"white",children:(Dt.name.length>F.ui.sessionNameWidth?Dt.name.slice(0,F.ui.sessionNameWidth-3)+"...":Dt.name).padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:`${Dt.windows} win${Dt.windows!==1?"s":""}`.padEnd(7)}),(0,v.jsx)(x,{color:"yellow",children:Dt.attached?"attached":" "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",fQ(Dt.lastAttached)]})]})},Dt.sessionId))]}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 attach | esc cancel"})})]})}if(Ht==="detail"&&je){let ut=te;return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:je.name}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",je.path.replace(process.env.HOME||"","~")]})]}),Ie.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No windows found"}):Ie.map((tt,Dt)=>(0,v.jsxs)(Et,{flexDirection:"column",marginBottom:1,children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===ut?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===ut?"cyan":tt.active?"green":"white",children:tt.name}),(0,v.jsx)(x,{dimColor:!0,children:` ${tt.panes} pane${tt.panes!==1?"s":""}`}),(0,v.jsx)(x,{color:"yellow",children:tt.active?" active":""})]}),Dt===ut&&tt.paneList&&tt.paneList.map(ht=>(0,v.jsxs)(Et,{marginLeft:3,children:[(0,v.jsx)(x,{dimColor:!0,children:`[${ht.index}] `}),(0,v.jsx)(x,{color:ht.active?"green":"white",children:ht.currentCommand}),ht.currentPath&&(0,v.jsx)(x,{dimColor:!0,children:` ${ht.currentPath.replace(process.env.HOME||"","~")}`})]},ht.index))]},tt.index)),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | esc back"})})]})}if(Ht==="help"){let ut=F.keybindings;return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:"Help"}),(0,v.jsx)(x,{dimColor:!0,children:" All available commands"})]}),(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsx)(x,{bold:!0,color:"white",children:"NAVIGATION"}),(0,v.jsxs)(x,{children:[" ",(0,v.jsxs)(x,{bold:!0,children:[ut["select-up"],"/",ut["select-down"]]}),(0,v.jsx)(x,{dimColor:!0,children:" Select session"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"SESSION MANAGEMENT"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.attach}),(0,v.jsx)(x,{dimColor:!0,children:" Attach to selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"green",bold:!0,children:ut.new}),(0,v.jsx)(x,{dimColor:!0,children:" Create new session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"yellow",bold:!0,children:ut.rename}),(0,v.jsx)(x,{dimColor:!0,children:" Rename selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"blue",bold:!0,children:ut.detach}),(0,v.jsx)(x,{dimColor:!0,children:" Detach selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"red",bold:!0,children:ut.kill}),(0,v.jsx)(x,{dimColor:!0,children:" Delete selected session"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"SEARCH & FILTER"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"cyan",bold:!0,children:ut.search}),(0,v.jsx)(x,{dimColor:!0,children:" Search sessions by name"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"yellow",bold:!0,children:ut.favorite}),(0,v.jsx)(x,{dimColor:!0,children:" Toggle favorite on selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"cyan",bold:!0,children:ut["favorites-filter"]}),(0,v.jsx)(x,{dimColor:!0,children:" Filter list to favorites only"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"ADVANCED"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"magenta",bold:!0,children:ut.config}),(0,v.jsx)(x,{dimColor:!0,children:" Config \u2014 manage windows for selected session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut.detail}),(0,v.jsx)(x,{dimColor:!0,children:" Show session details (windows & panes)"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut.refresh}),(0,v.jsx)(x,{dimColor:!0,children:" Refresh session list"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"BATCH OPERATIONS"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"white",bold:!0,children:ut["batch-mark"]}),(0,v.jsx)(x,{dimColor:!0,children:" Mark / unmark session"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"blue",bold:!0,children:ut["batch-detach"]}),(0,v.jsx)(x,{dimColor:!0,children:" Batch detach all marked sessions"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:"red",bold:!0,children:ut["batch-kill"]}),(0,v.jsx)(x,{dimColor:!0,children:" Batch delete all marked sessions"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"OTHER"})}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.quit}),(0,v.jsx)(x,{dimColor:!0,children:" Quit tmuxtui"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{bold:!0,children:ut.help}),(0,v.jsx)(x,{dimColor:!0,children:" Show this help screen"})]}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"PERSISTENCE"})}),(0,v.jsx)(x,{dimColor:!0,children:" Sessions live in tmux server memory and do NOT survive reboots."}),(0,v.jsx)(x,{dimColor:!0,children:" Install tmux-resurrect + tmux-continuum to save/restore across restarts."}),(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{bold:!0,color:"white",children:"PLUGINS"})}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",F.pluginsDir]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.resurrect?"green":"red",children:X.resurrect?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tmux-resurrect"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.continuum?"green":"red",children:X.continuum?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tmux-continuum"})]}),(0,v.jsxs)(x,{children:[" ",(0,v.jsx)(x,{color:X.tpm?"green":"red",children:X.tpm?"\u2713":"\u2717"}),(0,v.jsx)(x,{dimColor:!0,children:" tpm"})]})]}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"esc back to sessions"})})]})}if(Ht==="config"&&Me){if(jt==="new")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","new window"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 create | esc cancel"})})]});if(jt==="rename")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","rename window"]})]}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"New name: "}),(0,v.jsx)(x,{color:"cyan",children:Wt}),(0,v.jsx)(x,{backgroundColor:"cyan",children:" "})]}),ne&&(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"\u21B5 confirm | esc cancel"})})]});if(jt==="confirm-delete"&&st.length>0){let tt=st[xt];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsx)(Et,{marginBottom:1,children:(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"red",children:" \u26A0 delete "})}),(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{children:"Delete window "}),(0,v.jsx)(x,{bold:!0,color:"red",children:tt.name}),(0,v.jsx)(x,{children:"?"})]}),(0,v.jsx)(Et,{children:(0,v.jsx)(x,{dimColor:!0,children:"y confirm | n/esc cancel"})})]})}if(jt==="list")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ",Me.name]}),(0,v.jsxs)(x,{dimColor:!0,children:[" windows (",st.length,")"]})]}),st.length===0?(0,v.jsx)(x,{dimColor:!0,children:"No windows found"}):st.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===xt?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===xt?"cyan":tt.active?"green":"white",children:tt.name.padEnd(20)}),(0,v.jsxs)(x,{dimColor:!0,children:[tt.panes," pane",tt.panes!==1?"s":""]}),(0,v.jsx)(x,{color:"yellow",children:tt.active?" active":""})]},tt.index)),n&&(0,v.jsxs)(Et,{marginTop:1,children:[(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | "}),(0,v.jsx)(x,{color:"green",bold:!0,children:"n"}),(0,v.jsx)(x,{dimColor:!0,children:" new | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:"r"}),(0,v.jsx)(x,{dimColor:!0,children:" rename | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:"d"}),(0,v.jsx)(x,{dimColor:!0,children:" delete | "}),st.length>0&&st[xt].panes===1&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(x,{color:"cyan",bold:!0,children:"i"}),(0,v.jsx)(x,{dimColor:!0,children:" init panes | "})]}),st.length>0&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(x,{color:"blue",bold:!0,children:"m"}),(0,v.jsx)(x,{dimColor:!0,children:" move | "})]}),(0,v.jsx)(x,{dimColor:!0,children:"esc back"})]})]});if(jt==="move")return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ","move window "]}),(0,v.jsx)(x,{bold:!0,color:"cyan",children:st[xt]?.name}),(0,v.jsx)(x,{children:" to:"})]}),Rt.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===Be?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===Be?"cyan":"white",children:tt.name}),(0,v.jsx)(x,{dimColor:!0,children:` ${tt.windows} win${tt.windows!==1?"s":""}`}),(0,v.jsx)(x,{color:"yellow",children:tt.attached?" attached":""})]},tt.sessionId)),ne&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 move | esc cancel"})})]});let ut=Gs[at];return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"magenta",children:" config "}),(0,v.jsxs)(x,{children:[" ",st[xt]?.name]}),(0,v.jsx)(x,{dimColor:!0,children:" init panes"})]}),Gs.map((tt,Dt)=>(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:Dt===at?"\u25B8 ":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===at?"cyan":"white",children:`${tt.id}. ${tt.name.padEnd(12)}`}),(0,v.jsx)(x,{dimColor:!0,children:`${tt.panes} pane${tt.panes!==1?"s":""}`})]},tt.id)),(0,v.jsxs)(Et,{marginTop:1,flexDirection:"column",children:[(0,v.jsx)(x,{dimColor:!0,children:"Preview:"}),ut.preview.map((tt,Dt)=>(0,v.jsx)(x,{color:"cyan",children:tt},Dt))]}),ne&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{color:"red",children:ne})}),n&&(0,v.jsx)(Et,{marginTop:1,children:(0,v.jsx)(x,{dimColor:!0,children:"\u2191\u2193 select | \u21B5 apply | esc cancel"})})]})}let Ta=Math.min(q,Math.max(0,Xt.length-1)),hn=Xt.slice(vt,vt+aa),Kn=vt,la=Math.max(0,Xt.length-vt-aa);return(0,v.jsxs)(Et,{flexDirection:"column",paddingX:1,children:[(0,v.jsxs)(Et,{marginBottom:1,children:[(0,v.jsx)(x,{bold:!0,color:"white",backgroundColor:"blue",children:" tmuxtui "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ","tmux sessions (",Xt.length,hA?" \u2605":"","/",Y.length,")"]})]}),Xt.length===0?(0,v.jsx)(x,{dimColor:!0,children:hA?"No favorite sessions":"No tmux sessions found"}):(0,v.jsxs)(Et,{flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:" "}),(0,v.jsx)(x,{dimColor:!0,children:"NAME".padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:"WINS".padEnd(7)}),(0,v.jsx)(x,{dimColor:!0,children:"STATUS".padEnd(8)}),(0,v.jsx)(x,{dimColor:!0,children:" LAST USED"})]}),Kn>0&&(0,v.jsx)(x,{dimColor:!0,children:` \u25B2 ${Kn} more above`}),hn.map((ut,tt)=>{let Dt=vt+tt;return(0,v.jsxs)(Et,{flexDirection:"column",marginBottom:1,children:[(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{children:cA.has(ut.name)?"\u2611":"\u2610"}),(0,v.jsx)(x,{children:Qe.has(ut.name)?"\u2605":" "}),(0,v.jsx)(x,{children:Dt===Ta?"\u25B8":" "}),(0,v.jsx)(x,{bold:!0,color:Dt===Ta?"cyan":ut.attached?"green":"white",children:(ut.name.length>F.ui.sessionNameWidth?ut.name.slice(0,F.ui.sessionNameWidth-3)+"...":ut.name).padEnd(F.ui.sessionNameWidth+2)}),(0,v.jsx)(x,{dimColor:!0,children:`${ut.windows} win${ut.windows!==1?"s":""}`.padEnd(7)}),(0,v.jsx)(x,{color:"yellow",children:ut.attached?"attached":" "}),(0,v.jsxs)(x,{dimColor:!0,children:[" ",fQ(ut.lastAttached)]}),F.ui.showSessionId&&(0,v.jsxs)(x,{dimColor:!0,children:[" ",ut.sessionId]})]}),ut.path&&F.ui.showPath&&(0,v.jsxs)(x,{dimColor:!0,children:[" ",ut.path.replace(process.env.HOME||"","~")]})]},ut.sessionId)}),la>0&&(0,v.jsx)(x,{dimColor:!0,children:` \u25BC ${la} more below`})]}),n&&(0,v.jsxs)(Et,{marginTop:1,flexDirection:"column",children:[(0,v.jsxs)(Et,{children:[(0,v.jsxs)(x,{dimColor:!0,children:[F.keybindings["select-up"],"/",F.keybindings["select-down"]," select | ",F.keybindings.attach," attach | "]}),(0,v.jsx)(x,{color:"green",bold:!0,children:F.keybindings.new}),(0,v.jsx)(x,{dimColor:!0,children:" new | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:F.keybindings.rename}),(0,v.jsx)(x,{dimColor:!0,children:" rename | "}),(0,v.jsx)(x,{color:"magenta",bold:!0,children:F.keybindings.config}),(0,v.jsx)(x,{dimColor:!0,children:" config | "}),(0,v.jsxs)(x,{dimColor:!0,children:[F.keybindings.quit," quit | "]}),(0,v.jsx)(x,{bold:!0,children:F.keybindings.help}),(0,v.jsx)(x,{dimColor:!0,children:" help"})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:"cyan",bold:!0,children:F.keybindings.search}),(0,v.jsx)(x,{dimColor:!0,children:" search | "}),(0,v.jsx)(x,{color:"yellow",bold:!0,children:F.keybindings.favorite}),(0,v.jsx)(x,{dimColor:!0,children:" star | "}),(0,v.jsx)(x,{color:"cyan",bold:!0,children:F.keybindings["favorites-filter"]}),(0,v.jsx)(x,{dimColor:!0,children:" filter | "}),(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings.refresh}),(0,v.jsx)(x,{dimColor:!0,children:" refresh | "}),(0,v.jsx)(x,{color:"blue",bold:!0,children:F.keybindings.detach}),(0,v.jsx)(x,{dimColor:!0,children:" detach | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:F.keybindings.kill}),(0,v.jsx)(x,{dimColor:!0,children:" delete | "}),(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings.detail}),(0,v.jsx)(x,{dimColor:!0,children:" info"})]}),(0,v.jsxs)(Et,{children:[(0,v.jsx)(x,{color:"white",bold:!0,children:F.keybindings["batch-mark"]}),(0,v.jsx)(x,{dimColor:!0,children:" mark | "}),(0,v.jsx)(x,{color:"blue",bold:!0,children:F.keybindings["batch-detach"]}),(0,v.jsx)(x,{dimColor:!0,children:" batch detach | "}),(0,v.jsx)(x,{color:"red",bold:!0,children:F.keybindings["batch-kill"]}),(0,v.jsx)(x,{dimColor:!0,children:" batch kill"})]})]})]})}function dQ({onSelect:n,onCreate:u,onKill:s,onRename:c,onDetach:E,favoritesOnly:p,config:I}){let S=I??Xm();return(0,v.jsx)(hF,{interactive:!!process.stdin.isTTY,config:S,favoritesOnly:p,onSelect:n,onCreate:u,onKill:s,onRename:c,onDetach:E})}function km(n){process.stdout.write(`\x1B]0;[tmux] ${n}\x07`);let u=`'${n.replace(/'/g,"'\\''")}'`,s=process.env.TMUX?`tmux switch-client -t ${u}`:`tmux attach-session -t ${u}`;pQ(s,{stdio:"inherit"})}var Ja=process.argv.slice(2),lE=Xm();function QF(){console.log(`
292
292
  tmuxtui - Terminal UI for tmux session management
293
293
 
294
294
  USAGE:
@@ -310,7 +310,7 @@ EXAMPLES:
310
310
  tmuxtui init Create session from current directory
311
311
  tmuxtui . Open current directory's tmux session
312
312
  tmuxtui --favorites Show only favorited sessions
313
- `)}(Ja[0]==="help"||Ja[0]==="-h"||Ja[0]==="--help")&&(QF(),process.exit(0));(Ja[0]==="version"||Ja[0]==="-v"||Ja[0]==="--version")&&(console.log("1.6.0"),process.exit(0));if(Ja[0]==="init"||Ja[0]==="-i"){let n=$2(process.cwd()),u=process.cwd();try{cQ(n,u),rQ(lE.pluginsDir),console.log(`${n} project has been added to tmuxtui`)}catch{console.error("Failed to create session. A session with the same name may already exist."),process.exit(1)}process.exit(0)}J2(lE.pluginsDir);if(Ja[0]==="."){let n=$2(process.cwd());if(Qr().find(c=>c.name===n))try{km(n)}catch{process.exit(1)}else console.error(`Session "${n}" not found. Run \`tmuxtui init\` to create it first.`),process.exit(1);process.exit(0)}if(Ja[0]==="last"||Ja[0]==="-l"){let n=HB(Qr(),lE.defaultSort);n.length===0&&(console.error("No tmux sessions found"),process.exit(1));try{km(n[0].name)}catch{process.exit(1)}process.exit(0)}if(Ja[0]==="update"){let n="1.6.0";console.log(`Current version: v${n}`);let u;try{u=pQ("npm view tmux-tui version",{encoding:"utf8"}).trim()}catch{console.error("Failed to check latest version. Please check your network connection."),process.exit(1)}n===u&&(console.log("Already up to date."),process.exit(0)),console.log(`Updating to v${u}...`);try{pQ("npm install -g tmux-tui@latest",{stdio:"inherit"})}catch{process.exit(1)}console.log(`Done. Updated to v${u}`),process.exit(0)}var DF=Ja.includes("--favorites")||Ja.includes("-F"),W2=Ja.filter(n=>n!=="--favorites"&&n!=="-F");W2[0]!==void 0&&(console.error(`Unknown argument: ${W2[0]}`),console.error('Use "tmuxtui -h" or "tmuxtui --help" for usage information.'),process.exit(1));var aE={session:null,newSession:null},yF=nQ(P2.default.createElement(dQ,{onSelect:n=>{aE.session=n},onCreate:(n,u)=>{cQ(n,u),rQ(lE.pluginsDir),aE.newSession=n},onKill:n=>{F2(n)},onRename:(n,u)=>{b2(n,u)},onDetach:n=>{U2(n)},favoritesOnly:DF,config:lE}));await yF.waitUntilExit();try{aE.session?km(aE.session.name):aE.newSession&&lE.autoAttachOnCreate&&km(aE.newSession)}catch{process.exit(1)}
313
+ `)}(Ja[0]==="help"||Ja[0]==="-h"||Ja[0]==="--help")&&(QF(),process.exit(0));(Ja[0]==="version"||Ja[0]==="-v"||Ja[0]==="--version")&&(console.log("1.7.0"),process.exit(0));if(Ja[0]==="init"||Ja[0]==="-i"){let n=$2(process.cwd()),u=process.cwd();try{cQ(n,u),console.log(`\u2714 Session '${n}' created`),rQ(lE.pluginsDir)&&console.log("\u23F3 Saving tmux snapshot in background (for restart-restore)..."),console.log(`${n} project has been added to tmuxtui`)}catch{console.error("Failed to create session. A session with the same name may already exist."),process.exit(1)}process.exit(0)}J2(lE.pluginsDir);if(Ja[0]==="."){let n=$2(process.cwd());if(Qr().find(c=>c.name===n))try{km(n)}catch{process.exit(1)}else console.error(`Session "${n}" not found. Run \`tmuxtui init\` to create it first.`),process.exit(1);process.exit(0)}if(Ja[0]==="last"||Ja[0]==="-l"){let n=HB(Qr(),lE.defaultSort);n.length===0&&(console.error("No tmux sessions found"),process.exit(1));try{km(n[0].name)}catch{process.exit(1)}process.exit(0)}if(Ja[0]==="update"){let n="1.7.0";console.log(`Current version: v${n}`);let u;try{u=pQ("npm view tmux-tui version",{encoding:"utf8"}).trim()}catch{console.error("Failed to check latest version. Please check your network connection."),process.exit(1)}n===u&&(console.log("Already up to date."),process.exit(0)),console.log(`Updating to v${u}...`);try{pQ("npm install -g tmux-tui@latest",{stdio:"inherit"})}catch{process.exit(1)}console.log(`Done. Updated to v${u}`),process.exit(0)}var DF=Ja.includes("--favorites")||Ja.includes("-F"),W2=Ja.filter(n=>n!=="--favorites"&&n!=="-F");W2[0]!==void 0&&(console.error(`Unknown argument: ${W2[0]}`),console.error('Use "tmuxtui -h" or "tmuxtui --help" for usage information.'),process.exit(1));var aE={session:null,newSession:null},yF=nQ(P2.default.createElement(dQ,{onSelect:n=>{aE.session=n},onCreate:(n,u)=>{cQ(n,u),rQ(lE.pluginsDir),aE.newSession=n},onKill:n=>{F2(n)},onRename:(n,u)=>{b2(n,u)},onDetach:n=>{U2(n)},favoritesOnly:DF,config:lE}));await yF.waitUntilExit();try{aE.session?km(aE.session.name):aE.newSession&&lE.autoAttachOnCreate&&km(aE.newSession)}catch{process.exit(1)}
314
314
  /*! Bundled license information:
315
315
 
316
316
  react/cjs/react.production.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmux-tui",
3
- "version": "1.6.0",
3
+ "version": "1.7.0",
4
4
  "description": "Terminal UI for tmux session management",
5
5
  "type": "module",
6
6
  "bin": {