tide-commander 1.129.0 → 1.129.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{BossLogsModal-C_z1JzI-.js → BossLogsModal-BMJsPBdB.js} +1 -1
- package/dist/assets/{BossSpawnModal-B9AuxTmd.js → BossSpawnModal-DuDDNuE-.js} +1 -1
- package/dist/assets/{ControlsModal-BXxZjks_.js → ControlsModal-Cn3pkMIT.js} +1 -1
- package/dist/assets/{DockerLogsModal-BQjpp4lj.js → DockerLogsModal-D5XQ6zSr.js} +1 -1
- package/dist/assets/{EmbeddedEditor-C4gQ9cLk.js → EmbeddedEditor-Ct4fmYRC.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-DHgp8RSO.js → GmailOAuthSetup-Cfxh0FZm.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-DZ_83P-Y.js → GoogleOAuthSetup-Z-Yv0mbQ.js} +1 -1
- package/dist/assets/{IframeModal-DbjNOXKz.js → IframeModal-eyoeBSzE.js} +1 -1
- package/dist/assets/{IntegrationsPanel-CnvFTjRQ.js → IntegrationsPanel-DzdEuC2w.js} +2 -2
- package/dist/assets/{LogViewerModal-BfgVn06N.js → LogViewerModal-fhtTos_b.js} +1 -1
- package/dist/assets/{MonitoringModal-BTRMhtxv.js → MonitoringModal-D_QNY_Zh.js} +1 -1
- package/dist/assets/{PM2LogsModal-CDwt_Jai.js → PM2LogsModal-DulkKfnA.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-CYOJ_uTt.js → RestoreArchivedAreaModal-BkpEL2dc.js} +1 -1
- package/dist/assets/{Scene2DCanvas-BWBWM519.js → Scene2DCanvas-C5E1mERA.js} +1 -1
- package/dist/assets/SceneManager-BA7KiD3q.js +104 -0
- package/dist/assets/{SkillsPanel-C2sdGrMJ.js → SkillsPanel-uotqhq5s.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-NmcYdN-r.js → SlackMultiInstanceSetup-B1QA0scY.js} +1 -1
- package/dist/assets/{SpawnModal-DAVpw4Ua.js → SpawnModal-B1d-vt6c.js} +1 -1
- package/dist/assets/{StatisticsModal-CO2dq4Jq.js → StatisticsModal-CpMdoPSG.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-D5CgdBMg.js → SubordinateAssignmentModal-ALjpv2DP.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-C24eB0yM.js → TriggerManagerPanel-rrDTH1Oq.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-C6LVEaLe.js → WorkflowEditorPanel-BcuM9e70.js} +1 -1
- package/dist/assets/{area-logos-Dm5yLK6S.js → area-logos-BkmhbXfG.js} +1 -1
- package/dist/assets/{index-BR4FMR2x.js → index-BNoB11BS.js} +2 -2
- package/dist/assets/{index-t9CiHYbj.js → index-BiXjxgpq.js} +1 -1
- package/dist/assets/{index-Dwg5JJJ1.js → index-BoN1bGyV.js} +1 -1
- package/dist/assets/{index-D3Hb8Eia.js → index-C9NJLW6A.js} +3 -3
- package/dist/assets/{index-zF-Yzhxm.js → index-CfEgfolW.js} +1 -1
- package/dist/assets/{index-CpnCiWTV.js → index-DI7bDj0E.js} +1 -1
- package/dist/assets/{index-CCRzFjTC.js → index-DMCGsQg5.js} +1 -1
- package/dist/assets/{index-DUd2IFRK.js → index-ZQNyoovC.js} +1 -1
- package/dist/assets/{index-GaRJHdJw.js → index-dfuoBomr.js} +1 -1
- package/dist/assets/{main-Bi4grTFP.js → main-CEKV7I4r.js} +105 -105
- package/dist/assets/{web-Ye7eWObV.js → web-CvCmCymz.js} +1 -1
- package/dist/assets/{web-B5-Tp8cv.js → web-DTb2MfHS.js} +1 -1
- package/dist/assets/{web-DxS4BBTf.js → web-jSBoGXkW.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/SceneManager-CWp8ES8Z.js +0 -104
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bx as Oe,r as t,s as I,i as ye,by as Ee,h as _e,j as e,I as z,u as fe,bz as ze,bA as Te,bB as Be,bC as Ue,n as We,bD as Ke,bE as De,bF as Ve,af as Ge,ag as qe,ah as Ye,b2 as Je,W as Me,S as oe,aY as Xe,aV as Qe,a6 as Ze,X as Ie,av as et,a1 as tt,bG as st,o as X,bH as nt}from"./main-
|
|
1
|
+
import{bx as Oe,r as t,s as I,i as ye,by as Ee,h as _e,j as e,I as z,u as fe,bz as ze,bA as Te,bB as Be,bC as Ue,n as We,bD as Ke,bE as De,bF as Ve,af as Ge,ag as qe,ah as Ye,b2 as Je,W as Me,S as oe,aY as Xe,aV as Qe,a6 as Ze,X as Ie,av as et,a1 as tt,bG as st,o as X,bH as nt}from"./main-CEKV7I4r.js";import{FileExplorerPanel as at}from"./index-C9NJLW6A.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const Ne={status:"all",activity:"all",sort:"activity"},lt={"1h":3600*1e3,"6h":360*60*1e3,"24h":1440*60*1e3},Ae=20,me=3,ot={idle:"#4aff9e",working:"#4a9eff",waiting:"#ff9e4a",waiting_permission:"#ffcc00",error:"#ff4a4a",offline:"#888888",orphaned:"#ff9e4a"},ct=12e4;function rt(s){return s.trim().replace(/\r\n/g,`
|
|
2
2
|
`)}function $e(s,a){return`${s}:${rt(a)}`}function it(s,a,l,f){if(s.uuid&&a.has(s.uuid))return!1;if(s.uuid)return!0;const p=s.isUserPrompt?"user":"assistant",d=$e(p,s.text),M=s.timestamp||0,A=l.get(d);return A!==void 0&&Math.abs(M-A)<=ct?!1:M>f}function dt({isOpen:s,agents:a}){const l=Oe(),[f,p]=t.useState(new Map),d=t.useRef(new Set);t.useRef(a);const M=t.useMemo(()=>Array.from(a.keys()).sort().join(","),[a]),A=t.useMemo(()=>Array.from(a.values()).map(j=>`${j.id}:${j.sessionId||""}`).sort().join(","),[a]);t.useEffect(()=>{s||(d.current.clear(),p(new Map))},[s]),t.useEffect(()=>{if(!s)return;const j=new Set(Array.from(a.keys()));for(const i of d.current)j.has(i)||d.current.delete(i);let h=null;l>0&&(h=I.preserveOutputs(),d.current.clear());const v=async(i,C,F=0)=>{if(d.current.add(i.id),F>0&&await new Promise(x=>setTimeout(x,F)),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!0,hasMore:!1,totalCount:0}),k}),!i.sessionId){C&&C.length>0&&I.mergeOutputsWithHistory(i.id,[],C),p(x=>{const k=new Map(x);return k.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),k});return}try{const k=await(await _e(ye(`/api/agents/${i.id}/history?limit=${Ee}&offset=0`))).json(),P=k.messages||[],K=P.length>0?Math.max(...P.map(w=>w.timestamp?new Date(w.timestamp).getTime():0)):0,Y=new Set(P.map(w=>w.uuid).filter(w=>!!w)),V=new Map;for(const w of P){if(w.type!=="user"&&w.type!=="assistant")continue;const c=$e(w.type,w.content),L=w.timestamp?new Date(w.timestamp).getTime():0,W=V.get(c)??0;L>W&&V.set(c,L)}const G=I.getOutputs(i.id),U=(C&&C.length>0?[...C,...G]:G).filter(w=>it(w,Y,V,K));I.clearOutputs(i.id);for(const w of U)I.addOutput(i.id,w);p(w=>{const c=new Map(w);return c.set(i.id,{agentId:i.id,messages:P,loading:!1,hasMore:k.hasMore||!1,totalCount:k.totalCount||0}),c})}catch(x){if(console.error(`Failed to load history for ${i.name}:`,x),C&&C.length>0){I.clearOutputs(i.id);for(const k of C)I.addOutput(i.id,k)}p(k=>{const P=new Map(k);return P.set(i.id,{agentId:i.id,messages:[],loading:!1,hasMore:!1,totalCount:0}),P})}},u=l>0?500:0,D=Array.from(a.values());for(const i of D)if(!d.current.has(i.id)){const C=h==null?void 0:h.get(i.id);v(i,C,u)}},[s,M,A,l]);const R=t.useRef(a),N=t.useRef(f);R.current=a,N.current=f;const b=t.useCallback(async j=>{const h=R.current.get(j),v=N.current.get(j);if(!(h!=null&&h.sessionId)||!v||!v.hasMore)return;const u=v.messages.length;try{const i=await(await fetch(ye(`/api/agents/${j}/history?limit=${Ee}&offset=${u}`))).json();i.messages&&i.messages.length>0&&p(C=>{const F=new Map(C),x=C.get(j);return x&&F.set(j,{...x,messages:[...i.messages,...x.messages],hasMore:i.hasMore||!1}),F})}catch(D){console.error(`Failed to load more history for agent ${j}:`,D)}},[]),E=t.useCallback(j=>{d.current.delete(j),p(h=>{const v=new Map(h),u=h.get(j);return u&&v.set(j,{...u,messages:[],hasMore:!1,totalCount:0,loading:!1}),v})},[]);return{histories:f,loadMoreHistory:b,clearAgentHistory:E}}function ut({command:s,onCommandChange:a,useTextarea:l,forceTextarea:f,onForceTextarea:p,onSend:d,canSend:M,attachedFiles:A,onAddFile:R,onRemoveFile:N,uploadFile:b,onAddPastedText:E,placeholder:j="Message...",className:h="",compact:v=!1,inputRef:u}){const D=t.useRef(null),i=t.useRef(null),C=t.useRef(l);t.useEffect(()=>{if(l&&!C.current&&i.current){const c=i.current;c.focus(),c.selectionStart=c.selectionEnd=c.value.length}C.current=l},[l]),t.useEffect(()=>{const c=i.current;if(!c||!l)return;c.style.height="auto";const L=v?120:180,W=Math.min(c.scrollHeight,L);c.style.height=`${W}px`},[s,l,v]);const F=t.useCallback(async c=>{const L=c.clipboardData.items;for(const _ of L)if(_.type.startsWith("image/")){c.preventDefault();const $=_.getAsFile();if($){const H=await b($);H&&R(H)}return}const W=c.clipboardData.files;if(W.length>0){c.preventDefault();for(const _ of W){const $=await b(_);$&&R($)}return}const B=c.clipboardData.getData("text"),te=(B.match(/\n/g)||[]).length+1;if(te>5){c.preventDefault();const $=`[Pasted text #${E(B)} +${te} lines]`,H=c.target,se=H.selectionStart||0,ae=H.selectionEnd||0,ne=s.slice(0,se)+$+s.slice(ae);a(ne),l||p(!0)}},[s,a,l,p,b,R,E]),x=t.useCallback(async c=>{const L=c.target.files;if(L){for(const W of L){const B=await b(W);B&&R(B)}D.current&&(D.current.value="")}},[b,R]),k=t.useCallback(c=>{if(c.key==="Enter"&&c.shiftKey){l||(c.preventDefault(),p(!0));return}c.key==="Enter"&&(c.preventDefault(),d())},[l,p,d]),P=t.useCallback(c=>{},[]),K=t.useCallback(c=>{c.button===1&&(c.preventDefault(),c.stopPropagation())},[]),Y=t.useCallback(c=>{i.current=c,u==null||u(c)},[u]),V=v?"agent-panel-input":"guake-input",G=v?"agent-panel-input-container":"guake-input-container",Q=v?"agent-panel-attach-btn":"guake-attach-btn",U=v?"agent-panel-send-btn":"",w=l?v?"agent-panel-input-expanded":"guake-input-expanded":"";return e.jsxs(e.Fragment,{children:[A.length>0&&e.jsx("div",{className:v?"agent-panel-attachments":"guake-attachments",children:A.map(c=>e.jsxs("div",{className:`${v?"agent-panel-attachment":"guake-attachment"} ${c.isImage?"is-image":""}`,children:[e.jsx("span",{className:v?"agent-panel-attachment-icon":"guake-attachment-icon",children:e.jsx(z,{name:c.isImage?"file":"paperclip",size:12})}),e.jsx("span",{className:v?"agent-panel-attachment-name":"guake-attachment-name",title:c.path,children:c.name}),!v&&e.jsxs("span",{className:"guake-attachment-size",children:["(",Math.round(c.size/1024),"KB)"]}),e.jsx("button",{className:v?"agent-panel-attachment-remove":"guake-attachment-remove",onClick:()=>N(c.id),title:"Remove",children:"×"})]},c.id))}),e.jsxs("div",{className:`${V} ${w} ${h}`,children:[e.jsx("input",{ref:D,type:"file",multiple:!0,onChange:x,style:{display:"none"},accept:"*"}),e.jsxs("div",{className:G,onAuxClick:K,children:[e.jsx("button",{className:Q,onClick:()=>{var c;return(c=D.current)==null?void 0:c.click()},title:"Attach file (or paste image)",children:e.jsx(z,{name:"paperclip",size:14})}),l?e.jsx("textarea",{ref:Y,placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}):e.jsx("input",{ref:u,type:"text",placeholder:j,value:s,onChange:c=>a(c.target.value),onKeyDown:k,onPaste:F,onMouseDown:P}),e.jsx("button",{className:U,onClick:d,disabled:!M,title:"Send",children:e.jsx(z,{name:"send",size:14})})]})]})]})}function mt(s){const a=Math.floor(s/1e3),l=Math.floor(a/60),f=a%60;return`${l}:${f.toString().padStart(2,"0")}`}const ft=t.memo(function({agentId:a,isWorking:l,timestamp:f}){const{t:p}=fe(["terminal"]),[d,M]=t.useState(0);return t.useEffect(()=>{if(!l||!f){M(0);return}M(Date.now()-f);const A=setInterval(()=>{M(Date.now()-f)},1e3);return()=>clearInterval(A)},[l,f]),l?e.jsxs("div",{className:"guake-stop-bar",children:[e.jsx("span",{className:"guake-elapsed-timer",children:mt(d)}),e.jsxs("button",{className:"guake-stop-btn",onClick:()=>I.stopAgent(a),title:p("terminal:input.stopOperation"),children:[e.jsx("span",{className:"stop-icon",children:e.jsx(z,{name:"stop",size:12,weight:"fill"})}),e.jsx("span",{className:"stop-label",children:p("terminal:input.stop")})]})]}):null});function pt({agent:s,history:a,outputs:l,isExpanded:f,isFocused:p,advancedView:d,onExpand:M,onFocus:A,inputRef:R,onLoadMore:N,onClearHistory:b}){const{t:E}=fe(["terminal","common"]),j=ze(s.id),h=t.useRef(null),[v,u]=t.useState(!1),D=t.useRef(0),i=t.useRef(!1),[C,F]=t.useState(!0),[x,k]=t.useState(!1),[P,K]=t.useState(null),[Y,V]=t.useState(null),[G,Q]=t.useState(null);Te(`commander-image-modal-${s.id}`,P!==null,()=>K(null));const{command:U,setCommand:w,forceTextarea:c,setForceTextarea:L,useTextarea:W,setPastedTexts:B,incrementPastedCount:te,resetPastedCount:_,attachedFiles:$,setAttachedFiles:H,removeAttachedFile:se,uploadFile:ae,expandPastedTexts:ne}=Be({selectedAgentId:s.id}),le=U.trim().length>0||$.length>0,n=Ue({outputs:l,viewMode:d?"advanced":"simple"}),o=t.useMemo(()=>{const S=We(s);return{usedPercent:S.usedPercent,freePercent:S.freePercent,hasData:!!s.contextStats,totalTokens:S.totalTokens,contextWindow:S.contextWindow}},[s.contextStats,s.contextUsed,s.contextLimit]),g=t.useCallback(()=>{!v&&(a!=null&&a.hasMore)&&N&&(u(!0),D.current=h.current?h.current.scrollHeight-h.current.scrollTop:0,N())},[v,a==null?void 0:a.hasMore,N]);t.useEffect(()=>{v&&a&&!a.loading&&u(!1)},[a,v]);const m=t.useCallback(()=>{i.current=!0,F(!1)},[]),T=t.useRef(f),Z=t.useRef(p);t.useEffect(()=>{(f&&!T.current||p&&!Z.current)&&(i.current=!1,F(!0),k(!0)),T.current=f,Z.current=p},[f,p]);const ee=t.useRef(a==null?void 0:a.loading);t.useEffect(()=>{ee.current&&!(a!=null&&a.loading)&&(i.current=!1,F(!0),k(!0)),ee.current=a==null?void 0:a.loading},[a==null?void 0:a.loading]),t.useEffect(()=>{if(!x)return;const S=h.current;if(!S)return;const y=performance.now();let O=0,ue=-1,ke;const Re=()=>{const{scrollTop:Fe,scrollHeight:Se,clientHeight:Le}=S,He=Se-Fe-Le<=2;if(Math.abs(Se-ue)<=1&&He?O+=1:O=0,ue=Se,O>=3){k(!1);return}if(performance.now()-y>5e3){k(!1);return}ke=requestAnimationFrame(Re)};return ke=requestAnimationFrame(Re),()=>cancelAnimationFrame(ke)},[x]),t.useEffect(()=>{i.current||F(!0)},[n.length]);const q=t.useCallback(()=>!1,[]),ie=t.useCallback(S=>{const y=te();return B(O=>new Map(O).set(y,S)),y},[te,B]),he=t.useCallback(S=>{H(y=>[...y,S])},[H]),xe=t.useCallback(()=>{if(!le)return;if(U.trim()==="/clear"&&$.length===0){I.clearContext(s.id),b(),w(""),L(!1),B(new Map),H([]),_();return}let S=ne(U.trim());if($.length>0){const y=$.map(O=>O.isImage?`[Image: ${O.path}]`:`[File: ${O.path}]`).join(`
|
|
3
3
|
`);S=S?`${S}
|
|
4
4
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmbeddedEditor-
|
|
2
|
-
import{r as t,h as W,i as V,G as Yt,Z as Bs,S as Ht,_ as _s,s as Be,u as re,j as e,I as M,bI as zt,f as Vs,bJ as Ks,bK as Gn,bL as Ws,bM as qs,bN as Un,bO as Bn,bP as Pt,bQ as _n,bR as Vn,bS as Kn,bT as es,bU as Wn,bV as Ys,bW as Lt,bX as $t,ak as ct,bY as xt,bZ as yt,b_ as Is,b$ as qn,bd as Yn,c0 as Zt,c1 as Ft,c2 as Jn,c3 as Xn,c4 as Qn,c5 as Zn,c6 as ea,c7 as Ps,C as ta,o as sa}from"./main-Bi4grTFP.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function na(s){const[n,l]=t.useState(null),[d,r]=t.useState(!1),i=t.useCallback(async()=>{if(s){r(!0);try{const m=await W(V(`/api/files/git-status?path=${encodeURIComponent(s)}`)),o=await m.json();m.ok?l(o):l({isGitRepo:!1,files:[]})}catch(m){console.error("[FileExplorer] Failed to load git status:",m),l({isGitRepo:!1,files:[]})}finally{r(!1)}}},[s]);return{gitStatus:n,loading:d,loadGitStatus:i}}async function aa(s){try{const n=await W(V(`/api/files/git-original?path=${encodeURIComponent(s)}`)),l=await n.json();return n.ok&&!l.isNew?{content:l.content,isNew:!1}:{content:null,isNew:!0}}catch(n){return console.error("[FileExplorer] Failed to load original file:",n),{content:null,isNew:!0}}}const ra=new Set([".txt",".md",".markdown",".json",".yaml",".yml",".xml",".html",".htm",".css",".scss",".sass",".less",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".rb",".c",".cpp",".h",".hpp",".cs",".go",".rs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".hs",".ml",".fs",".sql",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".toml",".ini",".cfg",".conf",".env",".gitignore",".dockerignore",".editorconfig",".prettierrc",".eslintrc",".babelrc",".log",".csv",".tsv",".svg",""]),ia=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"]),la=new Set([".pdf"]),oa=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".zip",".tar",".gz",".rar",".7z",".exe",".dmg",".app",".deb",".rpm",".apk",".aab",".ipa",".msi",".mp3",".mp4",".wav",".avi",".mov",".mkv",".flac",".ogg",".webm",".ttf",".otf",".woff",".woff2",".eot",".sqlite",".db",".so",".dll",".dylib",".a",".o",".obj",".bin",".dat",".iso",".img",".jar",".war",".ear",".class"]);function ca(s){const n=s.toLowerCase();return ia.has(n)?"image":la.has(n)?"pdf":oa.has(n)?"binary":(ra.has(n),"text")}function da(){const[s,n]=t.useState(null),[l,d]=t.useState(!1),[r,i]=t.useState(null),m=t.useCallback(async h=>{var p,j;d(!0),i(null);try{const f=h.substring(h.lastIndexOf(".")).toLowerCase(),b=ca(f),w=h.substring(h.lastIndexOf("/")+1);if(b==="image"){const k=await W(V(`/api/files/binary?path=${encodeURIComponent(h)}`));if(!k.ok){const C=await k.json().catch(()=>({error:"Failed to load image"}));i(C.error||"Failed to load image"),n(null);return}const x=await k.blob(),v=URL.createObjectURL(x);n({path:h,filename:w,extension:f,content:"",size:x.size,modified:new Date().toISOString(),fileType:"image",dataUrl:v});return}if(b==="pdf"){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(!k.ok){i(x.error||"Failed to load PDF info"),n(null);return}n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"pdf",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&token=${encodeURIComponent(Yt())}`)});return}if(b==="binary"){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(!k.ok){i(x.error||"Failed to load file info"),n(null);return}n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"binary",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&download=true&token=${encodeURIComponent(Yt())}`)});return}const R=await W(V(`/api/files/read?path=${encodeURIComponent(h)}`)),g=await R.json();if(!R.ok){if((p=g.error)!=null&&p.includes("too large")||(j=g.error)!=null&&j.includes("binary")){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(k.ok){n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"binary",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&download=true&token=${encodeURIComponent(Yt())}`)});return}}i(g.error||"Failed to load file"),n(null);return}n({...g,fileType:"text"})}catch(f){const b=f instanceof Error?f.message:"Failed to load file";i(b),n(null)}finally{d(!1)}},[]),o=t.useCallback(()=>{n(h=>(h!=null&&h.dataUrl&&h.dataUrl.startsWith("blob:")&&URL.revokeObjectURL(h.dataUrl),null)),i(null)},[]);return{file:s,loading:l,error:r,loadFile:m,clearFile:o,setFile:n}}const Jt="file-explorer-state",ua=10080*60*1e3;function ha(s,n){return n?`${Jt}-folder-${n}`:s?`${Jt}-area-${s}`:`${Jt}-default`}async function ma(s){try{const n=await W(V(`/api/files/exists?path=${encodeURIComponent(s)}`));return n.ok?(await n.json()).exists===!0:!1}catch{return!1}}function fa({areaId:s,folderPath:n,isOpen:l}){const d=ha(s,n),r=t.useRef(!1);t.useEffect(()=>{r.current=!1},[s,n]);const i=t.useCallback(async()=>{if(r.current)return null;r.current=!0;try{const o=localStorage.getItem(d);if(!o)return null;const h=JSON.parse(o);if(Date.now()-h.timestamp>ua)return localStorage.removeItem(d),null;const j=(await Promise.all(h.tabs.map(async b=>({tab:b,exists:await ma(b.path)})))).filter(({exists:b})=>b).map(({tab:b})=>b);let f=h.activeTabPath;return f&&!j.some(b=>b.path===f)&&(f=j.length>0?j[0].path:null),{tabs:j,activeTabPath:f,viewMode:h.viewMode||"files",selectedFolderIndex:h.selectedFolderIndex||0,expandedPaths:new Set(h.expandedPaths||[])}}catch(o){return console.error("[FileExplorerStorage] Failed to load state:",o),null}},[d]),m=t.useCallback(o=>{if(l)try{const h={tabs:o.tabs,activeTabPath:o.activeTabPath,viewMode:o.viewMode,selectedFolderIndex:o.selectedFolderIndex,expandedPaths:Array.from(o.expandedPaths),timestamp:Date.now()};localStorage.setItem(d,JSON.stringify(h))}catch(h){console.error("[FileExplorerStorage] Failed to save state:",h)}},[d,l]);return{loadStoredState:i,saveState:m}}const Ls=280,$s=150,Hs=1200;function pa(){const[s,n]=t.useState(()=>{const p=Bs(Ht.TREE_PANEL_WIDTH,Ls);return p>=$s&&p<=Hs?p:Ls}),l=t.useRef(!1),[d,r]=t.useState(!1),i=t.useRef(0),m=t.useRef(0),o=t.useRef(s);o.current=s;const h=t.useCallback(p=>{p.preventDefault(),l.current=!0,r(!0),i.current=p.clientX,m.current=s,document.body.style.cursor="ew-resize",document.body.style.userSelect="none"},[s]);return t.useEffect(()=>{const p=f=>{if(!l.current)return;const b=f.clientX-i.current,w=Math.min(Hs,Math.max($s,m.current+b));n(w)},j=()=>{l.current&&(l.current=!1,r(!1),document.body.style.cursor="",document.body.style.userSelect="",_s(Ht.TREE_PANEL_WIDTH,o.current))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",j),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",j)}},[]),{treePanelWidth:s,handleResizeStart:h,isResizing:d}}const ga=100,xa=.65,ya=36;function ba(){const[s,n]=t.useState(()=>Bs(Ht.MOBILE_TREE_PANEL_HEIGHT,0)),l=t.useRef(s);l.current=s;const d=t.useRef(0),r=t.useRef(0),i=()=>Math.floor((window.innerHeight-ya)*xa),m=f=>Math.min(i(),Math.max(ga,f)),o=t.useCallback(f=>{n(f);const b=document.querySelector(".file-explorer-main");b&&b.style.setProperty("--fe-mobile-tree-height",`${f}px`)},[]),h=t.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",_s(Ht.MOBILE_TREE_PANEL_HEIGHT,l.current),Be.setTerminalResizing(!1)},[]),p=t.useCallback(f=>{f.preventDefault();const b=document.querySelector(".file-explorer-tree-panel"),w=l.current>0?l.current:(b==null?void 0:b.getBoundingClientRect().height)??240;d.current=f.clientY,r.current=w,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Be.setTerminalResizing(!0);const R=k=>{const x=k.clientY-d.current;o(m(r.current+x))},g=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",g),h()};document.addEventListener("mousemove",R),document.addEventListener("mouseup",g)},[o,h]),j=t.useCallback(f=>{if(f.touches.length!==1)return;const b=document.querySelector(".file-explorer-tree-panel"),w=l.current>0?l.current:(b==null?void 0:b.getBoundingClientRect().height)??240;d.current=f.touches[0].clientY,r.current=w,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Be.setTerminalResizing(!0);const R=k=>{if(k.touches.length!==1)return;k.preventDefault();const x=k.touches[0].clientY-d.current;o(m(r.current+x))},g=()=>{document.removeEventListener("touchmove",R),document.removeEventListener("touchend",g),document.removeEventListener("touchcancel",g),h()};document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("touchend",g),document.addEventListener("touchcancel",g)},[o,h]);return{mobileTreeHeight:s,handleResizeMouseDown:p,handleResizeTouchStart:j}}function ts(){const[s,n]=t.useState([]),[l,d]=t.useState(!1),[r,i]=t.useState(null),[m,o]=t.useState(null),h=t.useCallback(async k=>{d(!0),i(null);try{const x=await W(V(`/api/files/git-branches?path=${encodeURIComponent(k)}`)),v=await x.json();x.ok?n(v.branches||[]):(i(v.error||"Failed to load branches"),n([]))}catch(x){console.error("[GitBranches] Failed to load branches:",x),i("Failed to load branches"),n([])}finally{d(!1)}},[]),p=t.useCallback(async(k,x)=>{o("checkout"),i(null);try{const v=await W(V("/api/files/git-checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:x})}),C=await v.json();return v.ok||i(C.error||"Checkout failed"),C}catch(v){console.error("[GitBranches] Checkout failed:",v);const C={success:!1,error:"Checkout failed"};return i(C.error),C}finally{o(null)}},[]),j=t.useCallback(async(k,x,v)=>{o("create"),i(null);try{const C=await W(V("/api/files/git-branch-create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,name:x,startPoint:v})}),D=await C.json();return C.ok||i(D.error||"Failed to create branch"),D}catch(C){console.error("[GitBranches] Create branch failed:",C);const D={success:!1,error:"Failed to create branch"};return i(D.error),D}finally{o(null)}},[]),f=t.useCallback(async k=>{o("pull"),i(null);try{const x=await W(V("/api/files/git-pull"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return!x.ok&&!v.conflicts&&i(v.error||"Pull failed"),v}catch(x){console.error("[GitBranches] Pull failed:",x);const v={success:!1,error:"Pull failed"};return i(v.error),v}finally{o(null)}},[]),b=t.useCallback(async k=>{o("push"),i(null);try{const x=await W(V("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Push failed"),v}catch(x){console.error("[GitBranches] Push failed:",x);const v={success:!1,error:"Push failed"};return i(v.error),v}finally{o(null)}},[]),w=t.useCallback(async(k,x)=>{o("merge"),i(null);try{const v=await W(V("/api/files/git-merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:x})}),C=await v.json();return!v.ok&&!C.conflicts&&i(C.error||"Merge failed"),C}catch(v){console.error("[GitBranches] Merge failed:",v);const C={success:!1,error:"Merge failed"};return i(C.error),C}finally{o(null)}},[]),R=t.useCallback(async k=>{o("merge-abort"),i(null);try{const x=await W(V("/api/files/git-merge-abort"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Merge abort failed"),v}catch(x){console.error("[GitBranches] Merge abort failed:",x);const v={success:!1,error:"Merge abort failed"};return i(v.error),v}finally{o(null)}},[]),g=t.useCallback(async k=>{o("merge-continue"),i(null);try{const x=await W(V("/api/files/git-merge-continue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Merge continue failed"),v}catch(x){console.error("[GitBranches] Merge continue failed:",x);const v={success:!1,error:"Merge continue failed"};return i(v.error),v}finally{o(null)}},[]);return{branches:s,loading:l,error:r,operationInProgress:m,loadBranches:h,checkoutBranch:p,createBranch:j,pullFromRemote:f,pushToRemote:b,mergeBranch:w,mergeAbort:R,mergeContinue:g}}const ja=50,va=400,zs={branch:"",author:"",since:"",until:"",searchPath:"",search:""};function wa(){const[s,n]=t.useState([]),[l,d]=t.useState(!1),[r,i]=t.useState(!1),[m,o]=t.useState(null),[h,p]=t.useState(!1),[j,f]=t.useState(0),[b,w]=t.useState({...zs}),[R,g]=t.useState(null),[k,x]=t.useState([]),[v,C]=t.useState(!1),[D,N]=t.useState([]),[U,_]=t.useState(!1),O=t.useRef(null),se=t.useRef(""),Q=t.useCallback((z,I,$)=>{const P=$||b,ee=new URLSearchParams;return ee.set("path",z),ee.set("limit",String(ja)),ee.set("offset",String(I)),P.branch&&ee.set("branch",P.branch),P.author&&ee.set("author",P.author),P.since&&ee.set("since",P.since),P.until&&ee.set("until",P.until),P.searchPath&&ee.set("searchPath",P.searchPath),P.search&&ee.set("search",P.search),ee.toString()},[b]),T=t.useCallback(async z=>{se.current=z,d(!0),o(null),g(null),x([]);try{const I=Q(z,0),$=await W(V(`/api/files/git-log?${I}`)),P=await $.json();$.ok?(n(P.commits||[]),f(P.total||0),p(P.hasMore||!1)):(o(P.error||"Failed to load git history"),n([]))}catch(I){console.error("[useGitHistory] loadHistory error:",I),o("Failed to load git history"),n([])}finally{d(!1)}},[Q]),F=t.useCallback(async z=>{if(!(r||!h)){i(!0);try{const I=Q(z,s.length),$=await W(V(`/api/files/git-log?${I}`)),P=await $.json();$.ok&&(n(ee=>[...ee,...P.commits||[]]),f(P.total||0),p(P.hasMore||!1))}catch(I){console.error("[useGitHistory] loadMore error:",I)}finally{i(!1)}}},[Q,s.length,h,r]),K=t.useCallback(async z=>{if(g(z),!z){x([]);return}C(!0);try{const I=se.current,$=new URLSearchParams({path:I,hash:z.hash}),P=await W(V(`/api/files/git-commit-files?${$}`)),ee=await P.json();P.ok?x(ee.files||[]):x([])}catch(I){console.error("[useGitHistory] selectCommit files error:",I),x([])}finally{C(!1)}},[]),ne=t.useCallback((z,I)=>{w($=>({...$,[z]:I}))},[]),ie=t.useCallback(()=>{w({...zs})},[]);t.useEffect(()=>{const z=se.current;if(z)return O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{T(z)},va),()=>{O.current&&clearTimeout(O.current)}},[b]);const fe=t.useCallback(async z=>{_(!0);try{const I=new URLSearchParams({path:z}),$=await W(V(`/api/files/git-authors?${I}`)),P=await $.json();$.ok&&N(P.authors||[])}catch(I){console.error("[useGitHistory] loadAuthors error:",I)}finally{_(!1)}},[]);return{commits:s,loading:l,loadingMore:r,error:m,hasMore:h,total:j,filters:b,setFilter:ne,resetFilters:ie,selectedCommit:R,selectCommit:K,commitFiles:k,commitFilesLoading:v,loadHistory:T,loadMore:F,authors:D,authorsLoading:U,loadAuthors:fe}}function Ca(s){if(!s.current)return null;const n=[".file-viewer-code-with-lines",".file-viewer-markdown-wrapper",".file-viewer-code-wrapper",".file-viewer-diagram-wrapper",".file-viewer-image-wrapper",".file-viewer-pdf-wrapper"];for(const l of n){const d=s.current.querySelector(l);if(d&&Os(d))return d}return Os(s.current)?s.current:null}function Os(s){const n=["auto","scroll"].includes(getComputedStyle(s).overflowY),l=s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth;return n&&l}function Js(s){if(!s)return 19.5;const n=parseFloat(getComputedStyle(s).lineHeight);return isNaN(n)?19.5:n}function Xt(s,n=!0){const l=n?s.scrollHeight:0;s.scrollTo({top:l,behavior:"smooth"})}function Na(s){const{scrollTop:n,scrollHeight:l,clientHeight:d}=s;return l<=d?100:Math.round(n/(l-d)*100)}function ka(s,n){const l=Js(s),d=s.scrollTop,r=Math.floor(d/l)+1,i=n.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmbeddedEditor-Ct4fmYRC.js","assets/main-CEKV7I4r.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-Chj50gSY.js","assets/main-D086vUF0.css","assets/EmbeddedEditor-O_u2UVA4.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as t,h as W,i as V,G as Yt,Z as Bs,S as Ht,_ as _s,s as Be,u as re,j as e,I as M,bI as zt,f as Vs,bJ as Ks,bK as Gn,bL as Ws,bM as qs,bN as Un,bO as Bn,bP as Pt,bQ as _n,bR as Vn,bS as Kn,bT as es,bU as Wn,bV as Ys,bW as Lt,bX as $t,ak as ct,bY as xt,bZ as yt,b_ as Is,b$ as qn,bd as Yn,c0 as Zt,c1 as Ft,c2 as Jn,c3 as Xn,c4 as Qn,c5 as Zn,c6 as ea,c7 as Ps,C as ta,o as sa}from"./main-CEKV7I4r.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";function na(s){const[n,l]=t.useState(null),[d,r]=t.useState(!1),i=t.useCallback(async()=>{if(s){r(!0);try{const m=await W(V(`/api/files/git-status?path=${encodeURIComponent(s)}`)),o=await m.json();m.ok?l(o):l({isGitRepo:!1,files:[]})}catch(m){console.error("[FileExplorer] Failed to load git status:",m),l({isGitRepo:!1,files:[]})}finally{r(!1)}}},[s]);return{gitStatus:n,loading:d,loadGitStatus:i}}async function aa(s){try{const n=await W(V(`/api/files/git-original?path=${encodeURIComponent(s)}`)),l=await n.json();return n.ok&&!l.isNew?{content:l.content,isNew:!1}:{content:null,isNew:!0}}catch(n){return console.error("[FileExplorer] Failed to load original file:",n),{content:null,isNew:!0}}}const ra=new Set([".txt",".md",".markdown",".json",".yaml",".yml",".xml",".html",".htm",".css",".scss",".sass",".less",".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".rb",".c",".cpp",".h",".hpp",".cs",".go",".rs",".swift",".kt",".scala",".clj",".ex",".exs",".erl",".hs",".ml",".fs",".sql",".sh",".bash",".zsh",".fish",".ps1",".bat",".cmd",".toml",".ini",".cfg",".conf",".env",".gitignore",".dockerignore",".editorconfig",".prettierrc",".eslintrc",".babelrc",".log",".csv",".tsv",".svg",""]),ia=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"]),la=new Set([".pdf"]),oa=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".zip",".tar",".gz",".rar",".7z",".exe",".dmg",".app",".deb",".rpm",".apk",".aab",".ipa",".msi",".mp3",".mp4",".wav",".avi",".mov",".mkv",".flac",".ogg",".webm",".ttf",".otf",".woff",".woff2",".eot",".sqlite",".db",".so",".dll",".dylib",".a",".o",".obj",".bin",".dat",".iso",".img",".jar",".war",".ear",".class"]);function ca(s){const n=s.toLowerCase();return ia.has(n)?"image":la.has(n)?"pdf":oa.has(n)?"binary":(ra.has(n),"text")}function da(){const[s,n]=t.useState(null),[l,d]=t.useState(!1),[r,i]=t.useState(null),m=t.useCallback(async h=>{var p,j;d(!0),i(null);try{const f=h.substring(h.lastIndexOf(".")).toLowerCase(),b=ca(f),w=h.substring(h.lastIndexOf("/")+1);if(b==="image"){const k=await W(V(`/api/files/binary?path=${encodeURIComponent(h)}`));if(!k.ok){const C=await k.json().catch(()=>({error:"Failed to load image"}));i(C.error||"Failed to load image"),n(null);return}const x=await k.blob(),v=URL.createObjectURL(x);n({path:h,filename:w,extension:f,content:"",size:x.size,modified:new Date().toISOString(),fileType:"image",dataUrl:v});return}if(b==="pdf"){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(!k.ok){i(x.error||"Failed to load PDF info"),n(null);return}n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"pdf",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&token=${encodeURIComponent(Yt())}`)});return}if(b==="binary"){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(!k.ok){i(x.error||"Failed to load file info"),n(null);return}n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"binary",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&download=true&token=${encodeURIComponent(Yt())}`)});return}const R=await W(V(`/api/files/read?path=${encodeURIComponent(h)}`)),g=await R.json();if(!R.ok){if((p=g.error)!=null&&p.includes("too large")||(j=g.error)!=null&&j.includes("binary")){const k=await W(V(`/api/files/info?path=${encodeURIComponent(h)}`)),x=await k.json();if(k.ok){n({path:h,filename:w,extension:f,content:"",size:x.size,modified:x.modified,fileType:"binary",dataUrl:V(`/api/files/binary?path=${encodeURIComponent(h)}&download=true&token=${encodeURIComponent(Yt())}`)});return}}i(g.error||"Failed to load file"),n(null);return}n({...g,fileType:"text"})}catch(f){const b=f instanceof Error?f.message:"Failed to load file";i(b),n(null)}finally{d(!1)}},[]),o=t.useCallback(()=>{n(h=>(h!=null&&h.dataUrl&&h.dataUrl.startsWith("blob:")&&URL.revokeObjectURL(h.dataUrl),null)),i(null)},[]);return{file:s,loading:l,error:r,loadFile:m,clearFile:o,setFile:n}}const Jt="file-explorer-state",ua=10080*60*1e3;function ha(s,n){return n?`${Jt}-folder-${n}`:s?`${Jt}-area-${s}`:`${Jt}-default`}async function ma(s){try{const n=await W(V(`/api/files/exists?path=${encodeURIComponent(s)}`));return n.ok?(await n.json()).exists===!0:!1}catch{return!1}}function fa({areaId:s,folderPath:n,isOpen:l}){const d=ha(s,n),r=t.useRef(!1);t.useEffect(()=>{r.current=!1},[s,n]);const i=t.useCallback(async()=>{if(r.current)return null;r.current=!0;try{const o=localStorage.getItem(d);if(!o)return null;const h=JSON.parse(o);if(Date.now()-h.timestamp>ua)return localStorage.removeItem(d),null;const j=(await Promise.all(h.tabs.map(async b=>({tab:b,exists:await ma(b.path)})))).filter(({exists:b})=>b).map(({tab:b})=>b);let f=h.activeTabPath;return f&&!j.some(b=>b.path===f)&&(f=j.length>0?j[0].path:null),{tabs:j,activeTabPath:f,viewMode:h.viewMode||"files",selectedFolderIndex:h.selectedFolderIndex||0,expandedPaths:new Set(h.expandedPaths||[])}}catch(o){return console.error("[FileExplorerStorage] Failed to load state:",o),null}},[d]),m=t.useCallback(o=>{if(l)try{const h={tabs:o.tabs,activeTabPath:o.activeTabPath,viewMode:o.viewMode,selectedFolderIndex:o.selectedFolderIndex,expandedPaths:Array.from(o.expandedPaths),timestamp:Date.now()};localStorage.setItem(d,JSON.stringify(h))}catch(h){console.error("[FileExplorerStorage] Failed to save state:",h)}},[d,l]);return{loadStoredState:i,saveState:m}}const Ls=280,$s=150,Hs=1200;function pa(){const[s,n]=t.useState(()=>{const p=Bs(Ht.TREE_PANEL_WIDTH,Ls);return p>=$s&&p<=Hs?p:Ls}),l=t.useRef(!1),[d,r]=t.useState(!1),i=t.useRef(0),m=t.useRef(0),o=t.useRef(s);o.current=s;const h=t.useCallback(p=>{p.preventDefault(),l.current=!0,r(!0),i.current=p.clientX,m.current=s,document.body.style.cursor="ew-resize",document.body.style.userSelect="none"},[s]);return t.useEffect(()=>{const p=f=>{if(!l.current)return;const b=f.clientX-i.current,w=Math.min(Hs,Math.max($s,m.current+b));n(w)},j=()=>{l.current&&(l.current=!1,r(!1),document.body.style.cursor="",document.body.style.userSelect="",_s(Ht.TREE_PANEL_WIDTH,o.current))};return document.addEventListener("mousemove",p),document.addEventListener("mouseup",j),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",j)}},[]),{treePanelWidth:s,handleResizeStart:h,isResizing:d}}const ga=100,xa=.65,ya=36;function ba(){const[s,n]=t.useState(()=>Bs(Ht.MOBILE_TREE_PANEL_HEIGHT,0)),l=t.useRef(s);l.current=s;const d=t.useRef(0),r=t.useRef(0),i=()=>Math.floor((window.innerHeight-ya)*xa),m=f=>Math.min(i(),Math.max(ga,f)),o=t.useCallback(f=>{n(f);const b=document.querySelector(".file-explorer-main");b&&b.style.setProperty("--fe-mobile-tree-height",`${f}px`)},[]),h=t.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",_s(Ht.MOBILE_TREE_PANEL_HEIGHT,l.current),Be.setTerminalResizing(!1)},[]),p=t.useCallback(f=>{f.preventDefault();const b=document.querySelector(".file-explorer-tree-panel"),w=l.current>0?l.current:(b==null?void 0:b.getBoundingClientRect().height)??240;d.current=f.clientY,r.current=w,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Be.setTerminalResizing(!0);const R=k=>{const x=k.clientY-d.current;o(m(r.current+x))},g=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",g),h()};document.addEventListener("mousemove",R),document.addEventListener("mouseup",g)},[o,h]),j=t.useCallback(f=>{if(f.touches.length!==1)return;const b=document.querySelector(".file-explorer-tree-panel"),w=l.current>0?l.current:(b==null?void 0:b.getBoundingClientRect().height)??240;d.current=f.touches[0].clientY,r.current=w,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Be.setTerminalResizing(!0);const R=k=>{if(k.touches.length!==1)return;k.preventDefault();const x=k.touches[0].clientY-d.current;o(m(r.current+x))},g=()=>{document.removeEventListener("touchmove",R),document.removeEventListener("touchend",g),document.removeEventListener("touchcancel",g),h()};document.addEventListener("touchmove",R,{passive:!1}),document.addEventListener("touchend",g),document.addEventListener("touchcancel",g)},[o,h]);return{mobileTreeHeight:s,handleResizeMouseDown:p,handleResizeTouchStart:j}}function ts(){const[s,n]=t.useState([]),[l,d]=t.useState(!1),[r,i]=t.useState(null),[m,o]=t.useState(null),h=t.useCallback(async k=>{d(!0),i(null);try{const x=await W(V(`/api/files/git-branches?path=${encodeURIComponent(k)}`)),v=await x.json();x.ok?n(v.branches||[]):(i(v.error||"Failed to load branches"),n([]))}catch(x){console.error("[GitBranches] Failed to load branches:",x),i("Failed to load branches"),n([])}finally{d(!1)}},[]),p=t.useCallback(async(k,x)=>{o("checkout"),i(null);try{const v=await W(V("/api/files/git-checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:x})}),C=await v.json();return v.ok||i(C.error||"Checkout failed"),C}catch(v){console.error("[GitBranches] Checkout failed:",v);const C={success:!1,error:"Checkout failed"};return i(C.error),C}finally{o(null)}},[]),j=t.useCallback(async(k,x,v)=>{o("create"),i(null);try{const C=await W(V("/api/files/git-branch-create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,name:x,startPoint:v})}),D=await C.json();return C.ok||i(D.error||"Failed to create branch"),D}catch(C){console.error("[GitBranches] Create branch failed:",C);const D={success:!1,error:"Failed to create branch"};return i(D.error),D}finally{o(null)}},[]),f=t.useCallback(async k=>{o("pull"),i(null);try{const x=await W(V("/api/files/git-pull"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return!x.ok&&!v.conflicts&&i(v.error||"Pull failed"),v}catch(x){console.error("[GitBranches] Pull failed:",x);const v={success:!1,error:"Pull failed"};return i(v.error),v}finally{o(null)}},[]),b=t.useCallback(async k=>{o("push"),i(null);try{const x=await W(V("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Push failed"),v}catch(x){console.error("[GitBranches] Push failed:",x);const v={success:!1,error:"Push failed"};return i(v.error),v}finally{o(null)}},[]),w=t.useCallback(async(k,x)=>{o("merge"),i(null);try{const v=await W(V("/api/files/git-merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k,branch:x})}),C=await v.json();return!v.ok&&!C.conflicts&&i(C.error||"Merge failed"),C}catch(v){console.error("[GitBranches] Merge failed:",v);const C={success:!1,error:"Merge failed"};return i(C.error),C}finally{o(null)}},[]),R=t.useCallback(async k=>{o("merge-abort"),i(null);try{const x=await W(V("/api/files/git-merge-abort"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Merge abort failed"),v}catch(x){console.error("[GitBranches] Merge abort failed:",x);const v={success:!1,error:"Merge abort failed"};return i(v.error),v}finally{o(null)}},[]),g=t.useCallback(async k=>{o("merge-continue"),i(null);try{const x=await W(V("/api/files/git-merge-continue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:k})}),v=await x.json();return x.ok||i(v.error||"Merge continue failed"),v}catch(x){console.error("[GitBranches] Merge continue failed:",x);const v={success:!1,error:"Merge continue failed"};return i(v.error),v}finally{o(null)}},[]);return{branches:s,loading:l,error:r,operationInProgress:m,loadBranches:h,checkoutBranch:p,createBranch:j,pullFromRemote:f,pushToRemote:b,mergeBranch:w,mergeAbort:R,mergeContinue:g}}const ja=50,va=400,zs={branch:"",author:"",since:"",until:"",searchPath:"",search:""};function wa(){const[s,n]=t.useState([]),[l,d]=t.useState(!1),[r,i]=t.useState(!1),[m,o]=t.useState(null),[h,p]=t.useState(!1),[j,f]=t.useState(0),[b,w]=t.useState({...zs}),[R,g]=t.useState(null),[k,x]=t.useState([]),[v,C]=t.useState(!1),[D,N]=t.useState([]),[U,_]=t.useState(!1),O=t.useRef(null),se=t.useRef(""),Q=t.useCallback((z,I,$)=>{const P=$||b,ee=new URLSearchParams;return ee.set("path",z),ee.set("limit",String(ja)),ee.set("offset",String(I)),P.branch&&ee.set("branch",P.branch),P.author&&ee.set("author",P.author),P.since&&ee.set("since",P.since),P.until&&ee.set("until",P.until),P.searchPath&&ee.set("searchPath",P.searchPath),P.search&&ee.set("search",P.search),ee.toString()},[b]),T=t.useCallback(async z=>{se.current=z,d(!0),o(null),g(null),x([]);try{const I=Q(z,0),$=await W(V(`/api/files/git-log?${I}`)),P=await $.json();$.ok?(n(P.commits||[]),f(P.total||0),p(P.hasMore||!1)):(o(P.error||"Failed to load git history"),n([]))}catch(I){console.error("[useGitHistory] loadHistory error:",I),o("Failed to load git history"),n([])}finally{d(!1)}},[Q]),F=t.useCallback(async z=>{if(!(r||!h)){i(!0);try{const I=Q(z,s.length),$=await W(V(`/api/files/git-log?${I}`)),P=await $.json();$.ok&&(n(ee=>[...ee,...P.commits||[]]),f(P.total||0),p(P.hasMore||!1))}catch(I){console.error("[useGitHistory] loadMore error:",I)}finally{i(!1)}}},[Q,s.length,h,r]),K=t.useCallback(async z=>{if(g(z),!z){x([]);return}C(!0);try{const I=se.current,$=new URLSearchParams({path:I,hash:z.hash}),P=await W(V(`/api/files/git-commit-files?${$}`)),ee=await P.json();P.ok?x(ee.files||[]):x([])}catch(I){console.error("[useGitHistory] selectCommit files error:",I),x([])}finally{C(!1)}},[]),ne=t.useCallback((z,I)=>{w($=>({...$,[z]:I}))},[]),ie=t.useCallback(()=>{w({...zs})},[]);t.useEffect(()=>{const z=se.current;if(z)return O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{T(z)},va),()=>{O.current&&clearTimeout(O.current)}},[b]);const fe=t.useCallback(async z=>{_(!0);try{const I=new URLSearchParams({path:z}),$=await W(V(`/api/files/git-authors?${I}`)),P=await $.json();$.ok&&N(P.authors||[])}catch(I){console.error("[useGitHistory] loadAuthors error:",I)}finally{_(!1)}},[]);return{commits:s,loading:l,loadingMore:r,error:m,hasMore:h,total:j,filters:b,setFilter:ne,resetFilters:ie,selectedCommit:R,selectCommit:K,commitFiles:k,commitFilesLoading:v,loadHistory:T,loadMore:F,authors:D,authorsLoading:U,loadAuthors:fe}}function Ca(s){if(!s.current)return null;const n=[".file-viewer-code-with-lines",".file-viewer-markdown-wrapper",".file-viewer-code-wrapper",".file-viewer-diagram-wrapper",".file-viewer-image-wrapper",".file-viewer-pdf-wrapper"];for(const l of n){const d=s.current.querySelector(l);if(d&&Os(d))return d}return Os(s.current)?s.current:null}function Os(s){const n=["auto","scroll"].includes(getComputedStyle(s).overflowY),l=s.scrollHeight>s.clientHeight||s.scrollWidth>s.clientWidth;return n&&l}function Js(s){if(!s)return 19.5;const n=parseFloat(getComputedStyle(s).lineHeight);return isNaN(n)?19.5:n}function Xt(s,n=!0){const l=n?s.scrollHeight:0;s.scrollTo({top:l,behavior:"smooth"})}function Na(s){const{scrollTop:n,scrollHeight:l,clientHeight:d}=s;return l<=d?100:Math.round(n/(l-d)*100)}function ka(s,n){const l=Js(s),d=s.scrollTop,r=Math.floor(d/l)+1,i=n.split(`
|
|
3
3
|
`).length;return Math.min(r,i)}function Ea(s,n,l=!1){if(!n)return[];l||s.toLowerCase();const d=l?n:n.toLowerCase(),r=[];let i=0;const m=s.split(`
|
|
4
4
|
`);let o=0;for(let h=0;h<m.length;h++){const p=m[h],j=l?p:p.toLowerCase();let f=0,b=j.indexOf(d);for(;b!==-1;){const w=o+b;r.push({index:i++,line:h+1,column:b,length:d.length,charIndex:w}),f=b+d.length,b=j.indexOf(d,f)}o+=p.length+1}return r}function dt(s){return/[\w]/.test(s)}function _e(s){return/\s/.test(s)}function Sa(s,n,l){let d=n-1,r=l;const i=s.length,m=s[d]||"";if(r<m.length){const p=dt(m[r]);if(!_e(m[r]))for(;r<m.length&&!_e(m[r])&&dt(m[r])===p;)r++}for(;d<i;){const p=s[d]||"";for(;r<p.length&&_e(p[r]);)r++;if(r<p.length)return{line:d+1,col:r};d++,r=0}const o=i,h=Math.max(0,(s[i-1]||"").length-1);return{line:o,col:h}}function Ta(s,n,l){let d=n-1,r=l+1;const i=s.length;for(;d<i;){const h=s[d]||"";for(;r<h.length&&_e(h[r]);)r++;if(r<h.length)break;d++,r=0}if(d>=i)return{line:i,col:Math.max(0,(s[i-1]||"").length-1)};const m=s[d]||"",o=dt(m[r]);for(;r+1<m.length&&!_e(m[r+1])&&dt(m[r+1])===o;)r++;return{line:d+1,col:r}}function Ma(s,n,l){let d=n-1,r=l-1;for(;d>=0;){const o=s[d]||"";for(;r>=0&&_e(o[r]);)r--;if(r>=0)break;d--,d>=0&&(r=(s[d]||"").length-1)}if(d<0)return{line:1,col:0};const i=s[d]||"",m=dt(i[r]);for(;r>0&&!_e(i[r-1])&&dt(i[r-1])===m;)r--;return{line:d+1,col:r}}function Da(s,n,l,d){if(d==="none")return"";const{anchorLine:r,anchorCol:i,headLine:m,headCol:o}=l;if(d==="line"){const w=Math.min(r,m),R=Math.max(r,m);return n.slice(w-1,R).join(`
|
|
5
5
|
`)}let h,p,j,f;if(r<m||r===m&&i<=o?(h=r,p=i,j=m,f=o):(h=m,p=o,j=r,f=i),h===j)return(n[h-1]||"").substring(p,f+1);const b=[];b.push((n[h-1]||"").substring(p));for(let w=h;w<j-1;w++)b.push(n[w]||"");return b.push((n[j-1]||"").substring(0,f+1)),b.join(`
|
|
6
6
|
`)}function Xs(s){const{containerRef:n,isEnabled:l=!0,content:d="",onClose:r,onSearchOpen:i}=s,m=t.useRef({percentage:0,line:1,column:1}),o=t.useRef(null),h=t.useRef(19.5),p=t.useMemo(()=>d.split(`
|
|
7
|
-
`),[d]),j=p.length,[f,b]=t.useState(1),[w,R]=t.useState(0),[g,k]=t.useState(!1),[x,v]=t.useState("none"),[C,D]=t.useState(null),[N,U]=t.useState(!1),[_,O]=t.useState(""),[se,Q]=t.useState(0),[T,F]=t.useState(!1),K=t.useMemo(()=>Ea(d,_,!1),[d,_]),ne=t.useCallback(()=>{const c=o.current;if(!c)return;const G=Na(c),ae=ka(c,d),A=Math.max(1,Math.round(c.scrollLeft/7.8)+1);m.current={percentage:G,line:ae,column:A}},[d]),ie=t.useCallback(()=>{U(!0),O(""),Q(0),i==null||i()},[i]),fe=t.useCallback(()=>{U(!1),O(""),Q(0)},[]),z=t.useCallback(()=>{F(c=>!c)},[]),I=t.useCallback(c=>{const G=o.current;if(!G)return;const ae=G.querySelector(".file-viewer-pre"),ce=ae&&parseFloat(getComputedStyle(ae).lineHeight)||h.current,A=ae&&parseFloat(getComputedStyle(ae).paddingTop)||0,q=(ae?ae.offsetTop:0)+A+(c-1)*ce,Z=ce*3;G.scrollTo({top:Math.max(0,q-Z),behavior:"smooth"})},[]);t.useEffect(()=>{!N||K.length===0||Q(0)},[K,N]),t.useEffect(()=>{if(!N||K.length===0)return;const c=K[se];c&&(b(c.line),R(c.column),I(c.line))},[N,K,se,I]);const $=t.useCallback(()=>{K.length!==0&&Q(c=>(c+1)%K.length)},[K]),P=t.useCallback(()=>{K.length!==0&&Q(c=>(c-1+K.length)%K.length)},[K]),ee=t.useCallback(c=>{const G=o.current;if(!G)return;const ae=G.querySelector(".file-viewer-pre");if(!ae)return;const ce=parseFloat(getComputedStyle(ae).lineHeight),A=isNaN(ce)?h.current:ce,S=parseFloat(getComputedStyle(ae).paddingTop)||0,Z=ae.offsetTop+S+(c-1)*A,Te=Z+A,ve=G.scrollTop,X=ve+G.clientHeight;Z<ve?G.scrollTo({top:Math.max(0,Z),behavior:"auto"}):Te>X&&G.scrollTo({top:Te-G.clientHeight,behavior:"auto"})},[]),te=t.useCallback((c,G)=>{b(c),R(G),ee(c),x!=="none"&&D(ae=>ae?{...ae,headLine:c,headCol:G}:null)},[x,ee]),ge=t.useCallback(()=>{if(x==="none"||!C)return;const c=Da(d,p,C,x);c&&navigator.clipboard.writeText(c).catch(()=>{const G=document.createElement("textarea");G.value=c,G.style.position="fixed",G.style.left="-9999px",document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G)}),v("none"),D(null)},[x,C,d,p]),je=t.useCallback(c=>{const G=c.target;if((G.tagName==="INPUT"||G.tagName==="TEXTAREA")&&c.key!=="Escape")return;const ce=o.current;if(!ce)return;let A=!1;const S=h.current,q=Math.max(1,Math.floor(ce.clientHeight/S)),Z=Math.max(1,Math.floor(q/2)),Te=(X,xe)=>{const ze=Math.max(0,(p[X-1]||"").length-1);return Math.min(xe,Math.max(0,ze))},ve=(X,xe)=>{const ze=Te(X,xe);te(X,ze)};if(c.key==="v"&&!c.shiftKey&&!c.ctrlKey&&!N)c.preventDefault(),c.stopPropagation(),x==="char"?(v("none"),D(null)):(v("char"),D({anchorLine:f,anchorCol:w,headLine:f,headCol:w})),A=!0;else if(c.key==="V"&&c.shiftKey&&!c.ctrlKey&&!N)c.preventDefault(),c.stopPropagation(),x==="line"?(v("none"),D(null)):(v("line"),D({anchorLine:f,anchorCol:0,headLine:f,headCol:0})),A=!0;else if(c.key==="y"&&!c.ctrlKey&&x!=="none")c.preventDefault(),c.stopPropagation(),ge(),A=!0;else if(c.key==="j"||c.key==="ArrowDown"){c.preventDefault(),c.stopPropagation();const X=Math.min(f+1,j);ve(X,w),A=!0}else if(c.key==="k"||c.key==="ArrowUp"){c.preventDefault(),c.stopPropagation();const X=Math.max(f-1,1);ve(X,w),A=!0}else if(c.key==="d"&&c.ctrlKey||c.key==="d"&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.min(f+Z,j);ve(X,w),A=!0}else if(c.key==="u"&&c.ctrlKey||c.key==="u"&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.max(f-Z,1);ve(X,w),A=!0}else if((c.ctrlKey||c.metaKey)&&c.key==="f")c.preventDefault(),c.stopPropagation(),ie(),A=!0;else if(c.key==="f"&&!c.ctrlKey&&!c.metaKey&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.min(f+q,j);ve(X,w),A=!0}else if(c.key===" "||c.key==="PageDown"){c.preventDefault(),c.stopPropagation();const X=Math.min(f+q,j);ve(X,w),A=!0}else if(c.key==="b"&&!g&&x==="none"&&!N||c.key==="PageUp"){c.preventDefault(),c.stopPropagation();const X=Math.max(f-q,1);ve(X,w),A=!0}else if(c.key==="g"&&!c.shiftKey&&x==="none"&&!N)c.preventDefault(),c.stopPropagation(),te(1,0),Xt(ce,!1),A=!0;else if(c.key==="Home")c.preventDefault(),c.stopPropagation(),te(1,0),Xt(ce,!1),A=!0;else if(c.key==="G"&&c.shiftKey||c.key==="End")c.preventDefault(),c.stopPropagation(),te(j,0),Xt(ce,!0),A=!0;else if(c.key==="h"||c.key==="ArrowLeft")c.preventDefault(),c.stopPropagation(),te(f,Math.max(0,w-1)),A=!0;else if(c.key==="l"||c.key==="ArrowRight"){c.preventDefault(),c.stopPropagation();const X=(p[f-1]||"").length;te(f,Math.min(w+1,Math.max(0,X-1))),A=!0}else if(c.key==="w"&&!c.ctrlKey&&!N){c.preventDefault(),c.stopPropagation();const X=Sa(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="e"&&!c.ctrlKey&&!N){c.preventDefault(),c.stopPropagation();const X=Ta(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="b"&&!N){c.preventDefault(),c.stopPropagation();const X=Ma(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="0")c.preventDefault(),c.stopPropagation(),te(f,0),A=!0;else if(c.key==="$")c.preventDefault(),c.stopPropagation(),te(f,Math.max(0,(p[f-1]||"").length-1)),A=!0;else if(c.key==="^"){c.preventDefault(),c.stopPropagation();const xe=(p[f-1]||"").search(/\S/);te(f,xe>=0?xe:0),A=!0}else c.key==="/"?(c.preventDefault(),c.stopPropagation(),ie(),A=!0):c.key==="n"&&!N?(c.preventDefault(),c.stopPropagation(),$(),A=!0):c.key==="N"&&c.shiftKey&&!N?(c.preventDefault(),c.stopPropagation(),P(),A=!0):c.key==="?"&&x==="none"?(c.preventDefault(),c.stopPropagation(),z(),A=!0):c.key==="q"&&x==="none"?(c.preventDefault(),c.stopPropagation(),r==null||r(),A=!0):c.key==="Escape"&&(x!=="none"?(c.preventDefault(),c.stopPropagation(),v("none"),D(null),A=!0):N?(c.preventDefault(),c.stopPropagation(),fe(),A=!0):g&&(c.preventDefault(),c.stopPropagation(),k(!1),A=!0));A&&(c.key!=="Escape"&&!g&&k(!0),requestAnimationFrame(ne))},[r,ne,j,p,f,w,ee,N,fe,x,g,te,ge,ie,$,P,z]);return t.useEffect(()=>{if(!l)return;const c=Ca(n);if(o.current=c,!c){console.warn("[useLessNavigation] Could not find scrollable container");return}h.current=Js(c);const G=()=>{ne()};return window.addEventListener("keydown",je,{capture:!0}),c.addEventListener("scroll",G,{passive:!0}),ne(),()=>{window.removeEventListener("keydown",je,{capture:!0}),c.removeEventListener("scroll",G)}},[l,je,ne]),{scrollPercentage:m.current.percentage,currentLine:m.current.line,currentColumn:m.current.column,totalLines:j,cursorLine:f,cursorCol:w,cursorModeActive:g,visualMode:x,selection:C,searchActive:N,searchQuery:_,searchMatches:K,currentMatchIndex:se,startSearch:ie,setSearchQuery:O,nextMatch:$,prevMatch:P,clearSearch:fe,helpActive:T,toggleHelp:z}}const ss=({query:s,onQueryChange:n,matchCount:l,currentIndex:d,onNext:r,onPrev:i,onClose:m})=>{const{t:o}=re(["terminal"]),h=t.useRef(null);t.useEffect(()=>{var f;(f=h.current)==null||f.focus()},[]);const p=t.useCallback(f=>{f.stopPropagation(),f.key==="Enter"||f.key==="ArrowDown"?(f.preventDefault(),r()):f.key==="ArrowUp"&&(f.preventDefault(),i())},[r,i]),j=l===0&&s?o("terminal:fileExplorer.noMatches"):l>0?`${d+1}/${l}`:"";return e.jsxs("div",{className:"file-viewer-search-bar",children:[e.jsxs("div",{className:"file-viewer-search-input-wrapper",children:[e.jsx("span",{className:"file-viewer-search-prefix",children:"/"}),e.jsx("input",{ref:h,type:"text",className:"file-viewer-search-input",placeholder:o("terminal:fileExplorer.searchInFile"),value:s,onChange:f=>n(f.target.value),onKeyDown:p,autoComplete:"off",spellCheck:"false"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"file-viewer-search-counter",children:j}),e.jsxs("div",{className:"file-viewer-search-nav",children:[e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-prev",onClick:i,disabled:l===0,title:o("terminal:fileExplorer.previousMatch"),"aria-label":o("terminal:fileExplorer.previousMatch"),children:e.jsx(M,{name:"caret-up",size:10})}),e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-next",onClick:r,disabled:l===0,title:o("terminal:fileExplorer.nextMatch"),"aria-label":o("terminal:fileExplorer.nextMatch"),children:e.jsx(M,{name:"caret-down",size:10})})]})]}),e.jsx("button",{className:"file-viewer-search-close",onClick:m,title:o("terminal:fileExplorer.closeSearch"),"aria-label":o("terminal:fileExplorer.closeSearch"),children:e.jsx(M,{name:"close",size:12})})]})};ss.displayName="SearchBar";const Ra=[{keys:["j","↓"],description:"Move cursor down one line",category:"Navigation"},{keys:["k","↑"],description:"Move cursor up one line",category:"Navigation"},{keys:["h","←"],description:"Move cursor left",category:"Navigation"},{keys:["l","→"],description:"Move cursor right",category:"Navigation"},{keys:["0"],description:"Jump to start of line",category:"Navigation"},{keys:["$"],description:"Jump to end of line",category:"Navigation"},{keys:["^"],description:"First non-whitespace char",category:"Navigation"},{keys:["d","Ctrl+D"],description:"Half page down",category:"Navigation"},{keys:["u","Ctrl+U"],description:"Half page up",category:"Navigation"},{keys:["f","Space"],description:"Full page down",category:"Navigation"},{keys:["b","Page Up"],description:"Full page up",category:"Navigation"},{keys:["g","Home"],description:"Jump to top of file",category:"Navigation"},{keys:["G","End"],description:"Jump to bottom of file",category:"Navigation"},{keys:["w"],description:"Next word start",category:"Word Motion"},{keys:["e"],description:"Next word end",category:"Word Motion"},{keys:["b"],description:"Previous word start",category:"Word Motion"},{keys:["v"],description:"Character visual mode",category:"Visual Mode"},{keys:["V"],description:"Line visual mode",category:"Visual Mode"},{keys:["y"],description:"Yank (copy) selection",category:"Visual Mode"},{keys:["Escape"],description:"Exit visual mode",category:"Visual Mode"},{keys:["/"],description:"Open search bar",category:"Search"},{keys:["n"],description:"Next match",category:"Search"},{keys:["N"],description:"Previous match",category:"Search"},{keys:["?"],description:"Toggle this help overlay",category:"Help"},{keys:["Escape"],description:"Exit cursor mode (or visual/search)",category:"Help"},{keys:["Alt+E"],description:"Close file viewer",category:"Help"},{keys:["q"],description:"Close file viewer",category:"Help"}],ns=({onClose:s})=>{const{t:n}=re(["terminal"]),l=t.useCallback(i=>{i.target===i.currentTarget&&s()},[s]),d=t.useCallback(i=>{(i.key==="Escape"||i.key==="?")&&(i.preventDefault(),i.stopPropagation(),s())},[s]),r=Ra.reduce((i,m)=>(i[m.category]||(i[m.category]=[]),i[m.category].push(m),i),{});return e.jsx("div",{className:"keybindings-help-overlay",onClick:l,onKeyDown:d,tabIndex:0,role:"dialog","aria-label":n("terminal:fileExplorer.keybindingsHelp"),children:e.jsxs("div",{className:"keybindings-help-content",children:[e.jsx("button",{className:"keybindings-help-close",onClick:s,"aria-label":n("terminal:fileExplorer.closeHelp"),title:n("terminal:fileExplorer.pressEscapeToClose"),children:e.jsx(M,{name:"close",size:14})}),e.jsx("h2",{className:"keybindings-help-title",children:n("terminal:fileExplorer.keybindingsHelp")}),e.jsx("p",{className:"keybindings-help-subtitle",children:n("terminal:fileExplorer.keybindingsSubtitle")}),e.jsx("div",{className:"keybindings-help-categories",children:Object.entries(r).map(([i,m])=>e.jsxs("div",{className:"keybindings-help-category",children:[e.jsx("h3",{className:"keybindings-help-category-title",children:i}),e.jsx("div",{className:"keybindings-help-list",children:m.map((o,h)=>e.jsxs("div",{className:"keybindings-help-item",children:[e.jsx("div",{className:"keybindings-help-keys",children:o.keys.map((p,j)=>e.jsx("kbd",{className:"keybindings-help-key",children:p},j))}),e.jsx("div",{className:"keybindings-help-description",children:o.description})]},h))})]},i))}),e.jsx("p",{className:"keybindings-help-footer",children:n("terminal:fileExplorer.keybindingsFooter")})]})})};ns.displayName="KeybindingsHelp";const As=t.lazy(()=>Gn(()=>import("./EmbeddedEditor-C4gQ9cLk.js"),__vite__mapDeps([0,1,2,3,4,5])).then(s=>({default:s.EmbeddedEditor}))),Fa=[".md",".mdx",".markdown"],Gs="file-viewer-markdown-render",Ia=[".puml",".plantuml",".iuml",".pu"],Us="file-viewer-plantuml-render",Pa="https://kroki.io/plantuml/svg";function La(s){return Fa.includes(s.toLowerCase())}function $a(s){return Ia.includes(s.toLowerCase())}function Ha(){const[s,n]=t.useState(()=>{try{const d=localStorage.getItem(Gs);return d===null?!0:d==="true"}catch{return!0}}),l=t.useCallback(()=>{n(d=>{const r=!d;try{localStorage.setItem(Gs,String(r))}catch{}return r})},[]);return[s,l]}function za(){const[s,n]=t.useState(()=>{try{const d=localStorage.getItem(Us);return d===null?!0:d==="true"}catch{return!0}}),l=t.useCallback(()=>{n(d=>{const r=!d;try{localStorage.setItem(Us,String(r))}catch{}return r})},[]);return[s,l]}function Oa(s){const n=new TextEncoder().encode(s);let l="";for(const d of n)l+=String.fromCharCode(d);return`data:image/svg+xml;base64,${window.btoa(l)}`}function Ve({file:s,rightContent:n,onRevealInTree:l,editMode:d,onToggleEdit:r}){const{t:i}=re(["terminal","common"]),[m,o]=t.useState("idle"),[h,p]=t.useState("idle"),[j,f]=t.useState("idle"),b=s.fileType==="text"?zt(s.extension):s.extension.slice(1).toUpperCase(),w=s.fileType==="text"&&s.content!=null,{settings:R}=Vs(),g=async()=>{try{await Pt(s.content),f("copied"),setTimeout(()=>f("idle"),2e3)}catch{f("error"),setTimeout(()=>f("idle"),2e3)}},k=()=>{const D=new Blob([s.content],{type:"text/plain;charset=utf-8"}),N=URL.createObjectURL(D),U=document.createElement("a");U.href=N,U.download=s.filename,document.body.appendChild(U),U.click(),U.remove(),setTimeout(()=>URL.revokeObjectURL(N),1e3)},x=async()=>{o("loading");try{const D=await W(V("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s.path,...R.externalEditorCommand&&{editorCommand:R.externalEditorCommand}})});if(!D.ok){const N=await D.json().catch(()=>({error:"Unknown error"}));console.error("Failed to open in editor:",N),o("error"),setTimeout(()=>o("idle"),2e3);return}o("success"),setTimeout(()=>o("idle"),2e3)}catch(D){console.error("Error opening file in editor:",D),o("error"),setTimeout(()=>o("idle"),2e3)}},v=async()=>{if(s.path)try{await Kn(s.path),p("success"),setTimeout(()=>p("idle"),2e3)}catch(D){console.error("Error opening file explorer:",D),p("error"),setTimeout(()=>p("idle"),2e3)}},C=i("terminal:fileExplorer.openInFileExplorer");return e.jsxs("div",{className:"file-viewer-header",children:[e.jsxs("div",{className:"file-viewer-header-left",children:[e.jsx("span",{className:"file-viewer-filename",children:s.filename}),e.jsxs("span",{className:"file-viewer-meta",children:[Ks(s.size)," • ",b,s.content&&` • ${s.content.split(`
|
|
7
|
+
`),[d]),j=p.length,[f,b]=t.useState(1),[w,R]=t.useState(0),[g,k]=t.useState(!1),[x,v]=t.useState("none"),[C,D]=t.useState(null),[N,U]=t.useState(!1),[_,O]=t.useState(""),[se,Q]=t.useState(0),[T,F]=t.useState(!1),K=t.useMemo(()=>Ea(d,_,!1),[d,_]),ne=t.useCallback(()=>{const c=o.current;if(!c)return;const G=Na(c),ae=ka(c,d),A=Math.max(1,Math.round(c.scrollLeft/7.8)+1);m.current={percentage:G,line:ae,column:A}},[d]),ie=t.useCallback(()=>{U(!0),O(""),Q(0),i==null||i()},[i]),fe=t.useCallback(()=>{U(!1),O(""),Q(0)},[]),z=t.useCallback(()=>{F(c=>!c)},[]),I=t.useCallback(c=>{const G=o.current;if(!G)return;const ae=G.querySelector(".file-viewer-pre"),ce=ae&&parseFloat(getComputedStyle(ae).lineHeight)||h.current,A=ae&&parseFloat(getComputedStyle(ae).paddingTop)||0,q=(ae?ae.offsetTop:0)+A+(c-1)*ce,Z=ce*3;G.scrollTo({top:Math.max(0,q-Z),behavior:"smooth"})},[]);t.useEffect(()=>{!N||K.length===0||Q(0)},[K,N]),t.useEffect(()=>{if(!N||K.length===0)return;const c=K[se];c&&(b(c.line),R(c.column),I(c.line))},[N,K,se,I]);const $=t.useCallback(()=>{K.length!==0&&Q(c=>(c+1)%K.length)},[K]),P=t.useCallback(()=>{K.length!==0&&Q(c=>(c-1+K.length)%K.length)},[K]),ee=t.useCallback(c=>{const G=o.current;if(!G)return;const ae=G.querySelector(".file-viewer-pre");if(!ae)return;const ce=parseFloat(getComputedStyle(ae).lineHeight),A=isNaN(ce)?h.current:ce,S=parseFloat(getComputedStyle(ae).paddingTop)||0,Z=ae.offsetTop+S+(c-1)*A,Te=Z+A,ve=G.scrollTop,X=ve+G.clientHeight;Z<ve?G.scrollTo({top:Math.max(0,Z),behavior:"auto"}):Te>X&&G.scrollTo({top:Te-G.clientHeight,behavior:"auto"})},[]),te=t.useCallback((c,G)=>{b(c),R(G),ee(c),x!=="none"&&D(ae=>ae?{...ae,headLine:c,headCol:G}:null)},[x,ee]),ge=t.useCallback(()=>{if(x==="none"||!C)return;const c=Da(d,p,C,x);c&&navigator.clipboard.writeText(c).catch(()=>{const G=document.createElement("textarea");G.value=c,G.style.position="fixed",G.style.left="-9999px",document.body.appendChild(G),G.select(),document.execCommand("copy"),document.body.removeChild(G)}),v("none"),D(null)},[x,C,d,p]),je=t.useCallback(c=>{const G=c.target;if((G.tagName==="INPUT"||G.tagName==="TEXTAREA")&&c.key!=="Escape")return;const ce=o.current;if(!ce)return;let A=!1;const S=h.current,q=Math.max(1,Math.floor(ce.clientHeight/S)),Z=Math.max(1,Math.floor(q/2)),Te=(X,xe)=>{const ze=Math.max(0,(p[X-1]||"").length-1);return Math.min(xe,Math.max(0,ze))},ve=(X,xe)=>{const ze=Te(X,xe);te(X,ze)};if(c.key==="v"&&!c.shiftKey&&!c.ctrlKey&&!N)c.preventDefault(),c.stopPropagation(),x==="char"?(v("none"),D(null)):(v("char"),D({anchorLine:f,anchorCol:w,headLine:f,headCol:w})),A=!0;else if(c.key==="V"&&c.shiftKey&&!c.ctrlKey&&!N)c.preventDefault(),c.stopPropagation(),x==="line"?(v("none"),D(null)):(v("line"),D({anchorLine:f,anchorCol:0,headLine:f,headCol:0})),A=!0;else if(c.key==="y"&&!c.ctrlKey&&x!=="none")c.preventDefault(),c.stopPropagation(),ge(),A=!0;else if(c.key==="j"||c.key==="ArrowDown"){c.preventDefault(),c.stopPropagation();const X=Math.min(f+1,j);ve(X,w),A=!0}else if(c.key==="k"||c.key==="ArrowUp"){c.preventDefault(),c.stopPropagation();const X=Math.max(f-1,1);ve(X,w),A=!0}else if(c.key==="d"&&c.ctrlKey||c.key==="d"&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.min(f+Z,j);ve(X,w),A=!0}else if(c.key==="u"&&c.ctrlKey||c.key==="u"&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.max(f-Z,1);ve(X,w),A=!0}else if((c.ctrlKey||c.metaKey)&&c.key==="f")c.preventDefault(),c.stopPropagation(),ie(),A=!0;else if(c.key==="f"&&!c.ctrlKey&&!c.metaKey&&x==="none"&&!N){c.preventDefault(),c.stopPropagation();const X=Math.min(f+q,j);ve(X,w),A=!0}else if(c.key===" "||c.key==="PageDown"){c.preventDefault(),c.stopPropagation();const X=Math.min(f+q,j);ve(X,w),A=!0}else if(c.key==="b"&&!g&&x==="none"&&!N||c.key==="PageUp"){c.preventDefault(),c.stopPropagation();const X=Math.max(f-q,1);ve(X,w),A=!0}else if(c.key==="g"&&!c.shiftKey&&x==="none"&&!N)c.preventDefault(),c.stopPropagation(),te(1,0),Xt(ce,!1),A=!0;else if(c.key==="Home")c.preventDefault(),c.stopPropagation(),te(1,0),Xt(ce,!1),A=!0;else if(c.key==="G"&&c.shiftKey||c.key==="End")c.preventDefault(),c.stopPropagation(),te(j,0),Xt(ce,!0),A=!0;else if(c.key==="h"||c.key==="ArrowLeft")c.preventDefault(),c.stopPropagation(),te(f,Math.max(0,w-1)),A=!0;else if(c.key==="l"||c.key==="ArrowRight"){c.preventDefault(),c.stopPropagation();const X=(p[f-1]||"").length;te(f,Math.min(w+1,Math.max(0,X-1))),A=!0}else if(c.key==="w"&&!c.ctrlKey&&!N){c.preventDefault(),c.stopPropagation();const X=Sa(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="e"&&!c.ctrlKey&&!N){c.preventDefault(),c.stopPropagation();const X=Ta(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="b"&&!N){c.preventDefault(),c.stopPropagation();const X=Ma(p,f,w);te(X.line,X.col),A=!0}else if(c.key==="0")c.preventDefault(),c.stopPropagation(),te(f,0),A=!0;else if(c.key==="$")c.preventDefault(),c.stopPropagation(),te(f,Math.max(0,(p[f-1]||"").length-1)),A=!0;else if(c.key==="^"){c.preventDefault(),c.stopPropagation();const xe=(p[f-1]||"").search(/\S/);te(f,xe>=0?xe:0),A=!0}else c.key==="/"?(c.preventDefault(),c.stopPropagation(),ie(),A=!0):c.key==="n"&&!N?(c.preventDefault(),c.stopPropagation(),$(),A=!0):c.key==="N"&&c.shiftKey&&!N?(c.preventDefault(),c.stopPropagation(),P(),A=!0):c.key==="?"&&x==="none"?(c.preventDefault(),c.stopPropagation(),z(),A=!0):c.key==="q"&&x==="none"?(c.preventDefault(),c.stopPropagation(),r==null||r(),A=!0):c.key==="Escape"&&(x!=="none"?(c.preventDefault(),c.stopPropagation(),v("none"),D(null),A=!0):N?(c.preventDefault(),c.stopPropagation(),fe(),A=!0):g&&(c.preventDefault(),c.stopPropagation(),k(!1),A=!0));A&&(c.key!=="Escape"&&!g&&k(!0),requestAnimationFrame(ne))},[r,ne,j,p,f,w,ee,N,fe,x,g,te,ge,ie,$,P,z]);return t.useEffect(()=>{if(!l)return;const c=Ca(n);if(o.current=c,!c){console.warn("[useLessNavigation] Could not find scrollable container");return}h.current=Js(c);const G=()=>{ne()};return window.addEventListener("keydown",je,{capture:!0}),c.addEventListener("scroll",G,{passive:!0}),ne(),()=>{window.removeEventListener("keydown",je,{capture:!0}),c.removeEventListener("scroll",G)}},[l,je,ne]),{scrollPercentage:m.current.percentage,currentLine:m.current.line,currentColumn:m.current.column,totalLines:j,cursorLine:f,cursorCol:w,cursorModeActive:g,visualMode:x,selection:C,searchActive:N,searchQuery:_,searchMatches:K,currentMatchIndex:se,startSearch:ie,setSearchQuery:O,nextMatch:$,prevMatch:P,clearSearch:fe,helpActive:T,toggleHelp:z}}const ss=({query:s,onQueryChange:n,matchCount:l,currentIndex:d,onNext:r,onPrev:i,onClose:m})=>{const{t:o}=re(["terminal"]),h=t.useRef(null);t.useEffect(()=>{var f;(f=h.current)==null||f.focus()},[]);const p=t.useCallback(f=>{f.stopPropagation(),f.key==="Enter"||f.key==="ArrowDown"?(f.preventDefault(),r()):f.key==="ArrowUp"&&(f.preventDefault(),i())},[r,i]),j=l===0&&s?o("terminal:fileExplorer.noMatches"):l>0?`${d+1}/${l}`:"";return e.jsxs("div",{className:"file-viewer-search-bar",children:[e.jsxs("div",{className:"file-viewer-search-input-wrapper",children:[e.jsx("span",{className:"file-viewer-search-prefix",children:"/"}),e.jsx("input",{ref:h,type:"text",className:"file-viewer-search-input",placeholder:o("terminal:fileExplorer.searchInFile"),value:s,onChange:f=>n(f.target.value),onKeyDown:p,autoComplete:"off",spellCheck:"false"})]}),s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"file-viewer-search-counter",children:j}),e.jsxs("div",{className:"file-viewer-search-nav",children:[e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-prev",onClick:i,disabled:l===0,title:o("terminal:fileExplorer.previousMatch"),"aria-label":o("terminal:fileExplorer.previousMatch"),children:e.jsx(M,{name:"caret-up",size:10})}),e.jsx("button",{className:"file-viewer-search-btn file-viewer-search-next",onClick:r,disabled:l===0,title:o("terminal:fileExplorer.nextMatch"),"aria-label":o("terminal:fileExplorer.nextMatch"),children:e.jsx(M,{name:"caret-down",size:10})})]})]}),e.jsx("button",{className:"file-viewer-search-close",onClick:m,title:o("terminal:fileExplorer.closeSearch"),"aria-label":o("terminal:fileExplorer.closeSearch"),children:e.jsx(M,{name:"close",size:12})})]})};ss.displayName="SearchBar";const Ra=[{keys:["j","↓"],description:"Move cursor down one line",category:"Navigation"},{keys:["k","↑"],description:"Move cursor up one line",category:"Navigation"},{keys:["h","←"],description:"Move cursor left",category:"Navigation"},{keys:["l","→"],description:"Move cursor right",category:"Navigation"},{keys:["0"],description:"Jump to start of line",category:"Navigation"},{keys:["$"],description:"Jump to end of line",category:"Navigation"},{keys:["^"],description:"First non-whitespace char",category:"Navigation"},{keys:["d","Ctrl+D"],description:"Half page down",category:"Navigation"},{keys:["u","Ctrl+U"],description:"Half page up",category:"Navigation"},{keys:["f","Space"],description:"Full page down",category:"Navigation"},{keys:["b","Page Up"],description:"Full page up",category:"Navigation"},{keys:["g","Home"],description:"Jump to top of file",category:"Navigation"},{keys:["G","End"],description:"Jump to bottom of file",category:"Navigation"},{keys:["w"],description:"Next word start",category:"Word Motion"},{keys:["e"],description:"Next word end",category:"Word Motion"},{keys:["b"],description:"Previous word start",category:"Word Motion"},{keys:["v"],description:"Character visual mode",category:"Visual Mode"},{keys:["V"],description:"Line visual mode",category:"Visual Mode"},{keys:["y"],description:"Yank (copy) selection",category:"Visual Mode"},{keys:["Escape"],description:"Exit visual mode",category:"Visual Mode"},{keys:["/"],description:"Open search bar",category:"Search"},{keys:["n"],description:"Next match",category:"Search"},{keys:["N"],description:"Previous match",category:"Search"},{keys:["?"],description:"Toggle this help overlay",category:"Help"},{keys:["Escape"],description:"Exit cursor mode (or visual/search)",category:"Help"},{keys:["Alt+E"],description:"Close file viewer",category:"Help"},{keys:["q"],description:"Close file viewer",category:"Help"}],ns=({onClose:s})=>{const{t:n}=re(["terminal"]),l=t.useCallback(i=>{i.target===i.currentTarget&&s()},[s]),d=t.useCallback(i=>{(i.key==="Escape"||i.key==="?")&&(i.preventDefault(),i.stopPropagation(),s())},[s]),r=Ra.reduce((i,m)=>(i[m.category]||(i[m.category]=[]),i[m.category].push(m),i),{});return e.jsx("div",{className:"keybindings-help-overlay",onClick:l,onKeyDown:d,tabIndex:0,role:"dialog","aria-label":n("terminal:fileExplorer.keybindingsHelp"),children:e.jsxs("div",{className:"keybindings-help-content",children:[e.jsx("button",{className:"keybindings-help-close",onClick:s,"aria-label":n("terminal:fileExplorer.closeHelp"),title:n("terminal:fileExplorer.pressEscapeToClose"),children:e.jsx(M,{name:"close",size:14})}),e.jsx("h2",{className:"keybindings-help-title",children:n("terminal:fileExplorer.keybindingsHelp")}),e.jsx("p",{className:"keybindings-help-subtitle",children:n("terminal:fileExplorer.keybindingsSubtitle")}),e.jsx("div",{className:"keybindings-help-categories",children:Object.entries(r).map(([i,m])=>e.jsxs("div",{className:"keybindings-help-category",children:[e.jsx("h3",{className:"keybindings-help-category-title",children:i}),e.jsx("div",{className:"keybindings-help-list",children:m.map((o,h)=>e.jsxs("div",{className:"keybindings-help-item",children:[e.jsx("div",{className:"keybindings-help-keys",children:o.keys.map((p,j)=>e.jsx("kbd",{className:"keybindings-help-key",children:p},j))}),e.jsx("div",{className:"keybindings-help-description",children:o.description})]},h))})]},i))}),e.jsx("p",{className:"keybindings-help-footer",children:n("terminal:fileExplorer.keybindingsFooter")})]})})};ns.displayName="KeybindingsHelp";const As=t.lazy(()=>Gn(()=>import("./EmbeddedEditor-Ct4fmYRC.js"),__vite__mapDeps([0,1,2,3,4,5])).then(s=>({default:s.EmbeddedEditor}))),Fa=[".md",".mdx",".markdown"],Gs="file-viewer-markdown-render",Ia=[".puml",".plantuml",".iuml",".pu"],Us="file-viewer-plantuml-render",Pa="https://kroki.io/plantuml/svg";function La(s){return Fa.includes(s.toLowerCase())}function $a(s){return Ia.includes(s.toLowerCase())}function Ha(){const[s,n]=t.useState(()=>{try{const d=localStorage.getItem(Gs);return d===null?!0:d==="true"}catch{return!0}}),l=t.useCallback(()=>{n(d=>{const r=!d;try{localStorage.setItem(Gs,String(r))}catch{}return r})},[]);return[s,l]}function za(){const[s,n]=t.useState(()=>{try{const d=localStorage.getItem(Us);return d===null?!0:d==="true"}catch{return!0}}),l=t.useCallback(()=>{n(d=>{const r=!d;try{localStorage.setItem(Us,String(r))}catch{}return r})},[]);return[s,l]}function Oa(s){const n=new TextEncoder().encode(s);let l="";for(const d of n)l+=String.fromCharCode(d);return`data:image/svg+xml;base64,${window.btoa(l)}`}function Ve({file:s,rightContent:n,onRevealInTree:l,editMode:d,onToggleEdit:r}){const{t:i}=re(["terminal","common"]),[m,o]=t.useState("idle"),[h,p]=t.useState("idle"),[j,f]=t.useState("idle"),b=s.fileType==="text"?zt(s.extension):s.extension.slice(1).toUpperCase(),w=s.fileType==="text"&&s.content!=null,{settings:R}=Vs(),g=async()=>{try{await Pt(s.content),f("copied"),setTimeout(()=>f("idle"),2e3)}catch{f("error"),setTimeout(()=>f("idle"),2e3)}},k=()=>{const D=new Blob([s.content],{type:"text/plain;charset=utf-8"}),N=URL.createObjectURL(D),U=document.createElement("a");U.href=N,U.download=s.filename,document.body.appendChild(U),U.click(),U.remove(),setTimeout(()=>URL.revokeObjectURL(N),1e3)},x=async()=>{o("loading");try{const D=await W(V("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s.path,...R.externalEditorCommand&&{editorCommand:R.externalEditorCommand}})});if(!D.ok){const N=await D.json().catch(()=>({error:"Unknown error"}));console.error("Failed to open in editor:",N),o("error"),setTimeout(()=>o("idle"),2e3);return}o("success"),setTimeout(()=>o("idle"),2e3)}catch(D){console.error("Error opening file in editor:",D),o("error"),setTimeout(()=>o("idle"),2e3)}},v=async()=>{if(s.path)try{await Kn(s.path),p("success"),setTimeout(()=>p("idle"),2e3)}catch(D){console.error("Error opening file explorer:",D),p("error"),setTimeout(()=>p("idle"),2e3)}},C=i("terminal:fileExplorer.openInFileExplorer");return e.jsxs("div",{className:"file-viewer-header",children:[e.jsxs("div",{className:"file-viewer-header-left",children:[e.jsx("span",{className:"file-viewer-filename",children:s.filename}),e.jsxs("span",{className:"file-viewer-meta",children:[Ks(s.size)," • ",b,s.content&&` • ${s.content.split(`
|
|
8
8
|
`).length} lines`]})]}),e.jsxs("div",{className:"file-viewer-header-right",children:[r&&s.fileType==="text"&&e.jsx("button",{className:`file-viewer-edit-btn${d?" active":""}`,onClick:r,title:i(d?"terminal:fileExplorer.exitEdit":"terminal:fileExplorer.editFile"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M11.013 1.427a1.75 1.75 0 012.474 0l1.086 1.086a1.75 1.75 0 010 2.474l-8.61 8.61c-.21.21-.47.364-.756.445l-3.251.93a.75.75 0 01-.927-.928l.929-3.25a1.75 1.75 0 01.445-.758l8.61-8.61zm1.414 1.06a.25.25 0 00-.354 0L3.463 11.1a.25.25 0 00-.064.108l-.558 1.953 1.953-.558a.25.25 0 00.108-.064l8.61-8.61a.25.25 0 000-.354l-1.086-1.086z"})})}),w&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${j}`,onClick:g,title:i("terminal:fileExplorer.copyAllTitle"),children:i(j==="copied"?"terminal:fileExplorer.copied":j==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyAll")}),e.jsx("button",{className:"file-viewer-download-btn",onClick:k,title:i("terminal:fileExplorer.downloadFileTitle"),children:i("common:buttons.download")})]}),e.jsx("button",{className:`file-viewer-reveal-explorer-btn ${h}`,onClick:v,disabled:!s.path,title:C,"aria-label":C,children:h==="success"?e.jsx(M,{name:"check",size:14}):h==="error"?e.jsx(M,{name:"cross",size:14}):e.jsx(M,{name:"folder-open",size:14})}),e.jsx("button",{className:`file-viewer-open-editor-btn ${m}`,onClick:x,disabled:m==="loading",title:i(m==="error"?"terminal:fileExplorer.failedToOpenEditor":m==="success"?"terminal:fileExplorer.openingInEditor":"terminal:fileExplorer.openInEditor"),children:m==="success"?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 11-1.06-1.06l7.25-7.25a.75.75 0 011.06 0z"})}):m==="error"?e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})}):e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M1.5 1h6v1.5h-5v11h11v-5H15v6.5H0V1h1.5zm8 0H15v5.5h-1.5V3.56L7.28 9.78l-1.06-1.06L12.44 2.5H9.5V1z"})})}),l&&e.jsx("button",{className:"file-viewer-locate-btn",onClick:()=>l(s.path),title:i("terminal:fileExplorer.locateInTree"),children:e.jsx(M,{name:"target",size:14})}),n]})]})}function Aa({file:s,onRevealInTree:n,renderMarkdown:l,onToggleRender:d,editMode:r,onToggleEdit:i}){const m=t.useRef(null),o=t.useRef(null),h=t.useRef(null),{t:p}=re(["terminal","common"]),[j,f]=t.useState("idle"),[b,w]=t.useState("idle"),[R,g]=t.useState("idle"),[k,x]=t.useState("idle"),v=Xs({containerRef:h,isEnabled:!0,content:s.content});t.useEffect(()=>{if(!l&&m.current){const O=zt(s.extension);Ws(O).then(()=>{m.current&&qs(m.current)})}},[s,l]);const C=t.useCallback(async()=>{if(!o.current){f("error"),setTimeout(()=>f("idle"),2e3);return}try{const O=o.current.innerHTML,se=Un(O),Q=o.current.innerText;await Bn(se,Q),f("copied"),setTimeout(()=>f("idle"),2e3)}catch{f("error"),setTimeout(()=>f("idle"),2e3)}},[]),D=t.useCallback(async()=>{if(!o.current){w("error"),setTimeout(()=>w("idle"),2e3);return}try{const O=o.current.innerHTML;await Pt(O),w("copied"),setTimeout(()=>w("idle"),2e3)}catch{w("error"),setTimeout(()=>w("idle"),2e3)}},[]),N=t.useCallback(async()=>{try{await Pt(s.content),g("copied"),setTimeout(()=>g("idle"),2e3)}catch{g("error"),setTimeout(()=>g("idle"),2e3)}},[s.content]),U=t.useCallback(async()=>{try{await Pt(s.content),x("copied"),setTimeout(()=>x("idle"),2e3)}catch{x("error"),setTimeout(()=>x("idle"),2e3)}},[s.content]),_=e.jsxs("div",{className:"file-viewer-header-buttons",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${j}`,onClick:C,title:p("terminal:fileExplorer.copyRichTextTitle"),children:p(j==="copied"?"terminal:fileExplorer.copied":j==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyRichText")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${b}`,onClick:D,title:p("terminal:fileExplorer.copyHtmlTitle"),children:p(b==="copied"?"terminal:fileExplorer.copied":b==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyHtml")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${R}`,onClick:N,title:p("terminal:fileExplorer.copyMarkdownTitle"),children:p(R==="copied"?"terminal:fileExplorer.copied":R==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyMarkdown")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${k}`,onClick:U,title:p("terminal:fileExplorer.copyOriginalTitle"),children:p(k==="copied"?"terminal:fileExplorer.copied":k==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyOriginal")})]}),e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:d,title:p(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderMarkdown"),children:l?"</>":"Aa"})]});return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{file:s,onRevealInTree:n,rightContent:_,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:h,children:[l?e.jsx("div",{className:"file-viewer-markdown-wrapper",children:e.jsx("div",{className:"markdown-content",ref:o,children:e.jsx(_n,{remarkPlugins:[Vn],children:s.content})})}):e.jsx("div",{className:"file-viewer-code-wrapper",children:e.jsx("pre",{className:"file-viewer-pre",children:e.jsx("code",{ref:m,className:"language-markdown",children:s.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${v.currentLine}/${v.totalLines}`,children:v.scrollPercentage===100?"END":v.scrollPercentage===0?"TOP":`${v.scrollPercentage}%`}),v.searchActive&&e.jsx(ss,{query:v.searchQuery,onQueryChange:v.setSearchQuery,matchCount:v.searchMatches.length,currentIndex:v.currentMatchIndex,onNext:v.nextMatch,onPrev:v.prevMatch,onClose:v.clearSearch})]}),v.helpActive&&e.jsx(ns,{onClose:v.toggleHelp})]})}function Ga({file:s,onRevealInTree:n,renderPlantUml:l,onToggleRender:d,editMode:r,onToggleEdit:i}){const{t:m}=re(["terminal"]),o=t.useRef(null),h=t.useRef(null),[p,j]=t.useState(null),[f,b]=t.useState(!1),[w,R]=t.useState(null),g=Xs({containerRef:h,isEnabled:!0,content:s.content});t.useEffect(()=>{if(!l&&o.current){const x=zt(s.extension);Ws(x).then(()=>{o.current&&qs(o.current)})}},[s,l]),t.useEffect(()=>{if(!l)return;if(!s.content.trim()){j(null),R("Diagram is empty");return}const x=new AbortController;return b(!0),R(null),(async()=>{try{const C=await fetch(Pa,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8",Accept:"image/svg+xml"},body:s.content,signal:x.signal});if(!C.ok)throw new Error(`Render failed (${C.status})`);const D=await C.text();if(!D.includes("<svg"))throw new Error("Invalid SVG output");j(Oa(D))}catch(C){if(x.signal.aborted)return;const D=C instanceof Error?C.message:"Failed to render diagram";R(D),j(null)}finally{x.signal.aborted||b(!1)}})(),()=>x.abort()},[s.path,s.content,l]);const k=e.jsx("div",{className:"file-viewer-header-buttons",children:e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:d,title:m(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderDiagram"),children:l?"</>":m("terminal:fileExplorer.diagram")})});return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{file:s,onRevealInTree:n,rightContent:k,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:h,children:[l?e.jsxs("div",{className:"file-viewer-diagram-wrapper",children:[f&&e.jsx("div",{className:"file-viewer-placeholder",children:m("terminal:fileExplorer.renderingDiagram")}),!f&&p&&e.jsx("img",{src:p,alt:s.filename,className:"file-viewer-diagram-image"}),!f&&w&&e.jsxs("div",{className:"file-viewer-diagram-error",children:[e.jsxs("div",{children:[m("terminal:fileExplorer.couldNotRender"),": ",w]}),e.jsx("button",{className:"file-viewer-render-toggle",onClick:d,children:m("terminal:fileExplorer.showSource")})]})]}):e.jsx("div",{className:"file-viewer-code-wrapper",children:e.jsx("pre",{className:"file-viewer-pre",children:e.jsx("code",{ref:o,className:"language-plaintext",children:s.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${g.currentLine}/${g.totalLines}`,children:g.scrollPercentage===100?"END":g.scrollPercentage===0?"TOP":`${g.scrollPercentage}%`}),g.searchActive&&e.jsx(ss,{query:g.searchQuery,onQueryChange:g.setSearchQuery,matchCount:g.searchMatches.length,currentIndex:g.currentMatchIndex,onNext:g.nextMatch,onPrev:g.prevMatch,onClose:g.clearSearch})]}),g.helpActive&&e.jsx(ns,{onClose:g.toggleHelp})]})}function Ua({file:s,onRevealInTree:n}){const{t:l}=re(["common","terminal"]),d=()=>{if(s.dataUrl){const r=document.createElement("a");r.href=s.dataUrl,r.download=s.filename,r.click()}};return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{file:s,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:d,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-image-wrapper",children:s.dataUrl?e.jsx("img",{src:s.dataUrl,alt:s.filename,className:"file-viewer-image"}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadImage")})})]})}function Ba({file:s,onRevealInTree:n}){const{t:l}=re(["common","terminal"]),d=()=>{if(s.dataUrl){const r=document.createElement("a");r.href=s.dataUrl,r.download=s.filename,r.click()}};return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{file:s,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:d,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-pdf-wrapper",children:s.dataUrl?e.jsx("iframe",{src:s.dataUrl,title:s.filename,className:"file-viewer-pdf"}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadPdf")})})]})}function _a({file:s,onRevealInTree:n}){const{t:l}=re(["terminal","common"]),d=()=>{if(s.dataUrl){const i=document.createElement("a");i.href=s.dataUrl,i.download=s.filename,i.click()}},r=()=>{const i=s.extension.toLowerCase();return[".xlsx",".xls"].includes(i)?e.jsx(M,{name:"dashboard",size:48}):[".docx",".doc"].includes(i)?e.jsx(M,{name:"edit",size:48}):[".pptx",".ppt"].includes(i)?e.jsx(M,{name:"film",size:48}):[".zip",".tar",".gz",".rar",".7z"].includes(i)?e.jsx(M,{name:"file-zip",size:48}):[".mp3",".wav",".flac",".ogg"].includes(i)?e.jsx(M,{name:"music-note",size:48}):[".mp4",".avi",".mov",".mkv",".webm"].includes(i)?e.jsx(M,{name:"film",size:48}):[".exe",".dmg",".app",".msi"].includes(i)?e.jsx(M,{name:"gear",size:48}):[".apk",".aab",".ipa"].includes(i)?e.jsx(M,{name:"mobile",size:48}):[".jar",".war",".ear"].includes(i)?e.jsx(M,{name:"coffee",size:48}):[".iso",".img"].includes(i)?e.jsx(M,{name:"disc",size:48}):[".so",".dll",".dylib"].includes(i)?e.jsx(M,{name:"wrench",size:48}):e.jsx(M,{name:"folder",size:48})};return e.jsxs(e.Fragment,{children:[e.jsx(Ve,{file:s,onRevealInTree:n}),e.jsxs("div",{className:"file-viewer-binary",children:[e.jsx("div",{className:"file-viewer-binary-icon",children:r()}),e.jsx("div",{className:"file-viewer-binary-name",children:s.filename}),e.jsx("div",{className:"file-viewer-binary-size",children:Ks(s.size)}),e.jsx("div",{className:"file-viewer-binary-message",children:l("terminal:fileExplorer.cannotPreview")}),e.jsx("button",{className:"file-viewer-download-btn large",onClick:d,children:l("terminal:fileExplorer.downloadFile")})]})]})}function Va({file:s,loading:n,error:l,onRevealInTree:d,onFileEdited:r}){const{t:i}=re(["terminal","common"]),[m,o]=Ha(),[h,p]=za(),[j,f]=t.useState(!1);t.useEffect(()=>{f(!1)},[s==null?void 0:s.path]);const b=t.useCallback(async C=>{if(!s)return;const D=await W(V("/api/files/write"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:s.path,content:C})});if(!D.ok){const N=await D.json().catch(()=>({error:"Save failed"}));throw new Error(N.error||"Save failed")}},[s]),w=t.useCallback(()=>{f(C=>(C&&s&&(r==null||r(s.path)),!C))},[s,r]),R=t.useCallback(()=>{s&&(r==null||r(s.path))},[s,r]);if(n)return e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")});if(l)return e.jsx("div",{className:"file-viewer-placeholder error",children:l});if(!s)return e.jsxs("div",{className:"file-viewer-placeholder",children:[e.jsx("div",{className:"placeholder-icon",children:e.jsx(M,{name:"folder-open",size:32})}),e.jsx("div",{className:"placeholder-text",children:i("terminal:fileExplorer.selectFileToView")})]});const g=s.fileType||"text",k=g==="text"&&La(s.extension),x=g==="text"&&$a(s.extension),v=k||x;return v&&j&&s.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(Ve,{file:s,onRevealInTree:d,editMode:!0,onToggleEdit:w}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(As,{content:s.content,extension:s.extension,onSave:b,onCancel:w},s.path)})]}):g==="text"&&!v&&s.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(Ve,{file:s,onRevealInTree:d}),e.jsx(t.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(As,{content:s.content,extension:s.extension,onSave:b,onCancel:R},s.path)})]}):e.jsxs("div",{className:"file-viewer-content",children:[k&&e.jsx(Aa,{file:s,onRevealInTree:d,renderMarkdown:m,onToggleRender:o,editMode:j,onToggleEdit:w}),x&&!k&&e.jsx(Ga,{file:s,onRevealInTree:d,renderPlantUml:h,onToggleRender:p,editMode:j,onToggleEdit:w}),g==="image"&&e.jsx(Ua,{file:s,onRevealInTree:d}),g==="pdf"&&e.jsx(Ba,{file:s,onRevealInTree:d}),g==="binary"&&e.jsx(_a,{file:s,onRevealInTree:d})]})}const Qs=t.memo(Va,(s,n)=>s.loading!==n.loading||s.error!==n.error?!1:s.file===null&&n.file===null?!0:s.file===null||n.file===null?!1:s.file.path===n.file.path&&s.file.content===n.file.content&&s.file.modified===n.file.modified);Qs.displayName="FileViewer";function Zs({text:s,query:n}){if(!n)return e.jsx(e.Fragment,{children:s});const l=Wn(s,n);if(l)return e.jsxs(e.Fragment,{children:[s.slice(0,l.start),e.jsx("mark",{className:"search-highlight",children:s.slice(l.start,l.end)}),s.slice(l.end)]});const d=n.toLowerCase(),i=s.toLowerCase().indexOf(d);return i===-1?e.jsx(e.Fragment,{children:s}):e.jsxs(e.Fragment,{children:[s.slice(0,i),e.jsx("mark",{className:"search-highlight",children:s.slice(i,i+n.length)}),s.slice(i+n.length)]})}const Ka=t.memo(function({node:n,query:l,isSelected:d,onSelect:r,lineNumber:i}){const m=n.isDirectory?null:es(n),o=n.path.split("/");o[o.length-1];const h=o.slice(0,-1).join("/");return e.jsxs("div",{className:`search-result-item ${d?"selected":""}`,onClick:()=>r(n),children:[n.isDirectory?e.jsx("span",{className:"search-result-icon",children:e.jsx(M,{name:"folder",size:14})}):m?e.jsx("span",{className:"search-result-icon",style:{backgroundImage:`url('${m}')`},role:"img","aria-label":"file icon"}):e.jsx("span",{className:"search-result-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsxs("div",{className:"search-result-info",children:[e.jsxs("span",{className:"search-result-name",children:[e.jsx(Zs,{text:n.name,query:l}),i&&e.jsxs("span",{className:"search-result-line-badge",children:[":",i]})]}),e.jsx("span",{className:"search-result-path",children:h})]})]})}),Wa=t.memo(function({match:n,query:l,isSelected:d,onSelect:r}){const{t:i}=re(["terminal"]),m={name:n.name,path:n.path,isDirectory:!1,extension:n.extension},o=es(m),h=n.path.split("/"),p=h[h.length-1],j=h.slice(0,-1).join("/");return e.jsxs("div",{className:`content-search-item ${d?"selected":""}`,children:[e.jsxs("div",{className:`content-search-header ${d?"selected":""}`,onClick:()=>r(n.path),children:[o?e.jsx("span",{className:"content-search-icon",style:{backgroundImage:`url('${o}')`},role:"img","aria-label":"file icon"}):e.jsx("span",{className:"content-search-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{className:"content-search-name",children:p}),e.jsx("span",{className:"search-result-path",style:{fontSize:"10px"},children:j})]}),e.jsx("span",{className:"content-search-count",children:n.matches.length})]}),e.jsxs("div",{className:"content-search-matches",children:[n.matches.slice(0,5).map((f,b)=>e.jsxs("div",{className:"content-search-match",onClick:()=>r(n.path,f.line),children:[e.jsx("span",{className:"content-search-line-num",children:f.line}),e.jsx("span",{className:"content-search-line-content",children:e.jsx(Zs,{text:f.content.trim(),query:l})})]},`${n.path}-${f.line}-${b}`)),n.matches.length>5&&e.jsxs("div",{className:"content-search-match",style:{opacity:.6,cursor:"default"},children:[e.jsx("span",{className:"content-search-line-num",children:"..."}),e.jsx("span",{className:"content-search-line-content",children:i("terminal:fileExplorer.moreMatches",{count:n.matches.length-5})})]})]})]})});function qa({filenameResults:s,contentResults:n,onSelectFile:l,onSelectContent:d,selectedPath:r,query:i,lineNumber:m}){const{t:o}=re(["terminal"]),h=s.length>0,p=n.length>0;return!h&&!p?e.jsx("div",{className:"search-no-results",children:o("terminal:fileExplorer.noMatchesFound")}):e.jsxs("div",{className:"unified-search-results",children:[h&&e.jsxs("div",{className:"unified-search-section",children:[e.jsxs("div",{className:"unified-search-section-header",children:[e.jsx("span",{className:"unified-search-section-icon",children:e.jsx(M,{name:"file-text",size:14})}),e.jsx("span",{className:"unified-search-section-title",children:o("terminal:fileExplorer.files")}),e.jsx("span",{className:"unified-search-section-count",children:s.length})]}),e.jsx("div",{className:"unified-search-section-content",children:s.map(j=>e.jsx(Ka,{node:j,query:i,isSelected:r===j.path,onSelect:l,lineNumber:m},j.path))})]}),p&&e.jsxs("div",{className:"unified-search-section",children:[e.jsxs("div",{className:"unified-search-section-header",children:[e.jsx("span",{className:"unified-search-section-icon",children:e.jsx(M,{name:"edit",size:14})}),e.jsx("span",{className:"unified-search-section-title",children:o("terminal:fileExplorer.content")}),e.jsx("span",{className:"unified-search-section-count",children:o("terminal:fileExplorer.matchesInFiles",{matches:n.reduce((j,f)=>j+f.matches.length,0),files:n.length})})]}),e.jsx("div",{className:"unified-search-section-content",children:n.map(j=>e.jsx(Wa,{match:j,query:i,isSelected:r===j.path,onSelect:d},j.path))})]})]})}const en=t.memo(qa,(s,n)=>!(s.query!==n.query||s.selectedPath!==n.selectedPath||s.filenameResults.length!==n.filenameResults.length||s.contentResults.length!==n.contentResults.length));en.displayName="UnifiedSearchResults";const Ya=t.memo(function({file:n,isSelected:l,onSelect:d,onStage:r,isStaging:i,showDirPath:m,isChecked:o,onToggleCheck:h,onContextMenu:p,onDiscard:j}){const{t:f}=re(["terminal"]),b=n.status,w=yt[b],R=b==="deleted",g=b==="untracked"&&r,k=n.name.includes(".")?"."+n.name.split(".").pop():"",x=m&&n.path.includes("/")?n.path.slice(0,n.path.lastIndexOf("/")):"";return e.jsxs("div",{className:`git-file-item ${l?"selected":""}`,onClick:()=>!R&&d(n.path,b),onContextMenu:v=>{v.preventDefault(),p==null||p(v,n,b)},style:{cursor:R?"not-allowed":"pointer"},title:n.path,children:[h&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:o||!1,onChange:v=>{v.stopPropagation(),h(n.path)},onClick:v=>v.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:xt(k),alt:"file"}),e.jsxs("span",{className:"git-file-name",children:[n.name,x&&e.jsx("span",{className:"git-file-dir",children:x})]}),e.jsx("span",{className:"git-file-status",style:{color:w.color},children:w.icon}),n.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(M,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.oldPath.split("/").pop()]}),g&&e.jsx("button",{className:`git-stage-btn ${i?"staging":""}`,onClick:v=>{v.stopPropagation(),i||r(n.path)},title:f("terminal:fileExplorer.stageFile"),disabled:i,children:i?"...":"+"}),j&&e.jsx("button",{className:"git-discard-btn",onClick:v=>{v.stopPropagation(),j(n,b)},title:b==="untracked"||b==="added"?"Delete file":"Discard changes",children:e.jsx(M,{name:"revert",size:12})})]})}),Ja=16,Xa=22,Qa=t.memo(function s({node:n,depth:l,expandedDirs:d,onToggleDir:r,selectedPath:i,onSelect:m,onStage:o,stagingPaths:h,checkedFiles:p,onToggleCheck:j,onContextMenu:f,onDirContextMenu:b,onDiscard:w}){const{t:R}=re(["terminal"]),g=l*Ja;if(!n.isDirectory){const x=n.file.status,v=yt[x];return e.jsxs("div",{className:`git-file-item ${i===n.path?"selected":""}`,onClick:()=>x!=="deleted"&&m(n.file.path,x),onContextMenu:C=>{C.preventDefault(),f==null||f(C,n.file,x)},style:{paddingLeft:`${g+Xa}px`,cursor:x==="deleted"?"not-allowed":"pointer"},title:n.file.path,children:[j&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:(p==null?void 0:p.has(n.file.path))||!1,onChange:C=>{C.stopPropagation(),j(n.file.path)},onClick:C=>C.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:xt(n.file.name.includes(".")?"."+n.file.name.split(".").pop():""),alt:"file"}),e.jsx("span",{className:"git-file-name",children:n.file.name}),e.jsx("span",{className:"git-file-status",style:{color:v.color},children:v.icon}),n.file.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(M,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.file.oldPath.split("/").pop()]}),x==="untracked"&&o&&e.jsx("button",{className:`git-stage-btn ${h!=null&&h.has(n.path)?"staging":""}`,onClick:C=>{C.stopPropagation(),h!=null&&h.has(n.path)||o(n.file.path)},title:R("terminal:fileExplorer.stageFile"),disabled:h==null?void 0:h.has(n.path),children:h!=null&&h.has(n.path)?"...":"+"}),w&&e.jsx("button",{className:"git-discard-btn",onClick:C=>{C.stopPropagation(),w(n.file,x)},title:x==="untracked"||x==="added"?"Delete file":"Discard changes",children:e.jsx(M,{name:"revert",size:12})})]})}const k=d.has(n.path);return e.jsxs("div",{className:"tree-node-wrapper",children:[e.jsxs("div",{className:`tree-node directory ${k?"expanded":""}`,style:{paddingLeft:`${g}px`},onClick:()=>r(n.path),onContextMenu:x=>{x.preventDefault(),x.stopPropagation(),b==null||b(x,n)},children:[e.jsx("span",{className:`tree-arrow ${k?"expanded":""}`,children:e.jsx(M,{name:"caret-right",size:10})}),e.jsx("img",{className:"tree-folder-icon",src:k?"/assets/vscode-icons/default_folder_opened.svg":"/assets/vscode-icons/default_folder.svg",alt:"folder"}),e.jsx("span",{className:"tree-name",children:n.name}),e.jsx("span",{className:"git-tree-file-count",children:R("terminal:fileExplorer.fileCount",{count:n.fileCount})})]}),k&&e.jsx("div",{className:"tree-children",children:n.children.map(x=>e.jsx(s,{node:x,depth:l+1,expandedDirs:d,onToggleDir:r,selectedPath:i,onSelect:m,onStage:o,stagingPaths:h,checkedFiles:p,onToggleCheck:j,onContextMenu:f,onDirContextMenu:b,onDiscard:w},x.path))})]})}),Qt=t.memo(function({groupLabel:n,groupIcon:l,groupColor:d,files:r,treeNodes:i,viewMode:m,selectedPath:o,expandedDirs:h,onToggleDir:p,onFileSelect:j,onStageFile:f,onStageAll:b,stagingPaths:w,checkedFiles:R,onToggleCheck:g,onContextMenu:k,onDirContextMenu:x,onDiscardFile:v,onDiscardAll:C}){const{t:D}=re(["terminal"]);if(r.length===0)return null;const N=r.some(O=>O.status==="untracked"),U=N&&b&&r.length>0,_=w?r.every(O=>w.has(O.path)):!1;return e.jsxs("div",{className:"git-status-group",children:[e.jsxs("div",{className:"git-status-group-header",style:{color:d},children:[e.jsx("span",{className:"git-status-badge",style:{background:d},children:l}),n," (",r.length,")",U&&e.jsx("button",{className:`git-stage-all-btn ${_?"staging":""}`,onClick:O=>{O.stopPropagation(),_||b()},title:D("terminal:fileExplorer.stageAllUntracked"),disabled:_,children:_?"...":D("terminal:fileExplorer.stageAll")}),C&&e.jsxs("button",{className:"git-discard-all-btn",onClick:O=>{O.stopPropagation(),C()},title:N?`Delete all ${r.length} files`:`Discard all ${r.length} changes`,children:[e.jsx(M,{name:"revert",size:12})," All"]})]}),m==="tree"?e.jsx("div",{className:"git-tree-content",children:i.map(O=>e.jsx(Qa,{node:O,depth:0,expandedDirs:h,onToggleDir:p,selectedPath:o,onSelect:j,onStage:f,stagingPaths:w,checkedFiles:R,onToggleCheck:g,onContextMenu:k,onDirContextMenu:x,onDiscard:v},O.path))}):e.jsx("div",{className:"git-flat-content",children:r.map(O=>e.jsx(Ya,{file:O,isSelected:o===O.path,onSelect:j,onStage:O.status==="untracked"?f:void 0,isStaging:w==null?void 0:w.has(O.path),showDirPath:!0,isChecked:R==null?void 0:R.has(O.path),onToggleCheck:g,onContextMenu:k,onDiscard:v},O.path))})]})});function Za({gitStatus:s,loading:n,onFileSelect:l,selectedPath:d,onRefresh:r,onStageFiles:i,stagingPaths:m,currentFolder:o,onCommitComplete:h,mergeInProgress:p,mergingBranch:j,onMergeContinue:f,onMergeAbort:b,onConflictOpen:w,onRevealInTree:R}){const{t:g}=re(["terminal","common"]),[k,x]=t.useState("tree"),[v,C]=t.useState(new Set),[D,N]=t.useState(""),[U,_]=t.useState(""),[O,se]=t.useState(!1),[Q,T]=t.useState(new Set),[F,K]=t.useState(!1),[ne,ie]=t.useState(null),fe=t.useRef(null),{showToast:z}=Ys(),[I,$]=t.useState(null),[P,ee]=t.useState(null),[te,ge]=t.useState(null),je=t.useCallback((E,L)=>{ge({files:[E],label:E.name})},[]),c=t.useCallback(async()=>{if(!(!te||!o))try{const E=await W(V("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:te.files.map(B=>({path:B.path,status:B.status})),directory:o})}),L=await E.json();E.ok&&L.success?(z("success","Discarded",`Reverted ${te.files.length} file(s)`),r()):z("error","Discard Failed",L.error||"Could not discard changes")}catch{z("error","Discard Failed","Network error")}finally{ge(null)}},[te,o,r,z]),G=t.useCallback((E,L,B)=>{E.preventDefault(),E.stopPropagation(),$({isOpen:!0,position:{x:E.clientX,y:E.clientY},file:L,status:B})},[]),ae=t.useCallback(async(E,L)=>{if(o)try{const B=await W(V("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:E.path,status:L}],directory:o})}),pe=await B.json();B.ok&&pe.success?(z("success","Discarded",`Restored ${E.name}`),r()):z("error","Discard Failed",pe.error||"Could not discard changes")}catch{z("error","Discard Failed","Network error")}},[o,r,z]),ce=t.useCallback(async E=>{try{await navigator.clipboard.writeText(E),z("success","Copied","Full path copied")}catch{z("error","Copy Failed","Could not copy path")}},[z]),A=t.useCallback(async E=>{const L=o&&E.startsWith(o+"/")?E.slice(o.length+1):E;try{await navigator.clipboard.writeText(L),z("success","Copied","Relative path copied")}catch{z("error","Copy Failed","Could not copy path")}},[o,z]),S=t.useMemo(()=>{if(!I)return[];const{file:E,status:L}=I,B=[];return L==="conflict"&&w?B.push({id:"open-conflict",label:g("terminal:fileExplorer.gitContextMenu.openConflictResolver"),icon:e.jsx(M,{name:"warn",size:14}),onClick:()=>w(E.path)}):L!=="deleted"&&B.push({id:"open-file",label:g("terminal:fileExplorer.gitContextMenu.openFile"),icon:e.jsx(M,{name:"file-text",size:14}),onClick:()=>l(E.path,L)}),L!=="conflict"&&B.push({id:"stage-file",label:g("terminal:fileExplorer.gitContextMenu.stageFile"),icon:e.jsx(M,{name:"plus",size:14}),onClick:()=>{i([E.path])}}),B.push({id:"divider-1",label:"",divider:!0,onClick:()=>{}}),(L==="modified"||L==="deleted"||L==="renamed"||L==="conflict")&&B.push({id:"discard-changes",label:g("terminal:fileExplorer.gitContextMenu.discardChanges"),icon:e.jsx(M,{name:"revert",size:14}),danger:!0,onClick:()=>{ae(E,L)}}),(L==="untracked"||L==="added")&&B.push({id:"delete-file",label:g("terminal:fileExplorer.gitContextMenu.deleteFile"),icon:e.jsx(M,{name:"trash",size:14}),danger:!0,onClick:()=>{ae(E,L)}}),B.push({id:"divider-2",label:"",divider:!0,onClick:()=>{}}),B.push({id:"copy-full-path",label:g("terminal:fileExplorer.gitContextMenu.copyFullPath"),icon:e.jsx(M,{name:"pin",size:14}),onClick:()=>{ce(E.path)}}),B.push({id:"copy-relative-path",label:g("terminal:fileExplorer.gitContextMenu.copyRelativePath"),icon:e.jsx(M,{name:"clipboard",size:14}),onClick:()=>{A(E.path)}}),R&&L!=="deleted"&&B.push({id:"reveal-in-tree",label:g("terminal:fileExplorer.gitContextMenu.revealInTree"),icon:e.jsx(M,{name:"target",size:14}),onClick:()=>R(E.path)}),B},[I,l,i,w,R,ae,ce,A,g]),q=t.useCallback((E,L)=>{E.preventDefault(),E.stopPropagation(),ee({isOpen:!0,position:{x:E.clientX,y:E.clientY},node:L})},[]),Z=t.useCallback(E=>!E.isDirectory&&E.file?[E.file]:E.children.flatMap(L=>Z(L)),[]),Te=t.useCallback(async E=>{if(!o)return;const L=Z(E);if(L.length!==0)try{const B=await W(V("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:L.map(ye=>({path:ye.path,status:ye.status})),directory:o})}),pe=await B.json();B.ok&&pe.success?(z("success","Discarded",`Reverted ${L.length} file(s) in ${E.name}`),r()):z("error","Discard Failed",pe.error||"Could not discard changes")}catch{z("error","Discard Failed","Network error")}},[o,Z,r,z]),ve=t.useMemo(()=>{if(!P)return[];const{node:E}=P,L=Z(E);return[{id:"discard-dir",label:`Discard Changes (${L.length} files)`,icon:e.jsx(M,{name:"revert",size:14}),danger:!0,onClick:()=>{Te(E)}},{id:"stage-dir",label:`Stage All (${L.length} files)`,icon:e.jsx(M,{name:"plus",size:14}),onClick:()=>{i(L.map(B=>B.path))}}]},[P,Z,Te,i]),X=t.useCallback(E=>{C(L=>{const B=new Set(L);return B.has(E)?B.delete(E):B.add(E),B})},[]),{conflictFiles:xe,conflictTree:ze,changesFiles:Le,changesTree:bt,untrackedFiles:de,untrackedTree:ue,allDirPaths:Ee}=t.useMemo(()=>{if(!s||!s.isGitRepo||s.files.length===0)return{conflictFiles:[],conflictTree:[],changesFiles:[],changesTree:[],untrackedFiles:[],untrackedTree:[],allDirPaths:new Set};const E=new Set,L=s.files.filter(De=>De.status==="conflict"),B=Lt(L);$t(B,E);const pe=s.files.filter(De=>De.status==="modified"||De.status==="added"||De.status==="deleted"||De.status==="renamed"),ye=Lt(pe);$t(ye,E);const Je=s.files.filter(De=>De.status==="untracked"),$e=Lt(Je);return $t($e,E),{conflictFiles:L,conflictTree:B,changesFiles:pe,changesTree:ye,untrackedFiles:Je,untrackedTree:$e,allDirPaths:E}},[s]);t.useEffect(()=>{C(Ee)},[Ee]),t.useEffect(()=>{s!=null&&s.files&&T(new Set(s.files.map(E=>E.path)))},[s==null?void 0:s.files]);const we=t.useCallback(()=>{Le.length!==0&&ge({files:Le,label:`${Le.length} changed files`})},[Le]),Ke=t.useCallback(()=>{de.length!==0&&ge({files:de,label:`${de.length} unversioned files`})},[de]),Oe=t.useCallback(()=>{xe.length!==0&&ge({files:xe,label:`${xe.length} conflicted files`})},[xe]),jt=xe.length>0;t.useEffect(()=>{if(ne){const E=ne.type==="error"?8e3:4e3,L=setTimeout(()=>ie(null),E);return()=>clearTimeout(L)}},[ne]);const We=t.useCallback(async()=>{const E=!O;if(se(E),E&&o){_(D);try{const B=await(await W(V(`/api/files/git-log-message?path=${encodeURIComponent(o)}`))).json();B.message&&N(B.message)}catch{}}else N(U)},[O,o,D,U]),ut=t.useCallback(E=>{T(L=>{const B=new Set(L);return B.has(E)?B.delete(E):B.add(E),B})},[]),qe=t.useCallback(()=>{if(!(s!=null&&s.files))return;const E=s.files.map(B=>B.path),L=E.every(B=>Q.has(B));T(L?new Set:new Set(E))},[s==null?void 0:s.files,Q]),Ye=t.useCallback(async E=>{if(!(!o||!D.trim()||Q.size===0||F)){K(!0),ie(null);try{const L=await W(V("/api/files/git-commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o,message:D.trim(),amend:O,paths:Array.from(Q)})}),B=await L.json();if(!L.ok||!B.success){ie({type:"error",text:B.error||"Commit failed"}),K(!1);return}if(E)try{const pe=await W(V("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o})}),ye=await pe.json();pe.ok&&ye.success?ie({type:"success",text:g("terminal:fileExplorer.committedAndPushed")}):ie({type:"error",text:g("terminal:fileExplorer.committedButPushFailed",{error:ye.error||"Unknown error"})})}catch{ie({type:"error",text:g("terminal:fileExplorer.committedButPushFailed",{error:"Network error"})})}else ie({type:"success",text:g("terminal:fileExplorer.committedSuccessfully")});N(""),_(""),se(!1),r(),h==null||h()}catch(L){ie({type:"error",text:L.message||"Commit failed"})}finally{K(!1)}}},[o,D,O,Q,F,r,h]);if(n)return e.jsx("div",{className:"git-changes-loading",children:g("terminal:fileExplorer.loadingGitStatus")});if(!s||!s.isGitRepo)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(M,{name:"package",size:32})}),e.jsx("div",{className:"git-empty-text",children:g("terminal:fileExplorer.notGitRepo")})]});if(s.files.length===0)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(M,{name:"sparkle",size:32})}),e.jsx("div",{className:"git-empty-text",children:g("terminal:fileExplorer.workingTreeClean")}),e.jsx("div",{className:"git-empty-branch",children:g("terminal:fileExplorer.onBranch",{branch:s.branch})})]});const ht=E=>{i([E])},vt=()=>{const E=de.map(L=>L.path);E.length>0&&i(E)},Ce=(E,L)=>{L==="conflict"&&w?w(E):l(E,L)};return e.jsxs("div",{className:"git-changes",children:[e.jsxs("div",{className:"git-changes-header",children:[e.jsxs("span",{className:"git-branch",children:[e.jsx("span",{className:"git-branch-icon",children:e.jsx(M,{name:"git-branch",size:12})}),s.branch]}),s.counts&&e.jsxs("div",{className:"git-changes-summary",children:[(s.counts.conflict??0)>0&&e.jsxs("span",{className:"git-count conflict",children:[s.counts.conflict,"C"]}),s.counts.modified>0&&e.jsxs("span",{className:"git-count modified",children:[s.counts.modified,"M"]}),s.counts.added>0&&e.jsxs("span",{className:"git-count added",children:[s.counts.added,"A"]}),s.counts.deleted>0&&e.jsxs("span",{className:"git-count deleted",children:[s.counts.deleted,"D"]}),s.counts.untracked>0&&e.jsxs("span",{className:"git-count untracked",children:[s.counts.untracked,"?"]})]}),e.jsxs("div",{className:"git-view-toggle",children:[e.jsx("button",{className:`git-view-toggle-btn ${k==="flat"?"active":""}`,onClick:()=>x("flat"),title:g("terminal:fileExplorer.flatList"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"2",y:"3",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"7",width:"12",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"2",y:"11",width:"12",height:"1.5",rx:"0.5"})]})}),e.jsx("button",{className:`git-view-toggle-btn ${k==="tree"?"active":""}`,onClick:()=>x("tree"),title:g("terminal:fileExplorer.directoryTree"),children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"5.5",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"4",y:"9",width:"8",height:"1.5",rx:"0.5"}),e.jsx("rect",{x:"7",y:"12.5",width:"7",height:"1.5",rx:"0.5"})]})})]}),e.jsx("button",{className:"git-refresh-btn",onClick:r,title:g("common:buttons.refresh"),children:e.jsx(M,{name:"refresh",size:12})})]}),p&&e.jsxs("div",{className:"git-merge-banner",children:[e.jsx("span",{className:"git-merge-banner-icon",children:"⚠"}),e.jsx("span",{className:"git-merge-banner-text",children:g("terminal:fileExplorer.mergeInProgress",{branch:j?` (${j})`:""})}),e.jsxs("div",{className:"git-merge-actions",children:[e.jsx("button",{className:"git-merge-continue-btn",onClick:f,disabled:jt,title:g(jt?"terminal:fileExplorer.resolveAllConflictsFirst":"terminal:fileExplorer.continueMerge"),children:g("terminal:fileExplorer.continue")}),e.jsx("button",{className:"git-merge-abort-btn",onClick:b,title:g("terminal:fileExplorer.abortMerge"),children:g("terminal:fileExplorer.abort")})]})]}),e.jsxs("div",{className:"git-changes-list",children:[e.jsx(Qt,{groupLabel:g("terminal:fileExplorer.gitGroups.conflicts"),groupIcon:"C",groupColor:"#ff5555",files:xe,treeNodes:ze,viewMode:k,selectedPath:d,expandedDirs:v,onToggleDir:X,onFileSelect:Ce,checkedFiles:Q,onToggleCheck:ut,onContextMenu:G,onDirContextMenu:q,onDiscardFile:je,onDiscardAll:Oe}),e.jsx(Qt,{groupLabel:g("terminal:fileExplorer.gitGroups.changes"),groupIcon:"~",groupColor:"#c89a5a",files:Le,treeNodes:bt,viewMode:k,selectedPath:d,expandedDirs:v,onToggleDir:X,onFileSelect:Ce,checkedFiles:Q,onToggleCheck:ut,onContextMenu:G,onDirContextMenu:q,onDiscardFile:je,onDiscardAll:we}),e.jsx(Qt,{groupLabel:g("terminal:fileExplorer.gitGroups.unversioned"),groupIcon:"?",groupColor:"#6ab8c8",files:de,treeNodes:ue,viewMode:k,selectedPath:d,expandedDirs:v,onToggleDir:X,onFileSelect:Ce,onStageFile:ht,onStageAll:vt,stagingPaths:m,checkedFiles:Q,onToggleCheck:ut,onContextMenu:G,onDirContextMenu:q,onDiscardFile:je,onDiscardAll:Ke})]}),e.jsxs("div",{className:"git-commit-panel",children:[e.jsxs("div",{className:"git-commit-options",children:[e.jsxs("label",{className:"git-commit-amend-label",children:[e.jsx("input",{type:"checkbox",className:"git-commit-amend-checkbox",checked:O,onChange:We}),g("terminal:fileExplorer.amend")]}),e.jsx("span",{className:"git-commit-file-count",children:g("terminal:fileExplorer.fileCount",{count:Q.size})}),e.jsx("button",{className:"git-commit-select-toggle",onClick:qe,title:Q.size===s.files.length?g("terminal:fileExplorer.deselectAll"):g("terminal:fileExplorer.selectAll"),children:Q.size===s.files.length?g("terminal:fileExplorer.deselectAll"):g("terminal:fileExplorer.selectAll")})]}),e.jsx("textarea",{ref:fe,className:"git-commit-message",placeholder:g("terminal:fileExplorer.commitMessagePlaceholder"),value:D,onChange:E=>N(E.target.value),onKeyDown:E=>{(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),Ye(!1)),(E.metaKey||E.ctrlKey)&&E.shiftKey&&E.key==="Enter"&&(E.preventDefault(),Ye(!0)),E.stopPropagation()},rows:3,disabled:F}),ne&&e.jsx("div",{className:`git-commit-status ${ne.type}`,children:ne.text}),e.jsxs("div",{className:"git-commit-actions",children:[e.jsx("button",{className:"git-commit-btn",onClick:()=>Ye(!1),disabled:!D.trim()||Q.size===0||F,title:g("terminal:fileExplorer.commitCtrlEnter"),children:g(F?"terminal:fileExplorer.committing":"terminal:fileExplorer.commitAction")}),e.jsx("button",{className:"git-commit-push-btn",onClick:()=>Ye(!0),disabled:!D.trim()||Q.size===0||F,title:g("terminal:fileExplorer.commitAndPushCtrlShiftEnter"),children:F?"...":g("terminal:fileExplorer.commitAndPush")})]})]}),I&&e.jsx(ct,{isOpen:I.isOpen,position:I.position,worldPosition:{x:0,z:0},actions:S,onClose:()=>$(null)}),P&&e.jsx(ct,{isOpen:P.isOpen,position:P.position,worldPosition:{x:0,z:0},actions:ve,onClose:()=>ee(null)}),te&&e.jsx("div",{className:"git-discard-confirm-overlay",onClick:()=>ge(null),children:e.jsxs("div",{className:"git-discard-confirm",onClick:E=>E.stopPropagation(),children:[e.jsx("p",{children:te.files.some(E=>E.status==="untracked"||E.status==="added")?e.jsxs(e.Fragment,{children:["Delete ",e.jsx("strong",{children:te.label}),"?"]}):e.jsxs(e.Fragment,{children:["Discard changes to ",e.jsx("strong",{children:te.label}),"?"]})}),e.jsx("p",{className:"git-discard-confirm-hint",children:"This cannot be undone."}),e.jsxs("div",{className:"git-discard-confirm-actions",children:[e.jsx("button",{className:"git-discard-confirm-cancel",onClick:()=>ge(null),children:"Cancel"}),e.jsx("button",{className:"git-discard-confirm-btn",onClick:c,children:te.files.some(E=>E.status==="untracked"||E.status==="added")?"Delete":"Discard"})]})]})})]})}const tn=t.memo(Za,(s,n)=>s.loading!==n.loading||s.selectedPath!==n.selectedPath||s.stagingPaths!==n.stagingPaths||s.currentFolder!==n.currentFolder||s.mergeInProgress!==n.mergeInProgress||s.mergingBranch!==n.mergingBranch?!1:s.gitStatus===null&&n.gitStatus===null?!0:!(s.gitStatus===null||n.gitStatus===null||s.gitStatus.isGitRepo!==n.gitStatus.isGitRepo||s.gitStatus.branch!==n.gitStatus.branch||s.gitStatus.files.length!==n.gitStatus.files.length||s.gitStatus.mergeInProgress!==n.gitStatus.mergeInProgress));tn.displayName="GitChanges";const er=t.memo(function({tab:n,isActive:l,onSelect:d,onClose:r,onContextMenu:i}){const{t:m}=re(["terminal"]),o={name:n.filename,path:n.path,isDirectory:!1,extension:n.extension},h=t.useCallback(()=>{d(n.path)},[d,n.path]),p=t.useCallback(b=>{b.button===1&&(b.preventDefault(),b.stopPropagation(),r(n.path))},[r,n.path]),j=t.useCallback(b=>{b.preventDefault(),b.stopPropagation(),r(n.path)},[r,n.path]),f=t.useCallback(b=>{b.preventDefault(),b.stopPropagation(),i(b,n)},[i,n]);return e.jsxs("div",{className:`file-tab ${l?"active":""}`,onClick:h,onMouseDown:p,onContextMenu:f,title:n.path,children:[e.jsx("img",{className:"file-tab-icon",src:es(o),alt:"file"}),e.jsx("span",{className:"file-tab-name",children:n.filename}),e.jsx("button",{className:"file-tab-close",onClick:j,title:m("terminal:fileExplorer.closeMiddleClick"),children:"×"})]})});function tr(s){return typeof s.path=="string"&&s.path.startsWith("/")}function sr({tabs:s,activeTabPath:n,onSelectTab:l,onCloseTab:d,onCloseAllTabs:r,onShowGitHistory:i}){const{t:m}=re(["terminal"]),[o,h]=t.useState(null),p=t.useCallback((b,w)=>{h({isOpen:!0,position:{x:b.clientX,y:b.clientY},tab:w})},[]),j=t.useCallback(()=>h(null),[]),f=t.useMemo(()=>{if(!o)return[];const b=o.tab,w=!!i&&tr(b),R=[{id:"git-history",label:m("terminal:fileExplorer.showGitHistory")??"Show Git History",icon:e.jsx(M,{name:"git-commit",size:14}),disabled:!w,onClick:()=>{w&&i(b.path)}}];return r&&R.push({id:"divider-close-all",label:"",divider:!0,onClick:()=>{}},{id:"close-all-tabs",label:m("terminal:fileExplorer.closeAllTabs")??"Close all tabs",icon:e.jsx(M,{name:"cross",size:14}),danger:!0,onClick:()=>r()}),R},[o,i,r,m]);return s.length===0?null:e.jsxs("div",{className:"file-tabs-bar",children:[e.jsx("div",{className:"file-tabs-container",children:s.map(b=>e.jsx(er,{tab:b,isActive:n===b.path,onSelect:l,onClose:d,onContextMenu:p},b.path))}),o&&e.jsx(ct,{isOpen:o.isOpen,position:o.position,worldPosition:{x:0,z:0},actions:f,onClose:j})]})}const sn=t.memo(sr,(s,n)=>{if(s.activeTabPath!==n.activeTabPath||s.tabs.length!==n.tabs.length||s.onShowGitHistory!==n.onShowGitHistory||s.onCloseAllTabs!==n.onCloseAllTabs)return!1;for(let l=0;l<s.tabs.length;l++)if(s.tabs[l].path!==n.tabs[l].path)return!1;return!0});sn.displayName="FileTabs";const nr=t.memo(function({currentFolder:n,gitStatus:l,onBranchChanged:d,onMerge:r,onCompare:i,onPullConflicts:m}){const{t:o}=re(["terminal","common"]),[h,p]=t.useState(!1),[j,f]=t.useState(""),[b,w]=t.useState(!1),[R,g]=t.useState(""),[k,x]=t.useState(!1),[v,C]=t.useState(null),[D,N]=t.useState(null),U=t.useRef(null),_=t.useRef(null),O=t.useRef(null),{branches:se,loading:Q,operationInProgress:T,loadBranches:F,checkoutBranch:K,createBranch:ne,pullFromRemote:ie,pushToRemote:fe}=ts();t.useEffect(()=>{h&&n&&(F(n),setTimeout(()=>{var S;return(S=_.current)==null?void 0:S.focus()},50)),h||(f(""),w(!1),g(""),C(null))},[h,n,F]),t.useEffect(()=>{if(v){const S=v.type==="error"?8e3:3e3,q=setTimeout(()=>C(null),S);return()=>clearTimeout(q)}},[v]),t.useEffect(()=>{b&&setTimeout(()=>{var S;return(S=O.current)==null?void 0:S.focus()},50)},[b]),t.useEffect(()=>{if(!h)return;const S=Z=>{const Te=Z.target;!Te.closest(".branch-widget-selector")&&!Te.closest(".branch-widget-dropdown")&&p(!1)},q=Z=>{Z.key==="Escape"&&(Z.preventDefault(),Z.stopPropagation(),p(!1))};return document.addEventListener("click",S),document.addEventListener("keydown",q,!0),()=>{document.removeEventListener("click",S),document.removeEventListener("keydown",q,!0)}},[h]);const z=t.useCallback(async S=>{if(!n||T||S.isCurrent)return;const q=await K(n,S.name);q.success?(C({type:"success",text:o("terminal:fileExplorer.switchedToBranch",{branch:q.branch||S.name})}),d(),F(n)):C({type:"error",text:q.error||o("terminal:fileExplorer.checkoutFailed")})},[n,T,K,d,F]),I=t.useCallback(async()=>{if(!n||!R.trim()||T)return;const S=await ne(n,R.trim());S.success?(C({type:"success",text:o("terminal:fileExplorer.createdBranch",{branch:S.branch})}),w(!1),g(""),d(),F(n)):C({type:"error",text:S.error||o("terminal:fileExplorer.createBranchFailed")})},[n,R,T,ne,d,F]),$=t.useCallback(async()=>{if(!n||T)return;const S=await ie(n);S.success?(S.stashConflicts&&S.stashConflicts.length>0?(C({type:"error",text:`Pull succeeded but stash pop had conflicts: ${S.stashConflicts.length} file(s). Resolve manually.`}),m==null||m(S.stashConflicts),p(!1)):S.stashed?C({type:"success",text:"Pull complete. Local changes were auto-stashed and restored."}):C({type:"success",text:o("terminal:fileExplorer.pullComplete")}),d(),F(n)):S.conflicts&&S.conflicts.length>0?(C({type:"error",text:`Pull conflicts: ${S.conflicts.length} file(s)`}),m==null||m(S.conflicts),p(!1)):C({type:"error",text:S.error||o("terminal:fileExplorer.pullFailed")})},[n,T,ie,d,F,m]),P=t.useCallback(async()=>{if(!n||T)return;const S=await fe(n);S.success?C({type:"success",text:o("terminal:fileExplorer.pushComplete")}):C({type:"error",text:S.error||o("terminal:fileExplorer.pushFailed")})},[n,T,fe]),[ee,te]=t.useState(!1),ge=t.useCallback(async()=>{if(!(!n||T||ee)){te(!0);try{const S=await W(V("/api/files/git-fetch"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})});if(S.ok)C({type:"success",text:"Fetch complete"}),d(),F(n);else{const q=await S.json().catch(()=>({error:"Fetch failed"}));C({type:"error",text:q.error||"Fetch failed"})}}catch{C({type:"error",text:"Fetch failed"})}finally{te(!1)}}},[n,T,ee,d,F]),je=(l==null?void 0:l.branch)||"unknown",c=!!T,G=t.useCallback((S,q)=>{q.isCurrent||(S.preventDefault(),S.stopPropagation(),N({isOpen:!0,position:{x:S.clientX,y:S.clientY},branch:q.name}))},[]),ae=t.useMemo(()=>{if(!D)return[];const S=!!T||(l==null?void 0:l.mergeInProgress);return[{id:"compare",label:o("terminal:fileExplorer.showDiffWith",{branch:D.branch}),icon:e.jsx(M,{name:"arrows-horizontal",size:14}),disabled:!!T,onClick:()=>{i==null||i(D.branch),p(!1)}},{id:"merge",label:o("terminal:fileExplorer.mergeInto",{source:D.branch,target:je}),icon:"⤵",disabled:!!S,onClick:()=>{r&&r(D.branch),p(!1)}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"checkout",label:o("terminal:fileExplorer.checkoutBranch",{branch:D.branch}),icon:e.jsx(M,{name:"git-branch",size:14}),disabled:!!T,onClick:()=>{const q=se.find(Z=>Z.name===D.branch);q&&z(q)}}]},[D,T,l==null?void 0:l.mergeInProgress,je,r,i,se,z]),ce=t.useMemo(()=>{const S=se.filter(Z=>!Z.isRemote);if(!j)return S;const q=j.toLowerCase();return S.filter(Z=>Z.name.toLowerCase().includes(q))},[se,j]),A=t.useMemo(()=>{const S=se.filter(Z=>Z.isRemote);if(!j)return S;const q=j.toLowerCase();return S.filter(Z=>Z.name.toLowerCase().includes(q))},[se,j]);return e.jsxs("div",{className:"branch-widget",style:{position:"relative"},children:[e.jsxs("div",{className:"branch-widget-selector",onClick:S=>{S.stopPropagation(),p(!h)},title:`Branch: ${je}`,children:[e.jsx("svg",{className:"branch-widget-icon",width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm0 2.122a2.25 2.25 0 1 0-1 0v1.836A2.25 2.25 0 0 0 5.75 9.5h1.378a2.251 2.251 0 1 0 0-1H5.75a1.25 1.25 0 0 1-1.25-1.25V5.372Zm7.75 4.878a.75.75 0 1 0 0-1.5.75.75 0 0 0 0 1.5Zm-3-8.75a.75.75 0 1 0-1.5 0 .75.75 0 0 0 1.5 0Z"})}),e.jsx("span",{className:"branch-widget-name",children:je}),e.jsx("span",{className:"branch-widget-arrow",children:"▼"})]}),h&&e.jsxs("div",{className:"branch-widget-dropdown",ref:U,children:[e.jsx("div",{className:"branch-widget-search",children:e.jsx("input",{ref:_,type:"text",className:"branch-widget-search-input",placeholder:o("terminal:fileExplorer.searchBranches"),value:j,onChange:S=>f(S.target.value),onKeyDown:S=>S.stopPropagation()})}),v&&e.jsx("div",{className:`branch-widget-status ${v.type}`,children:v.text}),e.jsx("div",{className:"branch-widget-section-header",children:o("terminal:fileExplorer.actions")}),e.jsxs("div",{className:"branch-widget-actions",children:[e.jsxs("div",{className:`branch-widget-action-item ${c||ee?"disabled":""}`,onClick:ge,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 13l-3-3h2V6h2v4h2l-3 3zM8 3l3 3h-2v4H7V6H5l3-3z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:ee?"Fetching...":"Fetch"})]}),e.jsxs("div",{className:`branch-widget-action-item ${c?"disabled":""}`,onClick:$,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 12l-4-4h2.5V3h3v5H12L8 12z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o(T==="pull"?"terminal:fileExplorer.pulling":"terminal:fileExplorer.pull")})]}),e.jsxs("div",{className:`branch-widget-action-item ${c?"disabled":""}`,onClick:P,children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 4l4 4h-2.5v5h-3V8H4l4-4z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o(T==="push"?"terminal:fileExplorer.pushing":"terminal:fileExplorer.push")})]}),e.jsxs("div",{className:`branch-widget-action-item ${c?"disabled":""}`,onClick:()=>{c||w(!b)},children:[e.jsx("span",{className:"branch-widget-action-icon",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"currentColor",children:e.jsx("path",{d:"M8 2v5H3v2h5v5h2V9h5V7H10V2H8z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o("terminal:fileExplorer.newBranch")})]})]}),b&&e.jsxs("div",{className:"branch-widget-new-branch",children:[e.jsx("input",{ref:O,type:"text",className:"branch-widget-new-branch-input",placeholder:o("terminal:fileExplorer.branchNamePlaceholder"),value:R,onChange:S=>g(S.target.value),onKeyDown:S=>{S.stopPropagation(),S.key==="Enter"&&I(),S.key==="Escape"&&(w(!1),g(""))}}),e.jsx("button",{className:"branch-widget-new-branch-confirm",onClick:I,disabled:!R.trim()||c,children:T==="create"?"...":o("common:buttons.create")})]}),e.jsxs("div",{className:"branch-widget-section-header",children:[o("terminal:fileExplorer.localBranches"),Q&&e.jsxs("span",{className:"branch-widget-loading-hint",children:[" ",o("terminal:fileExplorer.loading")]})]}),e.jsxs("div",{className:"branch-widget-branch-list",children:[ce.length===0&&!Q&&e.jsx("div",{className:"branch-widget-empty",children:o("terminal:fileExplorer.noBranchesFound")}),ce.map(S=>e.jsxs("div",{className:`branch-widget-branch-item ${S.isCurrent?"current":""} ${c?"disabled":""}`,onClick:()=>z(S),onContextMenu:q=>G(q,S),title:S.lastMessage||S.name,children:[e.jsxs("span",{className:"branch-widget-branch-name",children:[S.isCurrent&&e.jsx("span",{className:"branch-widget-current-marker",children:"*"}),S.name]}),S.lastCommit&&e.jsx("span",{className:"branch-widget-branch-commit",children:S.lastCommit})]},S.name))]}),A.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"branch-widget-section-header clickable",onClick:()=>x(!k),children:[e.jsx("span",{className:"branch-widget-section-toggle",children:k?"▾":"▸"}),o("terminal:fileExplorer.remoteBranches",{count:A.length})]}),k&&e.jsx("div",{className:"branch-widget-branch-list",children:A.map(S=>e.jsxs("div",{className:`branch-widget-branch-item remote ${c?"disabled":""}`,onClick:()=>z(S),onContextMenu:q=>G(q,S),title:S.lastMessage||S.name,children:[e.jsx("span",{className:"branch-widget-branch-name",children:S.name}),S.lastCommit&&e.jsx("span",{className:"branch-widget-branch-commit",children:S.lastCommit})]},S.name))})]})]}),D&&e.jsx(ct,{isOpen:D.isOpen,position:D.position,worldPosition:{x:0,z:0},actions:ae,onClose:()=>N(null)})]})});function ar(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function It(s,n){if(!s)return"";const l=Is.languages[n];return l?Is.highlight(s,l,n):ar(s)}function rr(s){const n=[],l=s.split(`
|
|
9
9
|
`);let d=[],r=!1,i=[],m=[],o=!1;for(const h of l)h.startsWith("<<<<<<<")?(d.length>0&&(n.push({type:"unchanged",content:d.join(`
|
|
10
10
|
`)}),d=[]),r=!0,o=!1,i=[],m=[]):h.startsWith("=======")&&r?o=!0:h.startsWith(">>>>>>>")&&r?(n.push({type:"conflict",ours:i.join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{al as as,u as ts,aE as vs,aF as bs,aG as zs,j as s,I as F,a6 as Is,aH as Es,aI as $s,aJ as Ds,aK as Ms,r as c,ab as Ls,av as Ps,a2 as Ss,a1 as Xs,U as Rs,aL as Ys,aM as Gs,aN as Us,aO as ms,aP as _s,s as M,aQ as Fs,o as U}from"./main-Bi4grTFP.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:P,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:S})=>{const{t:x}=ts(["dashboard","common"]),X=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,Z]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:P,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{S==null||S(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),X&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:X?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),P=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:P.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:P.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ks({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:P,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ps(),S=Ss(),x=Xs(),rs=Rs(),X=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,Q]=c.useState(null),[ps,K]=c.useState(null),[R,T]=c.useState(!1),[p,B]=c.useState(null),W=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Gs(w,X):Us(w),[w,x,m,X]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{Q(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",K(i)},[]),ks=c.useCallback(()=>{K(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),Q(null),K(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),Q(null),K(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){T(!1),B(null);return}R&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),T(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(G),window.setTimeout(()=>l(G),0),G});return}const q=U(t,ss)||t.key==="ArrowLeft"?"left":U(t,es)||t.key==="ArrowDown"?"down":U(t,f)||t.key==="ArrowUp"?"up":U(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(B(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(U(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>X.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),T(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),S.size>0&&s.jsx(ws,{buildings:S,onSelectBuilding:P})]})]})}export{Ks as DashboardView};
|
|
1
|
+
import{al as as,u as ts,aE as vs,aF as bs,aG as zs,j as s,I as F,a6 as Is,aH as Es,aI as $s,aJ as Ds,aK as Ms,r as c,ab as Ls,av as Ps,a2 as Ss,a1 as Xs,U as Rs,aL as Ys,aM as Gs,aN as Us,aO as ms,aP as _s,s as M,aQ as Fs,o as U}from"./main-CEKV7I4r.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const fs=as.memo(({agent:a,isSelected:A,isKeyboardFocused:L=!1,onSelect:P,onDoubleClick:n,onChat:g,onFocus:h,onKill:w,onDragStart:S})=>{const{t:x}=ts(["dashboard","common"]),X=vs().has(a.id),N=bs(a.status),H=zs(a),j=Ms(H),I=a.taskLabel?s.jsxs(s.Fragment,{children:[s.jsx(F,{name:"task",size:12})," ",a.taskLabel]}):a.currentTask||a.lastAssignedTask,m=a.status==="idle"&&a.lastActivity>0,[,Z]=as.useState(0);return as.useEffect(()=>{if(!m)return;const b=window.setInterval(()=>Z(J=>J+1),15e3);return()=>window.clearInterval(b)},[m]),s.jsxs("div",{className:`dash-card dash-card--${N} ${A?"dash-card--selected":""} ${L?"dash-card--keyboard-focused":""}`,"data-agent-id":a.id,onClick:P,onDoubleClick:b=>{b.stopPropagation(),n()},onDragStart:b=>{S==null||S(a),b.dataTransfer.effectAllowed="move"},draggable:!0,title:x("cards.doubleClickHint"),children:[s.jsxs("div",{className:"dash-card__row1",children:[s.jsx("span",{className:`dash-card__status-dot dash-card__status-dot--${N}`}),s.jsx("span",{className:"dash-card__name",children:a.name}),s.jsxs("span",{className:"dash-card__class",children:[s.jsx(Is,{agent:a,size:14})," ",a.class]}),s.jsxs("span",{className:`dash-card__provider dash-card__provider--${a.provider}`,children:[s.jsx(F,{name:a.provider==="codex"||a.provider==="opencode"?"status-pending":"robot",size:11,weight:a.provider==="codex"||a.provider==="opencode"?"fill":"regular",color:a.provider==="codex"?"#a16207":a.provider==="opencode"?"#4ade80":void 0})," ",a.provider]}),X&&s.jsx("span",{className:"dash-card__unseen-badge",title:"New output available - click to view",children:"!"})]}),s.jsxs("div",{className:"dash-card__row2",children:[s.jsx("span",{className:`dash-card__status dash-card__status--${N}`,children:X?"Unseen":a.status}),s.jsxs("div",{className:"dash-card__context",children:[s.jsx("div",{className:"dash-card__context-bar",children:s.jsx("div",{className:`dash-card__context-fill dash-card__context-fill--${j}`,style:{width:`${H}%`}})}),s.jsxs("span",{className:`dash-card__context-pct dash-card__context-pct--${j}`,children:[H,"%"]})]})]}),s.jsxs("div",{className:"dash-card__row3",children:[s.jsxs("span",{className:"dash-card__workdir",title:a.cwd,children:[s.jsx(F,{name:"folder",size:11})," ",a.cwd.split("/").pop()||a.cwd]}),m&&s.jsxs("span",{className:"dash-card__idle-time",style:{color:Ds(a.lastActivity)},title:$s(a.lastActivity),children:[s.jsx(F,{name:"status-waiting-input",size:10})," ",Es(a.lastActivity)]})]}),I&&s.jsx("div",{className:"dash-card__row4",children:s.jsx("span",{className:"dash-card__task",children:I})}),s.jsxs("div",{className:"dash-card__actions",children:[g&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--chat",onClick:b=>{b.stopPropagation(),g()},title:x("cards.openTerminal"),children:x("cards.chat")}),w&&s.jsx("button",{className:"dash-card__action-btn dash-card__action-btn--danger",onClick:b=>{b.stopPropagation(),w()},title:x("cards.killAgent"),children:x("cards.stop")})]})]})});fs.displayName="AgentCard";const ws=({buildings:a,onSelectBuilding:A})=>{const{t:L}=ts(["dashboard"]),P=c.useMemo(()=>Array.from(a.values()).sort((n,g)=>n.name.localeCompare(g.name)),[a]);return s.jsxs("div",{className:"dashboard-view__buildings",children:[s.jsxs("div",{className:"dashboard-view__buildings-header",children:[s.jsx("span",{className:"dashboard-view__buildings-title",children:L("buildings.title")}),s.jsx("span",{className:"dashboard-view__buildings-count",children:P.length})]}),s.jsx("div",{className:"dashboard-view__buildings-row",children:P.map(n=>{const g=bs(n.status),h=Ls(n.type);return s.jsxs("button",{className:`dash-pill dash-pill--${g}`,onClick:()=>A==null?void 0:A(n.id),title:`${n.name} (${n.type}) - ${n.status}`,children:[s.jsx("span",{className:"dash-pill__icon",children:s.jsx(F,{name:h,size:14})}),s.jsx("span",{className:"dash-pill__name",children:n.name}),s.jsx("span",{className:`dash-pill__dot dash-pill__dot--${g}`})]},n.id)})})]})};ws.displayName="BuildingPills";function Ks({onSelectAgent:a,onFocusAgent:A,onKillAgent:L,onSelectBuilding:P,onOpenTerminal:n,onFocusZone:g}){const{t:h}=ts(["dashboard","common"]),w=Ps(),S=Ss(),x=Xs(),rs=Rs(),X=vs(),[N,H]=c.useState(""),[j,I]=c.useState("all"),[m,Z]=c.useState("zone"),[b,J]=c.useState(new Set),[k,Q]=c.useState(null),[ps,K]=c.useState(null),[R,T]=c.useState(!1),[p,B]=c.useState(null),W=c.useMemo(()=>{const e=Array.from(w.values());return{total:e.length,working:e.filter(i=>i.status==="working"||i.status==="waiting"||i.status==="waiting_permission").length,idle:e.filter(i=>i.status==="idle").length,error:e.filter(i=>i.status==="error"||i.status==="offline"||i.status==="orphaned").length}},[w]),ns=c.useMemo(()=>m==="zone"?Ys(w,x):m==="status"?Gs(w,X):Us(w),[w,x,m,X]),V=c.useMemo(()=>{const e=N.toLowerCase().trim(),i=ns.map(l=>({...l,agents:l.agents.filter(_=>{if(j==="working"){if(_.status!=="working"&&_.status!=="waiting"&&_.status!=="waiting_permission")return!1}else if(j==="error"&&_.status!=="error"&&_.status!=="offline"&&_.status!=="orphaned")return!1;return!(e&&!_.name.toLowerCase().includes(e)&&!_.class.toLowerCase().includes(e))})}));return m==="zone"?i:i.filter(l=>l.agents.length>0)},[ns,j,N,m]),O=c.useCallback(e=>e.area?`area:${e.area.id}`:`${m}:${e.label}`,[m]),C=c.useMemo(()=>{const e=[];return V.forEach(i=>{const l=O(i);if(b.has(l))return;const _=m==="status"?ms(i.agents,{prioritizeRecentlyIdle:!0}):_s(i.agents);e.push(..._)}),e},[V,b,m,O]),gs=c.useCallback(e=>{J(i=>{const l=new Set(i);return l.has(e)?l.delete(e):l.add(e),l})},[]),xs=c.useCallback(e=>{n==null||n(e)},[n]),js=c.useCallback(e=>{Q(e)},[]),Ns=c.useCallback((e,i)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",K(i)},[]),ks=c.useCallback(()=>{K(null)},[]),Cs=c.useCallback(e=>{if(!k)return;if(e===null){const E=M.getState(),t=Array.from(E.areas.values()).find(r=>r.assignedAgentIds.includes(k.id));t&&M.unassignAgentFromArea(k.id,t.id),Q(null),K(null);return}const i=x.get(e);if(!i)return;const l=Array.from(w.values()),_=Fs(i,l,k.position);M.updateAgent({...k,position:{...k.position,x:_.x,z:_.z}}),M.assignAgentToArea(k.id,e),Q(null),K(null)},[k,x,w]);return c.useEffect(()=>{if(C.length===0){T(!1),B(null);return}R&&(!p||!C.some(e=>e.id===p))&&(B(C[0].id),a==null||a(C[0].id))},[C,R,p,a]),c.useEffect(()=>{const e=t=>t instanceof HTMLElement?t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable:!1,i=t=>t instanceof HTMLElement?!!t.closest(".guake-terminal")||t.classList.contains("guake-input")||t.classList.contains("agent-panel-input"):!1,l=t=>{const r=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).find(z=>z.dataset.agentId===t);r==null||r.scrollIntoView({block:"nearest",inline:"nearest"})},_=(t,r)=>{var ds,os,cs,ls,us,hs;const z=Array.from(document.querySelectorAll(".dash-card[data-agent-id]")).map(d=>{const u=d.dataset.agentId;if(!u)return null;const y=d.getBoundingClientRect();return{id:u,centerX:y.left+y.width/2,centerY:y.top+y.height/2,height:y.height}}).filter(d=>d!==null).sort((d,u)=>d.centerY-u.centerY||d.centerX-u.centerX);if(z.length===0)return t;const ss=z.reduce((d,u)=>d+u.height,0)/z.length,es=Math.max(18,ss*.6),f=[];for(const d of z){const u=f[f.length-1];if(!u){f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}]);continue}const y=u.reduce((ys,As)=>ys+As.centerY,0)/u.length;Math.abs(d.centerY-y)<=es?u.push({id:d.id,centerX:d.centerX,centerY:d.centerY}):f.push([{id:d.id,centerX:d.centerX,centerY:d.centerY}])}f.forEach(d=>d.sort((u,y)=>u.centerX-y.centerX));const Y=f.findIndex(d=>d.some(u=>u.id===t));if(Y===-1)return((os=(ds=f[0])==null?void 0:ds[0])==null?void 0:os.id)??t;const $=f[Y],v=$.findIndex(d=>d.id===t);if(v===-1)return((ls=(cs=f[0])==null?void 0:cs[0])==null?void 0:ls.id)??t;if(r==="left")return((us=$[Math.max(0,v-1)])==null?void 0:us.id)??t;if(r==="right")return((hs=$[Math.min($.length-1,v+1)])==null?void 0:hs.id)??t;const q=r==="up"?Math.max(0,Y-1):Math.min(f.length-1,Y+1),o=f[q],G=$[v].centerX;let D=o[0],is=Math.abs(D.centerX-G);for(const d of o){const u=Math.abs(d.centerX-G);u<is&&(D=d,is=u)}return(D==null?void 0:D.id)??t},E=t=>{const r=M.getShortcuts(),z=r.find(o=>o.id==="dashboard-selector-toggle"),ss=r.find(o=>o.id==="dashboard-vim-left"),es=r.find(o=>o.id==="dashboard-vim-down"),f=r.find(o=>o.id==="dashboard-vim-up"),Y=r.find(o=>o.id==="dashboard-vim-right"),$=r.find(o=>o.id==="open-terminal"),v=M.getState();if(e(t.target))if(!v.terminalOpen&&i(t.target)&&document.activeElement instanceof HTMLElement)document.activeElement.blur();else return;if(U(t,z)){if(C.length===0)return;t.preventDefault(),t.stopPropagation(),T(!0),B(o=>{const G=o&&C.some(D=>D.id===o)?o:C[0].id;return a==null||a(G),window.setTimeout(()=>l(G),0),G});return}const q=U(t,ss)||t.key==="ArrowLeft"?"left":U(t,es)||t.key==="ArrowDown"?"down":U(t,f)||t.key==="ArrowUp"?"up":U(t,Y)||t.key==="ArrowRight"?"right":null;if(q&&R&&p){t.preventDefault(),t.stopPropagation();const o=_(p,q);o!==p&&(B(o),a==null||a(o),window.setTimeout(()=>l(o),0));return}if(U(t,$)){if(v.terminalOpen)return;if(R&&p&&v.agents.has(p)){t.preventDefault(),n==null||n(p);return}if(v.selectedAgentIds.size===1){t.preventDefault();const o=Array.from(v.selectedAgentIds)[0];n==null||n(o);return}if(v.lastSelectedAgentId&&v.agents.has(v.lastSelectedAgentId)){t.preventDefault(),n==null||n(v.lastSelectedAgentId);return}}};return document.addEventListener("keydown",E,!0),()=>document.removeEventListener("keydown",E,!0)},[C,R,p,n,a]),c.useEffect(()=>{const e=document.activeElement;e instanceof HTMLElement&&e.closest(".guake-terminal")&&!M.getState().terminalOpen&&e.blur()},[]),s.jsxs("div",{className:"dashboard-view",children:[s.jsxs("div",{className:"dashboard-view__topbar",children:[s.jsxs("div",{className:"dashboard-view__metrics",children:[s.jsxs("button",{className:`dashboard-view__metric-btn ${j==="all"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.total}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:labels.agents")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--working ${j==="working"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("working"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.working}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.working")})]}),s.jsxs("button",{className:"dashboard-view__metric-btn dashboard-view__metric-btn--idle ",onClick:()=>I("all"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.idle}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.idle")})]}),s.jsxs("button",{className:`dashboard-view__metric-btn dashboard-view__metric-btn--error ${j==="error"?"dashboard-view__metric-btn--active":""}`,onClick:()=>I("error"),children:[s.jsx("span",{className:"dashboard-view__metric-value",children:W.error}),s.jsx("span",{className:"dashboard-view__metric-label",children:h("common:status.error")})]})]}),s.jsx("input",{className:"dashboard-view__search",type:"text",placeholder:h("searchPlaceholder"),value:N,onChange:e=>H(e.target.value)})]}),s.jsxs("div",{className:"dashboard-view__grouping",children:[s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="zone"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("zone"),children:h("grouping.byZone")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="status"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("status"),children:h("grouping.byStatus")}),s.jsx("button",{className:`dashboard-view__grouping-btn ${m==="activity"?"dashboard-view__grouping-btn--active":""}`,onClick:()=>Z("activity"),children:h("grouping.byActivity")})]}),s.jsxs("div",{className:"dashboard-view__content",children:[V.map(e=>{const i=O(e),l=b.has(i),_=m==="status"?ms(e.agents,{prioritizeRecentlyIdle:!0}):_s(e.agents),E=e.agents.filter(r=>r.status==="working"||r.status==="waiting"||r.status==="waiting_permission").length,t=e.agents.filter(r=>X.has(r.id)).length;return s.jsxs("div",{className:`dashboard-view__zone ${ps===(e.area?e.area.id:null)&&k?"dashboard-view__zone--drag-over":""}`,onDragOver:r=>Ns(r,e.area?e.area.id:null),onDragLeave:ks,onDrop:()=>Cs(e.area?e.area.id:null),children:[s.jsxs("div",{className:"dashboard-view__zone-header",onClick:()=>gs(i),children:[s.jsxs("div",{className:"dashboard-view__zone-left",children:[s.jsx("span",{className:`dashboard-view__zone-chevron ${l?"dashboard-view__zone-chevron--collapsed":""}`,children:s.jsx(F,{name:"caret-down",size:12})}),s.jsx("span",{className:"dashboard-view__zone-dot",style:{backgroundColor:e.color}}),s.jsx("span",{className:"dashboard-view__zone-name",children:e.label}),s.jsxs("span",{className:"dashboard-view__zone-count",children:[h("agentCount",{count:e.agents.length}),E>0&&s.jsxs("span",{className:"dashboard-view__zone-working",children:[" · ",E," ",h("working")]}),t>0&&s.jsxs("span",{className:"dashboard-view__zone-unseen",children:[" · ",t," Unseen"]})]})]}),e.area&&g&&s.jsx("button",{className:"dashboard-view__zone-focus",onClick:r=>{r.stopPropagation(),g(e.area.id)},title:h("focusZone"),children:h("focusZone")})]}),!l&&s.jsx("div",{className:"dashboard-view__zone-grid",children:_.map(r=>s.jsx(fs,{agent:r,isSelected:rs.has(r.id),isKeyboardFocused:R&&p===r.id,onSelect:()=>{a==null||a(r.id),T(!0),B(r.id)},onDoubleClick:()=>xs(r.id),onChat:()=>n==null?void 0:n(r.id),onFocus:A?()=>A(r.id):void 0,onKill:L?()=>L(r.id):void 0,onDragStart:js},r.id))})]},i)}),V.length===0&&s.jsx("div",{className:"dashboard-view__empty",children:N?h("noAgentsMatching",{search:N}):h("noAgentsSpawned")}),S.size>0&&s.jsx(ws,{buildings:S,onSelectBuilding:P})]})]})}export{Ks as DashboardView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{bq as ta,u as B,j as e,aX as j,bt as Ms,bu as Fs,aY as ae,s as D,bv as $s,r as m,D as X,I as F,ab as Us,b5 as qe,f as na,bw as la,W as ia,S as oa,k as ra,aa as Ks,b6 as Ue}from"./main-
|
|
1
|
+
import{bq as ta,u as B,j as e,aX as j,bt as Ms,bu as Fs,aY as ae,s as D,bv as $s,r as m,D as X,I as F,ab as Us,b5 as qe,f as na,bw as la,W as ia,S as oa,k as ra,aa as Ks,b6 as Ue}from"./main-CEKV7I4r.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-Chj50gSY.js";const ca=[{value:"",labelKey:"terminal:building.colorDefault"},{value:"#2a2a3a",labelKey:"terminal:building.colorDarkGray"},{value:"#3a2a2a",labelKey:"terminal:building.colorDarkRed"},{value:"#2a3a2a",labelKey:"terminal:building.colorDarkGreen"},{value:"#2a2a4a",labelKey:"terminal:building.colorDarkBlue"},{value:"#3a3a2a",labelKey:"terminal:building.colorDarkYellow"},{value:"#3a2a3a",labelKey:"terminal:building.colorDarkPurple"},{value:"#2a3a3a",labelKey:"terminal:building.colorDarkCyan"},{value:"#4a3a3a",labelKey:"terminal:building.colorWarmBrown"},{value:"#3a4a4a",labelKey:"terminal:building.colorCoolSteel"}];function da(o){return ta.t(o)}function Ve(o){if(o===0)return"0 B";const p=1024,u=["B","KB","MB","GB"],x=Math.floor(Math.log(o)/Math.log(p));return parseFloat((o/Math.pow(p,x)).toFixed(1))+" "+u[x]}function ma(o){const u=Date.now()-o,x=Math.floor(u/(1e3*60*60)),n=Math.floor(u%(1e3*60*60)/(1e3*60));return x>0?`${x}h ${n}m`:`${n}m`}const Hs={30:"#1a1a1a",31:"#e74c3c",32:"#2ecc71",33:"#f39c12",34:"#3498db",35:"#9b59b6",36:"#00bcd4",37:"#ecf0f1",90:"#7f8c8d",91:"#ff6b6b",92:"#4ade80",93:"#fbbf24",94:"#60a5fa",95:"#c084fc",96:"#22d3ee",97:"#ffffff"};function qs(o){const p=[],u=/\x1B\[([0-9;]*)m/g;let x=0,n=null,y;for(;(y=u.exec(o))!==null;){if(y.index>x){const g=o.slice(x,y.index);n?p.push(e.jsx("span",{style:{color:n},children:g},p.length)):p.push(g)}const C=y[1].split(";").map(Number);for(const g of C)g===0||g===39?n=null:Hs[g]&&(n=Hs[g]);x=u.lastIndex}if(x<o.length){const C=o.slice(x);n?p.push(e.jsx("span",{style:{color:n},children:C},p.length)):p.push(C)}return p.length>0?p:[o]}function ua({buildingName:o,onClose:p,onConfirm:u}){const{t:x}=B(["terminal","common"]);return e.jsx("div",{className:"modal-overlay visible",onClick:p,children:e.jsxs("div",{className:"modal confirm-modal",onClick:n=>n.stopPropagation(),children:[e.jsx("div",{className:"modal-header",children:x("terminal:building.deleteBuilding")}),e.jsxs("div",{className:"modal-body confirm-modal-body",children:[e.jsx("p",{children:x("terminal:building.deleteConfirm",{name:o})}),e.jsx("p",{className:"confirm-modal-note",children:x("terminal:building.deleteNote")})]}),e.jsxs("div",{className:"modal-footer",children:[e.jsx("button",{className:"btn btn-secondary",onClick:p,children:x("common:buttons.cancel")}),e.jsx("button",{className:"btn btn-danger",onClick:u,autoFocus:!0,children:x("common:buttons.delete")})]})]})})}function pa({usePM2:o,setUsePM2:p}){const{t:u}=B(["terminal"]);return e.jsxs("div",{className:"form-section pm2-toggle-section",children:[e.jsxs("label",{className:"toggle-switch",children:[e.jsx("input",{type:"checkbox",className:"toggle-input",checked:o,onChange:x=>p(x.target.checked)}),e.jsx("span",{className:"toggle-track",children:e.jsx("span",{className:"toggle-thumb"})}),e.jsxs("span",{className:"toggle-label",children:[e.jsx("span",{className:"pm2-badge",children:"PM2"}),u("terminal:building.usePM2")]})]}),e.jsx("div",{className:"form-hint",children:u("terminal:building.pm2Hint")})]})}function ha({usePM2:o,pm2Script:p,setPm2Script:u,pm2Args:x,setPm2Args:n,pm2Interpreter:y,setPm2Interpreter:C,pm2InterpreterArgs:g,setPm2InterpreterArgs:v,pm2Env:s,setPm2Env:h,isEditMode:a,building:t,handleCommand:r}){var N;const{t:i}=B(["terminal","common"]);return o?e.jsxs("div",{className:"form-section pm2-config-section",children:[e.jsx("label",{className:"form-label",children:i("terminal:building.pm2Configuration")}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Script"),e.jsx(j,{text:i("terminal:building.helpPm2Script"),title:i("terminal:building.pm2Script"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:p,onChange:b=>u(b.target.value),placeholder:"npm, java, python, ./app.js",required:o})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Arguments"),e.jsx(j,{text:i("terminal:building.helpPm2Arguments"),title:i("terminal:building.pm2Arguments"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:x,onChange:b=>n(b.target.value),placeholder:"run dev, -jar app.jar, app.py"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Interpreter"),e.jsx(j,{text:i("terminal:building.helpPm2Interpreter"),title:i("terminal:building.pm2Interpreter"),position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:y,onChange:b=>C(b.target.value),children:Object.keys(Ms).map(b=>e.jsx("option",{value:b,children:Ms[b].label},b))})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2InterpArgs"),e.jsx(j,{text:i("terminal:building.helpPm2InterpArgs"),title:i("terminal:building.pm2InterpArgs"),position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:g,onChange:b=>v(b.target.value),placeholder:"-jar (for Java)"})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:[i("terminal:building.pm2Environment"),e.jsx(j,{text:i("terminal:building.helpPm2Environment"),title:i("terminal:building.pm2Environment"),position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:s,onChange:b=>h(b.target.value),placeholder:`KEY=value
|
|
2
2
|
SERVER_PORT=7201
|
|
3
3
|
NODE_ENV=production`,rows:3})]}),e.jsx("div",{className:"pm2-examples",children:e.jsxs("details",{children:[e.jsx("summary",{children:i("terminal:building.pm2Examples")}),e.jsxs("div",{className:"pm2-examples-content",children:[e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Node.js:"})," Script: ",e.jsx("code",{children:"npm"}),", Args: ",e.jsx("code",{children:"run dev"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Symfony:"})," Script: ",e.jsx("code",{children:"symfony"}),", Args: ",e.jsx("code",{children:"serve --no-daemon"}),", Interpreter: ",e.jsx("code",{children:"None"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Java JAR:"})," Script: ",e.jsx("code",{children:"app.jar"}),", Interpreter: ",e.jsx("code",{children:"Java"}),", Interp. Args: ",e.jsx("code",{children:"-jar"})]}),e.jsxs("div",{className:"pm2-example",children:[e.jsx("strong",{children:"Python:"})," Script: ",e.jsx("code",{children:"app.py"}),", Interpreter: ",e.jsx("code",{children:"Python 3"})]})]})]})}),a&&(t==null?void 0:t.pm2Status)&&e.jsx("div",{className:"pm2-status-display",children:e.jsxs("div",{className:"pm2-status-row",children:[e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"PID"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.pid||"-"})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"CPU"}),e.jsxs("span",{className:"pm2-metric-value",children:[((N=t.pm2Status.cpu)==null?void 0:N.toFixed(1))||"0","%"]})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"MEM"}),e.jsx("span",{className:"pm2-metric-value",children:Ve(t.pm2Status.memory||0)})]}),e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Restarts"}),e.jsx("span",{className:"pm2-metric-value",children:t.pm2Status.restarts||0})]}),t.pm2Status.uptime&&e.jsxs("span",{className:"pm2-metric",children:[e.jsx("span",{className:"pm2-metric-label",children:"Uptime"}),e.jsx("span",{className:"pm2-metric-value",children:ma(t.pm2Status.uptime)})]})]})}),a&&e.jsxs("div",{className:"pm2-actions",children:[e.jsx("button",{type:"button",className:"btn btn-sm btn-success",onClick:()=>r("start"),children:i("common:buttons.start")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>r("stop"),children:i("common:buttons.stop")}),e.jsx("button",{type:"button",className:"btn btn-sm btn-warning",onClick:()=>r("restart"),children:i("terminal:buildingAction.restart")}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>r("logs"),children:i("terminal:logs.title")})]})]}):null}function xa({dockerMode:o,setDockerMode:p,dockerImage:u,setDockerImage:x,dockerContainerName:n,setDockerContainerName:y,dockerCommand:C,setDockerCommand:g,dockerPorts:v,setDockerPorts:s,dockerVolumes:h,setDockerVolumes:a,dockerNetwork:t,setDockerNetwork:r,dockerRestart:i,setDockerRestart:N,dockerPull:b,setDockerPull:L,dockerEnv:T,setDockerEnv:A,dockerComposePath:$,setDockerComposePath:R,dockerComposeProject:K,setDockerComposeProject:I,dockerComposeServices:H,setDockerComposeServices:O,selectedExistingContainer:d,setSelectedExistingContainer:E,dockerContainersList:q,isEditMode:V,building:k,handleCommand:_}){const{t:M}=B(["config","common"]);return e.jsxs("div",{className:"form-section docker-config-section",children:[e.jsx("label",{className:"form-label",children:M("config:buildings.dockerConfig")}),e.jsxs("div",{className:"docker-mode-selector",children:[e.jsxs("label",{className:`docker-mode-option ${o==="container"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"container",checked:o==="container",onChange:()=>p("container")}),e.jsx("span",{className:"docker-mode-icon",children:"📦"}),e.jsx("span",{className:"docker-mode-label",children:"Container"}),e.jsx("span",{className:"docker-mode-desc",children:"Create a new container"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="compose"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"compose",checked:o==="compose",onChange:()=>p("compose")}),e.jsx("span",{className:"docker-mode-icon",children:"🛠"}),e.jsx("span",{className:"docker-mode-label",children:"Compose"}),e.jsx("span",{className:"docker-mode-desc",children:"Manage multiple services"})]}),e.jsxs("label",{className:`docker-mode-option ${o==="existing"?"active":""}`,children:[e.jsx("input",{type:"radio",name:"dockerMode",value:"existing",checked:o==="existing",onChange:()=>p("existing")}),e.jsx("span",{className:"docker-mode-icon",children:"🔎"}),e.jsx("span",{className:"docker-mode-label",children:"Existing"}),e.jsx("span",{className:"docker-mode-desc",children:"Adopt existing container"})]})]}),o==="container"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Image:",e.jsx(j,{text:"Docker image to run, e.g., nginx:latest, redis:alpine, my-app:v1",title:"Image",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:u,onChange:l=>x(l.target.value),placeholder:"nginx:latest",required:!0})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Container Name:",e.jsx(j,{text:"Custom name for the container. If empty, auto-generated based on building name.",title:"Container Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:n,onChange:l=>y(l.target.value),placeholder:"Auto-generated (tc-{name}-{id})"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Command:",e.jsx(j,{text:"Override the default container command. Leave empty to use image's CMD.",title:"Command Override",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:C,onChange:l=>g(l.target.value),placeholder:"Optional command override"})]}),e.jsxs("div",{className:"form-section docker-ports-section",children:[e.jsxs("label",{className:"form-label",children:["Port Mappings",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>s([...v,""]),children:"+ Add"})]}),v.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...v];z[S]=U.target.value,s(z)},placeholder:"8080:80 or 3000"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>s(v.filter((U,z)=>z!==S)),children:"x"})]},S)),v.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host:container (e.g., 8080:80) or same port (e.g., 3000)"})]}),e.jsxs("div",{className:"form-section docker-volumes-section",children:[e.jsxs("label",{className:"form-label",children:["Volume Mounts",e.jsx("button",{type:"button",className:"btn btn-sm btn-add",onClick:()=>a([...h,""]),children:"+ Add"})]}),h.map((l,S)=>e.jsxs("div",{className:"docker-mapping-row",children:[e.jsx("input",{type:"text",className:"form-input",value:l,onChange:U=>{const z=[...h];z[S]=U.target.value,a(z)},placeholder:"./data:/app/data or /host/path:/container/path"}),e.jsx("button",{type:"button",className:"btn btn-sm btn-danger",onClick:()=>a(h.filter((U,z)=>z!==S)),children:"x"})]},S)),h.length===0&&e.jsx("div",{className:"form-hint",children:"Format: host_path:container_path (relative paths resolved from working directory)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Network:",e.jsx(j,{text:"Docker network to connect to. Leave empty for default bridge network.",title:"Network",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:t,onChange:l=>r(l.target.value),placeholder:"bridge (default)"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Restart Policy:",e.jsx(j,{text:"When should Docker restart the container automatically?",title:"Restart Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:i,onChange:l=>N(l.target.value),children:Object.keys(Fs).map(l=>e.jsx("option",{value:l,children:Fs[l].label},l))})]})]}),o==="compose"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Compose File:",e.jsx(j,{text:"Path to docker-compose.yml file, relative to working directory.",title:"Compose File",position:"top",size:"sm"})]}),e.jsx(ae,{value:$,onChange:R,placeholder:"docker-compose.yml",className:"form-input",directoriesOnly:!1})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Project Name:",e.jsx(j,{text:"Override the compose project name. Leave empty for auto-generated name.",title:"Project Name",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:K,onChange:l=>I(l.target.value),placeholder:"Auto-generated"})]}),e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Services:",e.jsx(j,{text:"Specific services to manage (comma-separated). Leave empty for all services.",title:"Services",position:"top",size:"sm"})]}),e.jsx("input",{type:"text",className:"form-input",value:H,onChange:l=>O(l.target.value),placeholder:"All services (or: api, db, redis)"})]})]}),o==="existing"&&e.jsxs("div",{className:"docker-existing-section",children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Select Container:",e.jsx(j,{text:"Choose an existing Docker container to monitor and control. The container will not be deleted when removing the building.",title:"Existing Container",position:"top",size:"sm"})]}),e.jsxs("div",{className:"docker-existing-select-wrapper",children:[e.jsxs("select",{className:"form-input form-select",value:d,onChange:l=>E(l.target.value),required:o==="existing",children:[e.jsx("option",{value:"",children:"Select a container..."}),q.map(l=>e.jsxs("option",{value:l.name,children:[l.name," (",l.image,") - ",l.state]},l.id))]}),e.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>D.requestDockerContainersList(),title:"Refresh container list",children:"↻"})]})]}),q.length===0&&e.jsx("div",{className:"form-hint docker-existing-hint",children:"No containers found. Make sure Docker is running and you have containers available."}),d&&e.jsx("div",{className:"docker-existing-info",children:(()=>{const l=q.find(S=>S.name===d);return l?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Image:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.image})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Status:"}),e.jsx("span",{className:`docker-existing-info-value docker-status-${l.status}`,children:l.state})]}),e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"ID:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.id.slice(0,12)})]}),l.ports.length>0&&e.jsxs("div",{className:"docker-existing-info-row",children:[e.jsx("span",{className:"docker-existing-info-label",children:"Ports:"}),e.jsx("span",{className:"docker-existing-info-value",children:l.ports.map(S=>`${S.host}:${S.container}/${S.protocol}`).join(", ")})]})]}):null})()}),e.jsx("div",{className:"form-hint",children:"Note: Existing containers will not be deleted when you remove this building."})]}),o!=="existing"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"command-row",children:[e.jsxs("span",{className:"command-label",children:["Pull Policy:",e.jsx(j,{text:"When to pull images: always, only if missing, or never.",title:"Pull Policy",position:"top",size:"sm"})]}),e.jsx("select",{className:"form-input form-select",value:b,onChange:l=>L(l.target.value),children:Object.keys($s).map(l=>e.jsx("option",{value:l,children:$s[l].label},l))})]}),e.jsxs("div",{className:"command-row env-row",children:[e.jsxs("span",{className:"command-label",children:["Environment:",e.jsx(j,{text:"Environment variables in KEY=value format, one per line.",title:"Environment Variables",position:"top",size:"sm"})]}),e.jsx("textarea",{className:"form-input form-textarea",value:T,onChange:l=>A(l.target.value),placeholder:`KEY=value
|
|
4
4
|
DATABASE_URL=postgres://...
|