tide-commander 1.199.6 → 1.201.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/assets/{AudioPlayer-DbawH_kK.js → AudioPlayer-jjttJ6SM.js} +1 -1
- package/dist/assets/{BossLogsModal-DGR32RLh.js → BossLogsModal-DF0ar9g6.js} +1 -1
- package/dist/assets/{BossSpawnModal-1OOnwHa_.js → BossSpawnModal-rJfm0Ijw.js} +1 -1
- package/dist/assets/{ControlsModal-DFHBGDDH.js → ControlsModal-D4JLnO36.js} +1 -1
- package/dist/assets/{DockerLogsModal-CvQM5TOx.js → DockerLogsModal-ChSWCsD6.js} +1 -1
- package/dist/assets/{EmbeddedEditor-DGdihbaE.js → EmbeddedEditor-ChdfmuIg.js} +1 -1
- package/dist/assets/{FcStdViewer-BgT5FFuV.js → FcStdViewer-CdhcfLu8.js} +1 -1
- package/dist/assets/{GcodeViewer-CLAc1os2.js → GcodeViewer-CG5xftum.js} +1 -1
- package/dist/assets/{GlbViewer-DW3-EKE8.js → GlbViewer-DvmBSNPm.js} +1 -1
- package/dist/assets/{GmailOAuthSetup-ChWPdUvL.js → GmailOAuthSetup-yhSITtw7.js} +1 -1
- package/dist/assets/{GoogleOAuthSetup-QrN5TW8r.js → GoogleOAuthSetup-ugg8hhwa.js} +1 -1
- package/dist/assets/{IframeModal-DFnjMx4z.js → IframeModal-Bjo_-SSc.js} +1 -1
- package/dist/assets/{IntegrationsPanel-CxC744zM.js → IntegrationsPanel-JbfEFuTE.js} +2 -2
- package/dist/assets/{LogViewerModal-DAMjRGWX.js → LogViewerModal-CGGtQwwn.js} +1 -1
- package/dist/assets/{MonitoringModal-DjD33Q4Q.js → MonitoringModal-D7VxK2C8.js} +1 -1
- package/dist/assets/{PM2LogsModal-CpdUfSIi.js → PM2LogsModal-C-Ec4p65.js} +1 -1
- package/dist/assets/{RestoreArchivedAreaModal-Bjo5oNBo.js → RestoreArchivedAreaModal-BBZpQw8I.js} +1 -1
- package/dist/assets/{Scene2DCanvas-SVUlGMo1.js → Scene2DCanvas-Cpzgqdq1.js} +1 -1
- package/dist/assets/{SceneManager-BMNKqJTO.js → SceneManager-B9bEzlSi.js} +1 -1
- package/dist/assets/{SkillsPanel-C8onjf1H.js → SkillsPanel-crpQci9P.js} +1 -1
- package/dist/assets/{SlackMultiInstanceSetup-CgV-oGON.js → SlackMultiInstanceSetup-C1qkAM8r.js} +1 -1
- package/dist/assets/{SpawnModal-LXqc4WCm.js → SpawnModal-CIuJWY6N.js} +1 -1
- package/dist/assets/{StatisticsModal-ESAvPsy0.js → StatisticsModal-B14YGD66.js} +1 -1
- package/dist/assets/{StlViewer-NVExCnF3.js → StlViewer-D5EtQxO4.js} +1 -1
- package/dist/assets/{SubordinateAssignmentModal-DpdSOnqQ.js → SubordinateAssignmentModal-_8NWXgEl.js} +1 -1
- package/dist/assets/{ThreeAreaSelector-DAHbFYpb.js → ThreeAreaSelector-Bnb65bJt.js} +1 -1
- package/dist/assets/{ThreeViewShortcuts-BoxZeMmM.js → ThreeViewShortcuts-AI4Mj9zr.js} +1 -1
- package/dist/assets/{TriggerManagerPanel-CyaZWM4g.js → TriggerManagerPanel-aFrbWG0D.js} +1 -1
- package/dist/assets/{VideoPlayer-JEXTLcck.js → VideoPlayer-BSVjpcQa.js} +1 -1
- package/dist/assets/{WorkflowEditorPanel-DgqZRVud.js → WorkflowEditorPanel-CgFXTubk.js} +1 -1
- package/dist/assets/{abnfDiagram-VRR7QNED-Ntlrp2B1.js → abnfDiagram-VRR7QNED-LbVlypD7.js} +1 -1
- package/dist/assets/{arc-D3D4dl3j.js → arc-DDqZ78fN.js} +1 -1
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-CbVTw6bL.js → architectureDiagram-ZJ3FMSHR-BLfa7hLc.js} +1 -1
- package/dist/assets/{area-logos-CYXdsKnv.js → area-logos-ml30JJUi.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-BI-pDXhB.js → blockDiagram-677ZJIJ3-CHWx5n03.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-74-UMGJT.js → c4Diagram-LMCZKHZV-DvUxK9_Q.js} +1 -1
- package/dist/assets/channel-CxofHie1.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D3vAVBE2.js → chunk-2Q5K7J3B-BFtzwIJU.js} +1 -1
- package/dist/assets/{chunk-32BRIVSS-BxxreJ5z.js → chunk-32BRIVSS-CPbVoclL.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-D_bLkz8y.js → chunk-5VM5RSS4-dTYGN5E5.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-CgG_gI5j.js → chunk-EX3LRPZG-CtqfsWRW.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-CCD624Q4.js → chunk-JWPE2WC7-Bk6bqjv9.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-BXc7SqUw.js → chunk-MOJQB5TN-UYfo6GD_.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-DdE-eq8Q.js → chunk-RYQCIY6F-C8_6Iuf_.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-Co4r2qOX.js → chunk-V7JOEXUC-CGdZK5My.js} +1 -1
- package/dist/assets/{chunk-VR4S4FIN-D823l1GL.js → chunk-VR4S4FIN-C-HH5QTv.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-DNhI5Onf.js → chunk-XXDRQBXY-B2n8y5qo.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-15eANucY.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-15eANucY.js +1 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-DwwU-Vme.js → cose-bilkent-JH36ORCC-AB1HxIBy.js} +1 -1
- package/dist/assets/{cynefin-VYW2F7L2-FPusX1Pr.js → cynefin-VYW2F7L2-DTS_6pNv.js} +1 -1
- package/dist/assets/{cynefinDiagram-TSTJHNR4-D1ZQ8xBH.js → cynefinDiagram-TSTJHNR4-0oJZvAZy.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-B6vs-yvj.js → dagre-VKFMJZFB-mOn_d4U5.js} +1 -1
- package/dist/assets/{diagram-FQU43EPY-EIEpqhAS.js → diagram-FQU43EPY-DqHifujZ.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-BgK2guk8.js → diagram-G47NLZAW-BZ7eUs_p.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-CpdwzkT0.js → diagram-NH7WQ7WH-C3r43VXW.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-B1AdLJYG.js → diagram-OA4YK3LP-D2RSBPAX.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-BTLwXODW.js → diagram-WEI45ONY-B9Nkjrlq.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-BaFZwINa.js → ebnfDiagram-CCIWWBDH-B1RDvi6g.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-BHctMV_t.js → erDiagram-Q63AITRT-B38eKAG5.js} +1 -1
- package/dist/assets/{flowDiagram-23GEKE2U-FdEXIJDE.js → flowDiagram-23GEKE2U-C9txCjHm.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-BzSKiNew.js → ganttDiagram-NO4QXBWP-BGNoppCl.js} +1 -1
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-CCt1embf.js → gitGraphDiagram-IHSO6WYX-qrryYqaT.js} +1 -1
- package/dist/assets/{index-ChWT0VGM.js → index-B4sdd8Y2.js} +3 -3
- package/dist/assets/{index-YtoNwX7s.js → index-BXNPTpxx.js} +3 -3
- package/dist/assets/{index-YaKQQk9_.js → index-BdQoxlnS.js} +2 -2
- package/dist/assets/index-BoiyspB0.js +2 -0
- package/dist/assets/{index-UVAMV_H7.js → index-CKVTIr6G.js} +1 -1
- package/dist/assets/{index-DiILxoMf.js → index-CYxytlNP.js} +1 -1
- package/dist/assets/{index-CbRNk_Zg.js → index-ClvYehMs.js} +1 -1
- package/dist/assets/{index-vPlxnz-B.js → index-Drtp5UPa.js} +1 -1
- package/dist/assets/{index-rrOuVd7S.js → index-tE736Avl.js} +1 -1
- package/dist/assets/{infoDiagram-FWYZ7A6U-10zwrYDm.js → infoDiagram-FWYZ7A6U-DilAR8go.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-ByRrZfDV.js → ishikawaDiagram-FXEZZL3T-B0cTGbt1.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-CmYM751e.js → journeyDiagram-5HDEW3XC-eHbpGFin.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-Dh0ggxp3.js → kanban-definition-HUTT4EX6-BaSQRYl7.js} +1 -1
- package/dist/assets/{linear-CLAQtQPs.js → linear-BoUClmXF.js} +1 -1
- package/dist/assets/main-BdVckSM5.css +1 -0
- package/dist/assets/main-DuaHyH5t.js +341 -0
- package/dist/assets/{mermaid.core-CH7DoQlW.js → mermaid.core-CGrC54u1.js} +4 -4
- package/dist/assets/{mindmap-definition-LN4V7U3C-Bfw5UqxH.js → mindmap-definition-LN4V7U3C-BQWnb1yP.js} +1 -1
- package/dist/assets/{pegDiagram-2B236MQR-LbY5CO4b.js → pegDiagram-2B236MQR-Bs_4Go2e.js} +1 -1
- package/dist/assets/{pieDiagram-ENE6RG2P-D14z8IIZ.js → pieDiagram-ENE6RG2P-LCcCZeX5.js} +1 -1
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-CdRVHJGf.js → quadrantDiagram-ABIIQ3AL-CdlG1WsA.js} +1 -1
- package/dist/assets/{railroadDiagram-RFXS5EU6-Csv_sb84.js → railroadDiagram-RFXS5EU6-CAcrzOwC.js} +1 -1
- package/dist/assets/{requirementDiagram-TGXJPOKE-CZFOgd5I.js → requirementDiagram-TGXJPOKE-zgaCBhns.js} +1 -1
- package/dist/assets/{sankeyDiagram-HTMAVEWB-BvBQTJvz.js → sankeyDiagram-HTMAVEWB-Cvn05yAi.js} +1 -1
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-BVegUvqs.js → sequenceDiagram-DBY2YBRQ-C7oW7B56.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-FtRVl68V.js → sizeCapture-X5ZJPWSS-Z61MsHMO.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-DjZEX_y5.js → stateDiagram-2N3HPSRC-CHjZ2LvZ.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-ePlfPVZw.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-D7iHNp7G.js → swimlanes-5IMT3BWC-BOxFXKKq.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-ClgJ2Bw0.js +8 -0
- package/dist/assets/{timeline-definition-FHXFAJF6-DlAm5TB7.js → timeline-definition-FHXFAJF6-7Hw_U3c1.js} +1 -1
- package/dist/assets/{vennDiagram-L72KCM5P-B2jd5Egr.js → vennDiagram-L72KCM5P-DXOydhCz.js} +1 -1
- package/dist/assets/{wardleyDiagram-EHGQE667-BpSVMhG8.js → wardleyDiagram-EHGQE667-CHEopdXj.js} +1 -1
- package/dist/assets/{web-A7HWVS8k.js → web-BNIDHx-H.js} +1 -1
- package/dist/assets/{web-C9OGdTUE.js → web-DAWG2rda.js} +1 -1
- package/dist/assets/{web-DMfUbDpe.js → web-vmnQRY1J.js} +1 -1
- package/dist/assets/{xychartDiagram-FW5EYKEG-DUXSUD59.js → xychartDiagram-FW5EYKEG-BpNrwdIN.js} +1 -1
- package/dist/build-info.json +1 -1
- package/dist/index.html +2 -2
- package/dist/locales/en/terminal.json +26 -1
- package/dist/locales/es/terminal.json +2 -1
- package/dist/src/packages/server/routes/exec.js +64 -6
- package/dist/src/packages/server/routes/files.js +132 -1
- package/dist/src/packages/server/services/cfb-reader.js +153 -0
- package/dist/src/packages/server/services/document-doc.js +235 -0
- package/dist/src/packages/server/services/document-parse.js +1159 -0
- package/dist/src/packages/server/services/spreadsheet-biff.js +3 -135
- package/dist/src/packages/shared/document-types.js +22 -0
- package/package.json +1 -1
- package/dist/assets/channel-D9UzWg43.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-DEsVlshj.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-DEsVlshj.js +0 -1
- package/dist/assets/index-Ci4guETG.js +0 -2
- package/dist/assets/main-Dzc0Sg9A.css +0 -1
- package/dist/assets/main-fiQD9nPL.js +0 -334
- package/dist/assets/stateDiagram-v2-6OUMAXLB-Ct3Yc5aR.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-LdlH8jLU.js +0 -8
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmbeddedEditor-
|
|
2
|
-
import{r as s,c as V,d as A,N as It,cn as Jn,co as Yn,b7 as Qs,S as Ot,b8 as Zs,s as Ve,u as ie,j as e,I as D,ca as Ut,br as en,cp as tn,a1 as rs,cq as sn,cr as nn,cs as Xn,ct as Qn,at as zt,cu as Zn,cv as ea,cw as ta,a8 as ct,cx as sa,cy as is,cz as na,cA as an,cB as rn,cC as ln,cD as Ht,cE as At,bq as lt,cF as bt,cG as jt,cH as Us,cI as aa,a4 as ra,c9 as as,a0 as ia,cJ as la,cK as oa,cL as Lt,cM as ca,cN as da,cO as ua,cP as ha,b_ as ma,cQ as pa,cR as Gs,Z as fa,aq as ga}from"./main-fiQD9nPL.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function xa(t){const[n,l]=s.useState(null),[c,r]=s.useState(!1),i=s.useCallback(async()=>{if(t){r(!0);try{const h=await V(A(`/api/files/git-status?path=${encodeURIComponent(t)}`)),o=await h.json();h.ok?l(o):l({isGitRepo:!1,files:[]})}catch(h){console.error("[FileExplorer] Failed to load git status:",h),l({isGitRepo:!1,files:[]})}finally{r(!1)}}},[t]);return{gitStatus:n,loading:c,loadGitStatus:i}}async function ya(t){try{const n=await V(A(`/api/files/git-original?path=${encodeURIComponent(t)}`)),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 ba=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",""]),ja=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"]),va=new Set([".pdf"]),wa=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".zip",".tar",".gz",".rar",".7z",".exe",".dmg",".app",".deb",".rpm",".apk",".aab",".ipa",".msi",".ttf",".otf",".woff",".woff2",".eot",".sqlite",".db",".so",".dll",".dylib",".a",".o",".obj",".bin",".dat",".iso",".img",".jar",".war",".ear",".class"]);function Ca(t){const n=t.toLowerCase();return ja.has(n)?"image":va.has(n)?"pdf":Jn(n)?"audio":Yn(n)?"video":wa.has(n)?"binary":(ba.has(n),"text")}function Na(){const[t,n]=s.useState(null),[l,c]=s.useState(!1),[r,i]=s.useState(null),h=s.useCallback(async d=>{var g,b;c(!0),i(null);try{const p=d.substring(d.lastIndexOf(".")).toLowerCase(),v=Ca(p),k=d.substring(d.lastIndexOf("/")+1);if(v==="image"){const E=await V(A(`/api/files/binary?path=${encodeURIComponent(d)}`));if(!E.ok){const C=await E.json().catch(()=>({error:"Failed to load image"}));i(C.error||"Failed to load image"),n(null);return}const f=await E.blob(),j=URL.createObjectURL(f);n({path:d,filename:k,extension:p,content:"",size:f.size,modified:new Date().toISOString(),fileType:"image",dataUrl:j});return}if(v==="pdf"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load PDF info"),n(null);return}n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"pdf",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&token=${encodeURIComponent(It())}`)});return}if(v==="audio"||v==="video"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load media info"),n(null);return}const j=v==="video"?`&token=${encodeURIComponent(It())}`:"";n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:v,dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}${j}`)});return}if(v==="binary"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load file info"),n(null);return}n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"binary",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}const F=await V(A(`/api/files/read?path=${encodeURIComponent(d)}`)),y=await F.json();if(!F.ok){if((g=y.error)!=null&&g.includes("too large")||(b=y.error)!=null&&b.includes("binary")){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(E.ok){n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"binary",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}}i(y.error||"Failed to load file"),n(null);return}n({...y,fileType:"text"})}catch(p){const v=p instanceof Error?p.message:"Failed to load file";i(v),n(null)}finally{c(!1)}},[]),o=s.useCallback(()=>{n(d=>(d!=null&&d.dataUrl&&d.dataUrl.startsWith("blob:")&&URL.revokeObjectURL(d.dataUrl),null)),i(null)},[]);return{file:t,loading:l,error:r,loadFile:h,clearFile:o,setFile:n}}const ka="file-explorer-state",_s="file-explorer-recent-projects",Ea=10080*60*1e3,Sa=12;function ts(t){return`${ka}-folder-${t}`}async function Ta(t){try{const n=await V(A(`/api/files/exists?path=${encodeURIComponent(t)}`));return n.ok?(await n.json()).exists===!0:!1}catch{return!1}}function Da(){const t=s.useCallback(async r=>{if(!r)return null;try{const i=localStorage.getItem(ts(r));if(!i)return null;const h=JSON.parse(i);if(Date.now()-h.timestamp>Ea)return localStorage.removeItem(ts(r)),null;const d=(await Promise.all((h.tabs||[]).map(async b=>({tab:b,exists:await Ta(b.path)})))).filter(({exists:b})=>b).map(({tab:b})=>b);let g=h.activeTabPath;return g&&!d.some(b=>b.path===g)&&(g=d.length>0?d[0].path:null),{tabs:d,activeTabPath:g,viewMode:h.viewMode||"files",expandedPaths:new Set(h.expandedPaths||[])}}catch(i){return console.error("[FileExplorerStorage] Failed to load project state:",i),null}},[]),n=s.useCallback((r,i)=>{if(r)try{const h={tabs:i.tabs,activeTabPath:i.activeTabPath,viewMode:i.viewMode,expandedPaths:Array.from(i.expandedPaths),timestamp:Date.now()};localStorage.setItem(ts(r),JSON.stringify(h))}catch(h){console.error("[FileExplorerStorage] Failed to save project state:",h)}},[]),l=s.useCallback(()=>{try{const r=localStorage.getItem(_s);if(!r)return[];const i=JSON.parse(r);return Array.isArray(i)?i.filter(h=>typeof h=="string"):[]}catch{return[]}},[]),c=s.useCallback(r=>{if(!r)return l();const i=[r,...l().filter(h=>h!==r)].slice(0,Sa);try{localStorage.setItem(_s,JSON.stringify(i))}catch{}return i},[l]);return{loadProjectState:t,saveProjectState:n,loadRecentProjects:l,pushRecentProject:c}}const Bs=280,Vs=150,Ks=1200;function Ma(){const[t,n]=s.useState(()=>{const g=Qs(Ot.TREE_PANEL_WIDTH,Bs);return g>=Vs&&g<=Ks?g:Bs}),l=s.useRef(!1),[c,r]=s.useState(!1),i=s.useRef(0),h=s.useRef(0),o=s.useRef(t);o.current=t;const d=s.useCallback(g=>{g.preventDefault(),l.current=!0,r(!0),i.current=g.clientX,h.current=t,document.body.style.cursor="ew-resize",document.body.style.userSelect="none"},[t]);return s.useEffect(()=>{const g=p=>{if(!l.current)return;const v=p.clientX-i.current,k=Math.min(Ks,Math.max(Vs,h.current+v));n(k)},b=()=>{l.current&&(l.current=!1,r(!1),document.body.style.cursor="",document.body.style.userSelect="",Zs(Ot.TREE_PANEL_WIDTH,o.current))};return document.addEventListener("mousemove",g),document.addEventListener("mouseup",b),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",b)}},[]),{treePanelWidth:t,handleResizeStart:d,isResizing:c}}const Ra=100,Fa=.65,Pa=36;function Ia(){const[t,n]=s.useState(()=>Qs(Ot.MOBILE_TREE_PANEL_HEIGHT,0)),l=s.useRef(t);l.current=t;const c=s.useRef(0),r=s.useRef(0),i=()=>Math.floor((window.innerHeight-Pa)*Fa),h=p=>Math.min(i(),Math.max(Ra,p)),o=s.useCallback(p=>{n(p);const v=document.querySelector(".file-explorer-main");v&&v.style.setProperty("--fe-mobile-tree-height",`${p}px`)},[]),d=s.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",Zs(Ot.MOBILE_TREE_PANEL_HEIGHT,l.current),Ve.setTerminalResizing(!1)},[]),g=s.useCallback(p=>{p.preventDefault();const v=document.querySelector(".file-explorer-tree-panel"),k=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.clientY,r.current=k,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const F=E=>{const f=E.clientY-c.current;o(h(r.current+f))},y=()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",y),d()};document.addEventListener("mousemove",F),document.addEventListener("mouseup",y)},[o,d]),b=s.useCallback(p=>{if(p.touches.length!==1)return;const v=document.querySelector(".file-explorer-tree-panel"),k=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.touches[0].clientY,r.current=k,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const F=E=>{if(E.touches.length!==1)return;E.preventDefault();const f=E.touches[0].clientY-c.current;o(h(r.current+f))},y=()=>{document.removeEventListener("touchmove",F),document.removeEventListener("touchend",y),document.removeEventListener("touchcancel",y),d()};document.addEventListener("touchmove",F,{passive:!1}),document.addEventListener("touchend",y),document.addEventListener("touchcancel",y)},[o,d]);return{mobileTreeHeight:t,handleResizeMouseDown:g,handleResizeTouchStart:b}}function ls(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(null),[h,o]=s.useState(null),d=s.useCallback(async E=>{c(!0),i(null);try{const f=await V(A(`/api/files/git-branches?path=${encodeURIComponent(E)}`)),j=await f.json();f.ok?n(j.branches||[]):(i(j.error||"Failed to load branches"),n([]))}catch(f){console.error("[GitBranches] Failed to load branches:",f),i("Failed to load branches"),n([])}finally{c(!1)}},[]),g=s.useCallback(async(E,f)=>{o("checkout"),i(null);try{const j=await V(A("/api/files/git-checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,branch:f})}),C=await j.json();return j.ok||i(C.error||"Checkout failed"),C}catch(j){console.error("[GitBranches] Checkout failed:",j);const C={success:!1,error:"Checkout failed"};return i(C.error),C}finally{o(null)}},[]),b=s.useCallback(async(E,f,j)=>{o("create"),i(null);try{const C=await V(A("/api/files/git-branch-create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,name:f,startPoint:j})}),M=await C.json();return C.ok||i(M.error||"Failed to create branch"),M}catch(C){console.error("[GitBranches] Create branch failed:",C);const M={success:!1,error:"Failed to create branch"};return i(M.error),M}finally{o(null)}},[]),p=s.useCallback(async E=>{o("pull"),i(null);try{const f=await V(A("/api/files/git-pull"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return!f.ok&&!j.conflicts&&i(j.error||"Pull failed"),j}catch(f){console.error("[GitBranches] Pull failed:",f);const j={success:!1,error:"Pull failed"};return i(j.error),j}finally{o(null)}},[]),v=s.useCallback(async E=>{o("push"),i(null);try{const f=await V(A("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Push failed"),j}catch(f){console.error("[GitBranches] Push failed:",f);const j={success:!1,error:"Push failed"};return i(j.error),j}finally{o(null)}},[]),k=s.useCallback(async(E,f)=>{o("merge"),i(null);try{const j=await V(A("/api/files/git-merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,branch:f})}),C=await j.json();return!j.ok&&!C.conflicts&&i(C.error||"Merge failed"),C}catch(j){console.error("[GitBranches] Merge failed:",j);const C={success:!1,error:"Merge failed"};return i(C.error),C}finally{o(null)}},[]),F=s.useCallback(async E=>{o("merge-abort"),i(null);try{const f=await V(A("/api/files/git-merge-abort"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Merge abort failed"),j}catch(f){console.error("[GitBranches] Merge abort failed:",f);const j={success:!1,error:"Merge abort failed"};return i(j.error),j}finally{o(null)}},[]),y=s.useCallback(async E=>{o("merge-continue"),i(null);try{const f=await V(A("/api/files/git-merge-continue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Merge continue failed"),j}catch(f){console.error("[GitBranches] Merge continue failed:",f);const j={success:!1,error:"Merge continue failed"};return i(j.error),j}finally{o(null)}},[]);return{branches:t,loading:l,error:r,operationInProgress:h,loadBranches:d,checkoutBranch:g,createBranch:b,pullFromRemote:p,pushToRemote:v,mergeBranch:k,mergeAbort:F,mergeContinue:y}}const La=50,$a=400,Ws={branch:"",author:"",since:"",until:"",searchPath:"",search:""};function za(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(!1),[h,o]=s.useState(null),[d,g]=s.useState(!1),[b,p]=s.useState(0),[v,k]=s.useState({...Ws}),[F,y]=s.useState(null),[E,f]=s.useState([]),[j,C]=s.useState(!1),[M,H]=s.useState([]),[G,K]=s.useState(!1),w=s.useRef(null),re=s.useRef(""),_=s.useCallback((U,se,I)=>{const B=I||v,Z=new URLSearchParams;return Z.set("path",U),Z.set("limit",String(La)),Z.set("offset",String(se)),B.branch&&Z.set("branch",B.branch),B.author&&Z.set("author",B.author),B.since&&Z.set("since",B.since),B.until&&Z.set("until",B.until),B.searchPath&&Z.set("searchPath",B.searchPath),B.search&&Z.set("search",B.search),Z.toString()},[v]),R=s.useCallback(async U=>{re.current=U,c(!0),o(null),y(null),f([]);try{const se=_(U,0),I=await V(A(`/api/files/git-log?${se}`)),B=await I.json();I.ok?(n(B.commits||[]),p(B.total||0),g(B.hasMore||!1)):(o(B.error||"Failed to load git history"),n([]))}catch(se){console.error("[useGitHistory] loadHistory error:",se),o("Failed to load git history"),n([])}finally{c(!1)}},[_]),P=s.useCallback(async U=>{if(!(r||!d)){i(!0);try{const se=_(U,t.length),I=await V(A(`/api/files/git-log?${se}`)),B=await I.json();I.ok&&(n(Z=>[...Z,...B.commits||[]]),p(B.total||0),g(B.hasMore||!1))}catch(se){console.error("[useGitHistory] loadMore error:",se)}finally{i(!1)}}},[_,t.length,d,r]),X=s.useCallback(async U=>{if(y(U),!U){f([]);return}C(!0);try{const se=re.current,I=new URLSearchParams({path:se,hash:U.hash}),B=await V(A(`/api/files/git-commit-files?${I}`)),Z=await B.json();B.ok?f(Z.files||[]):f([])}catch(se){console.error("[useGitHistory] selectCommit files error:",se),f([])}finally{C(!1)}},[]),Q=s.useCallback((U,se)=>{k(I=>({...I,[U]:se}))},[]),ne=s.useCallback(()=>{k({...Ws})},[]);s.useEffect(()=>{const U=re.current;if(U)return w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{R(U)},$a),()=>{w.current&&clearTimeout(w.current)}},[v]);const ue=s.useCallback(async U=>{K(!0);try{const se=new URLSearchParams({path:U}),I=await V(A(`/api/files/git-authors?${se}`)),B=await I.json();I.ok&&H(B.authors||[])}catch(se){console.error("[useGitHistory] loadAuthors error:",se)}finally{K(!1)}},[]);return{commits:t,loading:l,loadingMore:r,error:h,hasMore:d,total:b,filters:v,setFilter:Q,resetFilters:ne,selectedCommit:F,selectCommit:X,commitFiles:E,commitFilesLoading:j,loadHistory:R,loadMore:P,authors:M,authorsLoading:G,loadAuthors:ue}}function Ha(t){if(!t.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 c=t.current.querySelector(l);if(c&&qs(c))return c}return qs(t.current)?t.current:null}function qs(t){const n=["auto","scroll"].includes(getComputedStyle(t).overflowY),l=t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth;return n&&l}function on(t){if(!t)return 19.5;const n=parseFloat(getComputedStyle(t).lineHeight);return isNaN(n)?19.5:n}function ss(t,n=!0){const l=n?t.scrollHeight:0;t.scrollTo({top:l,behavior:"smooth"})}function Aa(t){const{scrollTop:n,scrollHeight:l,clientHeight:c}=t;return l<=c?100:Math.round(n/(l-c)*100)}function Oa(t,n){const l=on(t),c=t.scrollTop,r=Math.floor(c/l)+1,i=n.split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/EmbeddedEditor-ChdfmuIg.js","assets/main-DuaHyH5t.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-DYBBrXTx.js","assets/main-BdVckSM5.css","assets/EmbeddedEditor-BipHj7Fz.css","assets/AudioPlayer-jjttJ6SM.js","assets/VideoPlayer-BSVjpcQa.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as s,c as V,d as A,N as It,co as Jn,cp as Yn,b7 as Qs,S as Ot,b8 as Zs,s as Ve,u as ie,j as e,I as D,cb as Ut,br as en,cq as tn,a1 as rs,cr as sn,cs as nn,ct as Xn,cu as Qn,at as zt,cv as Zn,cw as ea,cx as ta,a8 as ct,cy as sa,cz as is,cA as na,cB as an,cC as rn,cD as ln,cE as Ht,cF as At,bq as lt,cG as bt,cH as jt,cI as Us,cJ as aa,a4 as ra,ca as as,a0 as ia,cK as la,cL as oa,cM as Lt,cN as ca,cO as da,cP as ua,cQ as ha,b$ as ma,cR as pa,cS as Gs,Z as fa,aq as ga}from"./main-DuaHyH5t.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function xa(t){const[n,l]=s.useState(null),[c,r]=s.useState(!1),i=s.useCallback(async()=>{if(t){r(!0);try{const h=await V(A(`/api/files/git-status?path=${encodeURIComponent(t)}`)),o=await h.json();h.ok?l(o):l({isGitRepo:!1,files:[]})}catch(h){console.error("[FileExplorer] Failed to load git status:",h),l({isGitRepo:!1,files:[]})}finally{r(!1)}}},[t]);return{gitStatus:n,loading:c,loadGitStatus:i}}async function ya(t){try{const n=await V(A(`/api/files/git-original?path=${encodeURIComponent(t)}`)),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 ba=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",""]),ja=new Set([".png",".jpg",".jpeg",".gif",".webp",".bmp",".ico",".svg"]),va=new Set([".pdf"]),wa=new Set([".xlsx",".xls",".docx",".doc",".pptx",".ppt",".zip",".tar",".gz",".rar",".7z",".exe",".dmg",".app",".deb",".rpm",".apk",".aab",".ipa",".msi",".ttf",".otf",".woff",".woff2",".eot",".sqlite",".db",".so",".dll",".dylib",".a",".o",".obj",".bin",".dat",".iso",".img",".jar",".war",".ear",".class"]);function Ca(t){const n=t.toLowerCase();return ja.has(n)?"image":va.has(n)?"pdf":Jn(n)?"audio":Yn(n)?"video":wa.has(n)?"binary":(ba.has(n),"text")}function Na(){const[t,n]=s.useState(null),[l,c]=s.useState(!1),[r,i]=s.useState(null),h=s.useCallback(async d=>{var g,b;c(!0),i(null);try{const p=d.substring(d.lastIndexOf(".")).toLowerCase(),v=Ca(p),k=d.substring(d.lastIndexOf("/")+1);if(v==="image"){const E=await V(A(`/api/files/binary?path=${encodeURIComponent(d)}`));if(!E.ok){const C=await E.json().catch(()=>({error:"Failed to load image"}));i(C.error||"Failed to load image"),n(null);return}const f=await E.blob(),j=URL.createObjectURL(f);n({path:d,filename:k,extension:p,content:"",size:f.size,modified:new Date().toISOString(),fileType:"image",dataUrl:j});return}if(v==="pdf"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load PDF info"),n(null);return}n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"pdf",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&token=${encodeURIComponent(It())}`)});return}if(v==="audio"||v==="video"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load media info"),n(null);return}const j=v==="video"?`&token=${encodeURIComponent(It())}`:"";n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:v,dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}${j}`)});return}if(v==="binary"){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(!E.ok){i(f.error||"Failed to load file info"),n(null);return}n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"binary",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}const F=await V(A(`/api/files/read?path=${encodeURIComponent(d)}`)),y=await F.json();if(!F.ok){if((g=y.error)!=null&&g.includes("too large")||(b=y.error)!=null&&b.includes("binary")){const E=await V(A(`/api/files/info?path=${encodeURIComponent(d)}`)),f=await E.json();if(E.ok){n({path:d,filename:k,extension:p,content:"",size:f.size,modified:f.modified,fileType:"binary",dataUrl:A(`/api/files/binary?path=${encodeURIComponent(d)}&download=true&token=${encodeURIComponent(It())}`)});return}}i(y.error||"Failed to load file"),n(null);return}n({...y,fileType:"text"})}catch(p){const v=p instanceof Error?p.message:"Failed to load file";i(v),n(null)}finally{c(!1)}},[]),o=s.useCallback(()=>{n(d=>(d!=null&&d.dataUrl&&d.dataUrl.startsWith("blob:")&&URL.revokeObjectURL(d.dataUrl),null)),i(null)},[]);return{file:t,loading:l,error:r,loadFile:h,clearFile:o,setFile:n}}const ka="file-explorer-state",_s="file-explorer-recent-projects",Ea=10080*60*1e3,Sa=12;function ts(t){return`${ka}-folder-${t}`}async function Ta(t){try{const n=await V(A(`/api/files/exists?path=${encodeURIComponent(t)}`));return n.ok?(await n.json()).exists===!0:!1}catch{return!1}}function Da(){const t=s.useCallback(async r=>{if(!r)return null;try{const i=localStorage.getItem(ts(r));if(!i)return null;const h=JSON.parse(i);if(Date.now()-h.timestamp>Ea)return localStorage.removeItem(ts(r)),null;const d=(await Promise.all((h.tabs||[]).map(async b=>({tab:b,exists:await Ta(b.path)})))).filter(({exists:b})=>b).map(({tab:b})=>b);let g=h.activeTabPath;return g&&!d.some(b=>b.path===g)&&(g=d.length>0?d[0].path:null),{tabs:d,activeTabPath:g,viewMode:h.viewMode||"files",expandedPaths:new Set(h.expandedPaths||[])}}catch(i){return console.error("[FileExplorerStorage] Failed to load project state:",i),null}},[]),n=s.useCallback((r,i)=>{if(r)try{const h={tabs:i.tabs,activeTabPath:i.activeTabPath,viewMode:i.viewMode,expandedPaths:Array.from(i.expandedPaths),timestamp:Date.now()};localStorage.setItem(ts(r),JSON.stringify(h))}catch(h){console.error("[FileExplorerStorage] Failed to save project state:",h)}},[]),l=s.useCallback(()=>{try{const r=localStorage.getItem(_s);if(!r)return[];const i=JSON.parse(r);return Array.isArray(i)?i.filter(h=>typeof h=="string"):[]}catch{return[]}},[]),c=s.useCallback(r=>{if(!r)return l();const i=[r,...l().filter(h=>h!==r)].slice(0,Sa);try{localStorage.setItem(_s,JSON.stringify(i))}catch{}return i},[l]);return{loadProjectState:t,saveProjectState:n,loadRecentProjects:l,pushRecentProject:c}}const Bs=280,Vs=150,Ks=1200;function Ma(){const[t,n]=s.useState(()=>{const g=Qs(Ot.TREE_PANEL_WIDTH,Bs);return g>=Vs&&g<=Ks?g:Bs}),l=s.useRef(!1),[c,r]=s.useState(!1),i=s.useRef(0),h=s.useRef(0),o=s.useRef(t);o.current=t;const d=s.useCallback(g=>{g.preventDefault(),l.current=!0,r(!0),i.current=g.clientX,h.current=t,document.body.style.cursor="ew-resize",document.body.style.userSelect="none"},[t]);return s.useEffect(()=>{const g=p=>{if(!l.current)return;const v=p.clientX-i.current,k=Math.min(Ks,Math.max(Vs,h.current+v));n(k)},b=()=>{l.current&&(l.current=!1,r(!1),document.body.style.cursor="",document.body.style.userSelect="",Zs(Ot.TREE_PANEL_WIDTH,o.current))};return document.addEventListener("mousemove",g),document.addEventListener("mouseup",b),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",b)}},[]),{treePanelWidth:t,handleResizeStart:d,isResizing:c}}const Ra=100,Fa=.65,Pa=36;function Ia(){const[t,n]=s.useState(()=>Qs(Ot.MOBILE_TREE_PANEL_HEIGHT,0)),l=s.useRef(t);l.current=t;const c=s.useRef(0),r=s.useRef(0),i=()=>Math.floor((window.innerHeight-Pa)*Fa),h=p=>Math.min(i(),Math.max(Ra,p)),o=s.useCallback(p=>{n(p);const v=document.querySelector(".file-explorer-main");v&&v.style.setProperty("--fe-mobile-tree-height",`${p}px`)},[]),d=s.useCallback(()=>{document.body.style.cursor="",document.body.style.userSelect="",Zs(Ot.MOBILE_TREE_PANEL_HEIGHT,l.current),Ve.setTerminalResizing(!1)},[]),g=s.useCallback(p=>{p.preventDefault();const v=document.querySelector(".file-explorer-tree-panel"),k=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.clientY,r.current=k,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const F=E=>{const f=E.clientY-c.current;o(h(r.current+f))},y=()=>{document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",y),d()};document.addEventListener("mousemove",F),document.addEventListener("mouseup",y)},[o,d]),b=s.useCallback(p=>{if(p.touches.length!==1)return;const v=document.querySelector(".file-explorer-tree-panel"),k=l.current>0?l.current:(v==null?void 0:v.getBoundingClientRect().height)??240;c.current=p.touches[0].clientY,r.current=k,document.body.style.cursor="ns-resize",document.body.style.userSelect="none",Ve.setTerminalResizing(!0);const F=E=>{if(E.touches.length!==1)return;E.preventDefault();const f=E.touches[0].clientY-c.current;o(h(r.current+f))},y=()=>{document.removeEventListener("touchmove",F),document.removeEventListener("touchend",y),document.removeEventListener("touchcancel",y),d()};document.addEventListener("touchmove",F,{passive:!1}),document.addEventListener("touchend",y),document.addEventListener("touchcancel",y)},[o,d]);return{mobileTreeHeight:t,handleResizeMouseDown:g,handleResizeTouchStart:b}}function ls(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(null),[h,o]=s.useState(null),d=s.useCallback(async E=>{c(!0),i(null);try{const f=await V(A(`/api/files/git-branches?path=${encodeURIComponent(E)}`)),j=await f.json();f.ok?n(j.branches||[]):(i(j.error||"Failed to load branches"),n([]))}catch(f){console.error("[GitBranches] Failed to load branches:",f),i("Failed to load branches"),n([])}finally{c(!1)}},[]),g=s.useCallback(async(E,f)=>{o("checkout"),i(null);try{const j=await V(A("/api/files/git-checkout"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,branch:f})}),C=await j.json();return j.ok||i(C.error||"Checkout failed"),C}catch(j){console.error("[GitBranches] Checkout failed:",j);const C={success:!1,error:"Checkout failed"};return i(C.error),C}finally{o(null)}},[]),b=s.useCallback(async(E,f,j)=>{o("create"),i(null);try{const C=await V(A("/api/files/git-branch-create"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,name:f,startPoint:j})}),M=await C.json();return C.ok||i(M.error||"Failed to create branch"),M}catch(C){console.error("[GitBranches] Create branch failed:",C);const M={success:!1,error:"Failed to create branch"};return i(M.error),M}finally{o(null)}},[]),p=s.useCallback(async E=>{o("pull"),i(null);try{const f=await V(A("/api/files/git-pull"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return!f.ok&&!j.conflicts&&i(j.error||"Pull failed"),j}catch(f){console.error("[GitBranches] Pull failed:",f);const j={success:!1,error:"Pull failed"};return i(j.error),j}finally{o(null)}},[]),v=s.useCallback(async E=>{o("push"),i(null);try{const f=await V(A("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Push failed"),j}catch(f){console.error("[GitBranches] Push failed:",f);const j={success:!1,error:"Push failed"};return i(j.error),j}finally{o(null)}},[]),k=s.useCallback(async(E,f)=>{o("merge"),i(null);try{const j=await V(A("/api/files/git-merge"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E,branch:f})}),C=await j.json();return!j.ok&&!C.conflicts&&i(C.error||"Merge failed"),C}catch(j){console.error("[GitBranches] Merge failed:",j);const C={success:!1,error:"Merge failed"};return i(C.error),C}finally{o(null)}},[]),F=s.useCallback(async E=>{o("merge-abort"),i(null);try{const f=await V(A("/api/files/git-merge-abort"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Merge abort failed"),j}catch(f){console.error("[GitBranches] Merge abort failed:",f);const j={success:!1,error:"Merge abort failed"};return i(j.error),j}finally{o(null)}},[]),y=s.useCallback(async E=>{o("merge-continue"),i(null);try{const f=await V(A("/api/files/git-merge-continue"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:E})}),j=await f.json();return f.ok||i(j.error||"Merge continue failed"),j}catch(f){console.error("[GitBranches] Merge continue failed:",f);const j={success:!1,error:"Merge continue failed"};return i(j.error),j}finally{o(null)}},[]);return{branches:t,loading:l,error:r,operationInProgress:h,loadBranches:d,checkoutBranch:g,createBranch:b,pullFromRemote:p,pushToRemote:v,mergeBranch:k,mergeAbort:F,mergeContinue:y}}const La=50,$a=400,Ws={branch:"",author:"",since:"",until:"",searchPath:"",search:""};function za(){const[t,n]=s.useState([]),[l,c]=s.useState(!1),[r,i]=s.useState(!1),[h,o]=s.useState(null),[d,g]=s.useState(!1),[b,p]=s.useState(0),[v,k]=s.useState({...Ws}),[F,y]=s.useState(null),[E,f]=s.useState([]),[j,C]=s.useState(!1),[M,H]=s.useState([]),[G,K]=s.useState(!1),w=s.useRef(null),re=s.useRef(""),_=s.useCallback((U,se,I)=>{const B=I||v,Z=new URLSearchParams;return Z.set("path",U),Z.set("limit",String(La)),Z.set("offset",String(se)),B.branch&&Z.set("branch",B.branch),B.author&&Z.set("author",B.author),B.since&&Z.set("since",B.since),B.until&&Z.set("until",B.until),B.searchPath&&Z.set("searchPath",B.searchPath),B.search&&Z.set("search",B.search),Z.toString()},[v]),R=s.useCallback(async U=>{re.current=U,c(!0),o(null),y(null),f([]);try{const se=_(U,0),I=await V(A(`/api/files/git-log?${se}`)),B=await I.json();I.ok?(n(B.commits||[]),p(B.total||0),g(B.hasMore||!1)):(o(B.error||"Failed to load git history"),n([]))}catch(se){console.error("[useGitHistory] loadHistory error:",se),o("Failed to load git history"),n([])}finally{c(!1)}},[_]),P=s.useCallback(async U=>{if(!(r||!d)){i(!0);try{const se=_(U,t.length),I=await V(A(`/api/files/git-log?${se}`)),B=await I.json();I.ok&&(n(Z=>[...Z,...B.commits||[]]),p(B.total||0),g(B.hasMore||!1))}catch(se){console.error("[useGitHistory] loadMore error:",se)}finally{i(!1)}}},[_,t.length,d,r]),X=s.useCallback(async U=>{if(y(U),!U){f([]);return}C(!0);try{const se=re.current,I=new URLSearchParams({path:se,hash:U.hash}),B=await V(A(`/api/files/git-commit-files?${I}`)),Z=await B.json();B.ok?f(Z.files||[]):f([])}catch(se){console.error("[useGitHistory] selectCommit files error:",se),f([])}finally{C(!1)}},[]),Q=s.useCallback((U,se)=>{k(I=>({...I,[U]:se}))},[]),ne=s.useCallback(()=>{k({...Ws})},[]);s.useEffect(()=>{const U=re.current;if(U)return w.current&&clearTimeout(w.current),w.current=setTimeout(()=>{R(U)},$a),()=>{w.current&&clearTimeout(w.current)}},[v]);const ue=s.useCallback(async U=>{K(!0);try{const se=new URLSearchParams({path:U}),I=await V(A(`/api/files/git-authors?${se}`)),B=await I.json();I.ok&&H(B.authors||[])}catch(se){console.error("[useGitHistory] loadAuthors error:",se)}finally{K(!1)}},[]);return{commits:t,loading:l,loadingMore:r,error:h,hasMore:d,total:b,filters:v,setFilter:Q,resetFilters:ne,selectedCommit:F,selectCommit:X,commitFiles:E,commitFilesLoading:j,loadHistory:R,loadMore:P,authors:M,authorsLoading:G,loadAuthors:ue}}function Ha(t){if(!t.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 c=t.current.querySelector(l);if(c&&qs(c))return c}return qs(t.current)?t.current:null}function qs(t){const n=["auto","scroll"].includes(getComputedStyle(t).overflowY),l=t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth;return n&&l}function on(t){if(!t)return 19.5;const n=parseFloat(getComputedStyle(t).lineHeight);return isNaN(n)?19.5:n}function ss(t,n=!0){const l=n?t.scrollHeight:0;t.scrollTo({top:l,behavior:"smooth"})}function Aa(t){const{scrollTop:n,scrollHeight:l,clientHeight:c}=t;return l<=c?100:Math.round(n/(l-c)*100)}function Oa(t,n){const l=on(t),c=t.scrollTop,r=Math.floor(c/l)+1,i=n.split(`
|
|
3
3
|
`).length;return Math.min(r,i)}function Ua(t,n,l=!1){if(!n)return[];l||t.toLowerCase();const c=l?n:n.toLowerCase(),r=[];let i=0;const h=t.split(`
|
|
4
4
|
`);let o=0;for(let d=0;d<h.length;d++){const g=h[d],b=l?g:g.toLowerCase();let p=0,v=b.indexOf(c);for(;v!==-1;){const k=o+v;r.push({index:i++,line:d+1,column:v,length:c.length,charIndex:k}),p=v+c.length,v=b.indexOf(c,p)}o+=g.length+1}return r}function ot(t){return/[\w]/.test(t)}function Ke(t){return/\s/.test(t)}function Ga(t,n,l){let c=n-1,r=l;const i=t.length,h=t[c]||"";if(r<h.length){const g=ot(h[r]);if(!Ke(h[r]))for(;r<h.length&&!Ke(h[r])&&ot(h[r])===g;)r++}for(;c<i;){const g=t[c]||"";for(;r<g.length&&Ke(g[r]);)r++;if(r<g.length)return{line:c+1,col:r};c++,r=0}const o=i,d=Math.max(0,(t[i-1]||"").length-1);return{line:o,col:d}}function _a(t,n,l){let c=n-1,r=l+1;const i=t.length;for(;c<i;){const d=t[c]||"";for(;r<d.length&&Ke(d[r]);)r++;if(r<d.length)break;c++,r=0}if(c>=i)return{line:i,col:Math.max(0,(t[i-1]||"").length-1)};const h=t[c]||"",o=ot(h[r]);for(;r+1<h.length&&!Ke(h[r+1])&&ot(h[r+1])===o;)r++;return{line:c+1,col:r}}function Ba(t,n,l){let c=n-1,r=l-1;for(;c>=0;){const o=t[c]||"";for(;r>=0&&Ke(o[r]);)r--;if(r>=0)break;c--,c>=0&&(r=(t[c]||"").length-1)}if(c<0)return{line:1,col:0};const i=t[c]||"",h=ot(i[r]);for(;r>0&&!Ke(i[r-1])&&ot(i[r-1])===h;)r--;return{line:c+1,col:r}}function Va(t,n,l,c){if(c==="none")return"";const{anchorLine:r,anchorCol:i,headLine:h,headCol:o}=l;if(c==="line"){const k=Math.min(r,h),F=Math.max(r,h);return n.slice(k-1,F).join(`
|
|
5
5
|
`)}let d,g,b,p;if(r<h||r===h&&i<=o?(d=r,g=i,b=h,p=o):(d=h,g=o,b=r,p=i),d===b)return(n[d-1]||"").substring(g,p+1);const v=[];v.push((n[d-1]||"").substring(g));for(let k=d;k<b-1;k++)v.push(n[k]||"");return v.push((n[b-1]||"").substring(0,p+1)),v.join(`
|
|
6
6
|
`)}function cn(t){const{containerRef:n,isEnabled:l=!0,content:c="",onClose:r,onSearchOpen:i}=t,h=s.useRef({percentage:0,line:1,column:1}),o=s.useRef(null),d=s.useRef(19.5),g=s.useMemo(()=>c.split(`
|
|
7
|
-
`),[c]),b=g.length,[p,v]=s.useState(1),[k,F]=s.useState(0),[y,E]=s.useState(!1),[f,j]=s.useState("none"),[C,M]=s.useState(null),[H,G]=s.useState(!1),[K,w]=s.useState(""),[re,_]=s.useState(0),[R,P]=s.useState(!1),X=s.useMemo(()=>Ua(c,K,!1),[c,K]),Q=s.useCallback(()=>{const m=o.current;if(!m)return;const Y=Aa(m),le=Oa(m,c),T=Math.max(1,Math.round(m.scrollLeft/7.8)+1);h.current={percentage:Y,line:le,column:T}},[c]),ne=s.useCallback(()=>{G(!0),w(""),_(0),i==null||i()},[i]),ue=s.useCallback(()=>{G(!1),w(""),_(0)},[]),U=s.useCallback(()=>{P(m=>!m)},[]),se=s.useCallback(m=>{const Y=o.current;if(!Y)return;const le=Y.querySelector(".file-viewer-pre"),me=le&&parseFloat(getComputedStyle(le).lineHeight)||d.current,T=le&&parseFloat(getComputedStyle(le).paddingTop)||0,te=(le?le.offsetTop:0)+T+(m-1)*me,ae=me*3;Y.scrollTo({top:Math.max(0,te-ae),behavior:"smooth"})},[]);s.useEffect(()=>{!H||X.length===0||_(0)},[X,H]),s.useEffect(()=>{if(!H||X.length===0)return;const m=X[re];m&&(v(m.line),F(m.column),se(m.line))},[H,X,re,se]);const I=s.useCallback(()=>{X.length!==0&&_(m=>(m+1)%X.length)},[X]),B=s.useCallback(()=>{X.length!==0&&_(m=>(m-1+X.length)%X.length)},[X]),Z=s.useCallback(m=>{const Y=o.current;if(!Y)return;const le=Y.querySelector(".file-viewer-pre");if(!le)return;const me=parseFloat(getComputedStyle(le).lineHeight),T=isNaN(me)?d.current:me,S=parseFloat(getComputedStyle(le).paddingTop)||0,ae=le.offsetTop+S+(m-1)*T,pe=ae+T,oe=Y.scrollTop,W=oe+Y.clientHeight;ae<oe?Y.scrollTo({top:Math.max(0,ae),behavior:"auto"}):pe>W&&Y.scrollTo({top:pe-Y.clientHeight,behavior:"auto"})},[]),L=s.useCallback((m,Y)=>{v(m),F(Y),Z(m),f!=="none"&&M(le=>le?{...le,headLine:m,headCol:Y}:null)},[f,Z]),we=s.useCallback(()=>{if(f==="none"||!C)return;const m=Va(c,g,C,f);m&&navigator.clipboard.writeText(m).catch(()=>{const Y=document.createElement("textarea");Y.value=m,Y.style.position="fixed",Y.style.left="-9999px",document.body.appendChild(Y),Y.select(),document.execCommand("copy"),document.body.removeChild(Y)}),j("none"),M(null)},[f,C,c,g]),ee=s.useCallback(m=>{const Y=m.target;if((Y.tagName==="INPUT"||Y.tagName==="TEXTAREA")&&m.key!=="Escape")return;const me=o.current;if(!me)return;let T=!1;const S=d.current,te=Math.max(1,Math.floor(me.clientHeight/S)),ae=Math.max(1,Math.floor(te/2)),pe=(W,ye)=>{const Ge=Math.max(0,(g[W-1]||"").length-1);return Math.min(ye,Math.max(0,Ge))},oe=(W,ye)=>{const Ge=pe(W,ye);L(W,Ge)};if(m.key==="v"&&!m.shiftKey&&!m.ctrlKey&&!H)m.preventDefault(),m.stopPropagation(),f==="char"?(j("none"),M(null)):(j("char"),M({anchorLine:p,anchorCol:k,headLine:p,headCol:k})),T=!0;else if(m.key==="V"&&m.shiftKey&&!m.ctrlKey&&!H)m.preventDefault(),m.stopPropagation(),f==="line"?(j("none"),M(null)):(j("line"),M({anchorLine:p,anchorCol:0,headLine:p,headCol:0})),T=!0;else if(m.key==="y"&&!m.ctrlKey&&f!=="none")m.preventDefault(),m.stopPropagation(),we(),T=!0;else if(m.key==="j"||m.key==="ArrowDown"){m.preventDefault(),m.stopPropagation();const W=Math.min(p+1,b);oe(W,k),T=!0}else if(m.key==="k"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const W=Math.max(p-1,1);oe(W,k),T=!0}else if(m.key==="d"&&m.ctrlKey||m.key==="d"&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.min(p+ae,b);oe(W,k),T=!0}else if(m.key==="u"&&m.ctrlKey||m.key==="u"&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.max(p-ae,1);oe(W,k),T=!0}else if((m.ctrlKey||m.metaKey)&&m.key==="f")m.preventDefault(),m.stopPropagation(),ne(),T=!0;else if(m.key==="f"&&!m.ctrlKey&&!m.metaKey&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.min(p+te,b);oe(W,k),T=!0}else if(m.key===" "||m.key==="PageDown"){m.preventDefault(),m.stopPropagation();const W=Math.min(p+te,b);oe(W,k),T=!0}else if(m.key==="b"&&!y&&f==="none"&&!H||m.key==="PageUp"){m.preventDefault(),m.stopPropagation();const W=Math.max(p-te,1);oe(W,k),T=!0}else if(m.key==="g"&&!m.shiftKey&&f==="none"&&!H)m.preventDefault(),m.stopPropagation(),L(1,0),ss(me,!1),T=!0;else if(m.key==="Home")m.preventDefault(),m.stopPropagation(),L(1,0),ss(me,!1),T=!0;else if(m.key==="G"&&m.shiftKey||m.key==="End")m.preventDefault(),m.stopPropagation(),L(b,0),ss(me,!0),T=!0;else if(m.key==="h"||m.key==="ArrowLeft")m.preventDefault(),m.stopPropagation(),L(p,Math.max(0,k-1)),T=!0;else if(m.key==="l"||m.key==="ArrowRight"){m.preventDefault(),m.stopPropagation();const W=(g[p-1]||"").length;L(p,Math.min(k+1,Math.max(0,W-1))),T=!0}else if(m.key==="w"&&!m.ctrlKey&&!H){m.preventDefault(),m.stopPropagation();const W=Ga(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="e"&&!m.ctrlKey&&!H){m.preventDefault(),m.stopPropagation();const W=_a(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="b"&&!H){m.preventDefault(),m.stopPropagation();const W=Ba(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="0")m.preventDefault(),m.stopPropagation(),L(p,0),T=!0;else if(m.key==="$")m.preventDefault(),m.stopPropagation(),L(p,Math.max(0,(g[p-1]||"").length-1)),T=!0;else if(m.key==="^"){m.preventDefault(),m.stopPropagation();const ye=(g[p-1]||"").search(/\S/);L(p,ye>=0?ye:0),T=!0}else m.key==="/"?(m.preventDefault(),m.stopPropagation(),ne(),T=!0):m.key==="n"&&!H?(m.preventDefault(),m.stopPropagation(),I(),T=!0):m.key==="N"&&m.shiftKey&&!H?(m.preventDefault(),m.stopPropagation(),B(),T=!0):m.key==="?"&&f==="none"?(m.preventDefault(),m.stopPropagation(),U(),T=!0):m.key==="q"&&f==="none"?(m.preventDefault(),m.stopPropagation(),r==null||r(),T=!0):m.key==="Escape"&&(f!=="none"?(m.preventDefault(),m.stopPropagation(),j("none"),M(null),T=!0):H?(m.preventDefault(),m.stopPropagation(),ue(),T=!0):y&&(m.preventDefault(),m.stopPropagation(),E(!1),T=!0));T&&(m.key!=="Escape"&&!y&&E(!0),requestAnimationFrame(Q))},[r,Q,b,g,p,k,Z,H,ue,f,y,L,we,ne,I,B,U]);return s.useEffect(()=>{if(!l)return;const m=Ha(n);if(o.current=m,!m){console.warn("[useLessNavigation] Could not find scrollable container");return}d.current=on(m);const Y=()=>{Q()};return window.addEventListener("keydown",ee,{capture:!0}),m.addEventListener("scroll",Y,{passive:!0}),Q(),()=>{window.removeEventListener("keydown",ee,{capture:!0}),m.removeEventListener("scroll",Y)}},[l,ee,Q]),{scrollPercentage:h.current.percentage,currentLine:h.current.line,currentColumn:h.current.column,totalLines:b,cursorLine:p,cursorCol:k,cursorModeActive:y,visualMode:f,selection:C,searchActive:H,searchQuery:K,searchMatches:X,currentMatchIndex:re,startSearch:ne,setSearchQuery:w,nextMatch:I,prevMatch:B,clearSearch:ue,helpActive:R,toggleHelp:U}}const os=({query:t,onQueryChange:n,matchCount:l,currentIndex:c,onNext:r,onPrev:i,onClose:h})=>{const{t:o}=ie(["terminal"]),d=s.useRef(null);s.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const g=s.useCallback(p=>{p.stopPropagation(),p.key==="Enter"||p.key==="ArrowDown"?(p.preventDefault(),r()):p.key==="ArrowUp"&&(p.preventDefault(),i())},[r,i]),b=l===0&&t?o("terminal:fileExplorer.noMatches"):l>0?`${c+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:d,type:"text",className:"file-viewer-search-input",placeholder:o("terminal:fileExplorer.searchInFile"),value:t,onChange:p=>n(p.target.value),onKeyDown:g,autoComplete:"off",spellCheck:"false"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"file-viewer-search-counter",children:b}),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(D,{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(D,{name:"caret-down",size:10})})]})]}),e.jsx("button",{className:"file-viewer-search-close",onClick:h,title:o("terminal:fileExplorer.closeSearch"),"aria-label":o("terminal:fileExplorer.closeSearch"),children:e.jsx(D,{name:"close",size:12})})]})};os.displayName="SearchBar";const Ka=[{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"}],cs=({onClose:t})=>{const{t:n}=ie(["terminal"]),l=s.useCallback(i=>{i.target===i.currentTarget&&t()},[t]),c=s.useCallback(i=>{(i.key==="Escape"||i.key==="?")&&(i.preventDefault(),i.stopPropagation(),t())},[t]),r=Ka.reduce((i,h)=>(i[h.category]||(i[h.category]=[]),i[h.category].push(h),i),{});return e.jsx("div",{className:"keybindings-help-overlay",onClick:l,onKeyDown:c,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:t,"aria-label":n("terminal:fileExplorer.closeHelp"),title:n("terminal:fileExplorer.pressEscapeToClose"),children:e.jsx(D,{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,h])=>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:h.map((o,d)=>e.jsxs("div",{className:"keybindings-help-item",children:[e.jsx("div",{className:"keybindings-help-keys",children:o.keys.map((g,b)=>e.jsx("kbd",{className:"keybindings-help-key",children:g},b))}),e.jsx("div",{className:"keybindings-help-description",children:o.description})]},d))})]},i))}),e.jsx("p",{className:"keybindings-help-footer",children:n("terminal:fileExplorer.keybindingsFooter")})]})})};cs.displayName="KeybindingsHelp";const Js=s.lazy(()=>rs(()=>import("./EmbeddedEditor-DGdihbaE.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.EmbeddedEditor}))),Wa=s.lazy(()=>rs(()=>import("./AudioPlayer-DbawH_kK.js"),__vite__mapDeps([6,1,2,3,4])).then(t=>({default:t.AudioPlayer}))),qa=s.lazy(()=>rs(()=>import("./VideoPlayer-JEXTLcck.js"),__vite__mapDeps([7,1,2,3,4])).then(t=>({default:t.VideoPlayer}))),Ja=[".md",".mdx",".markdown"],Ys="file-viewer-markdown-render",Ya=[".puml",".plantuml",".iuml",".pu"],Xs="file-viewer-plantuml-render",Xa="https://kroki.io/plantuml/svg";function Qa(t){return Ja.includes(t.toLowerCase())}function Za(t){return Ya.includes(t.toLowerCase())}function er(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Ys);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Ys,String(r))}catch{}return r})},[]);return[t,l]}function tr(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Xs);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Xs,String(r))}catch{}return r})},[]);return[t,l]}function sr(t){const n=new TextEncoder().encode(t);let l="";for(const c of n)l+=String.fromCharCode(c);return`data:image/svg+xml;base64,${window.btoa(l)}`}function ze({file:t,rightContent:n,onRevealInTree:l,editMode:c,onToggleEdit:r}){const{t:i}=ie(["terminal","common"]),[h,o]=s.useState("idle"),[d,g]=s.useState("idle"),[b,p]=s.useState("idle"),v=t.fileType==="text"?Ut(t.extension):t.extension.slice(1).toUpperCase(),k=t.fileType==="text"&&t.content!=null,F=en(),y=async()=>{try{await zt(t.content),p("copied"),setTimeout(()=>p("idle"),2e3)}catch{p("error"),setTimeout(()=>p("idle"),2e3)}},E=async()=>{const M=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(M,t.filename,"text/plain;charset=utf-8")},f=async()=>{o("loading");try{const M=await V(A("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,...F.externalEditorCommand&&{editorCommand:F.externalEditorCommand}})});if(!M.ok){const H=await M.json().catch(()=>({error:"Unknown error"}));console.error("Failed to open in editor:",H),o("error"),setTimeout(()=>o("idle"),2e3);return}o("success"),setTimeout(()=>o("idle"),2e3)}catch(M){console.error("Error opening file in editor:",M),o("error"),setTimeout(()=>o("idle"),2e3)}},j=async()=>{if(t.path)try{await sa(t.path),g("success"),setTimeout(()=>g("idle"),2e3)}catch(M){console.error("Error opening file explorer:",M),g("error"),setTimeout(()=>g("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:t.filename}),e.jsxs("span",{className:"file-viewer-meta",children:[tn(t.size)," • ",v,t.content&&` • ${t.content.split(`
|
|
7
|
+
`),[c]),b=g.length,[p,v]=s.useState(1),[k,F]=s.useState(0),[y,E]=s.useState(!1),[f,j]=s.useState("none"),[C,M]=s.useState(null),[H,G]=s.useState(!1),[K,w]=s.useState(""),[re,_]=s.useState(0),[R,P]=s.useState(!1),X=s.useMemo(()=>Ua(c,K,!1),[c,K]),Q=s.useCallback(()=>{const m=o.current;if(!m)return;const Y=Aa(m),le=Oa(m,c),T=Math.max(1,Math.round(m.scrollLeft/7.8)+1);h.current={percentage:Y,line:le,column:T}},[c]),ne=s.useCallback(()=>{G(!0),w(""),_(0),i==null||i()},[i]),ue=s.useCallback(()=>{G(!1),w(""),_(0)},[]),U=s.useCallback(()=>{P(m=>!m)},[]),se=s.useCallback(m=>{const Y=o.current;if(!Y)return;const le=Y.querySelector(".file-viewer-pre"),me=le&&parseFloat(getComputedStyle(le).lineHeight)||d.current,T=le&&parseFloat(getComputedStyle(le).paddingTop)||0,te=(le?le.offsetTop:0)+T+(m-1)*me,ae=me*3;Y.scrollTo({top:Math.max(0,te-ae),behavior:"smooth"})},[]);s.useEffect(()=>{!H||X.length===0||_(0)},[X,H]),s.useEffect(()=>{if(!H||X.length===0)return;const m=X[re];m&&(v(m.line),F(m.column),se(m.line))},[H,X,re,se]);const I=s.useCallback(()=>{X.length!==0&&_(m=>(m+1)%X.length)},[X]),B=s.useCallback(()=>{X.length!==0&&_(m=>(m-1+X.length)%X.length)},[X]),Z=s.useCallback(m=>{const Y=o.current;if(!Y)return;const le=Y.querySelector(".file-viewer-pre");if(!le)return;const me=parseFloat(getComputedStyle(le).lineHeight),T=isNaN(me)?d.current:me,S=parseFloat(getComputedStyle(le).paddingTop)||0,ae=le.offsetTop+S+(m-1)*T,pe=ae+T,oe=Y.scrollTop,W=oe+Y.clientHeight;ae<oe?Y.scrollTo({top:Math.max(0,ae),behavior:"auto"}):pe>W&&Y.scrollTo({top:pe-Y.clientHeight,behavior:"auto"})},[]),L=s.useCallback((m,Y)=>{v(m),F(Y),Z(m),f!=="none"&&M(le=>le?{...le,headLine:m,headCol:Y}:null)},[f,Z]),we=s.useCallback(()=>{if(f==="none"||!C)return;const m=Va(c,g,C,f);m&&navigator.clipboard.writeText(m).catch(()=>{const Y=document.createElement("textarea");Y.value=m,Y.style.position="fixed",Y.style.left="-9999px",document.body.appendChild(Y),Y.select(),document.execCommand("copy"),document.body.removeChild(Y)}),j("none"),M(null)},[f,C,c,g]),ee=s.useCallback(m=>{const Y=m.target;if((Y.tagName==="INPUT"||Y.tagName==="TEXTAREA")&&m.key!=="Escape")return;const me=o.current;if(!me)return;let T=!1;const S=d.current,te=Math.max(1,Math.floor(me.clientHeight/S)),ae=Math.max(1,Math.floor(te/2)),pe=(W,ye)=>{const Ge=Math.max(0,(g[W-1]||"").length-1);return Math.min(ye,Math.max(0,Ge))},oe=(W,ye)=>{const Ge=pe(W,ye);L(W,Ge)};if(m.key==="v"&&!m.shiftKey&&!m.ctrlKey&&!H)m.preventDefault(),m.stopPropagation(),f==="char"?(j("none"),M(null)):(j("char"),M({anchorLine:p,anchorCol:k,headLine:p,headCol:k})),T=!0;else if(m.key==="V"&&m.shiftKey&&!m.ctrlKey&&!H)m.preventDefault(),m.stopPropagation(),f==="line"?(j("none"),M(null)):(j("line"),M({anchorLine:p,anchorCol:0,headLine:p,headCol:0})),T=!0;else if(m.key==="y"&&!m.ctrlKey&&f!=="none")m.preventDefault(),m.stopPropagation(),we(),T=!0;else if(m.key==="j"||m.key==="ArrowDown"){m.preventDefault(),m.stopPropagation();const W=Math.min(p+1,b);oe(W,k),T=!0}else if(m.key==="k"||m.key==="ArrowUp"){m.preventDefault(),m.stopPropagation();const W=Math.max(p-1,1);oe(W,k),T=!0}else if(m.key==="d"&&m.ctrlKey||m.key==="d"&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.min(p+ae,b);oe(W,k),T=!0}else if(m.key==="u"&&m.ctrlKey||m.key==="u"&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.max(p-ae,1);oe(W,k),T=!0}else if((m.ctrlKey||m.metaKey)&&m.key==="f")m.preventDefault(),m.stopPropagation(),ne(),T=!0;else if(m.key==="f"&&!m.ctrlKey&&!m.metaKey&&f==="none"&&!H){m.preventDefault(),m.stopPropagation();const W=Math.min(p+te,b);oe(W,k),T=!0}else if(m.key===" "||m.key==="PageDown"){m.preventDefault(),m.stopPropagation();const W=Math.min(p+te,b);oe(W,k),T=!0}else if(m.key==="b"&&!y&&f==="none"&&!H||m.key==="PageUp"){m.preventDefault(),m.stopPropagation();const W=Math.max(p-te,1);oe(W,k),T=!0}else if(m.key==="g"&&!m.shiftKey&&f==="none"&&!H)m.preventDefault(),m.stopPropagation(),L(1,0),ss(me,!1),T=!0;else if(m.key==="Home")m.preventDefault(),m.stopPropagation(),L(1,0),ss(me,!1),T=!0;else if(m.key==="G"&&m.shiftKey||m.key==="End")m.preventDefault(),m.stopPropagation(),L(b,0),ss(me,!0),T=!0;else if(m.key==="h"||m.key==="ArrowLeft")m.preventDefault(),m.stopPropagation(),L(p,Math.max(0,k-1)),T=!0;else if(m.key==="l"||m.key==="ArrowRight"){m.preventDefault(),m.stopPropagation();const W=(g[p-1]||"").length;L(p,Math.min(k+1,Math.max(0,W-1))),T=!0}else if(m.key==="w"&&!m.ctrlKey&&!H){m.preventDefault(),m.stopPropagation();const W=Ga(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="e"&&!m.ctrlKey&&!H){m.preventDefault(),m.stopPropagation();const W=_a(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="b"&&!H){m.preventDefault(),m.stopPropagation();const W=Ba(g,p,k);L(W.line,W.col),T=!0}else if(m.key==="0")m.preventDefault(),m.stopPropagation(),L(p,0),T=!0;else if(m.key==="$")m.preventDefault(),m.stopPropagation(),L(p,Math.max(0,(g[p-1]||"").length-1)),T=!0;else if(m.key==="^"){m.preventDefault(),m.stopPropagation();const ye=(g[p-1]||"").search(/\S/);L(p,ye>=0?ye:0),T=!0}else m.key==="/"?(m.preventDefault(),m.stopPropagation(),ne(),T=!0):m.key==="n"&&!H?(m.preventDefault(),m.stopPropagation(),I(),T=!0):m.key==="N"&&m.shiftKey&&!H?(m.preventDefault(),m.stopPropagation(),B(),T=!0):m.key==="?"&&f==="none"?(m.preventDefault(),m.stopPropagation(),U(),T=!0):m.key==="q"&&f==="none"?(m.preventDefault(),m.stopPropagation(),r==null||r(),T=!0):m.key==="Escape"&&(f!=="none"?(m.preventDefault(),m.stopPropagation(),j("none"),M(null),T=!0):H?(m.preventDefault(),m.stopPropagation(),ue(),T=!0):y&&(m.preventDefault(),m.stopPropagation(),E(!1),T=!0));T&&(m.key!=="Escape"&&!y&&E(!0),requestAnimationFrame(Q))},[r,Q,b,g,p,k,Z,H,ue,f,y,L,we,ne,I,B,U]);return s.useEffect(()=>{if(!l)return;const m=Ha(n);if(o.current=m,!m){console.warn("[useLessNavigation] Could not find scrollable container");return}d.current=on(m);const Y=()=>{Q()};return window.addEventListener("keydown",ee,{capture:!0}),m.addEventListener("scroll",Y,{passive:!0}),Q(),()=>{window.removeEventListener("keydown",ee,{capture:!0}),m.removeEventListener("scroll",Y)}},[l,ee,Q]),{scrollPercentage:h.current.percentage,currentLine:h.current.line,currentColumn:h.current.column,totalLines:b,cursorLine:p,cursorCol:k,cursorModeActive:y,visualMode:f,selection:C,searchActive:H,searchQuery:K,searchMatches:X,currentMatchIndex:re,startSearch:ne,setSearchQuery:w,nextMatch:I,prevMatch:B,clearSearch:ue,helpActive:R,toggleHelp:U}}const os=({query:t,onQueryChange:n,matchCount:l,currentIndex:c,onNext:r,onPrev:i,onClose:h})=>{const{t:o}=ie(["terminal"]),d=s.useRef(null);s.useEffect(()=>{var p;(p=d.current)==null||p.focus()},[]);const g=s.useCallback(p=>{p.stopPropagation(),p.key==="Enter"||p.key==="ArrowDown"?(p.preventDefault(),r()):p.key==="ArrowUp"&&(p.preventDefault(),i())},[r,i]),b=l===0&&t?o("terminal:fileExplorer.noMatches"):l>0?`${c+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:d,type:"text",className:"file-viewer-search-input",placeholder:o("terminal:fileExplorer.searchInFile"),value:t,onChange:p=>n(p.target.value),onKeyDown:g,autoComplete:"off",spellCheck:"false"})]}),t&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"file-viewer-search-counter",children:b}),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(D,{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(D,{name:"caret-down",size:10})})]})]}),e.jsx("button",{className:"file-viewer-search-close",onClick:h,title:o("terminal:fileExplorer.closeSearch"),"aria-label":o("terminal:fileExplorer.closeSearch"),children:e.jsx(D,{name:"close",size:12})})]})};os.displayName="SearchBar";const Ka=[{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"}],cs=({onClose:t})=>{const{t:n}=ie(["terminal"]),l=s.useCallback(i=>{i.target===i.currentTarget&&t()},[t]),c=s.useCallback(i=>{(i.key==="Escape"||i.key==="?")&&(i.preventDefault(),i.stopPropagation(),t())},[t]),r=Ka.reduce((i,h)=>(i[h.category]||(i[h.category]=[]),i[h.category].push(h),i),{});return e.jsx("div",{className:"keybindings-help-overlay",onClick:l,onKeyDown:c,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:t,"aria-label":n("terminal:fileExplorer.closeHelp"),title:n("terminal:fileExplorer.pressEscapeToClose"),children:e.jsx(D,{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,h])=>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:h.map((o,d)=>e.jsxs("div",{className:"keybindings-help-item",children:[e.jsx("div",{className:"keybindings-help-keys",children:o.keys.map((g,b)=>e.jsx("kbd",{className:"keybindings-help-key",children:g},b))}),e.jsx("div",{className:"keybindings-help-description",children:o.description})]},d))})]},i))}),e.jsx("p",{className:"keybindings-help-footer",children:n("terminal:fileExplorer.keybindingsFooter")})]})})};cs.displayName="KeybindingsHelp";const Js=s.lazy(()=>rs(()=>import("./EmbeddedEditor-ChdfmuIg.js"),__vite__mapDeps([0,1,2,3,4,5])).then(t=>({default:t.EmbeddedEditor}))),Wa=s.lazy(()=>rs(()=>import("./AudioPlayer-jjttJ6SM.js"),__vite__mapDeps([6,1,2,3,4])).then(t=>({default:t.AudioPlayer}))),qa=s.lazy(()=>rs(()=>import("./VideoPlayer-BSVjpcQa.js"),__vite__mapDeps([7,1,2,3,4])).then(t=>({default:t.VideoPlayer}))),Ja=[".md",".mdx",".markdown"],Ys="file-viewer-markdown-render",Ya=[".puml",".plantuml",".iuml",".pu"],Xs="file-viewer-plantuml-render",Xa="https://kroki.io/plantuml/svg";function Qa(t){return Ja.includes(t.toLowerCase())}function Za(t){return Ya.includes(t.toLowerCase())}function er(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Ys);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Ys,String(r))}catch{}return r})},[]);return[t,l]}function tr(){const[t,n]=s.useState(()=>{try{const c=localStorage.getItem(Xs);return c===null?!0:c==="true"}catch{return!0}}),l=s.useCallback(()=>{n(c=>{const r=!c;try{localStorage.setItem(Xs,String(r))}catch{}return r})},[]);return[t,l]}function sr(t){const n=new TextEncoder().encode(t);let l="";for(const c of n)l+=String.fromCharCode(c);return`data:image/svg+xml;base64,${window.btoa(l)}`}function ze({file:t,rightContent:n,onRevealInTree:l,editMode:c,onToggleEdit:r}){const{t:i}=ie(["terminal","common"]),[h,o]=s.useState("idle"),[d,g]=s.useState("idle"),[b,p]=s.useState("idle"),v=t.fileType==="text"?Ut(t.extension):t.extension.slice(1).toUpperCase(),k=t.fileType==="text"&&t.content!=null,F=en(),y=async()=>{try{await zt(t.content),p("copied"),setTimeout(()=>p("idle"),2e3)}catch{p("error"),setTimeout(()=>p("idle"),2e3)}},E=async()=>{const M=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(M,t.filename,"text/plain;charset=utf-8")},f=async()=>{o("loading");try{const M=await V(A("/api/files/open-in-editor"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,...F.externalEditorCommand&&{editorCommand:F.externalEditorCommand}})});if(!M.ok){const H=await M.json().catch(()=>({error:"Unknown error"}));console.error("Failed to open in editor:",H),o("error"),setTimeout(()=>o("idle"),2e3);return}o("success"),setTimeout(()=>o("idle"),2e3)}catch(M){console.error("Error opening file in editor:",M),o("error"),setTimeout(()=>o("idle"),2e3)}},j=async()=>{if(t.path)try{await sa(t.path),g("success"),setTimeout(()=>g("idle"),2e3)}catch(M){console.error("Error opening file explorer:",M),g("error"),setTimeout(()=>g("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:t.filename}),e.jsxs("span",{className:"file-viewer-meta",children:[tn(t.size)," • ",v,t.content&&` • ${t.content.split(`
|
|
8
8
|
`).length} lines`]})]}),e.jsxs("div",{className:"file-viewer-header-right",children:[r&&t.fileType==="text"&&e.jsx("button",{className:`file-viewer-edit-btn${c?" active":""}`,onClick:r,title:i(c?"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"})})}),k&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${b}`,onClick:y,title:i("terminal:fileExplorer.copyAllTitle"),children:i(b==="copied"?"terminal:fileExplorer.copied":b==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyAll")}),e.jsx("button",{className:"file-viewer-download-btn",onClick:E,title:i("terminal:fileExplorer.downloadFileTitle"),children:i("common:buttons.download")})]}),e.jsx("button",{className:`file-viewer-reveal-explorer-btn ${d}`,onClick:j,disabled:!t.path,title:C,"aria-label":C,children:d==="success"?e.jsx(D,{name:"check",size:14}):d==="error"?e.jsx(D,{name:"cross",size:14}):e.jsx(D,{name:"folder-open",size:14})}),e.jsx("button",{className:`file-viewer-open-editor-btn ${h}`,onClick:f,disabled:h==="loading",title:i(h==="error"?"terminal:fileExplorer.failedToOpenEditor":h==="success"?"terminal:fileExplorer.openingInEditor":"terminal:fileExplorer.openInEditor"),children:h==="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"})}):h==="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(t.path),title:i("terminal:fileExplorer.locateInTree"),children:e.jsx(D,{name:"target",size:14})}),n]})]})}function nr({file:t,onRevealInTree:n,renderMarkdown:l,onToggleRender:c,editMode:r,onToggleEdit:i}){const h=s.useRef(null),o=s.useRef(null),d=s.useRef(null),{t:g}=ie(["terminal","common"]),[b,p]=s.useState("idle"),[v,k]=s.useState("idle"),[F,y]=s.useState("idle"),[E,f]=s.useState("idle"),j=cn({containerRef:d,isEnabled:!0,content:t.content});s.useEffect(()=>{if(!l&&h.current){const w=Ut(t.extension);sn(w).then(()=>{h.current&&nn(h.current)})}},[t,l]);const C=s.useCallback(async()=>{if(!o.current){p("error"),setTimeout(()=>p("idle"),2e3);return}try{const w=o.current.innerHTML,re=Xn(w),_=o.current.innerText;await Qn(re,_),p("copied"),setTimeout(()=>p("idle"),2e3)}catch{p("error"),setTimeout(()=>p("idle"),2e3)}},[]),M=s.useCallback(async()=>{if(!o.current){k("error"),setTimeout(()=>k("idle"),2e3);return}try{const w=o.current.innerHTML;await zt(w),k("copied"),setTimeout(()=>k("idle"),2e3)}catch{k("error"),setTimeout(()=>k("idle"),2e3)}},[]),H=s.useCallback(async()=>{try{await zt(t.content),y("copied"),setTimeout(()=>y("idle"),2e3)}catch{y("error"),setTimeout(()=>y("idle"),2e3)}},[t.content]),G=s.useCallback(async()=>{try{await zt(t.content),f("copied"),setTimeout(()=>f("idle"),2e3)}catch{f("error"),setTimeout(()=>f("idle"),2e3)}},[t.content]),K=e.jsxs("div",{className:"file-viewer-header-buttons",children:[l&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:`file-viewer-copy-html-btn ${b}`,onClick:C,title:g("terminal:fileExplorer.copyRichTextTitle"),children:g(b==="copied"?"terminal:fileExplorer.copied":b==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyRichText")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${v}`,onClick:M,title:g("terminal:fileExplorer.copyHtmlTitle"),children:g(v==="copied"?"terminal:fileExplorer.copied":v==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyHtml")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${F}`,onClick:H,title:g("terminal:fileExplorer.copyMarkdownTitle"),children:g(F==="copied"?"terminal:fileExplorer.copied":F==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyMarkdown")}),e.jsx("button",{className:`file-viewer-copy-html-btn ${E}`,onClick:G,title:g("terminal:fileExplorer.copyOriginalTitle"),children:g(E==="copied"?"terminal:fileExplorer.copied":E==="error"?"terminal:fileExplorer.copyError":"terminal:fileExplorer.copyOriginal")})]}),e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:c,title:g(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderMarkdown"),children:l?"</>":"Aa"})]});return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:K,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:d,children:[l?e.jsx("div",{className:"file-viewer-markdown-wrapper",children:e.jsx("div",{className:"markdown-content",ref:o,children:e.jsx(Zn,{remarkPlugins:[ea],children:t.content})})}):e.jsx("div",{className:"file-viewer-code-wrapper",children:e.jsx("pre",{className:"file-viewer-pre",children:e.jsx("code",{ref:h,className:"language-markdown",children:t.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${j.currentLine}/${j.totalLines}`,children:j.scrollPercentage===100?"END":j.scrollPercentage===0?"TOP":`${j.scrollPercentage}%`}),j.searchActive&&e.jsx(os,{query:j.searchQuery,onQueryChange:j.setSearchQuery,matchCount:j.searchMatches.length,currentIndex:j.currentMatchIndex,onNext:j.nextMatch,onPrev:j.prevMatch,onClose:j.clearSearch})]}),j.helpActive&&e.jsx(cs,{onClose:j.toggleHelp})]})}function ar({file:t,onRevealInTree:n,renderPlantUml:l,onToggleRender:c,editMode:r,onToggleEdit:i}){const{t:h}=ie(["terminal"]),o=s.useRef(null),d=s.useRef(null),[g,b]=s.useState(null),[p,v]=s.useState(!1),[k,F]=s.useState(null),y=cn({containerRef:d,isEnabled:!0,content:t.content});s.useEffect(()=>{if(!l&&o.current){const f=Ut(t.extension);sn(f).then(()=>{o.current&&nn(o.current)})}},[t,l]),s.useEffect(()=>{if(!l)return;if(!t.content.trim()){b(null),F("Diagram is empty");return}const f=new AbortController;return v(!0),F(null),(async()=>{try{const C=await fetch(Xa,{method:"POST",headers:{"Content-Type":"text/plain; charset=utf-8",Accept:"image/svg+xml"},body:t.content,signal:f.signal});if(!C.ok)throw new Error(`Render failed (${C.status})`);const M=await C.text();if(!M.includes("<svg"))throw new Error("Invalid SVG output");b(sr(M))}catch(C){if(f.signal.aborted)return;const M=C instanceof Error?C.message:"Failed to render diagram";F(M),b(null)}finally{f.signal.aborted||v(!1)}})(),()=>f.abort()},[t.path,t.content,l]);const E=e.jsx("div",{className:"file-viewer-header-buttons",children:e.jsx("button",{className:`file-viewer-render-toggle ${l?"active":""}`,onClick:c,title:h(l?"terminal:fileExplorer.showSource":"terminal:fileExplorer.renderDiagram"),children:l?"</>":h("terminal:fileExplorer.diagram")})});return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:E,editMode:r,onToggleEdit:i}),e.jsxs("div",{className:"file-viewer-content-wrapper",ref:d,children:[l?e.jsxs("div",{className:"file-viewer-diagram-wrapper",children:[p&&e.jsx("div",{className:"file-viewer-placeholder",children:h("terminal:fileExplorer.renderingDiagram")}),!p&&g&&e.jsx("img",{src:g,alt:t.filename,className:"file-viewer-diagram-image"}),!p&&k&&e.jsxs("div",{className:"file-viewer-diagram-error",children:[e.jsxs("div",{children:[h("terminal:fileExplorer.couldNotRender"),": ",k]}),e.jsx("button",{className:"file-viewer-render-toggle",onClick:c,children:h("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:t.content})})}),e.jsx("div",{className:"file-viewer-scroll-indicator",title:`Line ${y.currentLine}/${y.totalLines}`,children:y.scrollPercentage===100?"END":y.scrollPercentage===0?"TOP":`${y.scrollPercentage}%`}),y.searchActive&&e.jsx(os,{query:y.searchQuery,onQueryChange:y.setSearchQuery,matchCount:y.searchMatches.length,currentIndex:y.currentMatchIndex,onNext:y.nextMatch,onPrev:y.prevMatch,onClose:y.clearSearch})]}),y.helpActive&&e.jsx(cs,{onClose:y.toggleHelp})]})}function rr({file:t,onRevealInTree:n}){const{t:l}=ie(["common","terminal"]),c=async()=>{const r=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(r,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-image-wrapper zoomable",children:t.dataUrl?e.jsx(ta,{src:t.dataUrl,alt:t.filename}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadImage")})})]})}function ir({file:t,onRevealInTree:n}){const{t:l}=ie(["common","terminal"]),c=async()=>{const r=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(r,t.filename,"application/pdf")};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-pdf-wrapper",children:t.dataUrl?e.jsx("iframe",{src:t.dataUrl,title:t.filename,className:"file-viewer-pdf"}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:fileExplorer.failedToLoadPdf")})})]})}function lr({file:t,onRevealInTree:n}){const{t:l}=ie(["common","terminal"]),c=async()=>{const r=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(r,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:c,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-audio-wrapper",children:t.dataUrl?e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:l("common:status.loading")}),children:e.jsx(Wa,{url:t.dataUrl,filename:t.filename})}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:audioPlayer.loadError",{defaultValue:"Could not load audio"})})})]})}function or({file:t,onRevealInTree:n}){const{t:l}=ie(["common","terminal"]),c=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`),r=async()=>{await ct(c,t.filename)};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,onRevealInTree:n,rightContent:e.jsx("button",{className:"file-viewer-download-btn",onClick:r,title:l("common:buttons.download"),children:l("common:buttons.download")})}),e.jsx("div",{className:"file-viewer-video-wrapper",children:t.dataUrl?e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:l("common:status.loading")}),children:e.jsx(qa,{url:t.dataUrl,downloadUrl:c,filename:t.filename})}):e.jsx("div",{className:"file-viewer-placeholder",children:l("terminal:videoPlayer.loadError",{defaultValue:"Could not load video"})})})]})}function cr({file:t,onRevealInTree:n}){const{t:l}=ie(["terminal","common"]),c=async()=>{const i=A(`/api/files/binary?path=${encodeURIComponent(t.path)}&download=true`);await ct(i,t.filename)},r=()=>{const i=t.extension.toLowerCase();return[".xlsx",".xls"].includes(i)?e.jsx(D,{name:"dashboard",size:48}):[".docx",".doc"].includes(i)?e.jsx(D,{name:"edit",size:48}):[".pptx",".ppt"].includes(i)?e.jsx(D,{name:"film",size:48}):[".zip",".tar",".gz",".rar",".7z"].includes(i)?e.jsx(D,{name:"file-zip",size:48}):[".mp3",".wav",".flac",".ogg"].includes(i)?e.jsx(D,{name:"music-note",size:48}):[".mp4",".avi",".mov",".mkv",".webm"].includes(i)?e.jsx(D,{name:"film",size:48}):[".exe",".dmg",".app",".msi"].includes(i)?e.jsx(D,{name:"gear",size:48}):[".apk",".aab",".ipa"].includes(i)?e.jsx(D,{name:"mobile",size:48}):[".jar",".war",".ear"].includes(i)?e.jsx(D,{name:"coffee",size:48}):[".iso",".img"].includes(i)?e.jsx(D,{name:"disc",size:48}):[".so",".dll",".dylib"].includes(i)?e.jsx(D,{name:"wrench",size:48}):e.jsx(D,{name:"folder",size:48})};return e.jsxs(e.Fragment,{children:[e.jsx(ze,{file:t,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:t.filename}),e.jsx("div",{className:"file-viewer-binary-size",children:tn(t.size)}),e.jsx("div",{className:"file-viewer-binary-message",children:l("terminal:fileExplorer.cannotPreview")}),e.jsx("button",{className:"file-viewer-download-btn large",onClick:c,children:l("terminal:fileExplorer.downloadFile")})]})]})}function dr({file:t,loading:n,error:l,onRevealInTree:c,onFileEdited:r}){const{t:i}=ie(["terminal","common"]),[h,o]=er(),[d,g]=tr(),[b,p]=s.useState(!1);s.useEffect(()=>{p(!1)},[t==null?void 0:t.path]);const v=s.useCallback(async C=>{if(!t)return;const M=await V(A("/api/files/write"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t.path,content:C})});if(!M.ok){const H=await M.json().catch(()=>({error:"Save failed"}));throw new Error(H.error||"Save failed")}},[t]),k=s.useCallback(()=>{p(C=>(C&&t&&(r==null||r(t.path)),!C))},[t,r]),F=s.useCallback(()=>{t&&(r==null||r(t.path))},[t,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(!t)return e.jsxs("div",{className:"file-viewer-placeholder",children:[e.jsx("div",{className:"placeholder-icon",children:e.jsx(D,{name:"folder-open",size:32})}),e.jsx("div",{className:"placeholder-text",children:i("terminal:fileExplorer.selectFileToView")})]});const y=t.fileType||"text",E=y==="text"&&Qa(t.extension),f=y==="text"&&Za(t.extension),j=E||f;return j&&b&&t.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(ze,{file:t,onRevealInTree:c,editMode:!0,onToggleEdit:k}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(Js,{content:t.content,extension:t.extension,onSave:v,onCancel:k},t.path)})]}):y==="text"&&!j&&t.content!=null?e.jsxs("div",{className:"file-viewer-content",children:[e.jsx(ze,{file:t,onRevealInTree:c}),e.jsx(s.Suspense,{fallback:e.jsx("div",{className:"file-viewer-placeholder",children:i("common:status.loading")}),children:e.jsx(Js,{content:t.content,extension:t.extension,onSave:v,onCancel:F},t.path)})]}):e.jsxs("div",{className:"file-viewer-content",children:[E&&e.jsx(nr,{file:t,onRevealInTree:c,renderMarkdown:h,onToggleRender:o,editMode:b,onToggleEdit:k}),f&&!E&&e.jsx(ar,{file:t,onRevealInTree:c,renderPlantUml:d,onToggleRender:g,editMode:b,onToggleEdit:k}),y==="image"&&e.jsx(rr,{file:t,onRevealInTree:c}),y==="pdf"&&e.jsx(ir,{file:t,onRevealInTree:c}),y==="audio"&&e.jsx(lr,{file:t,onRevealInTree:c}),y==="video"&&e.jsx(or,{file:t,onRevealInTree:c}),y==="binary"&&e.jsx(cr,{file:t,onRevealInTree:c})]})}const dn=s.memo(dr,(t,n)=>t.loading!==n.loading||t.error!==n.error?!1:t.file===null&&n.file===null?!0:t.file===null||n.file===null?!1:t.file.path===n.file.path&&t.file.content===n.file.content&&t.file.modified===n.file.modified);dn.displayName="FileViewer";function un({text:t,query:n}){if(!n)return e.jsx(e.Fragment,{children:t});const l=na(t,n);if(l)return e.jsxs(e.Fragment,{children:[t.slice(0,l.start),e.jsx("mark",{className:"search-highlight",children:t.slice(l.start,l.end)}),t.slice(l.end)]});const c=n.toLowerCase(),i=t.toLowerCase().indexOf(c);return i===-1?e.jsx(e.Fragment,{children:t}):e.jsxs(e.Fragment,{children:[t.slice(0,i),e.jsx("mark",{className:"search-highlight",children:t.slice(i,i+n.length)}),t.slice(i+n.length)]})}const ur=s.memo(function({node:n,query:l,isSelected:c,onSelect:r,lineNumber:i}){const h=n.isDirectory?null:is(n),o=n.path.split("/");o[o.length-1];const d=o.slice(0,-1).join("/");return e.jsxs("div",{className:`search-result-item ${c?"selected":""}`,onClick:()=>r(n),children:[n.isDirectory?e.jsx("span",{className:"search-result-icon",children:e.jsx(D,{name:"folder",size:14})}):h?e.jsx("span",{className:"search-result-icon",style:{backgroundImage:`url('${h}')`},role:"img","aria-label":"file icon"}):e.jsx("span",{className:"search-result-icon",children:e.jsx(D,{name:"file-text",size:14})}),e.jsxs("div",{className:"search-result-info",children:[e.jsxs("span",{className:"search-result-name",children:[e.jsx(un,{text:n.name,query:l}),i&&e.jsxs("span",{className:"search-result-line-badge",children:[":",i]})]}),e.jsx("span",{className:"search-result-path",children:d})]})]})}),hr=s.memo(function({match:n,query:l,isSelected:c,onSelect:r}){const{t:i}=ie(["terminal"]),h={name:n.name,path:n.path,isDirectory:!1,extension:n.extension},o=is(h),d=n.path.split("/"),g=d[d.length-1],b=d.slice(0,-1).join("/");return e.jsxs("div",{className:`content-search-item ${c?"selected":""}`,children:[e.jsxs("div",{className:`content-search-header ${c?"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(D,{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:g}),e.jsx("span",{className:"search-result-path",style:{fontSize:"10px"},children:b})]}),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((p,v)=>e.jsxs("div",{className:"content-search-match",onClick:()=>r(n.path,p.line),children:[e.jsx("span",{className:"content-search-line-num",children:p.line}),e.jsx("span",{className:"content-search-line-content",children:e.jsx(un,{text:p.content.trim(),query:l})})]},`${n.path}-${p.line}-${v}`)),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 mr({filenameResults:t,contentResults:n,onSelectFile:l,onSelectContent:c,selectedPath:r,query:i,lineNumber:h}){const{t:o}=ie(["terminal"]),d=t.length>0,g=n.length>0;return!d&&!g?e.jsx("div",{className:"search-no-results",children:o("terminal:fileExplorer.noMatchesFound")}):e.jsxs("div",{className:"unified-search-results",children:[d&&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(D,{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:t.length})]}),e.jsx("div",{className:"unified-search-section-content",children:t.map(b=>e.jsx(ur,{node:b,query:i,isSelected:r===b.path,onSelect:l,lineNumber:h},b.path))})]}),g&&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(D,{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((b,p)=>b+p.matches.length,0),files:n.length})})]}),e.jsx("div",{className:"unified-search-section-content",children:n.map(b=>e.jsx(hr,{match:b,query:i,isSelected:r===b.path,onSelect:c},b.path))})]})]})}const hn=s.memo(mr,(t,n)=>!(t.query!==n.query||t.selectedPath!==n.selectedPath||t.filenameResults.length!==n.filenameResults.length||t.contentResults.length!==n.contentResults.length));hn.displayName="UnifiedSearchResults";const pr=s.memo(function({file:n,isSelected:l,onSelect:c,onStage:r,isStaging:i,showDirPath:h,isChecked:o,onToggleCheck:d,onContextMenu:g,onDiscard:b}){const{t:p}=ie(["terminal"]),v=n.status,k=jt[v],F=v==="deleted",y=v==="untracked"&&r,E=n.name.includes(".")?"."+n.name.split(".").pop():"",f=h&&n.path.includes("/")?n.path.slice(0,n.path.lastIndexOf("/")):"";return e.jsxs("div",{className:`git-file-item ${l?"selected":""}`,onClick:()=>!F&&c(n.path,v),onContextMenu:j=>{j.preventDefault(),g==null||g(j,n,v)},style:{cursor:F?"not-allowed":"pointer"},title:n.path,children:[d&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:o||!1,onChange:j=>{j.stopPropagation(),d(n.path)},onClick:j=>j.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:bt(E),alt:"file"}),e.jsxs("span",{className:"git-file-name",children:[n.name,f&&e.jsx("span",{className:"git-file-dir",children:f})]}),e.jsx("span",{className:"git-file-status",style:{color:k.color},children:k.icon}),n.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(D,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.oldPath.split("/").pop()]}),y&&e.jsx("button",{className:`git-stage-btn ${i?"staging":""}`,onClick:j=>{j.stopPropagation(),i||r(n.path)},title:p("terminal:fileExplorer.stageFile"),disabled:i,children:i?"...":"+"}),b&&e.jsx("button",{className:"git-discard-btn",onClick:j=>{j.stopPropagation(),b(n,v)},title:v==="untracked"||v==="added"?"Delete file":"Discard changes",children:e.jsx(D,{name:"revert",size:12})})]})}),fr=16,gr=22,xr=s.memo(function t({node:n,depth:l,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h,onStage:o,stagingPaths:d,checkedFiles:g,onToggleCheck:b,onContextMenu:p,onDirContextMenu:v,onDiscard:k}){const{t:F}=ie(["terminal"]),y=l*fr;if(!n.isDirectory){const f=n.file.status,j=jt[f];return e.jsxs("div",{className:`git-file-item ${i===n.path?"selected":""}`,onClick:()=>f!=="deleted"&&h(n.file.path,f),onContextMenu:C=>{C.preventDefault(),p==null||p(C,n.file,f)},style:{paddingLeft:`${y+gr}px`,cursor:f==="deleted"?"not-allowed":"pointer"},title:n.file.path,children:[b&&e.jsx("input",{type:"checkbox",className:"git-file-checkbox",checked:(g==null?void 0:g.has(n.file.path))||!1,onChange:C=>{C.stopPropagation(),b(n.file.path)},onClick:C=>C.stopPropagation()}),e.jsx("img",{className:"tree-icon",src:bt(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:j.color},children:j.icon}),n.file.oldPath&&e.jsxs("span",{className:"git-file-renamed",children:[e.jsx(D,{name:"subitem",size:10,style:{transform:"rotate(180deg)"}})," ",n.file.oldPath.split("/").pop()]}),f==="untracked"&&o&&e.jsx("button",{className:`git-stage-btn ${d!=null&&d.has(n.path)?"staging":""}`,onClick:C=>{C.stopPropagation(),d!=null&&d.has(n.path)||o(n.file.path)},title:F("terminal:fileExplorer.stageFile"),disabled:d==null?void 0:d.has(n.path),children:d!=null&&d.has(n.path)?"...":"+"}),k&&e.jsx("button",{className:"git-discard-btn",onClick:C=>{C.stopPropagation(),k(n.file,f)},title:f==="untracked"||f==="added"?"Delete file":"Discard changes",children:e.jsx(D,{name:"revert",size:12})})]})}const E=c.has(n.path);return e.jsxs("div",{className:"tree-node-wrapper",children:[e.jsxs("div",{className:`tree-node directory ${E?"expanded":""}`,style:{paddingLeft:`${y}px`},onClick:()=>r(n.path),onContextMenu:f=>{f.preventDefault(),f.stopPropagation(),v==null||v(f,n)},children:[e.jsx("span",{className:`tree-arrow ${E?"expanded":""}`,children:e.jsx(D,{name:"caret-right",size:10})}),e.jsx("img",{className:"tree-folder-icon",src:E?"/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:F("terminal:fileExplorer.fileCount",{count:n.fileCount})})]}),E&&e.jsx("div",{className:"tree-children",children:n.children.map(f=>e.jsx(t,{node:f,depth:l+1,expandedDirs:c,onToggleDir:r,selectedPath:i,onSelect:h,onStage:o,stagingPaths:d,checkedFiles:g,onToggleCheck:b,onContextMenu:p,onDirContextMenu:v,onDiscard:k},f.path))})]})}),ns=s.memo(function({groupLabel:n,groupIcon:l,groupColor:c,files:r,treeNodes:i,viewMode:h,selectedPath:o,expandedDirs:d,onToggleDir:g,onFileSelect:b,onStageFile:p,onStageAll:v,stagingPaths:k,checkedFiles:F,onToggleCheck:y,onContextMenu:E,onDirContextMenu:f,onDiscardFile:j,onDiscardAll:C}){const{t:M}=ie(["terminal"]);if(r.length===0)return null;const H=r.some(w=>w.status==="untracked"),G=H&&v&&r.length>0,K=k?r.every(w=>k.has(w.path)):!1;return e.jsxs("div",{className:"git-status-group",children:[e.jsxs("div",{className:"git-status-group-header",style:{color:c},children:[e.jsx("span",{className:"git-status-badge",style:{background:c},children:l}),n," (",r.length,")",G&&e.jsx("button",{className:`git-stage-all-btn ${K?"staging":""}`,onClick:w=>{w.stopPropagation(),K||v()},title:M("terminal:fileExplorer.stageAllUntracked"),disabled:K,children:K?"...":M("terminal:fileExplorer.stageAll")}),C&&e.jsxs("button",{className:"git-discard-all-btn",onClick:w=>{w.stopPropagation(),C()},title:H?`Delete all ${r.length} files`:`Discard all ${r.length} changes`,children:[e.jsx(D,{name:"revert",size:12})," All"]})]}),h==="tree"?e.jsx("div",{className:"git-tree-content",children:i.map(w=>e.jsx(xr,{node:w,depth:0,expandedDirs:d,onToggleDir:g,selectedPath:o,onSelect:b,onStage:p,stagingPaths:k,checkedFiles:F,onToggleCheck:y,onContextMenu:E,onDirContextMenu:f,onDiscard:j},w.path))}):e.jsx("div",{className:"git-flat-content",children:r.map(w=>e.jsx(pr,{file:w,isSelected:o===w.path,onSelect:b,onStage:w.status==="untracked"?p:void 0,isStaging:k==null?void 0:k.has(w.path),showDirPath:!0,isChecked:F==null?void 0:F.has(w.path),onToggleCheck:y,onContextMenu:E,onDiscard:j},w.path))})]})});function yr({gitStatus:t,loading:n,onFileSelect:l,selectedPath:c,onRefresh:r,onStageFiles:i,stagingPaths:h,currentFolder:o,onCommitComplete:d,mergeInProgress:g,mergingBranch:b,onMergeContinue:p,onMergeAbort:v,onConflictOpen:k,onRevealInTree:F}){const{t:y}=ie(["terminal","common"]),[E,f]=s.useState("tree"),[j,C]=s.useState(new Set),[M,H]=s.useState(""),[G,K]=s.useState(""),[w,re]=s.useState(!1),[_,R]=s.useState(new Set),[P,X]=s.useState(!1),[Q,ne]=s.useState(null),ue=s.useRef(null),{showToast:U}=an(),[se,I]=s.useState(null),[B,Z]=s.useState(null),[L,we]=s.useState(null),ee=s.useCallback((N,$)=>{we({files:[N],label:N.name})},[]),m=s.useCallback(async()=>{if(!(!L||!o))try{const N=await V(A("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:L.files.map(O=>({path:O.path,status:O.status})),directory:o})}),$=await N.json();N.ok&&$.success?(U("success","Discarded",`Reverted ${L.files.length} file(s)`),r()):U("error","Discard Failed",$.error||"Could not discard changes")}catch{U("error","Discard Failed","Network error")}finally{we(null)}},[L,o,r,U]),Y=s.useCallback((N,$,O)=>{N.preventDefault(),N.stopPropagation(),I({isOpen:!0,position:{x:N.clientX,y:N.clientY},file:$,status:O})},[]),le=s.useCallback(async(N,$)=>{if(o)try{const O=await V(A("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:[{path:N.path,status:$}],directory:o})}),Ee=await O.json();O.ok&&Ee.success?(U("success","Discarded",`Restored ${N.name}`),r()):U("error","Discard Failed",Ee.error||"Could not discard changes")}catch{U("error","Discard Failed","Network error")}},[o,r,U]),me=s.useCallback(async N=>{try{await navigator.clipboard.writeText(N),U("success","Copied","Full path copied")}catch{U("error","Copy Failed","Could not copy path")}},[U]),T=s.useCallback(async N=>{const $=o&&N.startsWith(o+"/")?N.slice(o.length+1):N;try{await navigator.clipboard.writeText($),U("success","Copied","Relative path copied")}catch{U("error","Copy Failed","Could not copy path")}},[o,U]),S=s.useMemo(()=>{if(!se)return[];const{file:N,status:$}=se,O=[];return $==="conflict"&&k?O.push({id:"open-conflict",label:y("terminal:fileExplorer.gitContextMenu.openConflictResolver"),icon:e.jsx(D,{name:"warn",size:14}),onClick:()=>k(N.path)}):$!=="deleted"&&O.push({id:"open-file",label:y("terminal:fileExplorer.gitContextMenu.openFile"),icon:e.jsx(D,{name:"file-text",size:14}),onClick:()=>l(N.path,$)}),$!=="conflict"&&O.push({id:"stage-file",label:y("terminal:fileExplorer.gitContextMenu.stageFile"),icon:e.jsx(D,{name:"plus",size:14}),onClick:()=>{i([N.path])}}),$!=="deleted"&&O.push({id:"download-file",label:"Download File",icon:e.jsx(D,{name:"download",size:14}),onClick:()=>rn(N.path,N.path.split("/").pop()||"file")}),O.push({id:"divider-1",label:"",divider:!0,onClick:()=>{}}),($==="modified"||$==="deleted"||$==="renamed"||$==="conflict")&&O.push({id:"discard-changes",label:y("terminal:fileExplorer.gitContextMenu.discardChanges"),icon:e.jsx(D,{name:"revert",size:14}),danger:!0,onClick:()=>{le(N,$)}}),($==="untracked"||$==="added")&&O.push({id:"delete-file",label:y("terminal:fileExplorer.gitContextMenu.deleteFile"),icon:e.jsx(D,{name:"trash",size:14}),danger:!0,onClick:()=>{le(N,$)}}),O.push({id:"divider-2",label:"",divider:!0,onClick:()=>{}}),O.push({id:"copy-full-path",label:y("terminal:fileExplorer.gitContextMenu.copyFullPath"),icon:e.jsx(D,{name:"pin",size:14}),onClick:()=>{me(N.path)}}),O.push({id:"copy-relative-path",label:y("terminal:fileExplorer.gitContextMenu.copyRelativePath"),icon:e.jsx(D,{name:"clipboard",size:14}),onClick:()=>{T(N.path)}}),F&&$!=="deleted"&&O.push({id:"reveal-in-tree",label:y("terminal:fileExplorer.gitContextMenu.revealInTree"),icon:e.jsx(D,{name:"target",size:14}),onClick:()=>F(N.path)}),O},[se,l,i,k,F,le,me,T,y]),te=s.useCallback((N,$)=>{N.preventDefault(),N.stopPropagation(),Z({isOpen:!0,position:{x:N.clientX,y:N.clientY},node:$})},[]),ae=s.useCallback(N=>!N.isDirectory&&N.file?[N.file]:N.children.flatMap($=>ae($)),[]),pe=s.useCallback(async N=>{if(!o)return;const $=ae(N);if($.length!==0)try{const O=await V(A("/api/files/git-discard"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({files:$.map(Se=>({path:Se.path,status:Se.status})),directory:o})}),Ee=await O.json();O.ok&&Ee.success?(U("success","Discarded",`Reverted ${$.length} file(s) in ${N.name}`),r()):U("error","Discard Failed",Ee.error||"Could not discard changes")}catch{U("error","Discard Failed","Network error")}},[o,ae,r,U]),oe=s.useMemo(()=>{if(!B)return[];const{node:N}=B,$=ae(N);return[{id:"discard-dir",label:`Discard Changes (${$.length} files)`,icon:e.jsx(D,{name:"revert",size:14}),danger:!0,onClick:()=>{pe(N)}},{id:"stage-dir",label:`Stage All (${$.length} files)`,icon:e.jsx(D,{name:"plus",size:14}),onClick:()=>{i($.map(O=>O.path))}},{id:"divider-download",label:"",divider:!0,onClick:()=>{}},{id:"download-dir",label:"Download Folder (.zip)",icon:e.jsx(D,{name:"download",size:14}),onClick:()=>ln(N.path,N.name)}]},[B,ae,pe,i]),W=s.useCallback(N=>{C($=>{const O=new Set($);return O.has(N)?O.delete(N):O.add(N),O})},[]),{conflictFiles:ye,conflictTree:Ge,changesFiles:_e,changesTree:vt,untrackedFiles:He,untrackedTree:Gt,allDirPaths:dt}=s.useMemo(()=>{if(!t||!t.isGitRepo||t.files.length===0)return{conflictFiles:[],conflictTree:[],changesFiles:[],changesTree:[],untrackedFiles:[],untrackedTree:[],allDirPaths:new Set};const N=new Set,$=t.files.filter(De=>De.status==="conflict"),O=Ht($);At(O,N);const Ee=t.files.filter(De=>De.status==="modified"||De.status==="added"||De.status==="deleted"||De.status==="renamed"),Se=Ht(Ee);At(Se,N);const Ct=t.files.filter(De=>De.status==="untracked"),Je=Ht(Ct);return At(Je,N),{conflictFiles:$,conflictTree:O,changesFiles:Ee,changesTree:Se,untrackedFiles:Ct,untrackedTree:Je,allDirPaths:N}},[t]);s.useEffect(()=>{C(dt)},[dt]),s.useEffect(()=>{t!=null&&t.files&&R(new Set(t.files.map(N=>N.path)))},[t==null?void 0:t.files]);const We=s.useCallback(()=>{_e.length!==0&&we({files:_e,label:`${_e.length} changed files`})},[_e]),ut=s.useCallback(()=>{He.length!==0&&we({files:He,label:`${He.length} unversioned files`})},[He]),wt=s.useCallback(()=>{ye.length!==0&&we({files:ye,label:`${ye.length} conflicted files`})},[ye]),ht=ye.length>0;s.useEffect(()=>{if(Q){const N=Q.type==="error"?8e3:4e3,$=setTimeout(()=>ne(null),N);return()=>clearTimeout($)}},[Q]);const _t=s.useCallback(async()=>{const N=!w;if(re(N),N&&o){K(M);try{const O=await(await V(A(`/api/files/git-log-message?path=${encodeURIComponent(o)}`))).json();O.message&&H(O.message)}catch{}}else H(G)},[w,o,M,G]),qe=s.useCallback(N=>{R($=>{const O=new Set($);return O.has(N)?O.delete(N):O.add(N),O})},[]),Ce=s.useCallback(()=>{if(!(t!=null&&t.files))return;const N=t.files.map(O=>O.path),$=N.every(O=>_.has(O));R($?new Set:new Set(N))},[t==null?void 0:t.files,_]),ce=s.useCallback(async N=>{if(!(!o||!M.trim()||_.size===0||P)){X(!0),ne(null);try{const $=await V(A("/api/files/git-commit"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o,message:M.trim(),amend:w,paths:Array.from(_)})}),O=await $.json();if(!$.ok||!O.success){ne({type:"error",text:O.error||"Commit failed"}),X(!1);return}if(N)try{const Ee=await V(A("/api/files/git-push"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({directory:o})}),Se=await Ee.json();Ee.ok&&Se.success?ne({type:"success",text:y("terminal:fileExplorer.committedAndPushed")}):ne({type:"error",text:y("terminal:fileExplorer.committedButPushFailed",{error:Se.error||"Unknown error"})})}catch{ne({type:"error",text:y("terminal:fileExplorer.committedButPushFailed",{error:"Network error"})})}else ne({type:"success",text:y("terminal:fileExplorer.committedSuccessfully")});H(""),K(""),re(!1),r(),d==null||d()}catch($){ne({type:"error",text:$.message||"Commit failed"})}finally{X(!1)}}},[o,M,w,_,P,r,d]);if(n)return e.jsx("div",{className:"git-changes-loading",children:y("terminal:fileExplorer.loadingGitStatus")});if(!t||!t.isGitRepo)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(D,{name:"package",size:32})}),e.jsx("div",{className:"git-empty-text",children:y("terminal:fileExplorer.notGitRepo")})]});if(t.files.length===0)return e.jsxs("div",{className:"git-changes-empty",children:[e.jsx("div",{className:"git-empty-icon",children:e.jsx(D,{name:"sparkle",size:32})}),e.jsx("div",{className:"git-empty-text",children:y("terminal:fileExplorer.workingTreeClean")}),e.jsx("div",{className:"git-empty-branch",children:y("terminal:fileExplorer.onBranch",{branch:t.branch})})]});const Ne=N=>{i([N])},ke=()=>{const N=He.map($=>$.path);N.length>0&&i(N)},Ae=(N,$)=>{$==="conflict"&&k?k(N):l(N,$)};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(D,{name:"git-branch",size:12})}),t.branch]}),t.counts&&e.jsxs("div",{className:"git-changes-summary",children:[(t.counts.conflict??0)>0&&e.jsxs("span",{className:"git-count conflict",children:[t.counts.conflict,"C"]}),t.counts.modified>0&&e.jsxs("span",{className:"git-count modified",children:[t.counts.modified,"M"]}),t.counts.added>0&&e.jsxs("span",{className:"git-count added",children:[t.counts.added,"A"]}),t.counts.deleted>0&&e.jsxs("span",{className:"git-count deleted",children:[t.counts.deleted,"D"]}),t.counts.untracked>0&&e.jsxs("span",{className:"git-count untracked",children:[t.counts.untracked,"?"]})]}),e.jsxs("div",{className:"git-view-toggle",children:[e.jsx("button",{className:`git-view-toggle-btn ${E==="flat"?"active":""}`,onClick:()=>f("flat"),title:y("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 ${E==="tree"?"active":""}`,onClick:()=>f("tree"),title:y("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:y("common:buttons.refresh"),children:e.jsx(D,{name:"refresh",size:12})})]}),g&&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:y("terminal:fileExplorer.mergeInProgress",{branch:b?` (${b})`:""})}),e.jsxs("div",{className:"git-merge-actions",children:[e.jsx("button",{className:"git-merge-continue-btn",onClick:p,disabled:ht,title:y(ht?"terminal:fileExplorer.resolveAllConflictsFirst":"terminal:fileExplorer.continueMerge"),children:y("terminal:fileExplorer.continue")}),e.jsx("button",{className:"git-merge-abort-btn",onClick:v,title:y("terminal:fileExplorer.abortMerge"),children:y("terminal:fileExplorer.abort")})]})]}),e.jsxs("div",{className:"git-changes-list",children:[e.jsx(ns,{groupLabel:y("terminal:fileExplorer.gitGroups.conflicts"),groupIcon:"C",groupColor:"#ff5555",files:ye,treeNodes:Ge,viewMode:E,selectedPath:c,expandedDirs:j,onToggleDir:W,onFileSelect:Ae,checkedFiles:_,onToggleCheck:qe,onContextMenu:Y,onDirContextMenu:te,onDiscardFile:ee,onDiscardAll:wt}),e.jsx(ns,{groupLabel:y("terminal:fileExplorer.gitGroups.changes"),groupIcon:"~",groupColor:"#c89a5a",files:_e,treeNodes:vt,viewMode:E,selectedPath:c,expandedDirs:j,onToggleDir:W,onFileSelect:Ae,checkedFiles:_,onToggleCheck:qe,onContextMenu:Y,onDirContextMenu:te,onDiscardFile:ee,onDiscardAll:We}),e.jsx(ns,{groupLabel:y("terminal:fileExplorer.gitGroups.unversioned"),groupIcon:"?",groupColor:"#6ab8c8",files:He,treeNodes:Gt,viewMode:E,selectedPath:c,expandedDirs:j,onToggleDir:W,onFileSelect:Ae,onStageFile:Ne,onStageAll:ke,stagingPaths:h,checkedFiles:_,onToggleCheck:qe,onContextMenu:Y,onDirContextMenu:te,onDiscardFile:ee,onDiscardAll:ut})]}),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:w,onChange:_t}),y("terminal:fileExplorer.amend")]}),e.jsx("span",{className:"git-commit-file-count",children:y("terminal:fileExplorer.fileCount",{count:_.size})}),e.jsx("button",{className:"git-commit-select-toggle",onClick:Ce,title:_.size===t.files.length?y("terminal:fileExplorer.deselectAll"):y("terminal:fileExplorer.selectAll"),children:_.size===t.files.length?y("terminal:fileExplorer.deselectAll"):y("terminal:fileExplorer.selectAll")})]}),e.jsx("textarea",{ref:ue,className:"git-commit-message",placeholder:y("terminal:fileExplorer.commitMessagePlaceholder"),value:M,onChange:N=>H(N.target.value),onKeyDown:N=>{(N.metaKey||N.ctrlKey)&&N.key==="Enter"&&(N.preventDefault(),ce(!1)),(N.metaKey||N.ctrlKey)&&N.shiftKey&&N.key==="Enter"&&(N.preventDefault(),ce(!0)),N.stopPropagation()},rows:3,disabled:P}),Q&&e.jsx("div",{className:`git-commit-status ${Q.type}`,children:Q.text}),e.jsxs("div",{className:"git-commit-actions",children:[e.jsx("button",{className:"git-commit-btn",onClick:()=>ce(!1),disabled:!M.trim()||_.size===0||P,title:y("terminal:fileExplorer.commitCtrlEnter"),children:y(P?"terminal:fileExplorer.committing":"terminal:fileExplorer.commitAction")}),e.jsx("button",{className:"git-commit-push-btn",onClick:()=>ce(!0),disabled:!M.trim()||_.size===0||P,title:y("terminal:fileExplorer.commitAndPushCtrlShiftEnter"),children:P?"...":y("terminal:fileExplorer.commitAndPush")})]})]}),se&&e.jsx(lt,{isOpen:se.isOpen,position:se.position,worldPosition:{x:0,z:0},actions:S,onClose:()=>I(null)}),B&&e.jsx(lt,{isOpen:B.isOpen,position:B.position,worldPosition:{x:0,z:0},actions:oe,onClose:()=>Z(null)}),L&&e.jsx("div",{className:"git-discard-confirm-overlay",onClick:()=>we(null),children:e.jsxs("div",{className:"git-discard-confirm",onClick:N=>N.stopPropagation(),children:[e.jsx("p",{children:L.files.some(N=>N.status==="untracked"||N.status==="added")?e.jsxs(e.Fragment,{children:["Delete ",e.jsx("strong",{children:L.label}),"?"]}):e.jsxs(e.Fragment,{children:["Discard changes to ",e.jsx("strong",{children:L.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:()=>we(null),children:"Cancel"}),e.jsx("button",{className:"git-discard-confirm-btn",onClick:m,children:L.files.some(N=>N.status==="untracked"||N.status==="added")?"Delete":"Discard"})]})]})})]})}const mn=s.memo(yr,(t,n)=>t.loading!==n.loading||t.selectedPath!==n.selectedPath||t.stagingPaths!==n.stagingPaths||t.currentFolder!==n.currentFolder||t.mergeInProgress!==n.mergeInProgress||t.mergingBranch!==n.mergingBranch?!1:t.gitStatus===null&&n.gitStatus===null?!0:!(t.gitStatus===null||n.gitStatus===null||t.gitStatus.isGitRepo!==n.gitStatus.isGitRepo||t.gitStatus.branch!==n.gitStatus.branch||t.gitStatus.files.length!==n.gitStatus.files.length||t.gitStatus.mergeInProgress!==n.gitStatus.mergeInProgress));mn.displayName="GitChanges";const br=s.memo(function({tab:n,isActive:l,onSelect:c,onClose:r,onContextMenu:i}){const{t:h}=ie(["terminal"]),o={name:n.filename,path:n.path,isDirectory:!1,extension:n.extension},d=s.useCallback(()=>{c(n.path)},[c,n.path]),g=s.useCallback(v=>{v.button===1&&(v.preventDefault(),v.stopPropagation(),r(n.path))},[r,n.path]),b=s.useCallback(v=>{v.preventDefault(),v.stopPropagation(),r(n.path)},[r,n.path]),p=s.useCallback(v=>{v.preventDefault(),v.stopPropagation(),i(v,n)},[i,n]);return e.jsxs("div",{className:`file-tab ${l?"active":""}`,onClick:d,onMouseDown:g,onContextMenu:p,title:n.path,children:[e.jsx("img",{className:"file-tab-icon",src:is(o),alt:"file"}),e.jsx("span",{className:"file-tab-name",children:n.filename}),e.jsx("button",{className:"file-tab-close",onClick:b,title:h("terminal:fileExplorer.closeMiddleClick"),children:"×"})]})});function jr(t){return typeof t.path=="string"&&t.path.startsWith("/")}function vr({tabs:t,activeTabPath:n,onSelectTab:l,onCloseTab:c,onCloseAllTabs:r,onShowGitHistory:i}){const{t:h}=ie(["terminal"]),[o,d]=s.useState(null),g=s.useCallback((v,k)=>{d({isOpen:!0,position:{x:v.clientX,y:v.clientY},tab:k})},[]),b=s.useCallback(()=>d(null),[]),p=s.useMemo(()=>{if(!o)return[];const v=o.tab,k=!!i&&jr(v),F=[{id:"git-history",label:h("terminal:fileExplorer.showGitHistory")??"Show Git History",icon:e.jsx(D,{name:"git-commit",size:14}),disabled:!k,onClick:()=>{k&&i(v.path)}}];return r&&F.push({id:"divider-close-all",label:"",divider:!0,onClick:()=>{}},{id:"close-all-tabs",label:h("terminal:fileExplorer.closeAllTabs")??"Close all tabs",icon:e.jsx(D,{name:"cross",size:14}),danger:!0,onClick:()=>r()}),F},[o,i,r,h]);return t.length===0?null:e.jsxs("div",{className:"file-tabs-bar",children:[e.jsx("div",{className:"file-tabs-container",children:t.map(v=>e.jsx(br,{tab:v,isActive:n===v.path,onSelect:l,onClose:c,onContextMenu:g},v.path))}),o&&e.jsx(lt,{isOpen:o.isOpen,position:o.position,worldPosition:{x:0,z:0},actions:p,onClose:b})]})}const pn=s.memo(vr,(t,n)=>{if(t.activeTabPath!==n.activeTabPath||t.tabs.length!==n.tabs.length||t.onShowGitHistory!==n.onShowGitHistory||t.onCloseAllTabs!==n.onCloseAllTabs)return!1;for(let l=0;l<t.tabs.length;l++)if(t.tabs[l].path!==n.tabs[l].path)return!1;return!0});pn.displayName="FileTabs";const wr=s.memo(function({currentFolder:n,gitStatus:l,onBranchChanged:c,onMerge:r,onCompare:i,onPullConflicts:h}){const{t:o}=ie(["terminal","common"]),[d,g]=s.useState(!1),[b,p]=s.useState(""),[v,k]=s.useState(!1),[F,y]=s.useState(""),[E,f]=s.useState(!1),[j,C]=s.useState(null),[M,H]=s.useState(null),G=s.useRef(null),K=s.useRef(null),w=s.useRef(null),{branches:re,loading:_,operationInProgress:R,loadBranches:P,checkoutBranch:X,createBranch:Q,pullFromRemote:ne,pushToRemote:ue}=ls();s.useEffect(()=>{d&&n&&(P(n),setTimeout(()=>{var S;return(S=K.current)==null?void 0:S.focus()},50)),d||(p(""),k(!1),y(""),C(null))},[d,n,P]),s.useEffect(()=>{if(j){const S=j.type==="error"?8e3:3e3,te=setTimeout(()=>C(null),S);return()=>clearTimeout(te)}},[j]),s.useEffect(()=>{v&&setTimeout(()=>{var S;return(S=w.current)==null?void 0:S.focus()},50)},[v]),s.useEffect(()=>{if(!d)return;const S=ae=>{const pe=ae.target;!pe.closest(".branch-widget-selector")&&!pe.closest(".branch-widget-dropdown")&&g(!1)},te=ae=>{ae.key==="Escape"&&(ae.preventDefault(),ae.stopPropagation(),g(!1))};return document.addEventListener("click",S),document.addEventListener("keydown",te,!0),()=>{document.removeEventListener("click",S),document.removeEventListener("keydown",te,!0)}},[d]);const U=s.useCallback(async S=>{if(!n||R||S.isCurrent)return;const te=await X(n,S.name);te.success?(C({type:"success",text:o("terminal:fileExplorer.switchedToBranch",{branch:te.branch||S.name})}),c(),P(n)):C({type:"error",text:te.error||o("terminal:fileExplorer.checkoutFailed")})},[n,R,X,c,P]),se=s.useCallback(async()=>{if(!n||!F.trim()||R)return;const S=await Q(n,F.trim());S.success?(C({type:"success",text:o("terminal:fileExplorer.createdBranch",{branch:S.branch})}),k(!1),y(""),c(),P(n)):C({type:"error",text:S.error||o("terminal:fileExplorer.createBranchFailed")})},[n,F,R,Q,c,P]),I=s.useCallback(async()=>{if(!n||R)return;const S=await ne(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.`}),h==null||h(S.stashConflicts),g(!1)):S.stashed?C({type:"success",text:"Pull complete. Local changes were auto-stashed and restored."}):C({type:"success",text:o("terminal:fileExplorer.pullComplete")}),c(),P(n)):S.conflicts&&S.conflicts.length>0?(C({type:"error",text:`Pull conflicts: ${S.conflicts.length} file(s)`}),h==null||h(S.conflicts),g(!1)):C({type:"error",text:S.error||o("terminal:fileExplorer.pullFailed")})},[n,R,ne,c,P,h]),B=s.useCallback(async()=>{if(!n||R)return;const S=await ue(n);S.success?C({type:"success",text:o("terminal:fileExplorer.pushComplete")}):C({type:"error",text:S.error||o("terminal:fileExplorer.pushFailed")})},[n,R,ue]),[Z,L]=s.useState(!1),we=s.useCallback(async()=>{if(!(!n||R||Z)){L(!0);try{const S=await V(A("/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"}),c(),P(n);else{const te=await S.json().catch(()=>({error:"Fetch failed"}));C({type:"error",text:te.error||"Fetch failed"})}}catch{C({type:"error",text:"Fetch failed"})}finally{L(!1)}}},[n,R,Z,c,P]),ee=(l==null?void 0:l.branch)||"unknown",m=!!R,Y=s.useCallback((S,te)=>{te.isCurrent||(S.preventDefault(),S.stopPropagation(),H({isOpen:!0,position:{x:S.clientX,y:S.clientY},branch:te.name}))},[]),le=s.useMemo(()=>{if(!M)return[];const S=!!R||(l==null?void 0:l.mergeInProgress);return[{id:"compare",label:o("terminal:fileExplorer.showDiffWith",{branch:M.branch}),icon:e.jsx(D,{name:"arrows-horizontal",size:14}),disabled:!!R,onClick:()=>{i==null||i(M.branch),g(!1)}},{id:"merge",label:o("terminal:fileExplorer.mergeInto",{source:M.branch,target:ee}),icon:"⤵",disabled:!!S,onClick:()=>{r&&r(M.branch),g(!1)}},{id:"divider-1",label:"",divider:!0,onClick:()=>{}},{id:"checkout",label:o("terminal:fileExplorer.checkoutBranch",{branch:M.branch}),icon:e.jsx(D,{name:"git-branch",size:14}),disabled:!!R,onClick:()=>{const te=re.find(ae=>ae.name===M.branch);te&&U(te)}}]},[M,R,l==null?void 0:l.mergeInProgress,ee,r,i,re,U]),me=s.useMemo(()=>{const S=re.filter(ae=>!ae.isRemote);if(!b)return S;const te=b.toLowerCase();return S.filter(ae=>ae.name.toLowerCase().includes(te))},[re,b]),T=s.useMemo(()=>{const S=re.filter(ae=>ae.isRemote);if(!b)return S;const te=b.toLowerCase();return S.filter(ae=>ae.name.toLowerCase().includes(te))},[re,b]);return e.jsxs("div",{className:"branch-widget",style:{position:"relative"},children:[e.jsxs("div",{className:"branch-widget-selector",onClick:S=>{S.stopPropagation(),g(!d)},title:`Branch: ${ee}`,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:ee}),e.jsx("span",{className:"branch-widget-arrow",children:"▼"})]}),d&&e.jsxs("div",{className:"branch-widget-dropdown",ref:G,children:[e.jsx("div",{className:"branch-widget-search",children:e.jsx("input",{ref:K,type:"text",className:"branch-widget-search-input",placeholder:o("terminal:fileExplorer.searchBranches"),value:b,onChange:S=>p(S.target.value),onKeyDown:S=>S.stopPropagation()})}),j&&e.jsx("div",{className:`branch-widget-status ${j.type}`,children:j.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 ${m||Z?"disabled":""}`,onClick:we,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:Z?"Fetching...":"Fetch"})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick:I,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(R==="pull"?"terminal:fileExplorer.pulling":"terminal:fileExplorer.pull")})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick: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 4l4 4h-2.5v5h-3V8H4l4-4z"})})}),e.jsx("span",{className:"branch-widget-action-label",children:o(R==="push"?"terminal:fileExplorer.pushing":"terminal:fileExplorer.push")})]}),e.jsxs("div",{className:`branch-widget-action-item ${m?"disabled":""}`,onClick:()=>{m||k(!v)},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")})]})]}),v&&e.jsxs("div",{className:"branch-widget-new-branch",children:[e.jsx("input",{ref:w,type:"text",className:"branch-widget-new-branch-input",placeholder:o("terminal:fileExplorer.branchNamePlaceholder"),value:F,onChange:S=>y(S.target.value),onKeyDown:S=>{S.stopPropagation(),S.key==="Enter"&&se(),S.key==="Escape"&&(k(!1),y(""))}}),e.jsx("button",{className:"branch-widget-new-branch-confirm",onClick:se,disabled:!F.trim()||m,children:R==="create"?"...":o("common:buttons.create")})]}),e.jsxs("div",{className:"branch-widget-section-header",children:[o("terminal:fileExplorer.localBranches"),_&&e.jsxs("span",{className:"branch-widget-loading-hint",children:[" ",o("terminal:fileExplorer.loading")]})]}),e.jsxs("div",{className:"branch-widget-branch-list",children:[me.length===0&&!_&&e.jsx("div",{className:"branch-widget-empty",children:o("terminal:fileExplorer.noBranchesFound")}),me.map(S=>e.jsxs("div",{className:`branch-widget-branch-item ${S.isCurrent?"current":""} ${m?"disabled":""}`,onClick:()=>U(S),onContextMenu:te=>Y(te,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))]}),T.length>0&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"branch-widget-section-header clickable",onClick:()=>f(!E),children:[e.jsx("span",{className:"branch-widget-section-toggle",children:E?"▾":"▸"}),o("terminal:fileExplorer.remoteBranches",{count:T.length})]}),E&&e.jsx("div",{className:"branch-widget-branch-list",children:T.map(S=>e.jsxs("div",{className:`branch-widget-branch-item remote ${m?"disabled":""}`,onClick:()=>U(S),onContextMenu:te=>Y(te,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))})]})]}),M&&e.jsx(lt,{isOpen:M.isOpen,position:M.position,worldPosition:{x:0,z:0},actions:le,onClose:()=>H(null)})]})});function Cr(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function $t(t,n){if(!t)return"";const l=Us.languages[n];return l?Us.highlight(t,l,n):Cr(t)}function Nr(t){const n=[],l=t.split(`
|
|
9
9
|
`);let c=[],r=!1,i=[],h=[],o=!1;for(const d of l)d.startsWith("<<<<<<<")?(c.length>0&&(n.push({type:"unchanged",content:c.join(`
|
|
10
10
|
`)}),c=[]),r=!0,o=!1,i=[],h=[]):d.startsWith("=======")&&r?o=!0:d.startsWith(">>>>>>>")&&r?(n.push({type:"conflict",ours:i.join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-
|
|
2
|
-
import{a9 as e,a1 as a}from"./main-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/web-DAWG2rda.js","assets/main-DuaHyH5t.js","assets/vendor-react--Eh9ivFN.js","assets/vendor-three-DYBBrXTx.js","assets/main-BdVckSM5.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a9 as e,a1 as a}from"./main-DuaHyH5t.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";var i;(function(r){r.Heavy="HEAVY",r.Medium="MEDIUM",r.Light="LIGHT"})(i||(i={}));var t;(function(r){r.Success="SUCCESS",r.Warning="WARNING",r.Error="ERROR"})(t||(t={}));const E=e("Haptics",{web:()=>a(()=>import("./web-DAWG2rda.js"),__vite__mapDeps([0,1,2,3,4])).then(r=>new r.HapticsWeb)});export{E as Haptics,i as ImpactStyle,t as NotificationType};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as n,aW as $a,aX as oa,N as ba,aY as _a,j as e,aZ as wa,a_ as Da,u as sa,a$ as za,b0 as Ra,b1 as Oa,b2 as Fa,b3 as Ba,aj as Wa,b4 as Ha,b5 as Ua,aC as va,m as Vt,S as E,y as qt,b6 as ta,b7 as ca,b8 as Lt,b9 as xe,ba as Ga,s as g,K as ja,a0 as Ca,f as ka,bb as Xa,bc as da,bd as ua,I as d,be as Va,bf as aa,aF as Na,bg as qa,n as ya,ad as Aa,bh as Sa,bi as Ya,bj as Ka,bk as Za,ai as Ja,bl as Qa,bm as en,bn as tn,aI as an,aJ as nn,aK as sn,bo as ln,bp as rn,bq as na,Z as on,U as cn,br as dn,bs as un,bt as mn,bu as pn,bv as fn,bw as hn,bx as gn,by as xn,bz as Yt,bA as ma,bB as bn,bC as _n,bD as wn,z as vn,bE as jn,bF as Cn,bG as kn,bH as Nn,bI as ct,bJ as yn,bK as An,bL as Sn,bM as En,bN as wt,bO as In,bP as Mn,bQ as Tn,bR as Ln,p as Pn,D as $n,t as Kt,o as Dn}from"./main-DuaHyH5t.js";import{g as zn}from"./area-logos-ml30JJUi.js";import"./vendor-react--Eh9ivFN.js";import"./vendor-three-DYBBrXTx.js";function Rn(c){const o=n.useRef(c);o.current=c,n.useEffect(()=>{if(!$a())return;let m=null,b=!1;return oa.addListener("backButton",()=>{o.current()==="exit"&&oa.exitApp()}).then(y=>{b?y.remove():m=y}),()=>{b=!0,m&&(m.remove(),m=null)}},[])}async function On(c){const o=ba(),m=await fetch(`${_a()}/api/agents/${c}/terminal`,{method:"POST",headers:{Authorization:`Bearer ${o}`}});if(!m.ok){const b=await m.json().catch(()=>({}));throw new Error((b==null?void 0:b.error)||`Failed to start terminal (${m.status})`)}return m.json()}async function Fn(c){const o=ba();await fetch(`${_a()}/api/agents/${c}/terminal`,{method:"DELETE",headers:{Authorization:`Bearer ${o}`}})}const vt=new Map;function Bn({agentId:c}){const[o,m]=n.useState(null),[b,y]=n.useState(null);return n.useEffect(()=>{let M=!1;const A=vt.get(c);return A&&(clearTimeout(A),vt.delete(c)),m(null),y(null),On(c).then(k=>{M||m(k.url)}).catch(k=>{M||y(k instanceof Error?k.message:"Failed to start terminal")}),()=>{M=!0;const k=vt.get(c);k&&clearTimeout(k),vt.set(c,setTimeout(()=>{vt.delete(c),Fn(c)},2500))}},[c]),b?e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:b})}):o?e.jsx("div",{className:"flat-classic-terminal",children:e.jsx(wa,{terminalUrl:o,visible:!0})}):e.jsx("div",{className:"flat-classic-terminal flat-classic-terminal--message",children:e.jsx("span",{children:"Attaching to interactive session…"})})}const Zt=new Map,Wn=6e4;function pa(c){return Number.isFinite(c)?Math.abs(c)>=1e3?c.toLocaleString(void 0,{maximumFractionDigits:0}):c.toLocaleString(void 0,{maximumFractionDigits:2}):String(c)}function Hn(c,o){var y,M,A;const m=[];if(!c.rateLimits)return m;if(c.provider==="claude"){const k=c,K=[{key:"fiveHour",label:o("terminal:usage.currentSession"),window:k.rateLimits.fiveHour},{key:"sevenDay",label:o("terminal:usage.currentWeekAll"),window:k.rateLimits.sevenDay},{key:"sevenDayOpus",label:o("terminal:usage.currentWeekOpus"),window:k.rateLimits.sevenDayOpus},{key:"sevenDayFable",label:o("terminal:usage.currentWeekFable"),window:k.rateLimits.sevenDayFable}];for(const j of K)(j.window||j.key==="sevenDayFable")&&m.push(j);return m}const b=c;return(y=b.rateLimits)!=null&&y.weekly&&m.push({key:"weekly",label:o("terminal:usage.weeklyLimit"),window:b.rateLimits.weekly}),(M=b.rateLimits)!=null&&M.monthly&&m.push({key:"monthly",label:o("terminal:usage.monthlyLimit"),window:b.rateLimits.monthly}),(A=b.rateLimits)!=null&&A.onDemand&&m.push({key:"onDemand",label:o("terminal:usage.onDemandLimit"),window:b.rateLimits.onDemand}),m}function Un({agentId:c,contextSummary:o}){const{t:m}=sa(["terminal","common"]),[b,y]=n.useState(()=>{var R;return((R=Zt.get(c))==null?void 0:R.snapshot)??null}),[M,A]=n.useState(!1),[k,K]=n.useState(null),j=n.useRef(0);n.useEffect(()=>{const R=Zt.get(c);if(R&&Date.now()-R.fetchedAt<Wn){y(R.snapshot);return}const be=++j.current;A(!0),K(null),za(c).then(L=>{be===j.current&&(Zt.set(c,{snapshot:L,fetchedAt:Date.now()}),y(L),A(!1))}).catch(L=>{be===j.current&&(K(L.message||"Failed to load plan limits"),A(!1))})},[c]);const v=b?Hn(b,m):[];return e.jsxs("div",{className:"plan-limits-tooltip",children:[o&&e.jsx("div",{className:"plan-limits-tooltip__context",children:o}),e.jsx("div",{className:"plan-limits-tooltip__title",children:m("terminal:usage.limits")}),M&&!b&&e.jsxs("div",{className:"plan-limits-tooltip__muted",children:[m("common:status.loading"),"…"]}),!M&&k&&!b&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:m("terminal:usage.limitsError",{message:k})}),v.length>0?e.jsx("div",{className:"plan-limits-tooltip__gauges",children:v.map(({key:R,label:be,window:L})=>{const _e=L?Math.max(0,Math.min(100,L.utilization)):0,te=Oa(_e),ue=L!=null&&typeof L.used=="number"&&typeof L.limit=="number"&&Number.isFinite(L.used)&&Number.isFinite(L.limit);return e.jsxs("div",{className:"plan-limits-tooltip__gauge",children:[e.jsxs("div",{className:"plan-limits-tooltip__gauge-head",children:[e.jsx("span",{className:"plan-limits-tooltip__gauge-label",children:be}),e.jsx("span",{className:"plan-limits-tooltip__gauge-percent",style:{color:te},children:m("terminal:usage.percentUsed",{percent:Math.round(_e)})})]}),e.jsx("div",{className:"plan-limits-tooltip__bar",children:e.jsx("div",{className:"plan-limits-tooltip__bar-fill",style:{width:`${_e}%`,background:te}})}),e.jsxs("div",{className:"plan-limits-tooltip__reset",children:[L&&m("terminal:usage.resets",{time:Ra(L.resetsAt)}),ue&&e.jsx("span",{style:{marginLeft:8},children:m("terminal:usage.creditsUsed",{used:pa(L.used),limit:pa(L.limit)})})]})]},R)})}):b&&!M&&e.jsx("div",{className:"plan-limits-tooltip__muted",children:b.rateLimitsError?m("terminal:usage.limitsError",{message:b.rateLimitsError}):b.cliHint})]})}function Gn({agentId:c,disabled:o,contextSummary:m,children:b}){return e.jsx(Da,{position:"top",maxWidth:320,disabled:o,className:"plan-limits-tooltip-wrapper",triggerStyle:{display:"inline-flex",alignItems:"center"},content:e.jsx(Un,{agentId:c,contextSummary:m}),children:b})}const Xn=n.memo(function({className:o=""}){const{t:m}=sa(["common"]),[b,y]=Fa(),M=n.useRef(null),[A,k]=n.useState(null);n.useLayoutEffect(()=>{const j=M.current;if(!j)return;const v=j.querySelector(".view-mode-toggle__btn--active");v&&k({left:v.offsetLeft,width:v.offsetWidth})},[b]);const K=n.useCallback(j=>{if(j!==b){if(typeof window<"u"&&window.dispatchEvent(new CustomEvent("tide:viewmode-switch-pressed",{detail:{mode:j}})),j==="3d"){requestAnimationFrame(()=>y(j));return}y(j)}},[b,y]);return e.jsxs("div",{className:`view-mode-toggle ${o}`,ref:M,children:[A&&e.jsx("div",{className:"view-mode-toggle__indicator",style:{left:A.left,width:A.width}}),Ba.map(j=>e.jsxs("button",{className:`view-mode-toggle__btn ${b===j?"view-mode-toggle__btn--active":""}`,onClick:()=>K(j),title:m(`common:viewMode.descriptions.${j}`),children:[e.jsxs("span",{className:"view-mode-toggle__icon",children:[j==="2d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"21"})]}),j==="3d"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),j==="flat"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"3",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"3",y:"13",width:"8",height:"8",rx:"1"}),e.jsx("rect",{x:"13",y:"13",width:"8",height:"8",rx:"1"})]}),j==="dashboard"&&e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),e.jsx("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),e.jsx("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]})]}),e.jsx("span",{className:"view-mode-toggle__label",children:m(`common:viewMode.labels.${j}`)})]},j))]})}),Pt=3,$t=280,fa=320,Jt=240,ha=64,Vn=["simple","chat","advanced"],ga={simple:"Simple",chat:"Chat",advanced:"Advanced"},xa={simple:"○",chat:"◐",advanced:"◉"},qn={simple:"Simple view — clean messages only",chat:"Chat view — assistant replies (no tool calls)",advanced:"Advanced view — everything including tools"},Qt="flat-clear-context",Ea="tide:flat-embedded-panels";function Ia(){try{const c=localStorage.getItem(Ea),o=c?JSON.parse(c):{};return o&&typeof o=="object"?o:{}}catch{return{}}}function ea(c,o){try{const m=Ia();o?m[c]=o:delete m[c],localStorage.setItem(Ea,JSON.stringify(m))}catch{}}function Yn(c){const o=c.split("/").filter(Boolean);return o.length===0?c:o.slice(-2).join("/")}function Kn(c){if(c.provider==="codex"){const M=c.codexModel||"gpt-5.6-luna",A=Pn[M];return{model:(A==null?void 0:A.label)||M}}if(c.provider==="opencode")return{model:c.opencodeModel||"opencode"};if(c.provider==="grok"){const M=c.grokModel||$n,A=c.effort,k=A?Kt[A]:void 0;return{model:M,effort:k==null?void 0:k.label}}if(c.provider==="pi"){const M=c.piModel||"pi default",A=c.effort,k=A?Kt[A]:void 0;return{model:M,effort:k==null?void 0:k.label}}const o=c.model||c.detectedModel||"default",m=Dn[o],b=c.effort,y=b?Kt[b]:void 0;return{model:(m==null?void 0:m.label)||o,effort:y==null?void 0:y.label}}function Zn(c,o){if(o.type==="rectangle"&&o.width&&o.height){const m=o.width/2,b=o.height/2;return c.x>=o.center.x-m&&c.x<=o.center.x+m&&c.z>=o.center.z-b&&c.z<=o.center.z+b}if(o.type==="circle"&&o.radius){const m=c.x-o.center.x,b=c.z-o.center.z;return m*m+b*b<=o.radius*o.radius}return!1}const Jn=cn.memo(function({agentId:o,terminalViewMode:m,onTerminalViewModeChange:b,inspectorOpen:y,onToggleInspector:M,onShowTaskBoard:A,onImageClick:k,onFileClick:K,onBashClick:j,onViewMarkdown:v,onRequestClearSubordinates:R,keyboard:be,canNavigateBack:L,canNavigateForward:_e,onNavigateBack:te,onNavigateForward:ue,agentInfoOpen:Ze,onToggleAgentInfo:jt,onHeaderContextMenu:dt,onBuildingContextMenu:$e}){var Z,It;const p=ja(o),O=ka(),we=dn(),ve=n.useRef(null),me=n.useRef(null);un(!0,o);const Je=o,Qe=p,je=!!we.interactiveMode&&((p==null?void 0:p.provider)??"claude")==="claude"&&!!(p!=null&&p.sessionId),[ae,et]=n.useState(!1),[tt,Ue]=n.useState(null),Dt=n.useMemo(()=>{const a=Vn.map(l=>{const i=!ae&&m===l;return{id:`view-mode-${l}`,label:ga[l],icon:e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon",children:xa[l]}),shortcut:i?"✓":void 0,onClick:()=>{et(!1),b(l),Ue(null)}}});return je&&a.push({id:"view-mode-classic-tui",label:"Classic TUI",icon:e.jsx(d,{name:"terminal",size:13}),shortcut:ae?"✓":void 0,onClick:()=>{et(l=>!l),Ue(null)}}),a},[je,ae,m,b]),[Ge,pe]=n.useState(!1),D=n.useCallback(()=>pe(!1),[]);va("flat-chat-actions",Ge,D),n.useEffect(()=>{const a=()=>pe(l=>!l);return window.addEventListener("tide:toggle-chat-actions",a),()=>window.removeEventListener("tide:toggle-chat-actions",a)},[]),n.useEffect(()=>{et(!1),pe(!1)},[o]),n.useEffect(()=>{!je&&ae&&et(!1)},[je,ae]),n.useEffect(()=>{const a=me.current;if(!a)return;const l=u=>{u.button===3?(u.preventDefault(),u.stopPropagation(),te()):u.button===4&&(u.preventDefault(),u.stopPropagation(),ue())},i=u=>{(u.button===3||u.button===4)&&u.preventDefault()};return a.addEventListener("mouseup",l),a.addEventListener("mousedown",i),()=>{a.removeEventListener("mouseup",l),a.removeEventListener("mousedown",i)}},[te,ue]),n.useEffect(()=>{const a=me.current;if(!a)return;let l=0,i=0,u=0;const $=250,V=600,S=80,Le=1.5,ot=U=>{let t=U instanceof HTMLElement?U:null;for(;t&&t!==a;){const s=window.getComputedStyle(t).overflowX;if((s==="auto"||s==="scroll")&&t.scrollWidth>t.clientWidth)return!0;t=t.parentElement}return!1},z=U=>{const t=Date.now();if(t<u){U.preventDefault();return}if(Math.abs(U.deltaX)<=Math.abs(U.deltaY)*Le){l=0;return}if(ot(U.target)){l=0;return}t-i>$&&(l=0),i=t,l+=U.deltaX,l<=-S?(l=0,u=t+V,U.preventDefault(),te()):l>=S&&(l=0,u=t+V,U.preventDefault(),ue())};return a.addEventListener("wheel",z,{passive:!1}),()=>a.removeEventListener("wheel",z)},[te,ue]);const ne=Ca(),ut=n.useMemo(()=>{if(!p)return null;const a=new Set,l=[];for(const i of ne.values())i.archived||i.directories.length===0||i.assignedAgentIds.includes(o)&&(a.add(i.id),l.push(i));for(const i of ne.values())i.archived||i.directories.length===0||a.has(i.id)||Zn({x:p.position.x,z:p.position.z},i)&&(a.add(i.id),l.push(i));return l.length===0?null:l.flatMap(i=>i.directories.filter(u=>u&&u.trim().length>0).map(u=>({areaId:i.id,areaName:i.name,dir:u})))},[p,o,ne]),{branches:Ct,fetchRemote:Xe,fetchingDirs:De}=mn(ut),[Ce,at]=n.useState({}),[fe,Ve]=n.useState(null),Q=n.useMemo(()=>{var $,V;const a=g.getAreaForAgent(o);if(!a)return[];const l=[],i=($=a.directories.find(S=>S&&S.trim().length>0))==null?void 0:$.trim(),u=i?i.split("/").filter(Boolean).pop()||i:a.name;l.push({id:pn(a.id),name:u,hasUrl:!!Ce[a.id],isDefault:!0});for(const S of O.values())S.type==="terminal"&&g.isPositionInArea(S.position,a)&&l.push({id:S.id,name:S.name,hasUrl:!!((V=S.terminalStatus)!=null&&V.url)});return l},[o,O,ne,Ce]),se=n.useMemo(()=>{var i;const a=g.getAreaForAgent(o);if(!a)return[];const l=[];for(const u of O.values())u.type==="server"&&((i=u.pm2)!=null&&i.enabled)&&g.isPositionInArea(u.position,a)&&l.push({id:u.id,name:u.name});return l},[o,O]),nt=n.useMemo(()=>{const a=g.getAreaForAgent(o);if(!a)return[];const l=[];for(const i of O.values())i.type==="database"&&i.database&&g.isPositionInArea(i.position,a)&&l.push({id:i.id,name:i.name});return l},[o,O]),kt=fn(),qe=n.useMemo(()=>{const a=g.getAreaForAgent(o);if(!a)return[];const l=[];for(const i of O.values())if(i.type==="tests"&&g.isPositionInArea(i.position,a)){const u=!!i.folderPath&&kt.some($=>hn($,i.folderPath));l.push({id:i.id,name:i.name,working:u})}return l},[o,O,kt]),ke=n.useMemo(()=>{const a=g.getAreaForAgent(o);if(!a)return[];const l=[];for(const i of O.values())i.type==="http"&&g.isPositionInArea(i.position,a)&&l.push({id:i.id,name:i.name});return l},[o,O]),[,zt]=n.useReducer(a=>a+1,0),Ne=((Z=ve.current)==null?void 0:Z.search.searchMode)??!1,ye=n.useCallback(()=>{var a;(a=ve.current)==null||a.search.toggleSearch(),zt()},[]),mt=gn(),ie=mt.isPending(Qt),[_,he]=n.useState(null),F=_?O.get(_.buildingId):null,[Nt,ze]=n.useState(""),[pt,Rt]=n.useState(()=>xn()),B=n.useMemo(()=>{var a;return((a=g.getAreaForAgent(o))==null?void 0:a.id)??null},[o,O]),Re=n.useCallback((a,l)=>{ze(""),he(i=>{const u=(i==null?void 0:i.buildingId)===l?null:{type:a,buildingId:l};return B&&ea(B,u),u})},[B]),ee=n.useCallback(()=>{ze(""),he(null),B&&ea(B,null)},[B]);n.useEffect(()=>{if((_==null?void 0:_.type)!=="pm2-logs")return;const a=_.buildingId;return g.startLogStreaming(a,200),()=>g.stopLogStreaming(a)},[_]),n.useEffect(()=>{if(Ve(null),(_==null?void 0:_.type)!=="terminal"||!Yt(_.buildingId))return;const a=ma(_.buildingId);let l=!1;return bn(a).then(i=>{l||at(u=>u[a]===i.url?u:{...u,[a]:i.url})}).catch(i=>{l||Ve(i instanceof Error?i.message:"Failed to start terminal")}),()=>{l=!0}},[_]);const{height:Ot,onResizeStart:Ft}=_n(),{sidePanelWidth:Ae,handleSidePanelResizeStart:le}=wn(),[re,ft]=n.useState(()=>ta(E.GIT_PANEL_OPEN,!1)),[Oe,yt]=n.useState(()=>ta(E.BUILDINGS_PANEL_OPEN,!1)),[Fe,At]=n.useState(!1),st=n.useCallback(()=>{At(a=>!a)},[]),Ye=n.useCallback(()=>At(!1),[]),it=n.useCallback(()=>{ft(a=>{const l=!a;return xe(E.GIT_PANEL_OPEN,l),l})},[]),Se=n.useCallback(()=>{yt(a=>{const l=!a;return xe(E.BUILDINGS_PANEL_OPEN,l),l})},[]),Bt=n.useCallback(()=>{ft(!1),xe(E.GIT_PANEL_OPEN,!1)},[]),oe=n.useCallback(()=>{yt(!1),xe(E.BUILDINGS_PANEL_OPEN,!1)},[]),Be=vn(),We=n.useMemo(()=>({terminal:Q,"pm2-logs":se,database:nt,tests:qe,http:ke}),[Q,se,nt,qe,ke]);n.useEffect(()=>{if(!_)return;We[_.type].some(l=>l.id===_.buildingId)||(ze(""),he(null))},[_,We]);const St=n.useRef(void 0);n.useEffect(()=>{var l;if(St.current===B)return;St.current=B;const a=B?Ia()[B]:void 0;ze(""),a&&((l=We[a.type])!=null&&l.some(i=>i.id===a.buildingId))?he(a):he(null)},[B,We]),n.useEffect(()=>{const a=l=>{var $;const i=l.detail;if(!(i!=null&&i.buildingId)||!(i!=null&&i.type)||!(($=We[i.type])!=null&&$.some(V=>V.id===i.buildingId)))return;i.handled=!0,ze("");const u={type:i.type,buildingId:i.buildingId};he(u),B&&ea(B,u)};return window.addEventListener("tide:dock-building-flat",a),()=>window.removeEventListener("tide:dock-building-flat",a)},[We,B]);const[Ee,Ie]=n.useState(!1),ht=n.useRef(null);if(n.useEffect(()=>{if(!Ee)return;const a=l=>{ht.current&&!ht.current.contains(l.target)&&Ie(!1)};return document.addEventListener("mousedown",a),()=>document.removeEventListener("mousedown",a)},[Ee]),!p)return e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-chat__placeholder",children:[e.jsx("span",{className:"flat-chat__placeholder-icon",children:"💬"}),e.jsx("span",{className:"flat-chat__placeholder-text",children:"Select an agent to start chatting"})]})});const gt=!!p.contextStats,{totalTokens:Wt,contextWindow:ge,usedPercent:ce}=Na(p),xt=Math.round(ce*10)/10,Ht=Math.round((100-ce)*10)/10,bt=ce>=80?"#ff4a4a":ce>=60?"#ff9e4a":ce>=40?"#ffd700":"#4aff9e",He=(Wt/1e3).toFixed(1),lt=(ge/1e3).toFixed(1),Me=p.cwd,rt=Me?Yn(Me):null,Te=((It=p.subordinateIds)==null?void 0:It.length)||0,Et=Te>0;return e.jsxs("div",{ref:me,className:`flat-terminal-wrapper ${re||Oe||Fe?"flat-terminal-wrapper--with-side-panel":""}`,style:{"--guake-side-panel-width":`min(${Ae}px, 70%)`},children:[e.jsxs("div",{className:"flat-terminal-wrapper__header",children:[e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__header-main ${Ze?"flat-terminal-wrapper__header-main--active":""}`,onClick:jt,onContextMenu:a=>{a.preventDefault(),a.stopPropagation(),dt({x:a.clientX,y:a.clientY})},title:Ze?"Hide agent info":"Show agent info","aria-pressed":Ze,children:[e.jsxs("span",{className:`flat-terminal-wrapper__header-avatar${p.status==="working"?" is-working":""}`,children:[e.jsx(ya,{agent:p,size:28}),p.status==="working"&&e.jsx(aa,{animated:!0,size:12,className:"flat-terminal-wrapper__header-activity"})]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-info",children:[e.jsx("span",{className:"flat-terminal-wrapper__header-name",children:p.name}),e.jsx("span",{className:"flat-terminal-wrapper__header-status",style:{color:Sa(p.status)},title:p.status==="error"&&p.lastError?p.lastError:void 0,children:p.status})]}),p.taskLabel&&e.jsxs("span",{className:"flat-terminal-wrapper__header-task",title:p.taskLabel,children:["📋 ",p.taskLabel]}),e.jsxs("span",{className:"flat-terminal-wrapper__header-model",children:[e.jsx(Aa,{agent:p,alt:`${p.name} provider`,className:"flat-terminal-wrapper__header-provider-icon"}),(()=>{const{model:a,effort:l}=Kn(p);return e.jsxs("span",{className:"flat-terminal-wrapper__header-model-chip",title:l?`Model: ${a} · Effort: ${l}`:`Model: ${a}`,children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-name",children:a}),l&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flat-terminal-wrapper__header-model-sep","aria-hidden":"true",children:"·"}),e.jsx("span",{className:"flat-terminal-wrapper__header-model-effort",children:l})]})]})})()]})]}),e.jsxs("div",{className:"flat-terminal-wrapper__header-meta",children:[e.jsx("div",{className:"flat-terminal-wrapper__view-mode",children:e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__view-mode-btn flat-terminal-wrapper__view-mode-trigger${tt?" flat-terminal-wrapper__view-mode-trigger--open":""}`,onClick:a=>{const l=a.currentTarget.getBoundingClientRect();Ue({x:l.left,y:l.bottom+4})},title:ae?"Classic TUI — attach to the live interactive claude session in a terminal":qn[m],"aria-haspopup":"menu","aria-expanded":!!tt,"aria-label":"Message view mode",children:[e.jsx("span",{className:"flat-terminal-wrapper__view-mode-icon","aria-hidden":"true",children:ae?e.jsx(d,{name:"terminal",size:13}):xa[m]}),e.jsx("span",{className:"flat-terminal-wrapper__view-mode-label",children:ae?"Classic TUI":ga[m]}),e.jsx(d,{name:"caret-down",size:9})]})}),e.jsxs("div",{className:"flat-terminal-wrapper__actions",role:"group","aria-label":"Terminal actions",children:[e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:te,disabled:!L,title:"Back to previous agent","aria-label":"Back to previous agent",children:e.jsx(d,{name:"arrow-left",size:14})}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__action-btn",onClick:ue,disabled:!_e,title:"Forward to next agent","aria-label":"Forward to next agent",children:e.jsx(d,{name:"arrow-right",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Ne?"flat-terminal-wrapper__action-btn--active":""}`,onClick:ye,title:Ne?"Close search":"Search messages","aria-pressed":Ne,children:e.jsx(d,{name:Ne?"cross":"search",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn flat-terminal-wrapper__action-btn--danger ${ie?"flat-terminal-wrapper__action-btn--confirm":""}`,onClick:()=>mt.handleClick(Qt,()=>{var a;g.clearContext(o),(a=ve.current)==null||a.historyLoader.clearHistory()}),title:ie?"Click again to confirm clear context":"Clear context",children:e.jsx(d,{name:ie?"question":"clear",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${re?"flat-terminal-wrapper__action-btn--active":""}`,onClick:it,title:re?"Hide git panel":"Show git changes","aria-pressed":re,children:e.jsx(d,{name:"git-branch",size:14})}),e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Oe?"flat-terminal-wrapper__action-btn--active":""}`,onClick:Se,title:Oe?"Hide buildings panel":"Show area buildings","aria-pressed":Oe,children:e.jsx(d,{name:"buildings",size:14})}),e.jsxs("div",{className:"flat-terminal-wrapper__more",ref:ht,children:[e.jsx("button",{type:"button",className:`flat-terminal-wrapper__action-btn ${Ee?"flat-terminal-wrapper__action-btn--active":""}`,onClick:()=>Ie(a=>!a),title:"More actions","aria-expanded":Ee,children:"⋮"}),Ee&&e.jsxs("div",{className:"flat-terminal-wrapper__more-menu",role:"menu",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-terminal-wrapper__more-item ${Fe?"flat-terminal-wrapper__more-item--active":""}`,onClick:()=>{st(),Ie(!1)},title:Fe?"Hide Debug Panel":"Show Debug Panel",children:[e.jsx(d,{name:"bug",size:14}),e.jsx("span",{children:Fe?"Hide Debug Panel":"Show Debug Panel"})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item",onClick:()=>{g.collapseContext(o),Ie(!1)},disabled:p.status!=="idle",title:p.status!=="idle"?"Agent must be idle to collapse context":"Collapse context",children:[e.jsx(d,{name:"package",size:14}),e.jsx("span",{children:"Collapse context"})]}),Et&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{R(o,Te),Ie(!1)},children:[e.jsx(d,{name:"crown",size:14}),e.jsxs("span",{children:["Clear ",Te," subordinate",Te===1?"":"s"]})]}),e.jsx("div",{className:"flat-terminal-wrapper__more-divider"}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-terminal-wrapper__more-item flat-terminal-wrapper__more-item--danger",onClick:()=>{g.killAgent(o),Ie(!1)},children:[e.jsx(d,{name:"cross",size:14}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsxs("button",{type:"button",className:`flat-terminal-wrapper__inspector-toggle ${y?"flat-terminal-wrapper__inspector-toggle--active":""}`,onClick:M,title:y?"Hide inspector panel":"Show inspector panel","aria-label":y?"Hide inspector panel":"Show inspector panel","aria-pressed":y,children:[e.jsx("span",{className:"flat-terminal-wrapper__inspector-icon","aria-hidden":"true",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"1.5",y:"2.5",width:"13",height:"11",rx:"1.5"}),e.jsx("line",{x1:"10",y1:"2.5",x2:"10",y2:"13.5"})]})}),e.jsx("span",{className:"flat-terminal-wrapper__inspector-label",children:"Inspector"})]}),e.jsx("button",{type:"button",className:"flat-terminal-wrapper__close",onClick:()=>g.deselectAll(),title:"Close chat","aria-label":"Close chat",children:e.jsx(d,{name:"cross",size:14})})]})]}),Ge&&e.jsxs("div",{className:"flat-chat-actions-sheet-root",role:"presentation",children:[e.jsx("div",{className:"flat-chat-actions-sheet__backdrop",onClick:D}),e.jsxs("div",{className:"flat-chat-actions-sheet",role:"menu","aria-label":"Chat actions",children:[e.jsx("div",{className:"flat-chat-actions-sheet__grabber","aria-hidden":"true"}),e.jsxs("div",{className:"flat-chat-actions-sheet__title-row",children:[e.jsx("span",{className:"flat-chat-actions-sheet__title",children:p.name}),e.jsx("button",{type:"button",className:"flat-chat-actions-sheet__done",onClick:D,children:"Done"})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__grid",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${Ne?"is-active":""}`,onClick:()=>{ye(),D()},children:[e.jsx(d,{name:Ne?"cross":"search",size:20}),e.jsx("span",{children:Ne?"Close search":"Search"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${re?"is-active":""}`,onClick:()=>{it(),D()},children:[e.jsx(d,{name:"git-branch",size:20}),e.jsx("span",{children:"Git changes"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${Oe?"is-active":""}`,onClick:()=>{Se(),D()},children:[e.jsx(d,{name:"buildings",size:20}),e.jsx("span",{children:"Buildings"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__item ${Fe?"is-active":""}`,onClick:()=>{st(),D()},children:[e.jsx(d,{name:"bug",size:20}),e.jsx("span",{children:"Debug"})]})]}),e.jsxs("div",{className:"flat-chat-actions-sheet__list",children:[e.jsxs("button",{type:"button",role:"menuitem",className:`flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger ${ie?"is-armed":""}`,onClick:()=>mt.handleClick(Qt,()=>{var a;g.clearContext(o),(a=ve.current)==null||a.historyLoader.clearHistory(),D()}),children:[e.jsx(d,{name:ie?"question":"clear",size:18}),e.jsx("span",{children:ie?"Tap again to confirm clear":"Clear context"})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row",disabled:p.status!=="idle",onClick:()=>{g.collapseContext(o),D()},children:[e.jsx(d,{name:"package",size:18}),e.jsx("span",{children:"Collapse context"})]}),Et&&e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{R(o,Te),D()},children:[e.jsx(d,{name:"crown",size:18}),e.jsxs("span",{children:["Clear ",Te," subordinate",Te===1?"":"s"]})]}),e.jsxs("button",{type:"button",role:"menuitem",className:"flat-chat-actions-sheet__row flat-chat-actions-sheet__row--danger",onClick:()=>{g.killAgent(o),D()},children:[e.jsx(d,{name:"cross",size:18}),e.jsx("span",{children:"Remove agent"})]})]})]})]}),e.jsx(jn,{agent:p,onClick:A}),ae&&je?e.jsx(Bn,{agentId:o}):Je&&Qe?e.jsx(Cn,{ref:ve,agentId:Je,agent:Qe,viewMode:m,isOpen:!0,onImageClick:k,onFileClick:K,onBashClick:j,onViewMarkdown:v,keyboard:be,hasModalOpen:!1},Je):null,_&&(F||Yt(_.buildingId))&&(()=>{var Le,ot;const a=_.type,l=Yt(_.buildingId),i=(F==null?void 0:F.name)??`Terminal — ${((Le=Q.find(z=>z.id===_.buildingId))==null?void 0:Le.name)??"area"}`,u=l?Ce[ma(_.buildingId)]:(ot=F==null?void 0:F.terminalStatus)==null?void 0:ot.url,$={terminal:"terminal","pm2-logs":"scroll",database:"hard-drives",tests:"flask",http:"globe"},V=a==="terminal"&&!u,S=!V&&!l;return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"guake-bottom-terminal-resize",onMouseDown:Ft,role:"separator","aria-orientation":"horizontal","aria-label":"Resize embedded panel"}),e.jsxs("div",{className:"flat-bottom-panel",role:"region","aria-label":`${i} panel`,style:{height:Ot},children:[e.jsxs("div",{className:"flat-bottom-panel__header",children:[e.jsxs("span",{className:"flat-bottom-panel__title",children:[e.jsx(d,{name:$[a],size:12}),e.jsx("span",{children:i}),V&&e.jsx("span",{className:"flat-bottom-panel__muted",children:"(starting...)"})]}),e.jsxs("span",{className:"flat-bottom-panel__header-actions",children:[a==="pm2-logs"&&F&&e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",className:"guake-bottom-terminal-filter",value:Nt,onChange:z=>ze(z.target.value),placeholder:"Filter logs","aria-label":`Filter logs for ${F.name}`,spellCheck:!1}),e.jsx("select",{className:"guake-bottom-terminal-retention",value:pt===null?"unlimited":String(pt),onChange:z=>{const U=z.target.value==="unlimited"?null:Number(z.target.value);Rt(U),Nn(U)},"aria-label":`Max log retention for ${F.name}`,children:kn.map(z=>e.jsx("option",{value:z===null?"unlimited":String(z),children:z===null?"Unlimited":`${z.toLocaleString()} lines`},z===null?"unlimited":z))}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.clearStreamingLogs(_.buildingId),title:"Clear logs",children:e.jsx(d,{name:"trash",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>g.sendBuildingCommand(_.buildingId,"restart"),title:"Restart",children:e.jsx(d,{name:"restart",size:12})})]}),S&&e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:()=>{ee(),ct(_.buildingId)},title:"Maximize — open as modal","aria-label":"Open as modal",children:e.jsx(d,{name:"fullscreen",size:12})}),e.jsx("button",{type:"button",className:"flat-bottom-panel__close",onClick:ee,title:"Close panel","aria-label":"Close panel",children:e.jsx(d,{name:"cross",size:12})})]})]}),e.jsx("div",{className:"flat-bottom-panel__body",children:a==="terminal"?u?e.jsx(wa,{terminalUrl:u,visible:!0}):e.jsx("div",{className:"flat-bottom-panel__placeholder",children:fe??"Starting terminal..."}):a==="pm2-logs"?e.jsx(yn,{buildingId:_.buildingId,filterText:Nt,maxRetention:pt}):F?a==="database"?e.jsx(An,{building:F}):a==="tests"?e.jsx("div",{className:"tests-panel-host",children:e.jsx(Sn,{building:F,autoFocusSearch:!1})}):e.jsx("div",{className:"http-requests-panel-host",children:e.jsx(En,{building:F,autoFocusSearch:!1})}):null})]})]})})(),e.jsxs("div",{className:"flat-terminal-wrapper__statusbar",role:"contentinfo",children:[p.isDetached&&e.jsxs("span",{className:"flat-terminal-wrapper__detached",title:"Reattaching session...",children:[e.jsx(d,{name:"refresh",size:12}),e.jsx("span",{children:"Reattaching"})]}),Me&&rt&&e.jsxs("span",{className:"flat-terminal-wrapper__cwd",title:`Open in file explorer: ${Me}`,"aria-label":`Open ${Me} in file explorer`,role:"button",tabIndex:0,onClick:()=>g.openFileExplorer(Me),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.openFileExplorer(Me))},children:[e.jsx("span",{className:"flat-terminal-wrapper__cwd-icon",children:e.jsx(d,{name:"folder",size:12})}),e.jsx("span",{className:"flat-terminal-wrapper__cwd-text",children:rt})]}),ut&&ut.map(({areaId:a,areaName:l,dir:i})=>{const u=Ct.get(i),$=De.has(i),V=i.split("/").filter(Boolean).pop()||i;return e.jsxs("span",{className:"flat-terminal-wrapper__area-dir",title:`${l}: ${i}${u?` (${u.branch}${u.ahead?` ↑${u.ahead}`:""}${u.behind?` ↓${u.behind}`:""})`:""}`,onClick:()=>g.openFileExplorerForAreaFolder(a,i),children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-terminal-wrapper__area-dir-name",children:V}),u&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"flat-terminal-wrapper__area-dir-branch",children:[e.jsx(d,{name:"git-branch",size:10})," ",u.branch]}),u.ahead>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-ahead",title:`${u.ahead} ahead`,children:[e.jsx(d,{name:"arrow-up",size:9}),u.ahead]}),u.behind>0&&e.jsxs("span",{className:"flat-terminal-wrapper__branch-behind",title:`${u.behind} behind`,children:[e.jsx(d,{name:"arrow-down",size:9}),u.behind]}),e.jsx("span",{className:`flat-terminal-wrapper__area-fetch ${$?"flat-terminal-wrapper__area-fetch--fetching":""}`,title:"Git fetch",onClick:S=>{S.stopPropagation(),Xe(i)},children:e.jsx(d,{name:$?"hourglass":"download",size:12})})]})]},`${a}:${i}`)}),e.jsx(Gn,{agentId:o,disabled:((p==null?void 0:p.provider)??"claude")!=="claude"&&((p==null?void 0:p.provider)??"claude")!=="grok",contextSummary:gt?`Context: ${He}k / ${lt}k tokens (${xt}% used)`:void 0,children:e.jsxs("span",{className:"flat-terminal-wrapper__context",tabIndex:0,role:"button",onClick:()=>g.setContextModalAgentId(o),onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),g.setContextModalAgentId(o))},title:((p==null?void 0:p.provider)??"claude")!=="claude"&&((p==null?void 0:p.provider)??"claude")!=="grok"?gt?`Context usage: ${He}k / ${lt}k tokens (${xt}% used). Click to view stats.`:"Click to fetch context stats":void 0,children:[e.jsx("span",{className:"flat-terminal-wrapper__context-bar",children:e.jsx("span",{className:"flat-terminal-wrapper__context-bar-fill",style:{width:`${ce}%`,backgroundColor:bt}})}),e.jsxs("span",{className:"flat-terminal-wrapper__context-tokens",style:{color:bt},children:[He,"k/",lt,"k"]}),e.jsxs("span",{className:"flat-terminal-wrapper__context-free",children:["(",Ht,"% free)"]}),!gt&&e.jsx("span",{className:"flat-terminal-wrapper__context-warning",title:"No context stats yet",children:e.jsx(d,{name:"warn",size:12})})]})}),e.jsx("div",{className:"flat-terminal-wrapper__statusbar-spacer","aria-hidden":"true"}),Q.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area terminals",children:Q.map(a=>{const l=(_==null?void 0:_.buildingId)===a.id;return a.isDefault?e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn flat-terminal-wrapper__building-btn--default ${l?"flat-terminal-wrapper__building-btn--active":""}`,title:`${l?"Hide":"Show"} area terminal: ${a.name}`,onClick:()=>{l?ee():Re("terminal",a.id)},children:e.jsx(d,{name:"terminal",size:14})},a.id):e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""} ${a.hasUrl?"":"flat-terminal-wrapper__building-btn--offline"}`,title:`${l?"Hide":"Show"} terminal: ${a.name}${a.hasUrl?"":" (starting...)"}`,onClick:()=>{if(l){ee();return}if(a.hasUrl&&wt(a.id)==="modal"){ct(a.id);return}a.hasUrl||g.sendBuildingCommand(a.id,"start"),Re("terminal",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),$e(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"terminal",size:14})},a.id)})}),se.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area PM2 logs",children:se.map(a=>{const l=(_==null?void 0:_.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""}`,title:`${l?"Hide":"Show"} logs: ${a.name}`,onClick:()=>{l?ee():wt(a.id)==="modal"?ct(a.id):Re("pm2-logs",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),$e(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"scroll",size:14})},a.id)})}),nt.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area databases",children:nt.map(a=>{const l=(_==null?void 0:_.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""}`,title:`${l?"Hide":"Show"} database: ${a.name}`,onClick:()=>{l?ee():wt(a.id)==="modal"?ct(a.id):Re("database",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),$e(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"hard-drives",size:14})},a.id)})}),qe.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area tests",children:qe.map(a=>{const l=(_==null?void 0:_.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""} ${a.working?"flat-terminal-wrapper__building-btn--tests-working":""}`,title:a.working?`Running tests: ${a.name}`:`${l?"Hide":"Show"} tests: ${a.name}`,onClick:()=>{l?ee():wt(a.id)==="modal"?ct(a.id):Re("tests",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),$e(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"flask",size:14})},a.id)})}),ke.length>0&&e.jsx("span",{className:"flat-terminal-wrapper__buildings",role:"group","aria-label":"Area HTTP requests",children:ke.map(a=>{const l=(_==null?void 0:_.buildingId)===a.id;return e.jsx("button",{type:"button",className:`flat-terminal-wrapper__building-btn ${l?"flat-terminal-wrapper__building-btn--active":""}`,title:`${l?"Hide":"Show"} HTTP requests: ${a.name}`,onClick:()=>{l?ee():wt(a.id)==="modal"?ct(a.id):Re("http",a.id)},onContextMenu:i=>{i.preventDefault(),i.stopPropagation(),$e(a.id,{x:i.clientX,y:i.clientY})},children:e.jsx(d,{name:"globe",size:14})},a.id)})}),e.jsx("div",{className:"flat-terminal-wrapper__theme",children:e.jsx(In,{iconOnly:!0})})]}),re&&e.jsx(Mn,{agentId:o,agents:Be,onClose:Bt,branchInfoMap:Ct,fetchRemote:Xe,fetchingDirs:De,onResizeStart:a=>le(a,"right")}),Oe&&e.jsx(Tn,{agentId:o,onClose:oe}),Fe&&e.jsx(Ln,{agentId:o,onClose:Ye}),e.jsx(na,{isOpen:tt!==null,position:tt??{x:0,y:0},worldPosition:{x:0,z:0},actions:Dt,onClose:()=>Ue(null)})]})}),Qn={groups:[],gridCols:1,gridRows:1,positions:new Map};function ss({onAgentClick:c,onBuildingClick:o,onBuildingDoubleClick:m,onBuildingPopup:b,onAreaContextMenu:y,onOpenSpawnModal:M,onOpenBossSpawnModal:A,onOpenAreaModal:k}){const{t:K}=sa(["common"]),j=Wa(),v=n.useMemo(()=>j.size>0?j.values().next().value??null:null,[j]),R=Ha(v===null),be=Ua(),[L,_e]=n.useState(null),[te,ue]=n.useState(null),[Ze,jt]=n.useState(null);va("flatview-image-modal",L!==null,()=>_e(null));const[dt,$e]=n.useState(null),[p,O]=n.useState(null),[we,ve]=n.useState(null),[me,Je]=n.useState(null),[Qe,je]=n.useState(!1),ae=n.useCallback(()=>{je(t=>!t)},[]),et=n.useCallback(()=>{je(!1)},[]),[tt,Ue]=n.useState(()=>{const t=Vt(E.VIEW_MODE);return t==="simple"||t==="chat"||t==="advanced"?t:"simple"}),Dt=n.useCallback(t=>{Ue(t),qt(E.VIEW_MODE,t)},[]);n.useEffect(()=>{const t=s=>{if(s.key!==E.VIEW_MODE)return;const r=s.newValue;(r==="simple"||r==="chat"||r==="advanced")&&Ue(r)};return window.addEventListener("storage",t),()=>window.removeEventListener("storage",t)},[]);const[Ge,pe]=n.useState(()=>ta(E.FLAT_INSPECTOR_OPEN,!1)),[D,ne]=n.useState(!1),ut=n.useCallback(()=>ne(t=>!t),[]),Ct=n.useCallback(()=>ne(!1),[]);n.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-agents-drawer-state",{detail:{open:D}}))},[D]),n.useEffect(()=>{window.dispatchEvent(new CustomEvent("tide-flat-inspector-state",{detail:{open:Ge}}))},[Ge]),n.useEffect(()=>{const t=()=>ne(N=>!N),s=()=>{pe(N=>{const T=!N;return xe(E.FLAT_INSPECTOR_OPEN,T),T})},r=()=>{ne(!1),pe(!1),xe(E.FLAT_INSPECTOR_OPEN,!1)},x=()=>ne(!1),w=()=>{pe(!1),xe(E.FLAT_INSPECTOR_OPEN,!1)};return window.addEventListener("tide-toggle-flat-agents-drawer",t),window.addEventListener("tide-toggle-flat-inspector",s),window.addEventListener("tide-close-flat-side-views",r),window.addEventListener("tide-close-flat-agents-drawer-only",x),window.addEventListener("tide-close-flat-inspector-only",w),()=>{window.removeEventListener("tide-toggle-flat-agents-drawer",t),window.removeEventListener("tide-toggle-flat-inspector",s),window.removeEventListener("tide-close-flat-side-views",r),window.removeEventListener("tide-close-flat-agents-drawer-only",x),window.removeEventListener("tide-close-flat-inspector-only",w)}},[]);const Xe=n.useRef(null),De=n.useRef(null),[Ce,at]=n.useState(()=>{const t=ca(E.FLAT_MIDDLE_WIDTH,0);return t>=$t?t:null}),[fe,Ve]=n.useState(()=>{const t=ca(E.FLAT_INSPECTOR_WIDTH,0);return t>=Jt?t:null}),Q=n.useCallback(t=>{if(typeof window>"u")return t;const s=fe!==null?Pt+fe:0,r=window.innerWidth-ha-Pt-fa-s;return Math.max($t,Math.min(Math.max(r,$t),t))},[fe]),se=n.useCallback(t=>{var w;if(typeof window>"u")return t;const s=(w=Xe.current)==null?void 0:w.querySelector(".flat-middle"),r=(s==null?void 0:s.getBoundingClientRect().width)??$t,x=window.innerWidth-ha-r-Pt-fa-Pt;return Math.max(Jt,Math.min(Math.max(x,Jt),t))},[]);n.useEffect(()=>{if(Ce===null&&fe===null)return;const t=()=>{at(s=>{if(s===null)return s;const r=Q(s);return r===s?s:r}),Ve(s=>{if(s===null)return s;const r=se(s);return r===s?s:r})};return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)},[Ce,fe,Q,se]);const nt=n.useCallback(t=>{var r;if(t.button!==0)return;const s=(r=Xe.current)==null?void 0:r.querySelector(".flat-middle");s&&(t.currentTarget.setPointerCapture(t.pointerId),De.current={kind:"middle",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),kt=n.useCallback(t=>{var r;if(t.button!==0)return;const s=(r=Xe.current)==null?void 0:r.querySelector(".flat-inspector");s&&(t.currentTarget.setPointerCapture(t.pointerId),De.current={kind:"inspector",startX:t.clientX,startWidth:s.getBoundingClientRect().width,pointerId:t.pointerId},document.body.classList.add("flat-splitter-dragging"))},[]),qe=n.useCallback(t=>{const s=De.current;if(!s||t.pointerId!==s.pointerId)return;const r=t.clientX-s.startX;s.kind==="middle"?at(Q(s.startWidth+r)):Ve(se(s.startWidth-r))},[Q,se]),ke=n.useCallback(t=>{const s=De.current;if(!s||t.pointerId!==s.pointerId)return;try{t.currentTarget.releasePointerCapture(t.pointerId)}catch{}if(De.current=null,document.body.classList.remove("flat-splitter-dragging"),!(Math.abs(t.clientX-s.startX)>2))return;const x=t.clientX-s.startX;if(s.kind==="middle"){const w=Q(s.startWidth+x);at(w),Lt(E.FLAT_MIDDLE_WIDTH,w)}else{const w=se(s.startWidth-x);Ve(w),Lt(E.FLAT_INSPECTOR_WIDTH,w)}},[Q,se]),zt=n.useCallback(()=>{at(null),Lt(E.FLAT_MIDDLE_WIDTH,0)},[]),Ne=n.useCallback(()=>{Ve(null),Lt(E.FLAT_INSPECTOR_WIDTH,0)},[]),[ye,mt]=n.useState(()=>Vt(E.FLAT_INSPECTOR_VIEW)==="tracking"?"tracking":"agent"),ie=n.useCallback(t=>{mt(t),qt(E.FLAT_INSPECTOR_VIEW,t)},[]),_=n.useCallback(()=>{pe(t=>{const s=!t;return xe(E.FLAT_INSPECTOR_OPEN,s),s})},[]),he=n.useCallback(()=>{pe(!1),xe(E.FLAT_INSPECTOR_OPEN,!1)},[]),F=n.useCallback(()=>{ie("tracking"),pe(!0),xe(E.FLAT_INSPECTOR_OPEN,!0)},[ie]),Nt=Ga(),ze=n.useCallback((t,s)=>{_e({url:t,name:s})},[]),pt=n.useCallback((t,s)=>{ue({command:t,output:s,isLive:!1})},[]),Rt=n.useCallback((t,s)=>{var w;const r=j.size>0?Array.from(j)[0]:null,x=r?(w=g.getState().agents.get(r))==null?void 0:w.cwd:void 0;g.setFileViewerPath(t,s,x)},[j]),B=n.useCallback(t=>{jt(t)},[]),Re=n.useCallback((t,s)=>{$e({agentId:t,count:s})},[]),ee=n.useCallback(t=>{m?m(t):o(t)},[o,m]),Ot=n.useCallback(t=>{v&&O({agentId:v,position:t})},[v]),Ft=n.useCallback((t,s)=>{ve({buildingId:t,position:s})},[]);n.useEffect(()=>{je(!1)},[v]);const Ae=n.useRef([]),le=n.useRef(-1),re=n.useRef(!1),ft=n.useRef(Vt(E.LAST_OPENED_AGENT,"")||null),[Oe,yt]=n.useState(!1),[Fe,At]=n.useState(!1),st=n.useRef(!1),Ye=n.useRef(null),it=n.useRef(!1),Se=n.useMemo(()=>new Set(be),[be]),Bt=n.useMemo(()=>{const t=new Map(R.map(r=>[r.id,r])),s=new Map;for(const r of R)if((r.isBoss||r.class==="boss")&&r.subordinateIds&&r.subordinateIds.length>0){const x=r.subordinateIds.map(w=>t.get(w)).filter(w=>w!==void 0);x.length>0&&s.set(r.id,x)}return s},[R]),oe=n.useCallback(()=>{const t=Ae.current,s=le.current;yt(s>0),At(s>=0&&s<t.length-1)},[]),Be=n.useCallback(t=>{const s=Ae.current;if(s.length===0)return;let r=le.current+t;for(;r>=0&&r<s.length;){const x=s[r];if(Se.has(x)){re.current=!0,le.current=r,oe(),g.selectAgent(x);return}r+=t}},[Se,oe]),We=n.useCallback(()=>Be(-1),[Be]),St=n.useCallback(()=>Be(1),[Be]);Rn(n.useCallback(()=>{const t=Ae.current,s=le.current;return t.length>0&&s>0?(Be(-1),"handled"):"exit"},[Be]));const Ee=n.useCallback((t,s)=>{if(typeof window>"u")return;const r=window.history.state,w={...typeof r=="object"&&r!==null?r:{},__flatAgentNav:{agentId:t}};s==="replace"?window.history.replaceState(w,"",window.location.href):window.history.pushState(w,"",window.location.href)},[]);n.useEffect(()=>{if(!v){st.current=!1,Ye.current=null;return}if(!st.current){Ee(v,"replace"),st.current=!0,Ye.current=v;return}if(it.current){it.current=!1,Ye.current=v;return}Ye.current!==v&&(Ee(v,"push"),Ye.current=v)},[v,Ee]),n.useEffect(()=>{const t=s=>{var N,T;const r=(T=(N=s.state)==null?void 0:N.__flatAgentNav)==null?void 0:T.agentId;if(!r||typeof r!="string"||!Se.has(r)||r===v)return;it.current=!0,re.current=!0;const x=Ae.current,w=x.lastIndexOf(r);w>=0?le.current=w:(x.push(r),le.current=x.length-1),oe(),g.selectAgent(r)};return window.addEventListener("popstate",t),()=>window.removeEventListener("popstate",t)},[Se,v,oe]),n.useEffect(()=>{if(!v){Ae.current=[],le.current=-1,oe();return}if(ft.current=v,qt(E.LAST_OPENED_AGENT,v),re.current){re.current=!1,oe();return}const t=Ae.current,s=le.current;if(s>=0&&t[s]===v){oe();return}const r=s<t.length-1?t.slice(0,s+1):t.slice();r.push(v),r.length>100&&r.shift(),Ae.current=r,le.current=r.length-1,oe()},[v,oe]);const Ie=n.useCallback(t=>{c(t),ne(!1)},[c]),ht=v??"",gt=n.useCallback(()=>{},[]),Wt=n.useCallback(t=>{Ie(t)},[Ie]),ge=Ge,[ce,xt]=n.useState(ge),[Ht,bt]=n.useState(ge),He=ja(Qe||Ze!==null||ce&&ye==="agent"?v:null);n.useEffect(()=>{if(ge){xt(!0);return}bt(!1);const t=setTimeout(()=>xt(!1),240);return()=>clearTimeout(t)},[ge]),n.useEffect(()=>{if(!ce||!ge)return;let t=0;const s=requestAnimationFrame(()=>{t=requestAnimationFrame(()=>bt(!0))});return()=>{cancelAnimationFrame(s),cancelAnimationFrame(t)}},[ce,ge]);const lt=n.useRef(null);n.useEffect(()=>{if(v)return;const t=s=>{if(s.key!==" "&&s.key!=="Backspace")return;const r=s.target;if(r.tagName==="INPUT"||r.tagName==="TEXTAREA"||r.isContentEditable)return;const x=ft.current;!x||!Se.has(x)||(s.preventDefault(),g.selectAgent(x))};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[v,Se]);const[Me,rt]=n.useState(new Set),Te=n.useCallback(t=>{rt(s=>{const r=new Set(s);return r.has(t)?r.delete(t):r.add(t),r})},[]),Et=n.useCallback(t=>{rt(new Set(t))},[]),[Z,It]=n.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 768px)").matches);n.useEffect(()=>{if(typeof window>"u")return;const t=window.matchMedia("(max-width: 768px)"),s=r=>It(r.matches);return t.addEventListener("change",s),()=>t.removeEventListener("change",s)},[]);const[a,l]=n.useState(null),i=n.useCallback(t=>{l(s=>s===t?null:t)},[]),u=Ca(),$=ka(),[V]=Xa(),S=n.useMemo(()=>{if(v)return Qn;const t=new Map,s=[];for(const h of R){const C=g.getAreaForAgent(h.id);if(!da((C==null?void 0:C.id)??null))continue;if(!C||C.archived){s.push(h);continue}const P=t.get(C.id);P?P.push(h):t.set(C.id,[h])}const r=new Map,x=[];for(const h of $.values()){let C=!1;for(const P of u.values())if(!P.archived&&ua(P.id)&&g.isPositionInArea(h.position,P)){const de=r.get(P.id);de?de.push(h):r.set(P.id,[h]),C=!0;break}!C&&da(null)&&x.push(h)}const w=[];for(const[,h]of u){if(h.archived||!ua(h.id))continue;const C=t.get(h.id),P=r.get(h.id)??[];(C&&C.length>0||P.length>0)&&w.push({area:h,agents:C??[],buildings:P})}(s.length>0||x.length>0)&&w.push({area:{id:"__unassigned__",name:"Unassigned",color:"#6272a4",center:{x:0,z:0},type:"circle",radius:0,directories:[],archived:!1,assignedAgentIds:[],zIndex:0},agents:s,buildings:x});const N=w.filter(h=>h.area.id!=="__unassigned__"),T=w.filter(h=>h.area.id==="__unassigned__");let G=1,W=1;const f=new Map;if(N.length>1){let h=1/0,C=-1/0,P=1/0,de=-1/0;for(const q of N)h=Math.min(h,q.area.center.x),C=Math.max(C,q.area.center.x),P=Math.min(P,q.area.center.z),de=Math.max(de,q.area.center.z);const Pe=C-h||1,Mt=de-P||1;if(N.length<=4){G=N.length,W=1;const q=[...N].sort((Y,Ut)=>Y.area.center.x-Ut.area.center.x);for(let Y=0;Y<q.length;Y++)f.set(q[Y].area.id,{row:1,col:Y+1})}else{const q=[...N].sort((I,H)=>I.area.center.x-H.area.center.x),Y=[];for(let I=1;I<q.length;I++)Y.push(q[I].area.center.x-q[I-1].area.center.x);const Ut=Y.reduce((I,H)=>I+H,0)/Y.length||1;let ia=1;for(const I of Y)I>Ut*1.3&&ia++;G=Math.max(2,Math.min(ia,N.length));const Gt=[...N].sort((I,H)=>I.area.center.z-H.area.center.z),Tt=[];for(let I=1;I<Gt.length;I++)Tt.push(Gt[I].area.center.z-Gt[I-1].area.center.z);const Ma=Tt.reduce((I,H)=>I+H,0)/Tt.length||1;let la=1;for(const I of Tt)I>Ma*1.3&&la++;W=Math.max(2,Math.min(la,N.length)),G=Math.max(G,Math.ceil(N.length/W)),W=Math.max(W,Math.ceil(N.length/G));const Ta=Pe/G,La=Mt/W,Xt=new Set;for(const I of N){let H=Math.min(G-1,Math.max(0,Math.floor((I.area.center.x-h)/Ta))),Ke=Math.min(W-1,Math.max(0,Math.floor((I.area.center.z-P)/La))),_t=`${Ke},${H}`,ra=0;const Pa=W*G;for(;Xt.has(_t)&&ra<Pa;)H++,H>=G&&(H=0,Ke=(Ke+1)%W),_t=`${Ke},${H}`,ra++;Xt.has(_t)&&(Ke=W,H=0,_t=`${Ke},${H}`,W++),Xt.add(_t),f.set(I.area.id,{row:Ke+1,col:H+1})}}}const J=h=>{h.sort((C,P)=>{var Pe,Mt,q,Y;const de=(((Pe=C.position)==null?void 0:Pe.z)??0)-(((Mt=P.position)==null?void 0:Mt.z)??0);return de!==0?de:(((q=C.position)==null?void 0:q.x)??0)-(((Y=P.position)==null?void 0:Y.x)??0)})};for(const h of N)J(h.agents);for(const h of T)J(h.agents);const X=[...N,...T].sort((h,C)=>h.area.name.localeCompare(C.area.name,void 0,{sensitivity:"base",numeric:!0})||h.area.id.localeCompare(C.area.id));return f.clear(),X.forEach((h,C)=>{f.set(h.area.id,{row:Math.floor(C/G)+1,col:C%G+1})}),W=Math.max(1,Math.ceil(X.length/G)),{groups:X,gridCols:G,gridRows:W,positions:f}},[R,u,$,V,v]),Le=n.useMemo(()=>{let t=0,s=0;for(const r of S.groups)t+=r.agents.length,s+=r.agents.filter(x=>x.status==="working").length;return{areaCount:S.groups.length,agentCount:t,workingCount:s}},[S]),ot=n.useMemo(()=>{if(!p)return[];const t=g.getState().agents.get(p.agentId);return t?[{id:"edit-agent",label:"Edit Agent",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:open-agent-edit",{detail:{agentId:t.id}}))}},{id:"open-chat",label:"Open Chat",icon:e.jsx(d,{name:"chat",size:14}),onClick:()=>c(t.id)},{id:"clone-agent",label:"Clone Agent",icon:e.jsx(d,{name:"clipboard",size:14}),onClick:()=>g.cloneAgent(t.id)},{id:"fork-agent",label:"Fork Agent (with history)",icon:e.jsx(d,{name:"git-branch",size:14}),onClick:()=>g.forkAgent(t.id)},{id:"delete-agent",label:"Delete Agent",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>{Je({agentId:t.id,name:t.name})}}]:[]},[p,c]),z=n.useMemo(()=>{var N;if(!we)return[];const t=$.get(we.buildingId);if(!t)return[];const s=[],r=t.type==="server"||t.type==="docker"||t.type==="terminal",x=t.status==="running",w=t.type==="boss";if(s.push({id:"open",label:t.type==="database"?"Open Database":t.type==="folder"?"Open Folder":t.type==="tests"?"Open Tests":t.type==="http"?"Open Requests":t.type==="boss"?"View Boss Logs":t.type==="terminal"?"Open Terminal":t.type==="server"&&((N=t.pm2)!=null&&N.enabled)?"View PM2 Logs":"Open",icon:e.jsx(d,{name:t.type==="database"?"database":t.type==="folder"?"folder":t.type==="tests"?"flask":t.type==="http"?"globe":t.type==="terminal"?"terminal":"eye",size:14}),onClick:()=>ee(t.id)}),r&&(x||s.push({id:"start",label:"Start",icon:e.jsx(d,{name:"play",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"start")}),x&&(s.push({id:"restart",label:"Restart",icon:e.jsx(d,{name:"refresh",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"restart")}),s.push({id:"stop",label:"Stop",icon:e.jsx(d,{name:"stop",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"stop")}))),w&&t.subordinateBuildingIds&&t.subordinateBuildingIds.length>0&&(s.push({id:"start-all",label:"Start All Subordinates",icon:e.jsx(d,{name:"launch",size:14}),onClick:()=>{for(const T of t.subordinateBuildingIds)g.sendBuildingCommand(T,"start")}}),s.push({id:"stop-all",label:"Stop All Subordinates",icon:e.jsx(d,{name:"pause",size:14}),onClick:()=>{for(const T of t.subordinateBuildingIds)g.sendBuildingCommand(T,"stop")}}),s.push({id:"restart-all",label:"Restart All Subordinates",icon:e.jsx(d,{name:"restart",size:14}),onClick:()=>{for(const T of t.subordinateBuildingIds)g.sendBuildingCommand(T,"restart")}})),r&&s.push({id:"health-check",label:"Health Check",icon:e.jsx(d,{name:"health",size:14}),onClick:()=>g.sendBuildingCommand(t.id,"healthCheck")}),s.push({id:"divider-edit",label:"",divider:!0,onClick:()=>{}}),s.push({id:"edit",label:"Edit Building",icon:e.jsx(d,{name:"edit",size:14}),onClick:()=>{window.dispatchEvent(new CustomEvent("tide:building-edit",{detail:{buildingId:t.id}}))}}),s.push({id:"clone",label:"Clone Building",icon:e.jsx(d,{name:"copy",size:14}),onClick:()=>{g.createBuilding({name:`${t.name} (Copy)`,type:t.type,style:t.style,color:t.color,scale:t.scale,position:{x:t.position.x+2,z:t.position.z+2},cwd:t.cwd,folderPath:t.folderPath,commands:t.commands,pm2:t.pm2,docker:t.docker,database:t.database,terminal:t.terminal,urls:t.urls,subordinateBuildingIds:t.subordinateBuildingIds})}}),t.urls&&t.urls.length>0)for(const T of t.urls)s.push({id:`url-${T.label}`,label:T.label,icon:e.jsx(d,{name:"link",size:14}),onClick:()=>window.open(T.url,"_blank","noopener,noreferrer")});return s.push({id:"divider-danger",label:"",divider:!0,onClick:()=>{}}),s.push({id:"delete",label:"Delete Building",icon:e.jsx(d,{name:"trash",size:14}),danger:!0,onClick:()=>g.deleteBuilding(t.id)}),s},[we,$,ee]),U=n.useCallback(t=>{rt(new Set([t])),requestAnimationFrame(()=>{const s=lt.current;if(!s)return;const r=s.querySelector(`[data-area-id="${t}"]`);if(!r)return;const x=s.getBoundingClientRect(),N=r.getBoundingClientRect().top-x.top+s.scrollTop-8;s.scrollTo({top:Math.max(0,N),behavior:"smooth"})})},[]);return e.jsxs("div",{ref:Xe,className:`flat-view ${ge?"flat-view--with-inspector":""} ${v?"flat-view--has-chat":""} ${D?"flat-view--mobile-sidebar-open":""}`,style:(()=>{if(Ce===null&&fe===null)return;const t={};return Ce!==null&&(t["--flat-middle-width"]=`${Ce}px`),fe!==null&&(t["--flat-inspector-width"]=`${fe}px`),t})(),children:[D&&e.jsx("div",{className:"flat-mobile-sidebar-backdrop",onClick:Ct,"aria-hidden":"true"}),e.jsxs("div",{className:"flat-middle",children:[e.jsx("div",{className:"flat-middle__header",children:e.jsxs("div",{className:"flat-middle__actions",children:[e.jsx("button",{className:"flat-cta-btn flat-cta-btn--agent",onClick:M,title:"Create new agent",children:"+ Agent"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--boss",onClick:A,title:"Create new boss agent",children:"+ Boss"}),e.jsx("button",{className:"flat-cta-btn flat-cta-btn--area",onClick:k,title:"Create new area",children:"+ Area"})]})}),e.jsx("div",{className:"flat-middle__content",children:e.jsx(Va,{activeAgentId:ht,onClose:gt,onSelectAgent:Wt,expandedAreas:Me,onToggleArea:Te,onSetExpandedAreas:Et,agentListRef:lt})})]}),e.jsx("div",{className:"flat-splitter flat-splitter--middle",role:"separator","aria-orientation":"vertical","aria-label":"Resize agents panel",title:"Drag to resize · Double-click to reset",onPointerDown:nt,onPointerMove:qe,onPointerUp:ke,onPointerCancel:ke,onDoubleClick:zt}),e.jsxs("div",{className:"flat-right",children:[e.jsxs("button",{type:"button",className:"flat-mobile-sidebar-toggle","aria-label":D?"Close agents sidebar":"Open agents sidebar","aria-expanded":D,onClick:ut,children:[e.jsx(d,{name:"list",size:18}),e.jsx("span",{className:"flat-mobile-sidebar-toggle__label",children:"Agents"})]}),v?e.jsx(Jn,{agentId:v,terminalViewMode:tt,onTerminalViewModeChange:Dt,inspectorOpen:Ge,onToggleInspector:_,onShowTaskBoard:F,onImageClick:ze,onFileClick:Rt,onBashClick:pt,onViewMarkdown:B,onRequestClearSubordinates:Re,keyboard:Nt,canNavigateBack:Oe,canNavigateForward:Fe,onNavigateBack:We,onNavigateForward:St,agentInfoOpen:Qe,onToggleAgentInfo:ae,onHeaderContextMenu:Ot,onBuildingContextMenu:Ft}):e.jsx("div",{className:"flat-chat flat-chat--empty",children:e.jsxs("div",{className:"flat-map",children:[e.jsxs("div",{className:"flat-map__header",children:[e.jsx("span",{className:"flat-map__title",children:"🗺️ Areas"}),e.jsx("span",{className:"flat-map__hint",children:"Click an area to focus it, or an agent to chat"}),e.jsxs("span",{className:"flat-map__stats",children:[e.jsxs("span",{children:[Le.areaCount," areas"]}),e.jsxs("span",{children:[Le.agentCount," agents"]}),Le.workingCount>0&&e.jsxs("span",{className:"flat-map__stats-working",children:[e.jsx("span",{className:"flat-map__stats-dot","aria-hidden":"true"}),Le.workingCount," working"]})]}),e.jsx(Xn,{className:"flat-map__view-mode"})]}),e.jsx("div",{className:"flat-map__grid",style:{gridTemplateColumns:Z?"repeat(2, minmax(0, 1fr))":`repeat(${S.gridCols}, 1fr)`},children:S.groups.length===0?e.jsx("div",{className:"flat-map__empty",children:e.jsx("span",{children:"No areas or agents yet"})}):(Z?[...S.groups].sort((s,r)=>{const x=S.positions.get(s.area.id),w=S.positions.get(r.area.id);return!x&&!w?0:x?w?x.row-w.row||x.col-w.col:-1:1}):S.groups).map(s=>{var W;const r=s.area.id,x=S.positions.get(r),w=s.agents.filter(f=>f.status==="working").length,N=w>0,T=Z&&a!==r,G=Z&&!T;return e.jsxs("div",{className:`flat-map-area-card${N?" flat-map-area-card--working":""}${T?" flat-map-area-card--collapsed":""}${G?" flat-map-area-card--expanded":""}`,style:{"--area-color":s.area.color,gridRow:Z||x==null?void 0:x.row,gridColumn:Z||x==null?void 0:x.col},onContextMenu:f=>{y&&(f.preventDefault(),f.stopPropagation(),y(r,{x:f.clientX,y:f.clientY}))},children:[e.jsxs("button",{type:"button",className:"flat-map-area-card__header",onClick:()=>Z?i(r):U(r),title:Z?T?`Expand ${s.area.name}`:`Collapse ${s.area.name}`:`Focus ${s.area.name} in left panel`,"aria-expanded":Z?!T:void 0,children:[e.jsx("span",{className:"flat-map-area-card__color",style:{background:s.area.color}}),((W=s.area.logo)==null?void 0:W.filename)&&e.jsx("img",{className:"flat-map-area-card__logo",src:zn(s.area.logo.filename),alt:"","aria-hidden":"true",onError:f=>{f.currentTarget.style.display="none"}}),e.jsx("span",{className:"flat-map-area-card__name",children:s.area.name}),e.jsxs("span",{className:"flat-map-area-card__count",title:`${s.agents.length} agent${s.agents.length===1?"":"s"}`,"aria-label":`${s.agents.length} agent${s.agents.length===1?"":"s"}`,children:[e.jsx(d,{name:"users",size:10}),s.agents.length]}),N&&e.jsxs("span",{className:"flat-map-area-card__working",title:`${w} working agent${w===1?"":"s"}`,"aria-label":`${w} working agent${w===1?"":"s"}`,children:[e.jsx(aa,{animated:!0,size:12,className:"flat-map-area-card__working-glyph"}),e.jsx("span",{className:"flat-map-area-card__working-count",children:w})]}),Z&&e.jsx(d,{name:T?"caret-down":"caret-up",size:11,className:"flat-map-area-card__caret"})]}),e.jsx("div",{className:"flat-map-area-card__agents",children:s.agents.map(f=>{const J=f.isBoss||f.class==="boss",X=J?Bt.get(f.id):void 0,h=Na(f),C=h.usedPercent>=80?"#ff4a4a":h.usedPercent>=60?"#ff9e4a":h.usedPercent>=40?"#ffd700":"#4aff9e",P=`Context: ${(h.totalTokens/1e3).toFixed(1)}k / ${(h.contextWindow/1e3).toFixed(1)}k (${h.usedPercent}% used, ${h.freePercent}% free)`,de=f.latestTodos&&f.latestTodos.length>0||X&&X.length>0;return e.jsx(qa,{todos:f.latestTodos,subordinates:X,position:"top",children:e.jsxs("button",{type:"button",className:`flat-map-agent-chip ${f.status}`,onClick:()=>c(f.id),onContextMenu:Pe=>{Pe.preventDefault(),Pe.stopPropagation(),O({agentId:f.id,position:{x:Pe.clientX,y:Pe.clientY}})},title:de?void 0:`${J?"Boss · ":""}Open chat with ${f.name}
|
|
2
|
+
${P}`,children:[e.jsx(ya,{agent:f,size:16}),J&&e.jsx("span",{className:"flat-map-agent-chip__crown","aria-hidden":"true",children:e.jsx(d,{name:"crown",size:11,color:"#ffd700",weight:"fill"})}),e.jsx("span",{className:"flat-map-agent-chip__name",children:f.name}),e.jsx(Aa,{agent:f,alt:`${f.name} provider`,className:"flat-map-agent-chip__provider-icon"}),f.status==="working"?e.jsx(aa,{animated:!0,size:11,className:"flat-map-agent-chip__activity"}):e.jsx("span",{className:"flat-map-agent-chip__dot",style:{backgroundColor:Sa(f.status)}}),f.latestTodos&&f.latestTodos.length>0&&e.jsx(Ya,{todos:f.latestTodos,maxDots:6}),J&&X&&X.length>0&&e.jsx(Ka,{subordinates:X,maxDots:6}),e.jsx("span",{className:"flat-map-agent-chip__context-bar","aria-hidden":"true",children:e.jsx("span",{className:"flat-map-agent-chip__context-bar-fill",style:{width:`${h.usedPercent}%`,backgroundColor:C}})})]})},f.id)})}),s.area.directories.length>0&&e.jsx("div",{className:"flat-map-area-card__folders",role:"group","aria-label":`${s.area.name} folders`,children:s.area.directories.map(f=>{const J=f.split("/").filter(Boolean).pop()||f;return e.jsxs("button",{type:"button",className:"flat-map-folder-chip",onClick:X=>{X.stopPropagation(),g.openFileExplorerForAreaFolder(r,f)},title:`Open in file explorer: ${f}`,children:[e.jsx(d,{name:"folder-open",size:12}),e.jsx("span",{className:"flat-map-folder-chip__name",children:J})]},f)})}),s.buildings.length>0&&e.jsx("div",{className:"flat-map-area-card__buildings",children:s.buildings.map(f=>{var X;const J=(X=Za[f.type])==null?void 0:X.color;return e.jsxs("button",{type:"button",className:`flat-map-building-chip flat-map-building-chip--${f.status}`,style:J?{"--building-type-color":J}:void 0,onClick:h=>{if(b){const C=h.currentTarget.getBoundingClientRect();b(f.id,{x:C.right,y:C.top+C.height/2})}else ee(f.id)},onContextMenu:h=>{h.preventDefault(),h.stopPropagation(),ve({buildingId:f.id,position:{x:h.clientX,y:h.clientY}})},title:`${f.name} · ${f.type} · ${f.status}`,children:[e.jsx(d,{name:Ja(f.type),size:12,color:J}),e.jsx("span",{className:"flat-map-building-chip__name",children:f.name}),e.jsx("span",{className:"flat-map-building-chip__dot",style:{backgroundColor:Qa(f.status)}})]},f.id)})})]},r)})})]})})]}),ge&&e.jsx("div",{className:"flat-splitter flat-splitter--inspector",role:"separator","aria-orientation":"vertical","aria-label":"Resize inspector panel",title:"Drag to resize · Double-click to reset",onPointerDown:kt,onPointerMove:qe,onPointerUp:ke,onPointerCancel:ke,onDoubleClick:Ne}),ce&&e.jsxs("aside",{className:`flat-inspector ${Ht?"flat-inspector--open":"flat-inspector--closing"}`,"aria-label":"Inspector panel",children:[e.jsxs("div",{className:"flat-inspector__header",children:[e.jsxs("div",{className:"flat-inspector__tabs",role:"tablist","aria-label":"Inspector view",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":ye==="agent",className:`flat-inspector__tab ${ye==="agent"?"flat-inspector__tab--active":""}`,onClick:()=>ie("agent"),children:"Agent"}),e.jsx("button",{type:"button",role:"tab","aria-selected":ye==="tracking",className:`flat-inspector__tab ${ye==="tracking"?"flat-inspector__tab--active":""}`,onClick:()=>ie("tracking"),children:"Tracking"})]}),e.jsx("button",{type:"button",className:"flat-inspector__close",onClick:he,title:"Close inspector","aria-label":"Close inspector",children:"✕"})]}),e.jsx("div",{className:"flat-inspector__body",children:ye==="tracking"?e.jsx(en,{activeAgentId:v??"",onSelectAgent:t=>{c(t),window.innerWidth<=768&&he()}}):v?He?e.jsx(tn,{agent:He,onFocusAgent:t=>{c(t),window.innerWidth<=768&&he()},onKillAgent:t=>g.killAgent(t)}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Agent not found"})}):e.jsx("div",{className:"flat-inspector__empty",children:e.jsx("span",{children:"Select an agent to inspect"})})})]}),L&&e.jsx(an,{url:L.url,name:L.name,onClose:()=>_e(null)}),te&&e.jsx(nn,{state:te,onClose:()=>ue(null)}),e.jsx(sn,{agent:He??null,content:Ze,onClose:()=>jt(null)}),dt&&e.jsx(ln,{action:"clear-subordinates",selectedAgentId:dt.agentId,subordinateCount:dt.count,onClose:()=>$e(null),onClearHistory:()=>{}}),e.jsx(rn,{agent:He??null,isOpen:Qe&&!!v,onClose:et}),e.jsx(na,{isOpen:p!==null,position:(p==null?void 0:p.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:ot,onClose:()=>O(null)}),e.jsx(na,{isOpen:we!==null,position:(we==null?void 0:we.position)??{x:0,y:0},worldPosition:{x:0,z:0},actions:z,onClose:()=>ve(null)}),e.jsx(on,{isOpen:me!==null,title:K("common:confirm.removeAgentTitle"),message:K("common:confirm.removeAgentMessage",{name:(me==null?void 0:me.name)??""}),confirmLabel:K("common:buttons.remove"),cancelLabel:K("common:buttons.cancel"),variant:"danger",onConfirm:()=>{me&&g.removeAgentFromServer(me.agentId)},onClose:()=>Je(null)})]})}export{ss as FlatView};
|