@tom2012/cc-web 2026.4.19-j → 2026.4.19-l

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +1 -1
  2. package/backend/dist/hooks-manager.js +2 -2
  3. package/backend/dist/hooks-manager.js.map +1 -1
  4. package/backend/dist/index.js +1 -1
  5. package/backend/dist/index.js.map +1 -1
  6. package/backend/dist/routes/approval.d.ts.map +1 -1
  7. package/backend/dist/routes/approval.js +15 -7
  8. package/backend/dist/routes/approval.js.map +1 -1
  9. package/bin/ccweb-approval-hook.js +3 -1
  10. package/frontend/dist/assets/{AssistantMessageContent-BeYxoXBp.js → AssistantMessageContent-B5xM5JJL.js} +1 -1
  11. package/frontend/dist/assets/{GraphPreview-giBykFX4.js → GraphPreview-CP0HWB3D.js} +1 -1
  12. package/frontend/dist/assets/{MobilePage-BJfNH6P5.js → MobilePage-CKJsA5Bl.js} +3 -3
  13. package/frontend/dist/assets/{OfficePreview-DCcmZsIQ.js → OfficePreview-aUpVn8X7.js} +2 -2
  14. package/frontend/dist/assets/{PlanPanel-hOpV7PqT.js → PlanPanel-BUomc-uk.js} +1 -1
  15. package/frontend/dist/assets/{ProjectPage-C9gsvJHK.js → ProjectPage-DniZq70m.js} +4 -4
  16. package/frontend/dist/assets/{SettingsPage-B01sn-cT.js → SettingsPage-B1GOJwdi.js} +1 -1
  17. package/frontend/dist/assets/{ShareViewPage-BVWzZedA.js → ShareViewPage-0y_0_91E.js} +1 -1
  18. package/frontend/dist/assets/{SkillHubPage-BN-rpV8b.js → SkillHubPage-Bz1iodHC.js} +1 -1
  19. package/frontend/dist/assets/{bot-BY0Gl0Ea.js → bot-BPpxGUic.js} +1 -1
  20. package/frontend/dist/assets/{chevron-down-Cv9xjJgZ.js → chevron-down-CAohmFqo.js} +1 -1
  21. package/frontend/dist/assets/{chevron-up-qCxvNc4B.js → chevron-up-B6GEEk3k.js} +1 -1
  22. package/frontend/dist/assets/{index-DOT-jYY6.js → index-BfxRnyJK.js} +1 -1
  23. package/frontend/dist/assets/{index-DphnlW4X.js → index-DqQCNofi.js} +1 -1
  24. package/frontend/dist/assets/{index-DQ7mnz7m.js → index-Zh30nEgA.js} +2 -2
  25. package/frontend/dist/assets/{jszip.min-HhUCZiv_.js → jszip.min-DbeY1Bw4.js} +1 -1
  26. package/frontend/dist/assets/{matter-BrUHyU-T.js → matter-CJwWD_7Q.js} +1 -1
  27. package/frontend/dist/assets/{maximize-2-JKTPVHka.js → maximize-2-CKeeGyUI.js} +1 -1
  28. package/frontend/dist/assets/{search-8rUOyB4F.js → search-D6FWxasF.js} +1 -1
  29. package/frontend/dist/assets/{user-COizPgd6.js → user-BRwUyQma.js} +1 -1
  30. package/frontend/dist/index.html +1 -1
  31. package/package.json +1 -1
@@ -1,18 +1,18 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-giBykFX4.js","assets/index-DQ7mnz7m.js","assets/index-B02WMOK_.css","assets/maximize-2-JKTPVHka.js","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-BeYxoXBp.js","assets/chevron-down-Cv9xjJgZ.js","assets/chevron-up-qCxvNc4B.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-DphnlW4X.js","assets/bot-BY0Gl0Ea.js","assets/user-COizPgd6.js","assets/search-8rUOyB4F.js","assets/OfficePreview-DCcmZsIQ.js","assets/matter-BrUHyU-T.js","assets/PlanPanel-hOpV7PqT.js"])))=>i.map(i=>d[i]);
2
- var e,t,i,s,r,n;import{h as o,i as a,r as l,p as h,c,u as d,g as u,a as f,w as _,t as p,j as m,b as g,E as v,P as b,M as S,d as x,X as w,e as y,f as C,S as k,R as E,_ as N,s as R,k as D,l as L,D as M,T,m as P,F as B,n as j,o as A,C as O,q as I,A as z,v as H,x as W,y as F,B as $,z as U,G as K,I as q,H as V,J as Y,K as X,L as G,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as fe,a8 as _e,a9 as pe,aa as me,ab as ge,ac as ve,ad as be,ae as Se,af as xe,ag as we,ah as ye,ai as Ce,aj as ke,ak as Ee,al as Ne,am as Re,an as De,ao as Le,ap as Me,aq as Te,ar as Pe,as as Be,at as je,au as Ae,av as Oe,aw as Ie,ax as ze,ay as He,az as We,aA as Fe,aB as $e,aC as Ue,aD as Ke,aE as qe,aF as Ve,aG as Ye,aH as Xe,aI as Ge,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt}from"./index-DQ7mnz7m.js";import{p as it}from"./purify.es-CgRAQgUo.js";import{F as st,M as rt,r as nt,a as ot,b as at,h as lt,o as ht,c as ct,I as dt,A as ut,S as ft}from"./AssistantMessageContent-BeYxoXBp.js";import{S as _t,u as pt,c as mt}from"./index-DphnlW4X.js";import{C as gt}from"./chevron-down-Cv9xjJgZ.js";import{B as vt}from"./bot-BY0Gl0Ea.js";import{U as bt}from"./user-COizPgd6.js";import{S as St}from"./search-8rUOyB4F.js";import{C as xt}from"./chevron-up-qCxvNc4B.js";
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GraphPreview-CP0HWB3D.js","assets/index-Zh30nEgA.js","assets/index-B02WMOK_.css","assets/maximize-2-CKeeGyUI.js","assets/purify.es-CgRAQgUo.js","assets/AssistantMessageContent-B5xM5JJL.js","assets/chevron-down-CAohmFqo.js","assets/chevron-up-B6GEEk3k.js","assets/AssistantMessageContent-wklAmtGL.css","assets/index-DqQCNofi.js","assets/bot-BPpxGUic.js","assets/user-BRwUyQma.js","assets/search-D6FWxasF.js","assets/OfficePreview-aUpVn8X7.js","assets/matter-CJwWD_7Q.js","assets/PlanPanel-BUomc-uk.js"])))=>i.map(i=>d[i]);
2
+ var e,t,i,s,r,n;import{h as o,i as a,r as l,p as h,c,u as d,g as u,a as f,w as _,t as p,j as m,b as g,E as v,P as b,M as S,d as x,X as w,e as y,f as C,S as k,R as E,_ as N,s as R,k as D,l as L,D as M,T,m as P,F as B,n as j,o as A,C as O,q as I,A as z,v as H,x as W,y as F,B as $,z as U,G as K,I as q,H as V,J as Y,K as X,L as G,N as J,O as Z,Q,U as ee,V as te,W as ie,Y as se,Z as re,$ as ne,a0 as oe,a1 as ae,a2 as le,a3 as he,a4 as ce,a5 as de,a6 as ue,a7 as fe,a8 as _e,a9 as pe,aa as me,ab as ge,ac as ve,ad as be,ae as Se,af as xe,ag as we,ah as ye,ai as Ce,aj as ke,ak as Ee,al as Ne,am as Re,an as De,ao as Le,ap as Me,aq as Te,ar as Pe,as as Be,at as je,au as Ae,av as Oe,aw as Ie,ax as ze,ay as He,az as We,aA as Fe,aB as $e,aC as Ue,aD as Ke,aE as qe,aF as Ve,aG as Ye,aH as Xe,aI as Ge,aJ as Je,aK as Ze,aL as Qe,aM as et,aN as tt}from"./index-Zh30nEgA.js";import{p as it}from"./purify.es-CgRAQgUo.js";import{F as st,M as rt,r as nt,a as ot,b as at,h as lt,o as ht,c as ct,I as dt,A as ut,S as ft}from"./AssistantMessageContent-B5xM5JJL.js";import{S as _t,u as pt,c as mt}from"./index-DqQCNofi.js";import{C as gt}from"./chevron-down-CAohmFqo.js";import{B as vt}from"./bot-BPpxGUic.js";import{U as bt}from"./user-BRwUyQma.js";import{S as St}from"./search-D6FWxasF.js";import{C as xt}from"./chevron-up-B6GEEk3k.js";
3
3
  /**
4
4
  * @license lucide-react v0.309.0 - ISC
5
5
  *
6
6
  * This source code is licensed under the ISC license.
7
7
  * See the LICENSE file in the root directory of this source tree.
8
8
  */
9
- const wt=c("Brain",[["path",{d:"M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z",key:"1mhkh5"}],["path",{d:"M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z",key:"1d6s00"}]]),yt=c("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ct=c("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),kt=c("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Et=c("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Nt=c("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Rt=c("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Dt=c("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),Lt=c("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]),Mt=c("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Tt=c("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Pt=c("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),Bt=c("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),jt=c("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),At=c("ShieldAlert",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),Ot=c("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]),It=c("StopCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{width:"6",height:"6",x:"9",y:"9",key:"1wrtvo"}]]),zt=c("UploadCloud",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]]),Ht=c("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),Wt=c("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Ft=c("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),$t=E.lazy(()=>N(()=>import("./GraphPreview-giBykFX4.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.GraphPreview}))),Ut=E.lazy(()=>N(()=>import("./OfficePreview-DCcmZsIQ.js"),__vite__mapDeps([13,1,2,4])).then(e=>({default:e.OfficePreview}))),Kt=new Set(["docx","xlsx","xls","pptx"]),qt={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};
9
+ const wt=c("Brain",[["path",{d:"M9.5 2A2.5 2.5 0 0 1 12 4.5v15a2.5 2.5 0 0 1-4.96.44 2.5 2.5 0 0 1-2.96-3.08 3 3 0 0 1-.34-5.58 2.5 2.5 0 0 1 1.32-4.24 2.5 2.5 0 0 1 1.98-3A2.5 2.5 0 0 1 9.5 2Z",key:"1mhkh5"}],["path",{d:"M14.5 2A2.5 2.5 0 0 0 12 4.5v15a2.5 2.5 0 0 0 4.96.44 2.5 2.5 0 0 0 2.96-3.08 3 3 0 0 0 .34-5.58 2.5 2.5 0 0 0-1.32-4.24 2.5 2.5 0 0 0-1.98-3A2.5 2.5 0 0 0 14.5 2Z",key:"1d6s00"}]]),yt=c("ClipboardCopy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ct=c("Code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),kt=c("Copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Et=c("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Nt=c("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]),Rt=c("MessageSquare",[["path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z",key:"1lielz"}]]),Dt=c("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]),Lt=c("Minimize2",[["polyline",{points:"4 14 10 14 10 20",key:"11kfnr"}],["polyline",{points:"20 10 14 10 14 4",key:"rlmsce"}],["line",{x1:"14",x2:"21",y1:"10",y2:"3",key:"o5lafz"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]),Mt=c("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),Tt=c("PanelLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),Pt=c("PanelRight",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),Bt=c("Play",[["polygon",{points:"5 3 19 12 5 21 5 3",key:"191637"}]]),jt=c("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),At=c("ShieldAlert",[["path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10",key:"1irkt0"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M12 16h.01",key:"1drbdi"}]]),Ot=c("Shuffle",[["path",{d:"M2 18h1.4c1.3 0 2.5-.6 3.3-1.7l6.1-8.6c.7-1.1 2-1.7 3.3-1.7H22",key:"1wmou1"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 6h1.9c1.5 0 2.9.9 3.6 2.2",key:"10bdb2"}],["path",{d:"M22 18h-5.9c-1.3 0-2.6-.7-3.3-1.8l-.5-.8",key:"vgxac0"}],["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}]]),It=c("StopCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{width:"6",height:"6",x:"9",y:"9",key:"1wrtvo"}]]),zt=c("UploadCloud",[["path",{d:"M4 14.899A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.5 8.242",key:"1pljnt"}],["path",{d:"M12 12v9",key:"192myk"}],["path",{d:"m16 16-4-4-4 4",key:"119tzi"}]]),Ht=c("Upload",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"17 8 12 3 7 8",key:"t8dd8p"}],["line",{x1:"12",x2:"12",y1:"3",y2:"15",key:"widbto"}]]),Wt=c("ZoomIn",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),Ft=c("ZoomOut",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),$t=E.lazy(()=>N(()=>import("./GraphPreview-CP0HWB3D.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.GraphPreview}))),Ut=E.lazy(()=>N(()=>import("./OfficePreview-aUpVn8X7.js"),__vite__mapDeps([13,1,2,4])).then(e=>({default:e.OfficePreview}))),Kt=new Set(["docx","xlsx","xls","pptx"]),qt={js:"javascript",jsx:"jsx",ts:"typescript",tsx:"tsx",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",swift:"swift",c:"c",cpp:"cpp",h:"c",cs:"csharp",php:"php",sh:"bash",bash:"bash",zsh:"bash",yaml:"yaml",yml:"yaml",json:"json",toml:"toml",html:"html",htm:"html",xml:"xml",svg:"xml",css:"css",scss:"scss",less:"less",sql:"sql",graphql:"graphql",gql:"graphql",dockerfile:"docker",makefile:"makefile",r:"r",lua:"lua",dart:"dart",zig:"zig"};
10
10
  /**
11
11
  * @license lucide-react v0.309.0 - ISC
12
12
  *
13
13
  * This source code is licensed under the ISC license.
14
14
  * See the LICENSE file in the root directory of this source tree.
15
- */const Vt=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function Yt(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const Xt=[50,75,100,125,150,200,250,300],Gt=100;function Jt({filePath:e,onClose:t}){const i=e.endsWith("/.notebook/graph.yaml"),s=i?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[r,n]=l.useState(null),[o,a]=l.useState(null),[h,c]=l.useState(()=>i?"graph":"rendered"),[E,N]=l.useState(!1),[D,L]=l.useState(Gt),[M,T]=l.useState(""),[P,B]=l.useState(!1),[j,A]=l.useState(!1),O=l.useRef(null),[I,z]=l.useState(!0),{resolved:H}=d(),W=e.split("/").pop()??e,F=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),$=Vt.has(F),U=Kt.has(F),K=function(e){return"md"===e||"html"===e||"htm"===e||e in qt}(F),q=qt[F]||F,V=l.useMemo(()=>{if(!$)return"";const t=y(e),i=u(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,$]);l.useEffect(()=>{if(z(!0),n(null),a(null),L(function(e){const t=C(k.fileZoom,{},!0)[e];return Xt.includes(t)?t:Gt}(e)),A(!1),$||U)return n({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void c("rendered");c(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),f(e).then(e=>{n(e),T(e.content??"")}).catch(e=>a(e instanceof Error?e.message:"Failed to load file"))},[e,$,U]);const Y=l.useCallback(async()=>{B(!0);try{await _(e,M),n(e=>e?{...e,content:M,size:new Blob([M]).size}:e),A(!1)}catch(t){p.error(t instanceof Error?t.message:"保存失败")}finally{B(!1)}},[e,M]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===h&&(e.preventDefault(),Y())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h,Y]),l.useEffect(()=>{const e=e=>{if("Escape"===e.key&&I){if(j&&!confirm("有未保存的修改,确定关闭?"))return;t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[I,t,j]);const X=()=>{j&&!confirm("有未保存的修改,确定退出编辑?")||(c(i?"graph":K?"rendered":"plain"),A(!1))},G=t=>{L(t),function(e,t){const i=C(k.fileZoom,{},!0);t===Gt?delete i[e]:i[e]=t,R(k.fileZoom,i,!0)}(e,t)},J=(null==r?void 0:r.content)??"",Z="dark"===H?ht:ct,Q=D/100*12,ee=r&&!r.binary&&!r.tooLarge,te=l.useMemo(()=>{var e,t;if("md"!==F)return null;const i="edit"===h?M:J;if(!i)return 0;return((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0)},[F,J,M,h]);return m.jsx("div",{className:g("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",I?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&z(!1)},children:m.jsxs("div",{className:g("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200 pointer-events-auto",E?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg",!I&&!E&&"opacity-50"),onClick:()=>z(!0),onFocus:e=>{e.stopPropagation(),z(!0)},children:[m.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[m.jsx(st,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),m.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[W,j&&m.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),null!==te&&m.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs",children:[te.toLocaleString()," 字"]})]}),ee&&!$&&!U&&m.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[K&&m.jsxs(m.Fragment,{children:[m.jsxs("button",{onClick:()=>"edit"===h?X():c("plain"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","plain"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[m.jsx(Ct,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),m.jsxs("button",{onClick:()=>"edit"===h?X():c("rendered"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","rendered"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:Yt(F),children:[m.jsx(v,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:Yt(F)})]})]}),i&&m.jsxs("button",{onClick:()=>"edit"===h?X():c("graph"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","graph"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[m.jsx(Mt,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),m.jsxs("button",{onClick:()=>"edit"===h?X():(T((null==r?void 0:r.content)??""),A(!1),c("edit"),void setTimeout(()=>{var e;return null==(e=O.current)?void 0:e.focus()},0)),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","edit"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[m.jsx(b,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===h&&m.jsxs("button",{onClick:()=>{Y()},disabled:P||!j,className:g("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",j?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[m.jsx(_t,{className:"h-3 w-3"}),P?"保存中...":"保存"]}),(ee||$)&&"edit"!==h&&"graph"!==h&&m.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[m.jsx("button",{onClick:()=>{const e=[...Xt].reverse().find(e=>e<D);e&&G(e)},disabled:D<=Xt[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:m.jsx(Ft,{className:"h-3 w-3"})}),m.jsxs("button",{onClick:()=>G(Gt),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[D,"%"]}),m.jsx("button",{onClick:()=>{const e=Xt.find(e=>e>D);e&&G(e)},disabled:D>=Xt[Xt.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:m.jsx(Wt,{className:"h-3 w-3"})})]}),m.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>N(e=>!e),title:E?"退出全屏":"全屏",children:E?m.jsx(S,{className:"h-3.5 w-3.5"}):m.jsx(x,{className:"h-3.5 w-3.5"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{j&&!confirm("有未保存的修改,确定关闭?")||t()},children:m.jsx(w,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:g("flex-1 min-h-0","graph"===h?"overflow-hidden":"overflow-auto"),children:["graph"===h&&m.jsx(l.Suspense,{fallback:m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:m.jsx($t,{folderPath:s})}),"graph"!==h&&!r&&!o&&m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==h&&o&&m.jsx("p",{className:"text-sm text-red-400 p-4",children:o}),"graph"!==h&&$&&r&&m.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:m.jsx("img",{src:V,alt:W,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${D/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==h&&U&&r&&m.jsx(l.Suspense,{fallback:m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:m.jsx(Ut,{filePath:e,ext:F,zoom:D})}),"graph"!==h&&!$&&!U&&r&&r.binary&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[m.jsx(st,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:[(r.size/1024).toFixed(1)," KB"]})]}),"graph"!==h&&!U&&r&&r.tooLarge&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[m.jsx(st,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm",children:"File too large to preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:[(r.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==h&&ee&&null!==J&&m.jsxs(m.Fragment,{children:["edit"===h&&m.jsx("textarea",{ref:O,value:M,onChange:e=>{T(e.target.value),A(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${Q}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==h&&m.jsxs("div",{className:"p-4",style:{fontSize:`${Q}px`},children:["plain"===h&&m.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:J}),"rendered"===h&&"md"===F&&m.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:m.jsx(rt,{remarkPlugins:[ot,at],rehypePlugins:[nt],components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?m.jsx("code",{className:e,...i,children:t}):m.jsx(lt,{style:Z,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})}},children:J})}),"rendered"===h&&("html"===F||"htm"===F)&&m.jsx("iframe",{srcDoc:it.sanitize(J,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:W,style:{minHeight:"60vh",transform:`scale(${D/100})`,transformOrigin:"top left",width:1e4/D+"%",height:1e4/D+"%"}}),"rendered"===h&&"md"!==F&&"html"!==F&&"htm"!==F&&q&&m.jsx(lt,{style:Z,language:q,showLineNumbers:!0,lineNumberStyle:{color:"dark"===H?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:J}),"rendered"===h&&!K&&m.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:J})]})]})]})]})})}const Zt=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function Qt(e){const t=e.lastIndexOf(".");return t>=0&&Zt.has(e.slice(t+1).toLowerCase())}function ei({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,a]=l.useState(new Set),h=D(e=>e.get(t).filePreviewPath),c=D(e=>e.setFilePreviewPath),d=e=>c(t,e),[f,_]=l.useState(null),[v,b]=l.useState(!1),[S,x]=l.useState(!1),w=l.useRef(null),C=l.useRef(null);l.useEffect(()=>{if(!f)return;const e=()=>_(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[f]);const k=async t=>{if(0!==t.length){b(!0);try{await A(e,t),E(e)}catch(i){console.error("[FileTree] Upload failed:",i)}finally{b(!1)}}},E=l.useCallback(async e=>{a(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await L(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{a(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),a(new Set),E(e)},[e,E]);const N=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||E(e)),s})},[i,E]),R=l.useCallback(()=>{s(new Map),n(new Set([e])),a(new Set),E(e)},[e,E]),W=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return m.jsxs("div",{children:[m.jsxs("div",{className:g("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px"},onClick:()=>"dir"===e.type?N(e.path):d(e.path),onContextMenu:t=>{t.preventDefault(),_({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},children:[m.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?m.jsx(P,{className:"h-2.5 w-2.5 animate-spin"}):s?m.jsx(gt,{className:"h-2.5 w-2.5"}):m.jsx(O,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?m.jsx(B,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):m.jsx(I,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):Qt(e.name)?m.jsx(dt,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):m.jsx(st,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),m.jsx("span",{className:g("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),m.jsx(z,{initial:!1,children:"dir"===e.type&&s&&m.jsxs(H.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&m.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&m.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&W(a,t+1)]})})]},e.path)}),F=i.get(e),$=o.has(e),U=e.split("/").filter(Boolean).pop()??e;return m.jsxs(m.Fragment,{children:[h&&m.jsx(Jt,{filePath:h,onClose:()=>d(null)}),f&&m.jsxs("div",{ref:w,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:[m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{const t=f.filePath.startsWith(e+"/")?f.filePath.slice(e.length+1):f.filePath;navigator.clipboard.writeText(t),p.success("已复制相对路径"),_(null)},children:[m.jsx(kt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{navigator.clipboard.writeText(f.filePath),p.success("已复制绝对路径"),_(null)},children:[m.jsx(yt,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===f.type&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=y(e);const s=u();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`),i+=(i.includes("?")?"&":"?")+"dl=1";try{const e=await fetch(i);if(!e.ok){const t=await e.text().catch(()=>"");let i=`下载失败 (${e.status})`;try{i=JSON.parse(t).error||i}catch{}return void p.error(i)}const s=await e.blob(),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}catch{p.error("下载失败:网络错误")}})(f.filePath,f.fileName),_(null)},children:[m.jsx(M,{className:"h-3.5 w-3.5"}),"下载"]})]}),m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(window.confirm(`确认删除${n}?此操作不可撤销。`))try{await j(t),p.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?E(r):E(e)}catch(o){p.error(`删除失败: ${o.message}`)}})(f.filePath,f.fileName,f.type),_(null)},children:[m.jsx(T,{className:"h-3.5 w-3.5"}),"删除"]})]}),m.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[m.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx("input",{ref:C,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&k(t),e.target.value=""}}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=C.current)?void 0:e.click()},disabled:v,title:"上传文件",children:m.jsx(Ht,{className:g("h-3 w-3",v&&"animate-pulse")})}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:R,title:"Refresh file tree",children:m.jsx(P,{className:g("h-3 w-3",$&&"animate-spin")})})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[m.jsx(B,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),m.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:U})]}),m.jsxs("div",{className:g("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",S&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),x(!0)},onDragEnter:e=>{e.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:e=>{e.preventDefault(),x(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&k(t)},children:[v&&m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),S&&!v&&m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),$&&!F?m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):F&&0!==F.length?W(F,0):m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function ti(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function ii({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,f]=l.useState(!1),[_,v]=l.useState([]),[b,S]=l.useState(0),[x,w]=l.useState(!0),[y,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await W(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?_.length:0,s=await F(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),S(s.total)}catch{}finally{C(!1)}},[e,_.length]);l.useEffect(()=>{k(),E()},[e]);const N=async t=>{try{const{diff:i}=await V(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{p.error("获取 diff 失败")}},R=async t=>{try{await Y(e,[t]),p.success(`已暂存 ${t}`),await k()}catch{p.error("git add 失败")}},D=async()=>{if(c.trim()){f(!0);try{await X(e,c),p.success("提交成功"),d(""),await k()}catch(t){p.error(t instanceof Error?t.message:"提交失败")}finally{f(!1)}}};if(!t&&s)return m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[m.jsx(Et,{className:"h-5 w-5"}),m.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[m.jsx(Et,{className:"h-5 w-5"}),m.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),m.jsx($,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const L=[...t.modified??[],...t.deleted??[]],M=t.staged??[],T=t.untracked??[];return m.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[m.jsx(Et,{className:"h-3 w-3"}),m.jsx("span",{children:t.branch}),(t.ahead??0)>0&&m.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&m.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),m.jsx($,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:m.jsx(P,{className:g("h-3 w-3",s&&"animate-spin")})})]}),M.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",M.length,")"]}),M.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx(U,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),m.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{N(e)},children:e})]},e))]}),L.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",L.length,")"]}),L.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{R(e)},children:m.jsx(K,{className:"h-2.5 w-2.5"})}),m.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{N(e)},children:e})]},e))]}),T.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",T.length,")"]}),T.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{R(e)},children:m.jsx(K,{className:"h-2.5 w-2.5"})}),m.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===L.length&&0===M.length&&0===T.length&&m.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),M.length>0&&m.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[m.jsx(q,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||D()},className:"h-7 text-xs"}),m.jsx($,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{D()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${M.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&m.jsxs("div",{className:"border-t border-border pt-2",children:[m.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>w(e=>!e),children:[m.jsx(gt,{className:g("h-3 w-3 transition-transform",!x&&"-rotate-90")}),m.jsx(Nt,{className:"h-3 w-3"}),m.jsxs("span",{children:["提交历史 (",b,")"]})]}),x&&m.jsxs("div",{className:"space-y-0.5",children:[_.map((e,t)=>{const i=e.parents.length>1;return m.jsxs("div",{className:"flex gap-1.5 items-start group",children:[m.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[m.jsx("div",{className:g("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<_.length-1&&m.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),m.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[m.jsxs("div",{className:"flex items-baseline gap-1",children:[m.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),m.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),m.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[m.jsx("span",{children:e.author}),m.jsx("span",{children:ti(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>m.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),_.length<b&&m.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:y,children:y?"加载中...":`加载更多 (${_.length}/${b})`})]})]}),null!==n&&m.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[m.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),m.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",onClick:e=>e.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[m.jsx("span",{className:"truncate text-muted-foreground",children:a}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),m.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>m.jsx("span",{className:g("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}const si={feedback:{bg:"bg-blue-500",text:"text-blue-400",border:"border-blue-500/30"},user:{bg:"bg-green-500",text:"text-green-400",border:"border-green-500/30"},project:{bg:"bg-yellow-500",text:"text-yellow-400",border:"border-yellow-500/30"},reference:{bg:"bg-purple-500",text:"text-purple-400",border:"border-purple-500/30"}},ri={maintain:"请读取 .memory-pool/QUICK-REF.md,然后调用 POST /maintenance 获取维护建议并执行",load:"请调用 GET /api/memory-pool/{projectId}/surface 获取活跃层记忆,将重要记忆纳入当前上下文",save:"请从我们当前的对话中提取值得记忆的信息,通过 POST /balls API 存入记忆池",general:"请读取 .memory-pool/QUICK-REF.md,对记忆池执行你认为合适的操作"};function ni({projectId:e,onSend:t,onBallClick:i}){var s,r;const[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(!0),[u,f]=l.useState(!1),[_,v]=l.useState(!1),[b,S]=l.useState(!1),[x,w]=l.useState(!1),[y,C]=l.useState(1e4),[k,E]=l.useState(!1),N=l.useRef(null),R=l.useCallback(async()=>{var t;try{const i=await G(e);return o(i),(null==(t=i.state)?void 0:t.surface_width)&&C(i.state.surface_width),i.initialized}catch{return!1}},[e]),D=l.useCallback(async()=>{try{const t=await J(e);h(t)}catch{}},[e]);l.useEffect(()=>{let e=!1;return(async()=>{d(!0);const t=await R();!e&&t&&await D(),e||d(!1)})(),()=>{e=!0}},[e,R,D]),l.useEffect(()=>{if(!(null==n?void 0:n.initialized))return;const e=()=>D();N.current=setInterval(e,15e3);const t=()=>{document.hidden?N.current&&(clearInterval(N.current),N.current=null):(e(),N.current&&clearInterval(N.current),N.current=setInterval(e,15e3))};return document.addEventListener("visibilitychange",t),()=>{N.current&&clearInterval(N.current),document.removeEventListener("visibilitychange",t)}},[null==n?void 0:n.initialized,D]);const L=async()=>{f(!0);try{await Z(e),await R(),await D()}catch(t){console.error("Memory pool init failed:",t)}finally{f(!1)}},M=async()=>{var t;v(!0);try{const i=await ee(e);p.success(`记忆池已更新到 v${i.version}`,{description:null==(t=i.changes)?void 0:t.join(", ")}),await R(),await D()}catch(i){p.error("更新失败",{description:i.message})}finally{v(!1)}},T=e=>{t&&(t(ri[e]+"\r"),p.success("指令已发送到终端"))};if(c)return m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."});if(!(null==n?void 0:n.initialized))return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4",children:[m.jsx("div",{className:"text-3xl opacity-30",children:"🧠"}),m.jsx("p",{className:"text-muted-foreground text-xs text-center",children:"本项目尚未启用记忆池"}),m.jsx($,{size:"sm",onClick:L,disabled:u,children:u?"初始化中...":"初始化记忆池"})]});const P=(null==a?void 0:a.balls)??[],B=(null==(s=n.state)?void 0:s.active_capacity)??20,j=P.slice(0,B),A=P.slice(B);return m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between",children:[m.jsx("span",{className:"font-medium text-xs text-foreground",children:"记忆池"}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["t=",(null==(r=n.state)?void 0:r.t)??0," · ",P.length," balls"]}),m.jsx("button",{onClick:()=>w(e=>!e),className:g("text-[10px] px-1 py-0.5 rounded transition-colors",x?"text-blue-400 bg-blue-500/10":"text-muted-foreground hover:text-foreground"),"aria-label":"设置",children:"⚙"})]})]}),x&&m.jsxs("div",{className:"flex-shrink-0 mx-3 mb-2 p-2 rounded border border-border bg-muted/20 space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("label",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:"楔形宽度"}),m.jsx("input",{type:"number",min:1e3,max:1e5,step:1e3,value:y,onChange:e=>C(Number(e.target.value)),className:"flex-1 min-w-0 px-1.5 py-0.5 text-[10px] rounded border border-border bg-background text-foreground"}),m.jsx("span",{className:"text-[9px] text-muted-foreground",children:"tok"}),m.jsx("button",{onClick:async()=>{E(!0);try{const t=await Q(e,y);p.success(`楔形宽度已更新: ${t.surface_balls} balls, ~${t.total_tokens} tokens`)}catch(t){p.error("更新失败",{description:t.message})}finally{E(!1)}},disabled:k,className:"px-2 py-0.5 text-[10px] rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors disabled:opacity-50",children:k?"...":"保存"})]}),m.jsx("p",{className:"text-[9px] text-muted-foreground leading-tight",children:"控制 surface.md 中浮出水面的记忆总 token 量。越大 → LLM 读取更多记忆,越小 → 更省 token。"})]}),n.needsUpgrade&&m.jsxs("div",{className:"flex-shrink-0 mx-3 mb-2 px-2 py-1.5 rounded bg-orange-500/10 border border-orange-500/30 flex items-center justify-between",children:[m.jsx("span",{className:"text-[10px] text-orange-400",children:"记忆池格式需要更新"}),m.jsx("button",{onClick:M,disabled:_,className:"px-2 py-0.5 text-[10px] rounded bg-orange-500/20 text-orange-400 hover:bg-orange-500/30 transition-colors disabled:opacity-50",children:_?"更新中...":"更新"})]}),m.jsxs("div",{className:"flex-shrink-0 px-3 pb-2 flex gap-1 flex-wrap",children:[m.jsx("button",{onClick:()=>T("maintain"),className:"px-2 py-0.5 text-[10px] rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10 transition-colors",children:"整理"}),m.jsx("button",{onClick:()=>T("load"),className:"px-2 py-0.5 text-[10px] rounded border border-green-500/30 text-green-400 hover:bg-green-500/10 transition-colors",children:"读取"}),m.jsx("button",{onClick:()=>T("save"),className:"px-2 py-0.5 text-[10px] rounded border border-yellow-500/30 text-yellow-400 hover:bg-yellow-500/10 transition-colors",children:"保存"}),m.jsx("button",{onClick:()=>T("general"),className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:bg-muted/30 transition-colors",children:"通用"}),!n.needsUpgrade&&m.jsx("button",{onClick:M,disabled:_,className:"px-2 py-0.5 text-[10px] rounded border border-orange-500/30 text-orange-400 hover:bg-orange-500/10 transition-colors disabled:opacity-50",children:_?"更新中...":"更新"}),m.jsx("button",{onClick:async()=>{S(!0);try{const e=await te(),t=[];e.added>0&&t.push(`新增 ${e.added}`),e.updated>0&&t.push(`更新 ${e.updated}`),e.skipped>0&&t.push(`跳过 ${e.skipped}`),e.orphaned>0&&t.push(`孤儿 ${e.orphaned}`),p.success("全局记忆池已更新",{description:t.join(" · ")+(e.unreachable_projects.length>0?` | 不可达: ${e.unreachable_projects.join(", ")}`:"")})}catch(e){p.error("全局同步失败",{description:e.message})}finally{S(!1)}},disabled:b,className:"px-2 py-0.5 text-[10px] rounded border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors disabled:opacity-50",children:b?"同步中...":"同步全局"})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pb-3 space-y-1",children:[j.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"活跃层"}),j.map(e=>m.jsx(oi,{ball:e,onClick:()=>null==i?void 0:i(e,P,B)},e.id))]}),A.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-3 mb-1",children:"深层"}),A.map(e=>m.jsx(oi,{ball:e,deep:!0,onClick:()=>null==i?void 0:i(e,P,B)},e.id))]}),0===P.length&&m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:"记忆池为空,在终端中与 AI 对话时会自动积累记忆"})]})]})}function oi({ball:e,deep:t,onClick:i}){const s=si[e.type]??si.reference;return m.jsxs("div",{onClick:i,className:g("p-2 rounded-md cursor-pointer transition-colors border-l-2",t?"bg-muted/20 opacity-50 hover:opacity-70":"bg-muted/40 hover:bg-muted/60",s.border),children:[m.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:g("text-[10px] px-1 py-px rounded text-white",s.bg),children:e.type}),e.permanent&&m.jsx("span",{className:"text-[10px] px-1 py-px rounded bg-orange-500/20 text-orange-400",children:"permanent"})]}),m.jsxs("span",{className:g("text-[10px] font-medium",s.text),children:["B ",e.buoyancy.toFixed(1)]})]}),m.jsx("div",{className:"text-[11px] text-foreground leading-tight line-clamp-2",children:e.summary}),m.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["H=",e.H," · t=",e.t_last,e.diameter?` · ~${e.diameter}tok`:"",e.links.length>0?` · ${e.links.length} links`:""]})]})}const ai={feedback:{main:"#4a6cf7",light:"#6b8cff"},user:{main:"#22c55e",light:"#5ee87a"},project:{main:"#f59e0b",light:"#fbbf4e"},reference:{main:"#a78bfa",light:"#c4b5fd"}};function li({balls:e,selectedId:t,activeCapacity:i,onClose:s}){var r;const[n,o]=l.useState(t),[a,h]=l.useState(new Map),c=l.useRef(null);l.useEffect(()=>{const e=e=>{"Escape"===e.key&&s()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]);const d=500,u=510,f=475,_=l.useMemo(()=>e.map(e=>Math.min(50,Math.max(24,16+.4*e.summary.length))),[e]),p=e.map(e=>`${e.id}:${e.buoyancy.toFixed(2)}`).join(",");l.useEffect(()=>{var t;null==(t=c.current)||t.call(c),c.current=null;let i=!1;return N(()=>import("./matter-BrUHyU-T.js").then(e=>e.m),__vite__mapDeps([14,1,2])).then(t=>{if(i)return;const{Engine:s,Runner:r,Bodies:n,Composite:o,Body:a,Events:l}=t,d=s.create({gravity:{x:0,y:.8,scale:.001}}),p=30,m={isStatic:!0,restitution:.2,friction:.05},g=n.rectangle(300,10,270,p,m),v=n.rectangle(300,490,570,p,m),b=-150,S=Math.sqrt(225e3)+p,x=Math.atan2(450,b),w=n.rectangle(120,250,S,15,{...m,angle:x}),y=Math.sqrt(225e3)+p,C=Math.atan2(450,150),k=n.rectangle(480,250,y,15,{...m,angle:C}),E=new Array(e.length),N=[],R=e.map((e,t)=>t).sort((t,i)=>e[i].buoyancy-e[t].buoyancy);o.add(d.world,[g,v,w,k]),R.forEach((t,s)=>{const r=setTimeout(()=>{if(i)return;const s=_[t]/2,r=300+(Math.random()-.5)*u*.3,a=f-s-5,l=n.circle(r,a,s,{restitution:.2,friction:.01,frictionAir:.02,label:e[t].id});E[t]=l,o.add(d.world,l)},100*s);N.push(r)}),l.on(d,"beforeUpdate",()=>{for(let t=0;t<e.length;t++){const i=E[t];i&&a.applyForce(i,i.position,{x:0,y:-.001*e[t].buoyancy*i.mass})}});const D=r.create();let L;r.run(D,d);const M=()=>{const t=new Map;for(let i=0;i<e.length;i++){const s=E[i];s&&t.set(e[i].id,{x:s.position.x,y:s.position.y})}h(t),L=requestAnimationFrame(M)};L=requestAnimationFrame(M),c.current=()=>{N.forEach(clearTimeout),cancelAnimationFrame(L),r.stop(D),l.off(d,"beforeUpdate"),o.clear(d.world,!1),s.clear(d)}}),()=>{var e;i=!0,null==(e=c.current)||e.call(c),c.current=null}},[p,i]);const g=e.find(e=>e.id===n),v=Math.min(i,e.length);return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:m.jsxs("div",{className:"relative bg-background border border-border rounded-xl shadow-2xl overflow-hidden",style:{width:Math.min(640,window.innerWidth-40),height:Math.min(620,window.innerHeight-40)},onClick:e=>e.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[m.jsx("span",{className:"text-sm font-medium",children:"记忆池全景"}),m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500 inline-block"})," feedback"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 inline-block"})," user"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-500 inline-block"})," project"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-400 inline-block"})," reference"]}),m.jsx("button",{onClick:s,"aria-label":"关闭",className:"ml-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500 rounded",children:m.jsx(w,{className:"w-4 h-4"})})]})]}),m.jsxs("svg",{width:"100%",height:d,viewBox:"0 0 600 500",children:[m.jsx("path",{d:"M 195 25 L 405 25 L 555 475 L 45 475 Z",fill:"none",className:"stroke-border",strokeWidth:1.5,strokeLinejoin:"round",opacity:.5}),m.jsx("line",{x1:199,y1:27,x2:401,y2:27,className:"stroke-blue-500/30",strokeWidth:2}),e.map(e=>e.links.map(t=>{const i=a.get(e.id),s=a.get(t);return i&&s?m.jsx("line",{x1:i.x,y1:i.y,x2:s.x,y2:s.y,stroke:"#4a6cf744",strokeWidth:1,strokeDasharray:"4,4"},`${e.id}-${t}`):null})),e.map((e,t)=>{const i=a.get(e.id);if(!i)return null;const s=_[t],r=t<v,l=e.id===n,h=ai[e.type]??ai.reference;return m.jsxs("g",{onClick:()=>o(e.id),className:"cursor-pointer",opacity:r?1:.35,children:[m.jsx("circle",{cx:i.x,cy:i.y,r:s/2,fill:`url(#grad-${e.type})`,stroke:l?"currentColor":"none",strokeWidth:l?2:0}),s>30&&m.jsx("text",{x:i.x,y:i.y,textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:Math.max(9,.15*s),pointerEvents:"none",children:e.summary.slice(0,Math.floor(s/5))}),l&&m.jsx("circle",{cx:i.x,cy:i.y,r:s/2+4,fill:"none",stroke:h.main,strokeWidth:1.5,opacity:.6})]},e.id)}),m.jsx("defs",{children:Object.entries(ai).map(([e,{main:t,light:i}])=>m.jsxs("radialGradient",{id:`grad-${e}`,cx:"35%",cy:"35%",children:[m.jsx("stop",{offset:"0%",stopColor:i}),m.jsx("stop",{offset:"100%",stopColor:t})]},e))})]}),g&&m.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-4 py-2 bg-background/95 border-t border-border",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[m.jsx("span",{className:"text-[10px] px-1 py-px rounded text-white",style:{backgroundColor:(null==(r=ai[g.type])?void 0:r.main)??"#888"},children:g.type}),g.permanent&&m.jsx("span",{className:"text-[10px] px-1 py-px rounded bg-orange-500/20 text-orange-400",children:"permanent"}),m.jsx("span",{className:"text-xs font-medium text-foreground",children:g.summary})]}),m.jsxs("div",{className:"flex gap-3 text-[10px] text-muted-foreground",children:[m.jsxs("span",{children:["B=",g.buoyancy.toFixed(1)]}),m.jsxs("span",{children:["H=",g.H]}),m.jsxs("span",{children:["硬度=",g.hardness]}),g.links.length>0&&m.jsxs("span",{children:["连线: ",g.links.join(", ")]})]})]})]})})}function hi(e){const t=new Date(e),i=new Date,s=new Date(i.getFullYear(),i.getMonth(),i.getDate()),r=new Date(s.getTime()-864e5),n=new Date(s.getTime()-6048e5);return t>=s?"今天":t>=r?"昨天":t>=n?"本周":"更早"}function ci(e){return e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function di({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(!0),[n,o]=l.useState(!1),[a,h]=l.useState(""),[c,d]=l.useState(null),[u,f]=l.useState(null),[_,v]=l.useState(null),[b,S]=l.useState(!1),[x,y]=l.useState(new Set(["今天","昨天","本周"])),C=l.useRef(null),k=l.useCallback(async()=>{try{const t=await ie(e);i(t)}catch{}finally{r(!1)}},[e]);l.useEffect(()=>{r(!0),k(),C.current=setInterval(()=>{k()},15e3);const e=()=>{document.hidden?C.current&&(clearInterval(C.current),C.current=null):(k(),C.current&&clearInterval(C.current),C.current=setInterval(()=>{k()},15e3))};return document.addEventListener("visibilitychange",e),()=>{C.current&&clearInterval(C.current),document.removeEventListener("visibilitychange",e)}},[k]);const E=async(t=!1)=>{o(!0);try{const i=await re(e,t),s=[];i.synced>0&&s.push(`同步 ${i.synced} 个新对话`),i.updated>0&&s.push(`更新 ${i.updated} 个`),i.cleaned>0&&s.push(`清理 ${i.cleaned} 个旧记录`),t&&0===s.length&&s.push("已强制重建全部 v0"),s.length>0?(p.success(s.join(",")),await k()):p.info("已是最新")}catch{p.error("同步失败")}finally{o(!1)}},N=a?t.filter(e=>e.summary.toLowerCase().includes(a.toLowerCase())):t,R=new Map;for(const l of N){const e=hi(l.started_at);R.has(e)||R.set(e,[]),R.get(e).push(l)}return s?m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."}):c&&u?m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between border-b border-border",children:[m.jsx("button",{onClick:()=>{d(null),f(null)},className:"text-xs text-muted-foreground hover:text-foreground",children:"← 返回"}),m.jsx("button",{onClick:()=>{d(null),f(null)},className:"text-muted-foreground hover:text-foreground",children:m.jsx(w,{className:"h-3.5 w-3.5"})})]}),u.available_versions.length>1&&m.jsx("div",{className:"flex-shrink-0 px-3 py-1.5 flex gap-1 flex-wrap border-b border-border/50",children:u.available_versions.map(t=>m.jsx("button",{onClick:()=>{(async t=>{if(c){S(!0);try{const i=await se(e,c,t,"user");f(i),v(i.version)}catch{p.error("加载失败")}finally{S(!1)}}})(t)},className:g("px-1.5 py-0.5 rounded text-[10px] transition-colors",_===t?"bg-blue-500/20 text-blue-400":"text-muted-foreground/60 hover:text-foreground hover:bg-muted/50"),children:t},t))}),m.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2 text-xs space-y-2",children:b?m.jsx("div",{className:"text-center text-muted-foreground py-8",children:"加载中..."}):u.content.split(/(?=^## [UA]\d+)/m).filter(Boolean).map((e,t)=>{const i=e.match(/^## ([UA]\d+)(.*)\n/);if(!i)return m.jsx("pre",{className:"whitespace-pre-wrap text-muted-foreground",children:e},t);const s=i[1],r=i[2].trim(),n=e.slice(i[0].length).trim(),o=s.startsWith("U"),a=r.match(/\[c(\d+),(\d+)%/),l=a?parseInt(a[1]):0,h=a?parseInt(a[2]):100;return m.jsxs("div",{className:g("rounded-md p-2",o?"bg-blue-500/5 border-l-2 border-blue-500/30":"bg-muted/30 border-l-2 border-muted-foreground/20"),children:[m.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:s}),l>0&&m.jsxs("span",{className:g("text-[9px] px-1 py-px rounded",h<20?"bg-red-500/10 text-red-400":h<40?"bg-orange-500/10 text-orange-400":"bg-muted text-muted-foreground"),children:["c",l," ",h,"%"]})]}),m.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed",children:n})]},t)})})]}):m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between",children:[m.jsx("span",{className:"font-medium text-xs text-foreground",children:"信息"}),m.jsx("button",{onClick:()=>{E(!1)},onContextMenu:e=>{e.preventDefault(),E(!0)},disabled:n,className:"text-muted-foreground hover:text-foreground transition-colors",title:"同步(右键:强制重建全部 v0)",children:m.jsx(P,{className:g("h-3 w-3",n&&"animate-spin")})})]}),m.jsx("div",{className:"flex-shrink-0 px-3 pb-2",children:m.jsx("input",{type:"text",value:a,onChange:e=>h(e.target.value),placeholder:"搜索...",className:"w-full px-2 py-1 text-[11px] rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 outline-none focus:border-blue-500/50"})}),m.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pb-3 space-y-1",children:[0===N.length&&m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:0===t.length?"尚无对话记录,在终端中与 AI 对话后会自动同步到这里":"无匹配结果"}),["今天","昨天","本周","更早"].map(t=>{const s=R.get(t);if(!s||0===s.length)return null;const r=x.has(t);return m.jsxs("div",{children:[m.jsxs("button",{onClick:()=>{return e=t,void y(t=>{const i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i});var e},className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1 flex items-center gap-1 hover:text-foreground",children:[m.jsx("span",{className:g("transition-transform",r?"rotate-90":""),style:{display:"inline-block"},children:"▸"}),t," (",s.length,")"]}),r&&s.map(t=>m.jsx(ui,{conv:t,projectId:e,onClick:()=>{(async(t,i)=>{d(t),S(!0),v(null);try{const s=await se(e,t,i,"user");f(s),v(s.version)}catch{p.error("加载失败")}finally{S(!1)}})(t.id)},onDelete:()=>{(async t=>{if(confirm("确认删除此对话记录?所有版本将被永久删除。"))try{await ne(e,t),i(e=>e.filter(e=>e.id!==t)),c===t&&(d(null),f(null)),p.success("已删除")}catch{p.error("删除失败")}})(t.id)},onRefresh:k},t.id))]},t)})]})]})}function ui({conv:e,projectId:t,onClick:i,onDelete:s,onRefresh:r}){const[n,o]=l.useState(null),a="v0"!==e.latest;return m.jsxs("div",{onClick:n?void 0:i,className:g("rounded-md cursor-pointer transition-colors bg-muted/40 hover:bg-muted/60 border-l-2 border-border mb-1 group overflow-hidden",n&&"pointer-events-none"),children:[m.jsxs("div",{className:"p-2",children:[m.jsx("div",{className:"text-[11px] text-foreground leading-tight line-clamp-2",children:e.summary}),m.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-[10px] text-muted-foreground",children:[m.jsxs("span",{children:[e.turns,"轮"]}),m.jsx("span",{children:"·"}),a?m.jsxs("span",{children:[e.latest," (",ci(e.latest_tokens),"/",ci(e.original_tokens),")"]}):m.jsxs("span",{children:["v0 (",ci(e.original_tokens),")"]}),e.expand_count>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"·"}),m.jsxs("span",{children:["⤢",e.expand_count]})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all",children:[m.jsx("button",{onClick:async i=>{i.stopPropagation(),o("condense");try{const i=await oe(t,e.id);p.success(`已缩减为 ${i.version} (${ci(i.after_tokens)})`),r()}catch(s){p.error("缩减失败: "+((null==s?void 0:s.message)||"未知错误"),{duration:5e3})}finally{o(null)}},className:"text-muted-foreground hover:text-blue-400 transition-colors",title:"信息缩减(通过 Haiku)",children:m.jsx(Lt,{className:"h-3 w-3"})}),e.expand_count>0&&m.jsx("button",{onClick:async i=>{i.stopPropagation(),o("reorganize");try{const i=await ae(t,e.id);p.success(`已重整为 ${i.version},高关注: ${i.high_attention_turns.join(", ")}`),r()}catch(s){p.error("重整失败: "+((null==s?void 0:s.message)||"未知错误"),{duration:5e3})}finally{o(null)}},className:"text-muted-foreground hover:text-purple-400 transition-colors",title:"信息重整(基于展开数据)",children:m.jsx(Ot,{className:"h-3 w-3"})}),m.jsx("button",{onClick:e=>{e.stopPropagation(),s()},className:"text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:m.jsx(T,{className:"h-3 w-3"})})]})]})]}),n&&m.jsx("div",{className:"h-1 w-full bg-muted overflow-hidden",children:m.jsx("div",{className:g("h-full rounded-full","condense"===n?"bg-blue-500/60":"bg-purple-500/60"),style:{animation:"indeterminate 1.5s ease-in-out infinite"}})})]})}const fi=l.lazy(()=>N(()=>import("./PlanPanel-hOpV7PqT.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.PlanPanel}))),_i={files:"文件",git:"Git",plan:"计划",memory:"记忆",info:"信息"};function pi({projectPath:e,projectId:t,planStatus:i,planNodeUpdate:s,planReplan:r,onSend:n}){const[o,a]=l.useState("files"),[h,c]=l.useState(null);return m.jsxs("div",{className:"h-full flex flex-row",children:[m.jsx("div",{className:"flex flex-col flex-shrink-0 w-7 border-r border-border bg-background",children:["files","git","plan","memory","info"].map(e=>{const t="memory"===e;return m.jsx("button",{onClick:()=>!t&&a(e),disabled:t,"aria-label":_i[e],className:g("flex-none px-1.5 py-3 text-[11px] font-medium transition-colors select-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500",t?"text-muted-foreground/30 cursor-not-allowed":o===e?"text-blue-400 bg-muted/50 border-r-2 border-blue-500 -mr-px":"text-muted-foreground hover:text-foreground hover:bg-muted/30"),style:{writingMode:"vertical-rl"},title:t?"已停用":void 0,children:_i[e]},e)})}),m.jsxs(z,{mode:"wait",children:["files"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ei,{projectPath:e,projectId:t})},"files"),"git"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ii,{projectId:t})},"git"),"plan"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(l.Suspense,{fallback:m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."}),children:m.jsx(fi,{projectId:t,projectPath:e,planStatus:i,planNodeUpdate:s,planReplan:r})})},"plan"),"memory"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ni,{projectId:t,onSend:n,onBallClick:(e,t,i)=>c({balls:t,selectedId:e.id,capacity:i})})},"memory"),"info"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(di,{projectId:t})},"info")]}),h&&m.jsx(li,{balls:h.balls,selectedId:h.selectedId,activeCapacity:h.capacity,onClose:()=>c(null)})]})}function mi({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const f=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return m.jsx(fe,{open:e,onOpenChange:t,modal:!1,children:m.jsxs(_e,{noOverlay:!0,className:g("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[m.jsxs(pe,{children:[m.jsx(me,{children:r}),m.jsx(ge,{children:"Write the command that will be sent to Claude when this shortcut is triggered."})]}),m.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"shortcut-label",children:"Label"}),m.jsx(q,{id:"shortcut-label",placeholder:"Give it a name (optional)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),m.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[m.jsx(ve,{htmlFor:"shortcut-command",children:"Command"}),m.jsx("textarea",{id:"shortcut-command",placeholder:"Enter the command to send to Claude...",value:h,onChange:e=>c(e.target.value),className:g("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}})]})]}),m.jsxs(be,{className:"flex items-center justify-between sm:justify-between",children:[m.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx($,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),m.jsx($,{onClick:f,disabled:!h.trim(),children:"Save"})]})]})]})})}function gi({open:e,onOpenChange:t,label:i,command:s}){const[r,n]=l.useState(""),[o,a]=l.useState(()=>C(k.skillhubAuthor,"")),[h,c]=l.useState(""),[d,u]=l.useState(!1),[f,_]=l.useState(!1),[v,b]=l.useState(!0);l.useEffect(()=>{e&&b(!0)},[e]),l.useEffect(()=>{if(e){n(""),c(""),_(!1);const e=C(k.skillhubAuthor,"");e&&a(e)}},[e]);return m.jsx(fe,{open:e,onOpenChange:t,modal:!1,children:m.jsxs(_e,{noOverlay:!0,className:g("sm:max-w-md transition-opacity",!v&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),b(!1)},onClick:()=>b(!0),children:[m.jsxs(pe,{children:[m.jsx(me,{children:"分享到 SkillHub"}),m.jsxs(ge,{children:["将「",i,"」分享给社区,审核通过后将出现在 SkillHub 中。"]})]}),f?m.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"提交成功!等待审核后将出现在 SkillHub 中。"}):m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-desc",children:"描述"}),m.jsx("textarea",{id:"share-desc",placeholder:"简要描述这个命令的用途...",value:r,onChange:e=>n(e.target.value),className:g("w-full rounded-md border border-input bg-background px-3 py-2","text-sm min-h-[80px] resize-none","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2")})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-author",children:"作者"}),m.jsx(q,{id:"share-author",placeholder:"你的名字",value:o,onChange:e=>a(e.target.value)})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-tags",children:"标签(逗号分隔)"}),m.jsx(q,{id:"share-tags",placeholder:"代码审查, 中文, 测试",value:h,onChange:e=>c(e.target.value)})]})]}),m.jsx(be,{children:f?m.jsx($,{onClick:()=>t(!1),children:"关闭"}):m.jsxs(m.Fragment,{children:[m.jsx($,{variant:"outline",onClick:()=>t(!1),children:"取消"}),m.jsx($,{onClick:async()=>{if(!d){u(!0);try{R(k.skillhubAuthor,o),await we({label:i,command:s,description:r.trim(),author:o.trim()||"anonymous",tags:h.split(",").map(e=>e.trim()).filter(Boolean)}),_(!0)}catch(e){p.error(e instanceof Error?e.message:"Failed to submit")}finally{u(!1)}}},disabled:d,children:d?"提交中...":"提交"})]})})]})})}function vi({projectId:e,onSend:t}){const[i,s]=l.useState([]),[r,n]=l.useState([]),o=D(),a=o.get(e),[h,c]=l.useState(a.shortcutEditorOpen),[d,u]=l.useState(null),[f,_]=l.useState(a.shareHubOpen),[p,v]=l.useState(a.shareHubLabel),[S,x]=l.useState(a.shareHubCommand);l.useEffect(()=>{le(e).then(s).catch(()=>s([]))},[e]),l.useEffect(()=>{if(a.shortcutEditorOpen&&a.shortcutEditingId&&i.length>0){const e=i.find(e=>e.id===a.shortcutEditingId)??null;u(e)}},[i]),l.useEffect(()=>{he().then(n).catch(()=>n([]))},[]);const y=l.useCallback(e=>{const t=[],i=new Set;let s=e;const n=[];for(;s&&!i.has(s.id);)i.add(s.id),n.unshift(s),s=s.parentId?r.find(e=>e.id===s.parentId):void 0;for(const r of n)t.push(r.command);return t},[r]),C=l.useCallback(e=>{y(e).forEach((e,i)=>{setTimeout(()=>t(e+"\r"),500*i)})},[y,t]),k=(t,i,s)=>{s.stopPropagation(),v(t),x(i),_(!0),o.setShareHub(e,!0,t,i)};return m.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[m.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Shortcuts"}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{u(null),c(!0),o.setShortcutEditor(e,!0,null)},title:"New shortcut",children:m.jsx(K,{className:"h-3.5 w-3.5"})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[r.length>0&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1 pb-0.5",children:[m.jsx(ce,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"全局"})]}),r.map(e=>{var t;const i=e.parentId?null==(t=r.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return m.jsxs("div",{className:g("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>C(e),title:i?`继承自「${i}」`:"Click to send",children:[m.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-6 leading-snug",children:e.label}),i&&m.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[m.jsx(de,{className:"h-2.5 w-2.5 text-muted-foreground"}),m.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",i]})]}),!i&&e.label!==e.command&&m.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug",children:e.command}),m.jsx("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:t=>k(e.label,e.command,t),title:"分享到 SkillHub",children:m.jsx(jt,{className:"h-3 w-3"})})})]},e.id)}),i.length>0&&m.jsx("div",{className:"flex items-center gap-1.5 px-1 pt-2 pb-0.5",children:m.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"项目"})})]}),0===i.length&&0===r.length&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[m.jsx(ce,{className:"h-5 w-5"}),m.jsxs("p",{className:"text-xs text-center leading-relaxed",children:["No shortcuts yet.",m.jsx("br",{}),"Click ",m.jsx("strong",{className:"text-muted-foreground",children:"+"})," to add one."]})]}),i.map(i=>m.jsxs("div",{className:g("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>t(i.command+"\r"),title:"Click to send",children:[m.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-10 leading-snug",children:i.label}),i.label!==i.command&&m.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug pr-10",children:i.command}),m.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:e=>k(i.label,i.command,e),title:"分享到 SkillHub",children:m.jsx(jt,{className:"h-3 w-3"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-blue-400 transition-colors",onClick:t=>((t,i)=>{i.stopPropagation(),u(t),c(!0),o.setShortcutEditor(e,!0,t.id)})(i,t),title:"Edit shortcut",children:m.jsx(b,{className:"h-3 w-3"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-red-400 transition-colors",onClick:t=>(async(t,i)=>{i.stopPropagation();try{await ue(e,t),s(e=>e.filter(e=>e.id!==t))}catch(r){console.error("Failed to delete shortcut:",r)}})(i.id,t),title:"Delete shortcut",children:m.jsx(w,{className:"h-3 w-3"})})]})]},i.id))]}),m.jsx(mi,{open:h,onOpenChange:t=>{c(t),t||o.setShortcutEditor(e,!1)},initialLabel:(null==d?void 0:d.label)??"",initialCommand:(null==d?void 0:d.command)??"",title:d?"Edit Shortcut":"New Shortcut",onSave:async(t,i)=>{try{if(d){const r=await Se(e,d.id,{label:t,command:i});s(e=>e.map(e=>e.id===r.id?r:e))}else{const r=await xe(e,{label:t,command:i});s(e=>[...e,r])}}catch(r){console.error("Failed to save shortcut:",r)}u(null)}}),m.jsx(gi,{open:f,onOpenChange:t=>{_(t),t||o.setShareHub(e,!1)},label:p,command:S})]})}function bi(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Si(e){return`这是我们上一次的聊天记录,请你回忆:\n\n${e.messages.map(e=>`[${"user"===e.role?"User":"Assistant"}]: ${e.content}`).join("\n\n")}`}function xi({session:e,onClose:t,onRecall:i,isFocused:s,onFocusChange:r}){return l.useEffect(()=>{const e=e=>{"Escape"===e.key&&t()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]),m.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>r(!1)}),m.jsxs(H.div,{initial:{opacity:0,scale:.95,y:8},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:8},transition:{duration:.2,ease:"easeOut"},className:g("relative z-10 w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl transition-opacity",!s&&"opacity-50"),onClick:()=>r(!0),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-11 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:bi(e.startedAt)}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("button",{className:"flex items-center gap-1.5 text-xs px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white transition-colors",onClick:()=>{i(Si(e)),t()},children:[m.jsx(wt,{className:"h-3 w-3"}),"回忆"]}),m.jsx("button",{"aria-label":"关闭",className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500 rounded",onClick:t,children:m.jsx(w,{className:"h-4 w-4"})})]})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-h-0",children:[0===e.messages.length&&m.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),e.messages.map((e,t)=>m.jsxs("div",{className:g("flex gap-2.5","user"===e.role?"flex-row-reverse":"flex-row"),children:[m.jsx("div",{className:g("flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center mt-0.5","user"===e.role?"bg-blue-600/20":"bg-muted"),children:"user"===e.role?m.jsx(bt,{className:"h-3 w-3 text-blue-400"}):m.jsx(vt,{className:"h-3 w-3 text-muted-foreground"})}),m.jsx("div",{className:g("max-w-[85%] text-xs rounded-lg px-3 py-2 whitespace-pre-wrap break-words","user"===e.role?"bg-blue-600/20 text-blue-100 dark:text-blue-100 border border-blue-500/20":"bg-muted text-foreground border border-border"),children:e.content})]},t))]})]})]})}function wi({projectId:e,onSend:t}){var i;const[s,r]=l.useState([]),[n,o]=l.useState(null),a=D(),h=a.get(e).sessionId,[c,d]=l.useState(!0),u=s.filter(e=>e.messageCount>0),f=null==(i=u.find(e=>!e.isCurrent))?void 0:i.id;l.useEffect(()=>{let t=null;const i=()=>{document.hidden||ye(e).then(r).catch(()=>{})};ye(e).then(r).catch(()=>r([]));const s=()=>{n(),t=setInterval(i,5e3)},n=()=>{t&&(clearInterval(t),t=null)},o=()=>{document.hidden?n():s()};return s(),document.addEventListener("visibilitychange",o),()=>{n(),document.removeEventListener("visibilitychange",o)}},[e]),l.useEffect(()=>{h&&Ce(e,h).then(e=>o(e)).catch(()=>a.setSessionId(e,null))},[]);const _=()=>{o(null),a.setSessionId(e,null)},v=async t=>{try{i=await Ce(e,t),o(i),d(!0),a.setSessionId(e,i.id)}catch{}var i};return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[0===u.length&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[m.jsx(vt,{className:"h-5 w-5"}),m.jsx("p",{className:"text-xs text-center",children:"暂无历史记录"})]}),u.map(i=>{const s=i.isCurrent,r=!i.isCurrent&&i.id===f;return m.jsxs("div",{className:g("group rounded border bg-muted hover:border-muted-foreground/30 transition-colors",s?"border-blue-500/50":"border-border"),children:[m.jsxs("button",{className:"w-full text-left px-3 pt-2 pb-1",onClick:()=>{v(i.id)},children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:bi(i.startedAt)}),s&&m.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30 leading-none",children:"当前"}),r&&m.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground border border-border leading-none",children:"最近"})]}),m.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:[i.messageCount," 条消息"]})]}),m.jsxs("div",{className:"px-3 pb-2 flex justify-end gap-1.5",children:[m.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async e=>{e.stopPropagation();try{const e=await ke(i.id),t=window.location.origin+e.shareUrl;await navigator.clipboard.writeText(t),p.success("分享链接已复制到剪贴板")}catch(t){p.error(t instanceof Error?t.message:"分享失败")}},children:[m.jsx(jt,{className:"h-2.5 w-2.5"}),"分享"]}),m.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async s=>{s.stopPropagation();try{const s=await Ce(e,i.id);r=Si(s),t(r+"\r")}catch{}var r},children:[m.jsx(wt,{className:"h-2.5 w-2.5"}),"回忆"]})]})]},i.id)})]}),m.jsx(z,{children:n&&m.jsx(xi,{session:n,onClose:_,onRecall:e=>{t(e+"\r"),_()},isFocused:c,onFocusChange:d})})]})}const yi={shortcuts:"快捷命令",history:"历史记录"};function Ci({projectId:e,onSend:t}){const[i,s]=l.useState("shortcuts");return m.jsxs("div",{className:"h-full flex flex-row bg-background text-foreground",children:[m.jsx("div",{className:"flex-1 min-w-0 overflow-hidden flex flex-col",children:m.jsxs(z,{mode:"wait",children:["shortcuts"===i&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-h-0",children:m.jsx(vi,{projectId:e,onSend:t})},"shortcuts"),"history"===i&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-h-0",children:m.jsx(wi,{projectId:e,onSend:t})},"history")]})}),m.jsx("div",{className:"flex flex-col flex-shrink-0 w-7 border-l border-border bg-background",children:["shortcuts","history"].map(e=>m.jsx("button",{onClick:()=>s(e),"aria-label":yi[e],className:g("flex-none px-1.5 py-3 text-[11px] font-medium transition-colors select-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500",i===e?"text-blue-400 bg-muted/50 border-l-2 border-blue-500 -ml-px":"text-muted-foreground hover:text-foreground hover:bg-muted/30"),style:{writingMode:"vertical-rl"},children:yi[e]},e))})]})}function ki({status:e}){return m.jsxs("span",{className:g("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[m.jsx("span",{className:g("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Ei({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const c=Ee(),[d,u]=l.useState(!1),[f,_]=l.useState(!1),[v,b]=l.useState(!1);l.useEffect(()=>{const e=()=>b(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);return m.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:m.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[m.jsx($,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c("/"),children:m.jsx(Ne,{className:"h-4 w-4"})}),m.jsx("button",{className:g("p-1 rounded transition-colors",i?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:n,title:"Toggle file tree",children:m.jsx(Tt,{className:"h-4 w-4"})}),m.jsx("button",{className:g("p-1 rounded transition-colors",s?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:o,title:"Toggle right panel",children:m.jsx(Pt,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&m.jsx("button",{className:g("p-1 rounded transition-colors",r?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:a,title:"对话框 (Ctrl+I)",children:m.jsx(Rt,{className:"h-4 w-4"})}),m.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[m.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),m.jsx(ki,{status:e.status}),m.jsx(Re,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),m.jsx(De,{}),m.jsx(Le,{}),m.jsx($,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:v?"退出全屏":"全屏",children:v?m.jsx(S,{className:"h-3.5 w-3.5"}):m.jsx(x,{className:"h-3.5 w-3.5"})}),m.jsxs($,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{_(!0);try{await Te(t)}catch(e){p.error(e instanceof Error?e.message:"备份失败")}finally{_(!1)}})()},disabled:f,title:"备份到云盘",children:[f?m.jsx(Me,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):m.jsx(zt,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),"stopped"===e.status&&m.jsxs($,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{u(!0);try{h(await Pe(e.id))}catch(t){console.error(t)}finally{u(!1)}})()},disabled:d,children:[m.jsx(Bt,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
15
+ */const Vt=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function Yt(e){return"md"===e?"Markdown":"html"===e||"htm"===e?"HTML":"高亮"}const Xt=[50,75,100,125,150,200,250,300],Gt=100;function Jt({filePath:e,onClose:t}){const i=e.endsWith("/.notebook/graph.yaml"),s=i?e.replace(/\/.notebook\/graph\.yaml$/,""):"",[r,n]=l.useState(null),[o,a]=l.useState(null),[h,c]=l.useState(()=>i?"graph":"rendered"),[E,N]=l.useState(!1),[D,L]=l.useState(Gt),[M,T]=l.useState(""),[P,B]=l.useState(!1),[j,A]=l.useState(!1),O=l.useRef(null),[I,z]=l.useState(!0),{resolved:H}=d(),W=e.split("/").pop()??e,F=l.useMemo(()=>function(e){const t=e.split("/").pop()??"",i=t.toLowerCase();if("dockerfile"===i)return"dockerfile";if("makefile"===i)return"makefile";const s=t.lastIndexOf(".");return s>=0?t.slice(s+1).toLowerCase():""}(e),[e]),$=Vt.has(F),U=Kt.has(F),K=function(e){return"md"===e||"html"===e||"htm"===e||e in qt}(F),q=qt[F]||F,V=l.useMemo(()=>{if(!$)return"";const t=y(e),i=u(),s=`${t}&t=${Date.now()}`;return i?`${s}&token=${encodeURIComponent(i)}`:s},[e,$]);l.useEffect(()=>{if(z(!0),n(null),a(null),L(function(e){const t=C(k.fileZoom,{},!0)[e];return Xt.includes(t)?t:Gt}(e)),A(!1),$||U)return n({path:e,binary:!1,tooLarge:!1,size:0,content:null}),void c("rendered");c(e.endsWith("/.notebook/graph.yaml")?"graph":"rendered"),f(e).then(e=>{n(e),T(e.content??"")}).catch(e=>a(e instanceof Error?e.message:"Failed to load file"))},[e,$,U]);const Y=l.useCallback(async()=>{B(!0);try{await _(e,M),n(e=>e?{...e,content:M,size:new Blob([M]).size}:e),A(!1)}catch(t){p.error(t instanceof Error?t.message:"保存失败")}finally{B(!1)}},[e,M]);l.useEffect(()=>{const e=e=>{(e.metaKey||e.ctrlKey)&&"s"===e.key&&"edit"===h&&(e.preventDefault(),Y())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[h,Y]),l.useEffect(()=>{const e=e=>{if("Escape"===e.key&&I){if(j&&!confirm("有未保存的修改,确定关闭?"))return;t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[I,t,j]);const X=()=>{j&&!confirm("有未保存的修改,确定退出编辑?")||(c(i?"graph":K?"rendered":"plain"),A(!1))},G=t=>{L(t),function(e,t){const i=C(k.fileZoom,{},!0);t===Gt?delete i[e]:i[e]=t,R(k.fileZoom,i,!0)}(e,t)},J=(null==r?void 0:r.content)??"",Z="dark"===H?ht:ct,Q=D/100*12,ee=r&&!r.binary&&!r.tooLarge,te=l.useMemo(()=>{var e,t;if("md"!==F)return null;const i="edit"===h?M:J;if(!i)return 0;return((null==(e=i.match(/[\u4e00-\u9fff\u3400-\u4dbf]/g))?void 0:e.length)??0)+((null==(t=i.replace(/[\u4e00-\u9fff\u3400-\u4dbf]/g," ").match(/[a-zA-Z0-9]+/g))?void 0:t.length)??0)},[F,J,M,h]);return m.jsx("div",{className:g("fixed inset-0 z-50 flex items-center justify-center transition-all duration-200",I?"bg-black/60 backdrop-blur-sm pointer-events-auto":"bg-transparent pointer-events-none"),onClick:e=>{e.target===e.currentTarget&&z(!1)},children:m.jsxs("div",{className:g("relative flex flex-col bg-background border border-border shadow-2xl transition-all duration-200 pointer-events-auto",E?"w-screen h-screen rounded-none":"w-[72vw] max-w-4xl h-[80vh] rounded-lg",!I&&!E&&"opacity-50"),onClick:()=>z(!0),onFocus:e=>{e.stopPropagation(),z(!0)},children:[m.jsxs("div",{className:"flex items-center gap-2 px-4 h-10 border-b border-border flex-shrink-0",children:[m.jsx(st,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),m.jsxs("span",{className:"flex-1 text-sm text-foreground font-medium truncate",title:e,children:[W,j&&m.jsx("span",{className:"text-muted-foreground ml-1",children:"*"}),null!==te&&m.jsxs("span",{className:"text-muted-foreground font-normal ml-2 text-xs",children:[te.toLocaleString()," 字"]})]}),ee&&!$&&!U&&m.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5",children:[K&&m.jsxs(m.Fragment,{children:[m.jsxs("button",{onClick:()=>"edit"===h?X():c("plain"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","plain"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"纯文本",children:[m.jsx(Ct,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"源码"})]}),m.jsxs("button",{onClick:()=>"edit"===h?X():c("rendered"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","rendered"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:Yt(F),children:[m.jsx(v,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:Yt(F)})]})]}),i&&m.jsxs("button",{onClick:()=>"edit"===h?X():c("graph"),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","graph"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"图谱",children:[m.jsx(Mt,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"图谱"})]}),m.jsxs("button",{onClick:()=>"edit"===h?X():(T((null==r?void 0:r.content)??""),A(!1),c("edit"),void setTimeout(()=>{var e;return null==(e=O.current)?void 0:e.focus()},0)),className:g("p-1 rounded-sm transition-colors flex items-center gap-1 text-xs","edit"===h?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),title:"编辑",children:[m.jsx(b,{className:"h-3 w-3"}),m.jsx("span",{className:"hidden sm:inline",children:"编辑"})]})]}),"edit"===h&&m.jsxs("button",{onClick:()=>{Y()},disabled:P||!j,className:g("flex items-center gap-1 text-xs px-2 py-1 rounded transition-colors",j?"bg-blue-600 hover:bg-blue-500 text-white":"bg-muted text-muted-foreground"),title:"保存 (⌘S)",children:[m.jsx(_t,{className:"h-3 w-3"}),P?"保存中...":"保存"]}),(ee||$)&&"edit"!==h&&"graph"!==h&&m.jsxs("div",{className:"flex items-center rounded-md border border-border bg-muted/50 p-0.5 gap-0.5",children:[m.jsx("button",{onClick:()=>{const e=[...Xt].reverse().find(e=>e<D);e&&G(e)},disabled:D<=Xt[0],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"缩小",children:m.jsx(Ft,{className:"h-3 w-3"})}),m.jsxs("button",{onClick:()=>G(Gt),className:"px-1 text-xs text-muted-foreground hover:text-foreground transition-colors min-w-[36px] text-center",title:"重置缩放",children:[D,"%"]}),m.jsx("button",{onClick:()=>{const e=Xt.find(e=>e>D);e&&G(e)},disabled:D>=Xt[Xt.length-1],className:"p-1 rounded-sm text-muted-foreground hover:text-foreground transition-colors disabled:opacity-30",title:"放大",children:m.jsx(Wt,{className:"h-3 w-3"})})]}),m.jsx("button",{className:"p-1 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>N(e=>!e),title:E?"退出全屏":"全屏",children:E?m.jsx(S,{className:"h-3.5 w-3.5"}):m.jsx(x,{className:"h-3.5 w-3.5"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{j&&!confirm("有未保存的修改,确定关闭?")||t()},children:m.jsx(w,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:g("flex-1 min-h-0","graph"===h?"overflow-hidden":"overflow-auto"),children:["graph"===h&&m.jsx(l.Suspense,{fallback:m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:m.jsx($t,{folderPath:s})}),"graph"!==h&&!r&&!o&&m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),"graph"!==h&&o&&m.jsx("p",{className:"text-sm text-red-400 p-4",children:o}),"graph"!==h&&$&&r&&m.jsx("div",{className:"flex items-center justify-center p-4 h-full",children:m.jsx("img",{src:V,alt:W,className:"max-w-full max-h-full object-contain rounded",style:{transform:`scale(${D/100})`,transformOrigin:"center center"},draggable:!1})}),"graph"!==h&&U&&r&&m.jsx(l.Suspense,{fallback:m.jsx("p",{className:"text-sm text-muted-foreground p-4",children:"Loading…"}),children:m.jsx(Ut,{filePath:e,ext:F,zoom:D})}),"graph"!==h&&!$&&!U&&r&&r.binary&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[m.jsx(st,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm",children:"Binary file — cannot preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:[(r.size/1024).toFixed(1)," KB"]})]}),"graph"!==h&&!U&&r&&r.tooLarge&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-12 text-muted-foreground p-4",children:[m.jsx(st,{className:"h-8 w-8"}),m.jsx("p",{className:"text-sm",children:"File too large to preview"}),m.jsxs("p",{className:"text-xs text-muted-foreground",children:[(r.size/1024/1024).toFixed(2)," MB (limit 5 MB)"]})]}),"graph"!==h&&ee&&null!==J&&m.jsxs(m.Fragment,{children:["edit"===h&&m.jsx("textarea",{ref:O,value:M,onChange:e=>{T(e.target.value),A(!0)},className:"w-full h-full bg-transparent text-foreground font-mono outline-none resize-none p-4 leading-relaxed",style:{fontSize:`${Q}px`,minHeight:"100%"},spellCheck:!1}),"edit"!==h&&m.jsxs("div",{className:"p-4",style:{fontSize:`${Q}px`},children:["plain"===h&&m.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:J}),"rendered"===h&&"md"===F&&m.jsx("div",{className:"prose dark:prose-invert max-w-none prose-pre:bg-muted prose-pre:border prose-pre:border-border prose-code:text-foreground",style:{fontSize:"inherit"},children:m.jsx(rt,{remarkPlugins:[ot,at],rehypePlugins:[nt],components:{code({className:e,children:t,...i}){const s=/language-(\w+)/.exec(e||"");return!s&&!e?m.jsx("code",{className:e,...i,children:t}):m.jsx(lt,{style:Z,language:(null==s?void 0:s[1])||"text",PreTag:"div",customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0},children:String(t).replace(/\n$/,"")})}},children:J})}),"rendered"===h&&("html"===F||"htm"===F)&&m.jsx("iframe",{srcDoc:it.sanitize(J,{WHOLE_DOCUMENT:!0,ADD_TAGS:["style","link"]}),className:"w-full h-full border-0 rounded bg-white",sandbox:"",title:W,style:{minHeight:"60vh",transform:`scale(${D/100})`,transformOrigin:"top left",width:1e4/D+"%",height:1e4/D+"%"}}),"rendered"===h&&"md"!==F&&"html"!==F&&"htm"!==F&&q&&m.jsx(lt,{style:Z,language:q,showLineNumbers:!0,lineNumberStyle:{color:"dark"===H?"#555":"#aaa",fontSize:"inherit"},customStyle:{fontSize:"inherit",borderRadius:"6px",margin:0,background:"transparent"},children:J}),"rendered"===h&&!K&&m.jsx("pre",{className:"font-mono text-foreground whitespace-pre-wrap break-words leading-relaxed",style:{fontSize:"inherit"},children:J})]})]})]})]})})}const Zt=new Set(["png","jpg","jpeg","gif","webp","svg","bmp","ico","avif","tiff","tif"]);function Qt(e){const t=e.lastIndexOf(".");return t>=0&&Zt.has(e.slice(t+1).toLowerCase())}function ei({projectPath:e,projectId:t}){const[i,s]=l.useState(new Map),[r,n]=l.useState(new Set([e])),[o,a]=l.useState(new Set),h=D(e=>e.get(t).filePreviewPath),c=D(e=>e.setFilePreviewPath),d=e=>c(t,e),[f,_]=l.useState(null),[v,b]=l.useState(!1),[S,x]=l.useState(!1),w=l.useRef(null),C=l.useRef(null);l.useEffect(()=>{if(!f)return;const e=()=>_(null);return window.addEventListener("click",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("click",e),window.removeEventListener("scroll",e,!0)}},[f]);const k=async t=>{if(0!==t.length){b(!0);try{await A(e,t),E(e)}catch(i){console.error("[FileTree] Upload failed:",i)}finally{b(!1)}}},E=l.useCallback(async e=>{a(t=>{if(t.has(e))return t;const i=new Set(t);return i.add(e),i});try{const t=await L(e);s(i=>new Map(i).set(e,t.entries))}catch(t){console.error("[FileTree] Failed to load:",e,t),s(t=>new Map(t).set(e,[]))}finally{a(t=>{const i=new Set(t);return i.delete(e),i})}},[]);l.useEffect(()=>{s(new Map),n(new Set([e])),a(new Set),E(e)},[e,E]);const N=l.useCallback(e=>{n(t=>{const s=new Set(t);return s.has(e)?s.delete(e):(s.add(e),i.has(e)||E(e)),s})},[i,E]),R=l.useCallback(()=>{s(new Map),n(new Set([e])),a(new Set),E(e)},[e,E]),W=(e,t)=>e.map(e=>{const s=r.has(e.path),n=o.has(e.path),a=i.get(e.path),l=e.name.startsWith(".");return m.jsxs("div",{children:[m.jsxs("div",{className:g("flex items-center gap-1 py-[3px] rounded cursor-pointer","hover:bg-muted",l&&"opacity-50"),style:{paddingLeft:14*t+6+"px",paddingRight:"6px"},onClick:()=>"dir"===e.type?N(e.path):d(e.path),onContextMenu:t=>{t.preventDefault(),_({x:t.clientX,y:t.clientY,filePath:e.path,fileName:e.name,type:e.type})},children:[m.jsx("span",{className:"w-3 flex-shrink-0 text-muted-foreground",children:"dir"===e.type&&(n?m.jsx(P,{className:"h-2.5 w-2.5 animate-spin"}):s?m.jsx(gt,{className:"h-2.5 w-2.5"}):m.jsx(O,{className:"h-2.5 w-2.5"}))}),"dir"===e.type?s?m.jsx(B,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):m.jsx(I,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}):Qt(e.name)?m.jsx(dt,{className:"h-3.5 w-3.5 text-green-400 flex-shrink-0"}):m.jsx(st,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),m.jsx("span",{className:g("text-xs truncate leading-none","dir"===e.type?"text-foreground":"text-muted-foreground"),title:e.path,children:e.name})]}),m.jsx(z,{initial:!1,children:"dir"===e.type&&s&&m.jsxs(H.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.15,ease:"easeInOut"},className:"overflow-hidden",children:[!a&&!n&&m.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"—"}),0===(null==a?void 0:a.length)&&m.jsx("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:14*(t+1)+6+16+"px"},children:"empty"}),a&&a.length>0&&W(a,t+1)]})})]},e.path)}),F=i.get(e),$=o.has(e),U=e.split("/").filter(Boolean).pop()??e;return m.jsxs(m.Fragment,{children:[h&&m.jsx(Jt,{filePath:h,onClose:()=>d(null)}),f&&m.jsxs("div",{ref:w,className:"fixed z-50 min-w-[140px] bg-popover border border-border rounded-md shadow-md py-1",style:{left:f.x,top:f.y},onClick:e=>e.stopPropagation(),children:[m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{const t=f.filePath.startsWith(e+"/")?f.filePath.slice(e.length+1):f.filePath;navigator.clipboard.writeText(t),p.success("已复制相对路径"),_(null)},children:[m.jsx(kt,{className:"h-3.5 w-3.5"}),"复制相对路径"]}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{navigator.clipboard.writeText(f.filePath),p.success("已复制绝对路径"),_(null)},children:[m.jsx(yt,{className:"h-3.5 w-3.5"}),"复制绝对路径"]}),"file"===f.type&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground text-left",onClick:()=>{(async(e,t)=>{let i=y(e);const s=u();s&&(i+=`${i.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`),i+=(i.includes("?")?"&":"?")+"dl=1";try{const e=await fetch(i);if(!e.ok){const t=await e.text().catch(()=>"");let i=`下载失败 (${e.status})`;try{i=JSON.parse(t).error||i}catch{}return void p.error(i)}const s=await e.blob(),r=URL.createObjectURL(s),n=document.createElement("a");n.href=r,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r)}catch{p.error("下载失败:网络错误")}})(f.filePath,f.fileName),_(null)},children:[m.jsx(M,{className:"h-3.5 w-3.5"}),"下载"]})]}),m.jsx("div",{className:"my-1 border-t border-border"}),m.jsxs("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 text-xs hover:bg-destructive/80 hover:text-destructive-foreground text-left",onClick:()=>{(async(t,s,r)=>{const n="dir"===r?`文件夹 "${s}" 及其所有内容`:`文件 "${s}"`;if(window.confirm(`确认删除${n}?此操作不可撤销。`))try{await j(t),p.success(`已删除: ${s}`);const r=t.substring(0,t.lastIndexOf("/"));r&&i.has(r)?E(r):E(e)}catch(o){p.error(`删除失败: ${o.message}`)}})(f.filePath,f.fileName,f.type),_(null)},children:[m.jsx(T,{className:"h-3.5 w-3.5"}),"删除"]})]}),m.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[m.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Files"}),m.jsxs("div",{className:"flex items-center gap-0.5",children:[m.jsx("input",{ref:C,type:"file",multiple:!0,className:"hidden",onChange:e=>{const t=Array.from(e.target.files??[]);t.length>0&&k(t),e.target.value=""}}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:()=>{var e;return null==(e=C.current)?void 0:e.click()},disabled:v,title:"上传文件",children:m.jsx(Ht,{className:g("h-3 w-3",v&&"animate-pulse")})}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground p-0.5 rounded transition-colors",onClick:R,title:"Refresh file tree",children:m.jsx(P,{className:g("h-3 w-3",$&&"animate-spin")})})]})]}),m.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 border-b border-border flex-shrink-0",children:[m.jsx(B,{className:"h-3.5 w-3.5 text-blue-400 flex-shrink-0"}),m.jsx("span",{className:"text-xs text-foreground font-medium truncate",title:e,children:U})]}),m.jsxs("div",{className:g("flex-1 overflow-y-auto py-1 min-h-0 transition-colors",S&&"bg-accent/30 ring-1 ring-inset ring-accent"),onDragOver:e=>{e.preventDefault(),x(!0)},onDragEnter:e=>{e.preventDefault(),x(!0)},onDragLeave:()=>x(!1),onDrop:e=>{e.preventDefault(),x(!1);const t=Array.from(e.dataTransfer.files);t.length>0&&k(t)},children:[v&&m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"上传中..."}),S&&!v&&m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-1",children:"松开以上传文件"}),$&&!F?m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Loading…"}):F&&0!==F.length?W(F,0):m.jsx("div",{className:"text-xs text-muted-foreground px-4 py-3",children:"Empty folder"})]})]})]})}function ti(e){const t=new Date(e),i=Date.now()-t.getTime();return i<36e5?`${Math.floor(i/6e4)}分钟前`:i<864e5?`${Math.floor(i/36e5)}小时前`:i<6048e5?`${Math.floor(i/864e5)}天前`:t.toLocaleDateString()}function ii({projectId:e}){const[t,i]=l.useState(null),[s,r]=l.useState(!0),[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(""),[u,f]=l.useState(!1),[_,v]=l.useState([]),[b,S]=l.useState(0),[x,w]=l.useState(!0),[y,C]=l.useState(!1),k=l.useCallback(async()=>{r(!0);try{i(await W(e))}catch{i(null)}finally{r(!1)}},[e]),E=l.useCallback(async(t=!1)=>{C(!0);try{const i=t?_.length:0,s=await F(e,30,i);v(e=>t?[...e,...s.commits]:s.commits),S(s.total)}catch{}finally{C(!1)}},[e,_.length]);l.useEffect(()=>{k(),E()},[e]);const N=async t=>{try{const{diff:i}=await V(e,t);o(i||"(no diff)"),h(t??"all changes")}catch{p.error("获取 diff 失败")}},R=async t=>{try{await Y(e,[t]),p.success(`已暂存 ${t}`),await k()}catch{p.error("git add 失败")}},D=async()=>{if(c.trim()){f(!0);try{await X(e,c),p.success("提交成功"),d(""),await k()}catch(t){p.error(t instanceof Error?t.message:"提交失败")}finally{f(!1)}}};if(!t&&s)return m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[m.jsx(Et,{className:"h-5 w-5"}),m.jsx("p",{children:"加载中…"})]});if(!t||!t.isRepo)return m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50 text-xs",children:[m.jsx(Et,{className:"h-5 w-5"}),m.jsx("p",{children:t?"非 Git 仓库":"加载失败"}),m.jsx($,{variant:"ghost",size:"sm",className:"h-6 text-xs",onClick:()=>{k()},children:"重试"})]});const L=[...t.modified??[],...t.deleted??[]],M=t.staged??[],T=t.untracked??[];return m.jsxs("div",{className:"flex flex-col h-full overflow-y-auto p-2 space-y-2 text-xs",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-1 text-muted-foreground font-medium",children:[m.jsx(Et,{className:"h-3 w-3"}),m.jsx("span",{children:t.branch}),(t.ahead??0)>0&&m.jsxs("span",{className:"text-blue-400",children:["↑",t.ahead]}),(t.behind??0)>0&&m.jsxs("span",{className:"text-yellow-400",children:["↓",t.behind]})]}),m.jsx($,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:()=>{k()},disabled:s,children:m.jsx(P,{className:g("h-3 w-3",s&&"animate-spin")})})]}),M.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["已暂存 (",M.length,")"]}),M.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx(U,{className:"h-2.5 w-2.5 text-green-500 flex-shrink-0"}),m.jsx("button",{className:"flex-1 text-left truncate text-green-400",onClick:()=>{N(e)},children:e})]},e))]}),L.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未暂存 (",L.length,")"]}),L.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{R(e)},children:m.jsx(K,{className:"h-2.5 w-2.5"})}),m.jsx("button",{className:"flex-1 text-left truncate text-yellow-400",onClick:()=>{N(e)},children:e})]},e))]}),T.length>0&&m.jsxs("div",{children:[m.jsxs("div",{className:"text-muted-foreground mb-1 font-medium",children:["未跟踪 (",T.length,")"]}),T.map(e=>m.jsxs("div",{className:"flex items-center gap-1 py-0.5 px-1 rounded hover:bg-muted",children:[m.jsx("button",{className:"flex-shrink-0 h-4 w-4 flex items-center justify-center rounded hover:bg-green-500/20 text-muted-foreground hover:text-green-400",title:"git add",onClick:()=>{R(e)},children:m.jsx(K,{className:"h-2.5 w-2.5"})}),m.jsx("span",{className:"flex-1 truncate text-muted-foreground",children:e})]},e))]}),0===L.length&&0===M.length&&0===T.length&&m.jsx("p",{className:"text-muted-foreground/50 text-center py-4",children:"工作区干净"}),M.length>0&&m.jsxs("div",{className:"space-y-1.5 pt-1 border-t border-border",children:[m.jsx(q,{placeholder:"提交消息…",value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||D()},className:"h-7 text-xs"}),m.jsx($,{size:"sm",className:"w-full h-7 text-xs",onClick:()=>{D()},disabled:!c.trim()||u,children:u?"提交中…":`提交 (${M.length} 文件)`})]}),(null==t?void 0:t.isRepo)&&m.jsxs("div",{className:"border-t border-border pt-2",children:[m.jsxs("button",{className:"flex items-center gap-1 text-muted-foreground font-medium mb-1 w-full text-left",onClick:()=>w(e=>!e),children:[m.jsx(gt,{className:g("h-3 w-3 transition-transform",!x&&"-rotate-90")}),m.jsx(Nt,{className:"h-3 w-3"}),m.jsxs("span",{children:["提交历史 (",b,")"]})]}),x&&m.jsxs("div",{className:"space-y-0.5",children:[_.map((e,t)=>{const i=e.parents.length>1;return m.jsxs("div",{className:"flex gap-1.5 items-start group",children:[m.jsxs("div",{className:"flex flex-col items-center flex-shrink-0 w-3",children:[m.jsx("div",{className:g("w-2 h-2 rounded-full flex-shrink-0 mt-1",0===t?"bg-blue-400":i?"bg-purple-400":"bg-muted-foreground/40")}),t<_.length-1&&m.jsx("div",{className:"w-px flex-1 bg-border min-h-[12px]"})]}),m.jsxs("div",{className:"flex-1 min-w-0 pb-1",children:[m.jsxs("div",{className:"flex items-baseline gap-1",children:[m.jsx("span",{className:"font-mono text-muted-foreground/60 text-[10px] flex-shrink-0",children:e.hashShort}),m.jsx("span",{className:"truncate leading-tight",children:e.message.split("\n")[0]})]}),m.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground/50 mt-0.5",children:[m.jsx("span",{children:e.author}),m.jsx("span",{children:ti(e.date)}),e.branches.length>0&&e.branches.slice(0,2).map(e=>m.jsx("span",{className:"px-1 py-px rounded bg-blue-500/10 text-blue-400 text-[9px]",children:e.replace("remotes/origin/","↑")},e))]})]})]},e.hash)}),_.length<b&&m.jsx("button",{className:"w-full text-center text-[10px] text-muted-foreground hover:text-foreground py-1",onClick:()=>{E(!0)},disabled:y,children:y?"加载中...":`加载更多 (${_.length}/${b})`})]})]}),null!==n&&m.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:()=>o(null),children:[m.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm"}),m.jsxs("div",{className:"relative z-10 w-[700px] max-w-[95vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl",onClick:e=>e.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-10 border-b border-border text-sm font-medium flex-shrink-0",children:[m.jsx("span",{className:"truncate text-muted-foreground",children:a}),m.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>o(null),children:"✕"})]}),m.jsx("pre",{className:"flex-1 overflow-auto p-3 text-[11px] font-mono whitespace-pre leading-relaxed",children:n.split("\n").map((e,t)=>m.jsx("span",{className:g("block",e.startsWith("+")&&!e.startsWith("+++")&&"text-green-400 bg-green-400/5",e.startsWith("-")&&!e.startsWith("---")&&"text-red-400 bg-red-400/5",e.startsWith("@@")&&"text-blue-400"),children:e},t))})]})]})]})}const si={feedback:{bg:"bg-blue-500",text:"text-blue-400",border:"border-blue-500/30"},user:{bg:"bg-green-500",text:"text-green-400",border:"border-green-500/30"},project:{bg:"bg-yellow-500",text:"text-yellow-400",border:"border-yellow-500/30"},reference:{bg:"bg-purple-500",text:"text-purple-400",border:"border-purple-500/30"}},ri={maintain:"请读取 .memory-pool/QUICK-REF.md,然后调用 POST /maintenance 获取维护建议并执行",load:"请调用 GET /api/memory-pool/{projectId}/surface 获取活跃层记忆,将重要记忆纳入当前上下文",save:"请从我们当前的对话中提取值得记忆的信息,通过 POST /balls API 存入记忆池",general:"请读取 .memory-pool/QUICK-REF.md,对记忆池执行你认为合适的操作"};function ni({projectId:e,onSend:t,onBallClick:i}){var s,r;const[n,o]=l.useState(null),[a,h]=l.useState(null),[c,d]=l.useState(!0),[u,f]=l.useState(!1),[_,v]=l.useState(!1),[b,S]=l.useState(!1),[x,w]=l.useState(!1),[y,C]=l.useState(1e4),[k,E]=l.useState(!1),N=l.useRef(null),R=l.useCallback(async()=>{var t;try{const i=await G(e);return o(i),(null==(t=i.state)?void 0:t.surface_width)&&C(i.state.surface_width),i.initialized}catch{return!1}},[e]),D=l.useCallback(async()=>{try{const t=await J(e);h(t)}catch{}},[e]);l.useEffect(()=>{let e=!1;return(async()=>{d(!0);const t=await R();!e&&t&&await D(),e||d(!1)})(),()=>{e=!0}},[e,R,D]),l.useEffect(()=>{if(!(null==n?void 0:n.initialized))return;const e=()=>D();N.current=setInterval(e,15e3);const t=()=>{document.hidden?N.current&&(clearInterval(N.current),N.current=null):(e(),N.current&&clearInterval(N.current),N.current=setInterval(e,15e3))};return document.addEventListener("visibilitychange",t),()=>{N.current&&clearInterval(N.current),document.removeEventListener("visibilitychange",t)}},[null==n?void 0:n.initialized,D]);const L=async()=>{f(!0);try{await Z(e),await R(),await D()}catch(t){console.error("Memory pool init failed:",t)}finally{f(!1)}},M=async()=>{var t;v(!0);try{const i=await ee(e);p.success(`记忆池已更新到 v${i.version}`,{description:null==(t=i.changes)?void 0:t.join(", ")}),await R(),await D()}catch(i){p.error("更新失败",{description:i.message})}finally{v(!1)}},T=e=>{t&&(t(ri[e]+"\r"),p.success("指令已发送到终端"))};if(c)return m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."});if(!(null==n?void 0:n.initialized))return m.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 p-4",children:[m.jsx("div",{className:"text-3xl opacity-30",children:"🧠"}),m.jsx("p",{className:"text-muted-foreground text-xs text-center",children:"本项目尚未启用记忆池"}),m.jsx($,{size:"sm",onClick:L,disabled:u,children:u?"初始化中...":"初始化记忆池"})]});const P=(null==a?void 0:a.balls)??[],B=(null==(s=n.state)?void 0:s.active_capacity)??20,j=P.slice(0,B),A=P.slice(B);return m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between",children:[m.jsx("span",{className:"font-medium text-xs text-foreground",children:"记忆池"}),m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["t=",(null==(r=n.state)?void 0:r.t)??0," · ",P.length," balls"]}),m.jsx("button",{onClick:()=>w(e=>!e),className:g("text-[10px] px-1 py-0.5 rounded transition-colors",x?"text-blue-400 bg-blue-500/10":"text-muted-foreground hover:text-foreground"),"aria-label":"设置",children:"⚙"})]})]}),x&&m.jsxs("div",{className:"flex-shrink-0 mx-3 mb-2 p-2 rounded border border-border bg-muted/20 space-y-2",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("label",{className:"text-[10px] text-muted-foreground whitespace-nowrap",children:"楔形宽度"}),m.jsx("input",{type:"number",min:1e3,max:1e5,step:1e3,value:y,onChange:e=>C(Number(e.target.value)),className:"flex-1 min-w-0 px-1.5 py-0.5 text-[10px] rounded border border-border bg-background text-foreground"}),m.jsx("span",{className:"text-[9px] text-muted-foreground",children:"tok"}),m.jsx("button",{onClick:async()=>{E(!0);try{const t=await Q(e,y);p.success(`楔形宽度已更新: ${t.surface_balls} balls, ~${t.total_tokens} tokens`)}catch(t){p.error("更新失败",{description:t.message})}finally{E(!1)}},disabled:k,className:"px-2 py-0.5 text-[10px] rounded bg-blue-500/20 text-blue-400 hover:bg-blue-500/30 transition-colors disabled:opacity-50",children:k?"...":"保存"})]}),m.jsx("p",{className:"text-[9px] text-muted-foreground leading-tight",children:"控制 surface.md 中浮出水面的记忆总 token 量。越大 → LLM 读取更多记忆,越小 → 更省 token。"})]}),n.needsUpgrade&&m.jsxs("div",{className:"flex-shrink-0 mx-3 mb-2 px-2 py-1.5 rounded bg-orange-500/10 border border-orange-500/30 flex items-center justify-between",children:[m.jsx("span",{className:"text-[10px] text-orange-400",children:"记忆池格式需要更新"}),m.jsx("button",{onClick:M,disabled:_,className:"px-2 py-0.5 text-[10px] rounded bg-orange-500/20 text-orange-400 hover:bg-orange-500/30 transition-colors disabled:opacity-50",children:_?"更新中...":"更新"})]}),m.jsxs("div",{className:"flex-shrink-0 px-3 pb-2 flex gap-1 flex-wrap",children:[m.jsx("button",{onClick:()=>T("maintain"),className:"px-2 py-0.5 text-[10px] rounded border border-blue-500/30 text-blue-400 hover:bg-blue-500/10 transition-colors",children:"整理"}),m.jsx("button",{onClick:()=>T("load"),className:"px-2 py-0.5 text-[10px] rounded border border-green-500/30 text-green-400 hover:bg-green-500/10 transition-colors",children:"读取"}),m.jsx("button",{onClick:()=>T("save"),className:"px-2 py-0.5 text-[10px] rounded border border-yellow-500/30 text-yellow-400 hover:bg-yellow-500/10 transition-colors",children:"保存"}),m.jsx("button",{onClick:()=>T("general"),className:"px-2 py-0.5 text-[10px] rounded border border-border text-muted-foreground hover:bg-muted/30 transition-colors",children:"通用"}),!n.needsUpgrade&&m.jsx("button",{onClick:M,disabled:_,className:"px-2 py-0.5 text-[10px] rounded border border-orange-500/30 text-orange-400 hover:bg-orange-500/10 transition-colors disabled:opacity-50",children:_?"更新中...":"更新"}),m.jsx("button",{onClick:async()=>{S(!0);try{const e=await te(),t=[];e.added>0&&t.push(`新增 ${e.added}`),e.updated>0&&t.push(`更新 ${e.updated}`),e.skipped>0&&t.push(`跳过 ${e.skipped}`),e.orphaned>0&&t.push(`孤儿 ${e.orphaned}`),p.success("全局记忆池已更新",{description:t.join(" · ")+(e.unreachable_projects.length>0?` | 不可达: ${e.unreachable_projects.join(", ")}`:"")})}catch(e){p.error("全局同步失败",{description:e.message})}finally{S(!1)}},disabled:b,className:"px-2 py-0.5 text-[10px] rounded border border-cyan-500/30 text-cyan-400 hover:bg-cyan-500/10 transition-colors disabled:opacity-50",children:b?"同步中...":"同步全局"})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pb-3 space-y-1",children:[j.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1",children:"活跃层"}),j.map(e=>m.jsx(oi,{ball:e,onClick:()=>null==i?void 0:i(e,P,B)},e.id))]}),A.length>0&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"text-[10px] text-muted-foreground uppercase tracking-wider mt-3 mb-1",children:"深层"}),A.map(e=>m.jsx(oi,{ball:e,deep:!0,onClick:()=>null==i?void 0:i(e,P,B)},e.id))]}),0===P.length&&m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:"记忆池为空,在终端中与 AI 对话时会自动积累记忆"})]})]})}function oi({ball:e,deep:t,onClick:i}){const s=si[e.type]??si.reference;return m.jsxs("div",{onClick:i,className:g("p-2 rounded-md cursor-pointer transition-colors border-l-2",t?"bg-muted/20 opacity-50 hover:opacity-70":"bg-muted/40 hover:bg-muted/60",s.border),children:[m.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx("span",{className:g("text-[10px] px-1 py-px rounded text-white",s.bg),children:e.type}),e.permanent&&m.jsx("span",{className:"text-[10px] px-1 py-px rounded bg-orange-500/20 text-orange-400",children:"permanent"})]}),m.jsxs("span",{className:g("text-[10px] font-medium",s.text),children:["B ",e.buoyancy.toFixed(1)]})]}),m.jsx("div",{className:"text-[11px] text-foreground leading-tight line-clamp-2",children:e.summary}),m.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:["H=",e.H," · t=",e.t_last,e.diameter?` · ~${e.diameter}tok`:"",e.links.length>0?` · ${e.links.length} links`:""]})]})}const ai={feedback:{main:"#4a6cf7",light:"#6b8cff"},user:{main:"#22c55e",light:"#5ee87a"},project:{main:"#f59e0b",light:"#fbbf4e"},reference:{main:"#a78bfa",light:"#c4b5fd"}};function li({balls:e,selectedId:t,activeCapacity:i,onClose:s}){var r;const[n,o]=l.useState(t),[a,h]=l.useState(new Map),c=l.useRef(null);l.useEffect(()=>{const e=e=>{"Escape"===e.key&&s()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[s]);const d=500,u=510,f=475,_=l.useMemo(()=>e.map(e=>Math.min(50,Math.max(24,16+.4*e.summary.length))),[e]),p=e.map(e=>`${e.id}:${e.buoyancy.toFixed(2)}`).join(",");l.useEffect(()=>{var t;null==(t=c.current)||t.call(c),c.current=null;let i=!1;return N(()=>import("./matter-CJwWD_7Q.js").then(e=>e.m),__vite__mapDeps([14,1,2])).then(t=>{if(i)return;const{Engine:s,Runner:r,Bodies:n,Composite:o,Body:a,Events:l}=t,d=s.create({gravity:{x:0,y:.8,scale:.001}}),p=30,m={isStatic:!0,restitution:.2,friction:.05},g=n.rectangle(300,10,270,p,m),v=n.rectangle(300,490,570,p,m),b=-150,S=Math.sqrt(225e3)+p,x=Math.atan2(450,b),w=n.rectangle(120,250,S,15,{...m,angle:x}),y=Math.sqrt(225e3)+p,C=Math.atan2(450,150),k=n.rectangle(480,250,y,15,{...m,angle:C}),E=new Array(e.length),N=[],R=e.map((e,t)=>t).sort((t,i)=>e[i].buoyancy-e[t].buoyancy);o.add(d.world,[g,v,w,k]),R.forEach((t,s)=>{const r=setTimeout(()=>{if(i)return;const s=_[t]/2,r=300+(Math.random()-.5)*u*.3,a=f-s-5,l=n.circle(r,a,s,{restitution:.2,friction:.01,frictionAir:.02,label:e[t].id});E[t]=l,o.add(d.world,l)},100*s);N.push(r)}),l.on(d,"beforeUpdate",()=>{for(let t=0;t<e.length;t++){const i=E[t];i&&a.applyForce(i,i.position,{x:0,y:-.001*e[t].buoyancy*i.mass})}});const D=r.create();let L;r.run(D,d);const M=()=>{const t=new Map;for(let i=0;i<e.length;i++){const s=E[i];s&&t.set(e[i].id,{x:s.position.x,y:s.position.y})}h(t),L=requestAnimationFrame(M)};L=requestAnimationFrame(M),c.current=()=>{N.forEach(clearTimeout),cancelAnimationFrame(L),r.stop(D),l.off(d,"beforeUpdate"),o.clear(d.world,!1),s.clear(d)}}),()=>{var e;i=!0,null==(e=c.current)||e.call(c),c.current=null}},[p,i]);const g=e.find(e=>e.id===n),v=Math.min(i,e.length);return m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60",onClick:s,children:m.jsxs("div",{className:"relative bg-background border border-border rounded-xl shadow-2xl overflow-hidden",style:{width:Math.min(640,window.innerWidth-40),height:Math.min(620,window.innerHeight-40)},onClick:e=>e.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[m.jsx("span",{className:"text-sm font-medium",children:"记忆池全景"}),m.jsxs("div",{className:"flex items-center gap-3 text-xs",children:[m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-blue-500 inline-block"})," feedback"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-green-500 inline-block"})," user"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-yellow-500 inline-block"})," project"]}),m.jsxs("span",{className:"flex items-center gap-1",children:[m.jsx("span",{className:"w-2 h-2 rounded-full bg-purple-400 inline-block"})," reference"]}),m.jsx("button",{onClick:s,"aria-label":"关闭",className:"ml-2 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500 rounded",children:m.jsx(w,{className:"w-4 h-4"})})]})]}),m.jsxs("svg",{width:"100%",height:d,viewBox:"0 0 600 500",children:[m.jsx("path",{d:"M 195 25 L 405 25 L 555 475 L 45 475 Z",fill:"none",className:"stroke-border",strokeWidth:1.5,strokeLinejoin:"round",opacity:.5}),m.jsx("line",{x1:199,y1:27,x2:401,y2:27,className:"stroke-blue-500/30",strokeWidth:2}),e.map(e=>e.links.map(t=>{const i=a.get(e.id),s=a.get(t);return i&&s?m.jsx("line",{x1:i.x,y1:i.y,x2:s.x,y2:s.y,stroke:"#4a6cf744",strokeWidth:1,strokeDasharray:"4,4"},`${e.id}-${t}`):null})),e.map((e,t)=>{const i=a.get(e.id);if(!i)return null;const s=_[t],r=t<v,l=e.id===n,h=ai[e.type]??ai.reference;return m.jsxs("g",{onClick:()=>o(e.id),className:"cursor-pointer",opacity:r?1:.35,children:[m.jsx("circle",{cx:i.x,cy:i.y,r:s/2,fill:`url(#grad-${e.type})`,stroke:l?"currentColor":"none",strokeWidth:l?2:0}),s>30&&m.jsx("text",{x:i.x,y:i.y,textAnchor:"middle",dominantBaseline:"central",fill:"#fff",fontSize:Math.max(9,.15*s),pointerEvents:"none",children:e.summary.slice(0,Math.floor(s/5))}),l&&m.jsx("circle",{cx:i.x,cy:i.y,r:s/2+4,fill:"none",stroke:h.main,strokeWidth:1.5,opacity:.6})]},e.id)}),m.jsx("defs",{children:Object.entries(ai).map(([e,{main:t,light:i}])=>m.jsxs("radialGradient",{id:`grad-${e}`,cx:"35%",cy:"35%",children:[m.jsx("stop",{offset:"0%",stopColor:i}),m.jsx("stop",{offset:"100%",stopColor:t})]},e))})]}),g&&m.jsxs("div",{className:"absolute bottom-0 left-0 right-0 px-4 py-2 bg-background/95 border-t border-border",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[m.jsx("span",{className:"text-[10px] px-1 py-px rounded text-white",style:{backgroundColor:(null==(r=ai[g.type])?void 0:r.main)??"#888"},children:g.type}),g.permanent&&m.jsx("span",{className:"text-[10px] px-1 py-px rounded bg-orange-500/20 text-orange-400",children:"permanent"}),m.jsx("span",{className:"text-xs font-medium text-foreground",children:g.summary})]}),m.jsxs("div",{className:"flex gap-3 text-[10px] text-muted-foreground",children:[m.jsxs("span",{children:["B=",g.buoyancy.toFixed(1)]}),m.jsxs("span",{children:["H=",g.H]}),m.jsxs("span",{children:["硬度=",g.hardness]}),g.links.length>0&&m.jsxs("span",{children:["连线: ",g.links.join(", ")]})]})]})]})})}function hi(e){const t=new Date(e),i=new Date,s=new Date(i.getFullYear(),i.getMonth(),i.getDate()),r=new Date(s.getTime()-864e5),n=new Date(s.getTime()-6048e5);return t>=s?"今天":t>=r?"昨天":t>=n?"本周":"更早"}function ci(e){return e>=1e3?(e/1e3).toFixed(1)+"K":String(e)}function di({projectId:e}){const[t,i]=l.useState([]),[s,r]=l.useState(!0),[n,o]=l.useState(!1),[a,h]=l.useState(""),[c,d]=l.useState(null),[u,f]=l.useState(null),[_,v]=l.useState(null),[b,S]=l.useState(!1),[x,y]=l.useState(new Set(["今天","昨天","本周"])),C=l.useRef(null),k=l.useCallback(async()=>{try{const t=await ie(e);i(t)}catch{}finally{r(!1)}},[e]);l.useEffect(()=>{r(!0),k(),C.current=setInterval(()=>{k()},15e3);const e=()=>{document.hidden?C.current&&(clearInterval(C.current),C.current=null):(k(),C.current&&clearInterval(C.current),C.current=setInterval(()=>{k()},15e3))};return document.addEventListener("visibilitychange",e),()=>{C.current&&clearInterval(C.current),document.removeEventListener("visibilitychange",e)}},[k]);const E=async(t=!1)=>{o(!0);try{const i=await re(e,t),s=[];i.synced>0&&s.push(`同步 ${i.synced} 个新对话`),i.updated>0&&s.push(`更新 ${i.updated} 个`),i.cleaned>0&&s.push(`清理 ${i.cleaned} 个旧记录`),t&&0===s.length&&s.push("已强制重建全部 v0"),s.length>0?(p.success(s.join(",")),await k()):p.info("已是最新")}catch{p.error("同步失败")}finally{o(!1)}},N=a?t.filter(e=>e.summary.toLowerCase().includes(a.toLowerCase())):t,R=new Map;for(const l of N){const e=hi(l.started_at);R.has(e)||R.set(e,[]),R.get(e).push(l)}return s?m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."}):c&&u?m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between border-b border-border",children:[m.jsx("button",{onClick:()=>{d(null),f(null)},className:"text-xs text-muted-foreground hover:text-foreground",children:"← 返回"}),m.jsx("button",{onClick:()=>{d(null),f(null)},className:"text-muted-foreground hover:text-foreground",children:m.jsx(w,{className:"h-3.5 w-3.5"})})]}),u.available_versions.length>1&&m.jsx("div",{className:"flex-shrink-0 px-3 py-1.5 flex gap-1 flex-wrap border-b border-border/50",children:u.available_versions.map(t=>m.jsx("button",{onClick:()=>{(async t=>{if(c){S(!0);try{const i=await se(e,c,t,"user");f(i),v(i.version)}catch{p.error("加载失败")}finally{S(!1)}}})(t)},className:g("px-1.5 py-0.5 rounded text-[10px] transition-colors",_===t?"bg-blue-500/20 text-blue-400":"text-muted-foreground/60 hover:text-foreground hover:bg-muted/50"),children:t},t))}),m.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-2 text-xs space-y-2",children:b?m.jsx("div",{className:"text-center text-muted-foreground py-8",children:"加载中..."}):u.content.split(/(?=^## [UA]\d+)/m).filter(Boolean).map((e,t)=>{const i=e.match(/^## ([UA]\d+)(.*)\n/);if(!i)return m.jsx("pre",{className:"whitespace-pre-wrap text-muted-foreground",children:e},t);const s=i[1],r=i[2].trim(),n=e.slice(i[0].length).trim(),o=s.startsWith("U"),a=r.match(/\[c(\d+),(\d+)%/),l=a?parseInt(a[1]):0,h=a?parseInt(a[2]):100;return m.jsxs("div",{className:g("rounded-md p-2",o?"bg-blue-500/5 border-l-2 border-blue-500/30":"bg-muted/30 border-l-2 border-muted-foreground/20"),children:[m.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[m.jsx("span",{className:"font-mono text-[10px] text-muted-foreground",children:s}),l>0&&m.jsxs("span",{className:g("text-[9px] px-1 py-px rounded",h<20?"bg-red-500/10 text-red-400":h<40?"bg-orange-500/10 text-orange-400":"bg-muted text-muted-foreground"),children:["c",l," ",h,"%"]})]}),m.jsx("div",{className:"whitespace-pre-wrap break-words leading-relaxed",children:n})]},t)})})]}):m.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[m.jsxs("div",{className:"flex-shrink-0 px-3 pt-2 pb-1 flex items-center justify-between",children:[m.jsx("span",{className:"font-medium text-xs text-foreground",children:"信息"}),m.jsx("button",{onClick:()=>{E(!1)},onContextMenu:e=>{e.preventDefault(),E(!0)},disabled:n,className:"text-muted-foreground hover:text-foreground transition-colors",title:"同步(右键:强制重建全部 v0)",children:m.jsx(P,{className:g("h-3 w-3",n&&"animate-spin")})})]}),m.jsx("div",{className:"flex-shrink-0 px-3 pb-2",children:m.jsx("input",{type:"text",value:a,onChange:e=>h(e.target.value),placeholder:"搜索...",className:"w-full px-2 py-1 text-[11px] rounded border border-border bg-background text-foreground placeholder:text-muted-foreground/50 outline-none focus:border-blue-500/50"})}),m.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pb-3 space-y-1",children:[0===N.length&&m.jsx("div",{className:"text-xs text-muted-foreground text-center py-8",children:0===t.length?"尚无对话记录,在终端中与 AI 对话后会自动同步到这里":"无匹配结果"}),["今天","昨天","本周","更早"].map(t=>{const s=R.get(t);if(!s||0===s.length)return null;const r=x.has(t);return m.jsxs("div",{children:[m.jsxs("button",{onClick:()=>{return e=t,void y(t=>{const i=new Set(t);return i.has(e)?i.delete(e):i.add(e),i});var e},className:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1 flex items-center gap-1 hover:text-foreground",children:[m.jsx("span",{className:g("transition-transform",r?"rotate-90":""),style:{display:"inline-block"},children:"▸"}),t," (",s.length,")"]}),r&&s.map(t=>m.jsx(ui,{conv:t,projectId:e,onClick:()=>{(async(t,i)=>{d(t),S(!0),v(null);try{const s=await se(e,t,i,"user");f(s),v(s.version)}catch{p.error("加载失败")}finally{S(!1)}})(t.id)},onDelete:()=>{(async t=>{if(confirm("确认删除此对话记录?所有版本将被永久删除。"))try{await ne(e,t),i(e=>e.filter(e=>e.id!==t)),c===t&&(d(null),f(null)),p.success("已删除")}catch{p.error("删除失败")}})(t.id)},onRefresh:k},t.id))]},t)})]})]})}function ui({conv:e,projectId:t,onClick:i,onDelete:s,onRefresh:r}){const[n,o]=l.useState(null),a="v0"!==e.latest;return m.jsxs("div",{onClick:n?void 0:i,className:g("rounded-md cursor-pointer transition-colors bg-muted/40 hover:bg-muted/60 border-l-2 border-border mb-1 group overflow-hidden",n&&"pointer-events-none"),children:[m.jsxs("div",{className:"p-2",children:[m.jsx("div",{className:"text-[11px] text-foreground leading-tight line-clamp-2",children:e.summary}),m.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-[10px] text-muted-foreground",children:[m.jsxs("span",{children:[e.turns,"轮"]}),m.jsx("span",{children:"·"}),a?m.jsxs("span",{children:[e.latest," (",ci(e.latest_tokens),"/",ci(e.original_tokens),")"]}):m.jsxs("span",{children:["v0 (",ci(e.original_tokens),")"]}),e.expand_count>0&&m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"·"}),m.jsxs("span",{children:["⤢",e.expand_count]})]}),m.jsxs("div",{className:"ml-auto flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-all",children:[m.jsx("button",{onClick:async i=>{i.stopPropagation(),o("condense");try{const i=await oe(t,e.id);p.success(`已缩减为 ${i.version} (${ci(i.after_tokens)})`),r()}catch(s){p.error("缩减失败: "+((null==s?void 0:s.message)||"未知错误"),{duration:5e3})}finally{o(null)}},className:"text-muted-foreground hover:text-blue-400 transition-colors",title:"信息缩减(通过 Haiku)",children:m.jsx(Lt,{className:"h-3 w-3"})}),e.expand_count>0&&m.jsx("button",{onClick:async i=>{i.stopPropagation(),o("reorganize");try{const i=await ae(t,e.id);p.success(`已重整为 ${i.version},高关注: ${i.high_attention_turns.join(", ")}`),r()}catch(s){p.error("重整失败: "+((null==s?void 0:s.message)||"未知错误"),{duration:5e3})}finally{o(null)}},className:"text-muted-foreground hover:text-purple-400 transition-colors",title:"信息重整(基于展开数据)",children:m.jsx(Ot,{className:"h-3 w-3"})}),m.jsx("button",{onClick:e=>{e.stopPropagation(),s()},className:"text-muted-foreground hover:text-red-400 transition-colors",title:"删除",children:m.jsx(T,{className:"h-3 w-3"})})]})]})]}),n&&m.jsx("div",{className:"h-1 w-full bg-muted overflow-hidden",children:m.jsx("div",{className:g("h-full rounded-full","condense"===n?"bg-blue-500/60":"bg-purple-500/60"),style:{animation:"indeterminate 1.5s ease-in-out infinite"}})})]})}const fi=l.lazy(()=>N(()=>import("./PlanPanel-BUomc-uk.js"),__vite__mapDeps([15,1,2,3,4,5,6,7,8,9,10,11,12])).then(e=>({default:e.PlanPanel}))),_i={files:"文件",git:"Git",plan:"计划",memory:"记忆",info:"信息"};function pi({projectPath:e,projectId:t,planStatus:i,planNodeUpdate:s,planReplan:r,onSend:n}){const[o,a]=l.useState("files"),[h,c]=l.useState(null);return m.jsxs("div",{className:"h-full flex flex-row",children:[m.jsx("div",{className:"flex flex-col flex-shrink-0 w-7 border-r border-border bg-background",children:["files","git","plan","memory","info"].map(e=>{const t="memory"===e;return m.jsx("button",{onClick:()=>!t&&a(e),disabled:t,"aria-label":_i[e],className:g("flex-none px-1.5 py-3 text-[11px] font-medium transition-colors select-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500",t?"text-muted-foreground/30 cursor-not-allowed":o===e?"text-blue-400 bg-muted/50 border-r-2 border-blue-500 -mr-px":"text-muted-foreground hover:text-foreground hover:bg-muted/30"),style:{writingMode:"vertical-rl"},title:t?"已停用":void 0,children:_i[e]},e)})}),m.jsxs(z,{mode:"wait",children:["files"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ei,{projectPath:e,projectId:t})},"files"),"git"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ii,{projectId:t})},"git"),"plan"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(l.Suspense,{fallback:m.jsx("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"加载中..."}),children:m.jsx(fi,{projectId:t,projectPath:e,planStatus:i,planNodeUpdate:s,planReplan:r})})},"plan"),"memory"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(ni,{projectId:t,onSend:n,onBallClick:(e,t,i)=>c({balls:t,selectedId:e.id,capacity:i})})},"memory"),"info"===o&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-w-0 overflow-hidden",children:m.jsx(di,{projectId:t})},"info")]}),h&&m.jsx(li,{balls:h.balls,selectedId:h.selectedId,activeCapacity:h.capacity,onClose:()=>c(null)})]})}function mi({open:e,onOpenChange:t,initialLabel:i,initialCommand:s,title:r,onSave:n}){const[o,a]=l.useState(i),[h,c]=l.useState(s),[d,u]=l.useState(!0);l.useEffect(()=>{e&&u(!0)},[e]),l.useEffect(()=>{e&&(a(i),c(s))},[e,i,s]);const f=()=>{const e=h.trim();e&&(n(o.trim()||e,e),t(!1))};return m.jsx(fe,{open:e,onOpenChange:t,modal:!1,children:m.jsxs(_e,{noOverlay:!0,className:g("sm:max-w-2xl max-h-[85vh] flex flex-col transition-opacity",!d&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),u(!1)},onClick:()=>u(!0),children:[m.jsxs(pe,{children:[m.jsx(me,{children:r}),m.jsx(ge,{children:"Write the command that will be sent to Claude when this shortcut is triggered."})]}),m.jsxs("div",{className:"space-y-4 flex-1 min-h-0 flex flex-col",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"shortcut-label",children:"Label"}),m.jsx(q,{id:"shortcut-label",placeholder:"Give it a name (optional)",value:o,onChange:e=>a(e.target.value),className:"text-base",autoFocus:!0})]}),m.jsxs("div",{className:"space-y-2 flex-1 flex flex-col min-h-0",children:[m.jsx(ve,{htmlFor:"shortcut-command",children:"Command"}),m.jsx("textarea",{id:"shortcut-command",placeholder:"Enter the command to send to Claude...",value:h,onChange:e=>c(e.target.value),className:g("flex-1 min-h-[200px] w-full rounded-md border border-input bg-background px-4 py-3","text-base leading-relaxed font-mono","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","resize-none"),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),f())}})]})]}),m.jsxs(be,{className:"flex items-center justify-between sm:justify-between",children:[m.jsx("span",{className:"text-xs text-muted-foreground",children:"⌘↩ to save"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx($,{variant:"outline",onClick:()=>t(!1),children:"Cancel"}),m.jsx($,{onClick:f,disabled:!h.trim(),children:"Save"})]})]})]})})}function gi({open:e,onOpenChange:t,label:i,command:s}){const[r,n]=l.useState(""),[o,a]=l.useState(()=>C(k.skillhubAuthor,"")),[h,c]=l.useState(""),[d,u]=l.useState(!1),[f,_]=l.useState(!1),[v,b]=l.useState(!0);l.useEffect(()=>{e&&b(!0)},[e]),l.useEffect(()=>{if(e){n(""),c(""),_(!1);const e=C(k.skillhubAuthor,"");e&&a(e)}},[e]);return m.jsx(fe,{open:e,onOpenChange:t,modal:!1,children:m.jsxs(_e,{noOverlay:!0,className:g("sm:max-w-md transition-opacity",!v&&"opacity-50"),onInteractOutside:e=>{e.preventDefault(),b(!1)},onClick:()=>b(!0),children:[m.jsxs(pe,{children:[m.jsx(me,{children:"分享到 SkillHub"}),m.jsxs(ge,{children:["将「",i,"」分享给社区,审核通过后将出现在 SkillHub 中。"]})]}),f?m.jsx("div",{className:"py-6 text-center text-sm text-muted-foreground",children:"提交成功!等待审核后将出现在 SkillHub 中。"}):m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-desc",children:"描述"}),m.jsx("textarea",{id:"share-desc",placeholder:"简要描述这个命令的用途...",value:r,onChange:e=>n(e.target.value),className:g("w-full rounded-md border border-input bg-background px-3 py-2","text-sm min-h-[80px] resize-none","ring-offset-background placeholder:text-muted-foreground","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2")})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-author",children:"作者"}),m.jsx(q,{id:"share-author",placeholder:"你的名字",value:o,onChange:e=>a(e.target.value)})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx(ve,{htmlFor:"share-tags",children:"标签(逗号分隔)"}),m.jsx(q,{id:"share-tags",placeholder:"代码审查, 中文, 测试",value:h,onChange:e=>c(e.target.value)})]})]}),m.jsx(be,{children:f?m.jsx($,{onClick:()=>t(!1),children:"关闭"}):m.jsxs(m.Fragment,{children:[m.jsx($,{variant:"outline",onClick:()=>t(!1),children:"取消"}),m.jsx($,{onClick:async()=>{if(!d){u(!0);try{R(k.skillhubAuthor,o),await we({label:i,command:s,description:r.trim(),author:o.trim()||"anonymous",tags:h.split(",").map(e=>e.trim()).filter(Boolean)}),_(!0)}catch(e){p.error(e instanceof Error?e.message:"Failed to submit")}finally{u(!1)}}},disabled:d,children:d?"提交中...":"提交"})]})})]})})}function vi({projectId:e,onSend:t}){const[i,s]=l.useState([]),[r,n]=l.useState([]),o=D(),a=o.get(e),[h,c]=l.useState(a.shortcutEditorOpen),[d,u]=l.useState(null),[f,_]=l.useState(a.shareHubOpen),[p,v]=l.useState(a.shareHubLabel),[S,x]=l.useState(a.shareHubCommand);l.useEffect(()=>{le(e).then(s).catch(()=>s([]))},[e]),l.useEffect(()=>{if(a.shortcutEditorOpen&&a.shortcutEditingId&&i.length>0){const e=i.find(e=>e.id===a.shortcutEditingId)??null;u(e)}},[i]),l.useEffect(()=>{he().then(n).catch(()=>n([]))},[]);const y=l.useCallback(e=>{const t=[],i=new Set;let s=e;const n=[];for(;s&&!i.has(s.id);)i.add(s.id),n.unshift(s),s=s.parentId?r.find(e=>e.id===s.parentId):void 0;for(const r of n)t.push(r.command);return t},[r]),C=l.useCallback(e=>{y(e).forEach((e,i)=>{setTimeout(()=>t(e+"\r"),500*i)})},[y,t]),k=(t,i,s)=>{s.stopPropagation(),v(t),x(i),_(!0),o.setShareHub(e,!0,t,i)};return m.jsxs("div",{className:"h-full flex flex-col bg-background text-foreground select-none",children:[m.jsxs("div",{className:"flex items-center justify-between px-3 h-9 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Shortcuts"}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-foreground transition-colors",onClick:()=>{u(null),c(!0),o.setShortcutEditor(e,!0,null)},title:"New shortcut",children:m.jsx(K,{className:"h-3.5 w-3.5"})})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[r.length>0&&m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex items-center gap-1.5 px-1 pt-1 pb-0.5",children:[m.jsx(ce,{className:"h-3 w-3 text-muted-foreground"}),m.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"全局"})]}),r.map(e=>{var t;const i=e.parentId?null==(t=r.find(t=>t.id===e.parentId))?void 0:t.label:void 0;return m.jsxs("div",{className:g("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>C(e),title:i?`继承自「${i}」`:"Click to send",children:[m.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-6 leading-snug",children:e.label}),i&&m.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[m.jsx(de,{className:"h-2.5 w-2.5 text-muted-foreground"}),m.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["继承: ",i]})]}),!i&&e.label!==e.command&&m.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug",children:e.command}),m.jsx("div",{className:"absolute top-1.5 right-1.5 opacity-0 group-hover:opacity-100 transition-opacity",children:m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:t=>k(e.label,e.command,t),title:"分享到 SkillHub",children:m.jsx(jt,{className:"h-3 w-3"})})})]},e.id)}),i.length>0&&m.jsx("div",{className:"flex items-center gap-1.5 px-1 pt-2 pb-0.5",children:m.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wider",children:"项目"})})]}),0===i.length&&0===r.length&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[m.jsx(ce,{className:"h-5 w-5"}),m.jsxs("p",{className:"text-xs text-center leading-relaxed",children:["No shortcuts yet.",m.jsx("br",{}),"Click ",m.jsx("strong",{className:"text-muted-foreground",children:"+"})," to add one."]})]}),i.map(i=>m.jsxs("div",{className:g("group relative rounded px-3 py-2 cursor-pointer","bg-muted hover:bg-accent","border border-transparent hover:border-muted-foreground/30","transition-colors"),onClick:()=>t(i.command+"\r"),title:"Click to send",children:[m.jsx("div",{className:"text-xs font-medium text-foreground truncate pr-10 leading-snug",children:i.label}),i.label!==i.command&&m.jsx("div",{className:"text-xs text-muted-foreground font-mono truncate mt-0.5 leading-snug pr-10",children:i.command}),m.jsxs("div",{className:"absolute top-1.5 right-1.5 flex items-center gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity",children:[m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-green-400 transition-colors",onClick:e=>k(i.label,i.command,e),title:"分享到 SkillHub",children:m.jsx(jt,{className:"h-3 w-3"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-blue-400 transition-colors",onClick:t=>((t,i)=>{i.stopPropagation(),u(t),c(!0),o.setShortcutEditor(e,!0,t.id)})(i,t),title:"Edit shortcut",children:m.jsx(b,{className:"h-3 w-3"})}),m.jsx("button",{className:"p-0.5 rounded text-muted-foreground hover:text-red-400 transition-colors",onClick:t=>(async(t,i)=>{i.stopPropagation();try{await ue(e,t),s(e=>e.filter(e=>e.id!==t))}catch(r){console.error("Failed to delete shortcut:",r)}})(i.id,t),title:"Delete shortcut",children:m.jsx(w,{className:"h-3 w-3"})})]})]},i.id))]}),m.jsx(mi,{open:h,onOpenChange:t=>{c(t),t||o.setShortcutEditor(e,!1)},initialLabel:(null==d?void 0:d.label)??"",initialCommand:(null==d?void 0:d.command)??"",title:d?"Edit Shortcut":"New Shortcut",onSave:async(t,i)=>{try{if(d){const r=await Se(e,d.id,{label:t,command:i});s(e=>e.map(e=>e.id===r.id?r:e))}else{const r=await xe(e,{label:t,command:i});s(e=>[...e,r])}}catch(r){console.error("Failed to save shortcut:",r)}u(null)}}),m.jsx(gi,{open:f,onOpenChange:t=>{_(t),t||o.setShareHub(e,!1)},label:p,command:S})]})}function bi(e){return new Date(e).toLocaleString("zh-CN",{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}function Si(e){return`这是我们上一次的聊天记录,请你回忆:\n\n${e.messages.map(e=>`[${"user"===e.role?"User":"Assistant"}]: ${e.content}`).join("\n\n")}`}function xi({session:e,onClose:t,onRecall:i,isFocused:s,onFocusChange:r}){return l.useEffect(()=>{const e=e=>{"Escape"===e.key&&t()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[t]),m.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",children:[m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:()=>r(!1)}),m.jsxs(H.div,{initial:{opacity:0,scale:.95,y:8},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.95,y:8},transition:{duration:.2,ease:"easeOut"},className:g("relative z-10 w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col bg-background border border-border rounded-lg shadow-2xl transition-opacity",!s&&"opacity-50"),onClick:()=>r(!0),children:[m.jsxs("div",{className:"flex items-center justify-between px-4 h-11 border-b border-border flex-shrink-0",children:[m.jsx("span",{className:"text-sm font-medium text-foreground",children:bi(e.startedAt)}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsxs("button",{className:"flex items-center gap-1.5 text-xs px-2.5 py-1 rounded bg-blue-600 hover:bg-blue-500 text-white transition-colors",onClick:()=>{i(Si(e)),t()},children:[m.jsx(wt,{className:"h-3 w-3"}),"回忆"]}),m.jsx("button",{"aria-label":"关闭",className:"text-muted-foreground hover:text-foreground transition-colors p-0.5 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500 rounded",onClick:t,children:m.jsx(w,{className:"h-4 w-4"})})]})]}),m.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 min-h-0",children:[0===e.messages.length&&m.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),e.messages.map((e,t)=>m.jsxs("div",{className:g("flex gap-2.5","user"===e.role?"flex-row-reverse":"flex-row"),children:[m.jsx("div",{className:g("flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center mt-0.5","user"===e.role?"bg-blue-600/20":"bg-muted"),children:"user"===e.role?m.jsx(bt,{className:"h-3 w-3 text-blue-400"}):m.jsx(vt,{className:"h-3 w-3 text-muted-foreground"})}),m.jsx("div",{className:g("max-w-[85%] text-xs rounded-lg px-3 py-2 whitespace-pre-wrap break-words","user"===e.role?"bg-blue-600/20 text-blue-100 dark:text-blue-100 border border-blue-500/20":"bg-muted text-foreground border border-border"),children:e.content})]},t))]})]})]})}function wi({projectId:e,onSend:t}){var i;const[s,r]=l.useState([]),[n,o]=l.useState(null),a=D(),h=a.get(e).sessionId,[c,d]=l.useState(!0),u=s.filter(e=>e.messageCount>0),f=null==(i=u.find(e=>!e.isCurrent))?void 0:i.id;l.useEffect(()=>{let t=null;const i=()=>{document.hidden||ye(e).then(r).catch(()=>{})};ye(e).then(r).catch(()=>r([]));const s=()=>{n(),t=setInterval(i,5e3)},n=()=>{t&&(clearInterval(t),t=null)},o=()=>{document.hidden?n():s()};return s(),document.addEventListener("visibilitychange",o),()=>{n(),document.removeEventListener("visibilitychange",o)}},[e]),l.useEffect(()=>{h&&Ce(e,h).then(e=>o(e)).catch(()=>a.setSessionId(e,null))},[]);const _=()=>{o(null),a.setSessionId(e,null)},v=async t=>{try{i=await Ce(e,t),o(i),d(!0),a.setSessionId(e,i.id)}catch{}var i};return m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"flex-1 overflow-y-auto p-2 space-y-1.5 min-h-0",children:[0===u.length&&m.jsxs("div",{className:"flex flex-col items-center gap-2 py-8 text-muted-foreground/50",children:[m.jsx(vt,{className:"h-5 w-5"}),m.jsx("p",{className:"text-xs text-center",children:"暂无历史记录"})]}),u.map(i=>{const s=i.isCurrent,r=!i.isCurrent&&i.id===f;return m.jsxs("div",{className:g("group rounded border bg-muted hover:border-muted-foreground/30 transition-colors",s?"border-blue-500/50":"border-border"),children:[m.jsxs("button",{className:"w-full text-left px-3 pt-2 pb-1",onClick:()=>{v(i.id)},children:[m.jsxs("div",{className:"flex items-center gap-1.5",children:[m.jsx("span",{className:"text-xs font-medium text-foreground",children:bi(i.startedAt)}),s&&m.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-blue-500/20 text-blue-400 border border-blue-500/30 leading-none",children:"当前"}),r&&m.jsx("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-muted text-muted-foreground border border-border leading-none",children:"最近"})]}),m.jsxs("div",{className:"text-[10px] text-muted-foreground mt-0.5",children:[i.messageCount," 条消息"]})]}),m.jsxs("div",{className:"px-3 pb-2 flex justify-end gap-1.5",children:[m.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async e=>{e.stopPropagation();try{const e=await ke(i.id),t=window.location.origin+e.shareUrl;await navigator.clipboard.writeText(t),p.success("分享链接已复制到剪贴板")}catch(t){p.error(t instanceof Error?t.message:"分享失败")}},children:[m.jsx(jt,{className:"h-2.5 w-2.5"}),"分享"]}),m.jsxs("button",{className:"flex items-center gap-1 text-[10px] px-2 py-0.5 rounded bg-secondary hover:bg-accent text-muted-foreground hover:text-foreground transition-colors",onClick:async s=>{s.stopPropagation();try{const s=await Ce(e,i.id);r=Si(s),t(r+"\r")}catch{}var r},children:[m.jsx(wt,{className:"h-2.5 w-2.5"}),"回忆"]})]})]},i.id)})]}),m.jsx(z,{children:n&&m.jsx(xi,{session:n,onClose:_,onRecall:e=>{t(e+"\r"),_()},isFocused:c,onFocusChange:d})})]})}const yi={shortcuts:"快捷命令",history:"历史记录"};function Ci({projectId:e,onSend:t}){const[i,s]=l.useState("shortcuts");return m.jsxs("div",{className:"h-full flex flex-row bg-background text-foreground",children:[m.jsx("div",{className:"flex-1 min-w-0 overflow-hidden flex flex-col",children:m.jsxs(z,{mode:"wait",children:["shortcuts"===i&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-h-0",children:m.jsx(vi,{projectId:e,onSend:t})},"shortcuts"),"history"===i&&m.jsx(H.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15},className:"flex-1 min-h-0",children:m.jsx(wi,{projectId:e,onSend:t})},"history")]})}),m.jsx("div",{className:"flex flex-col flex-shrink-0 w-7 border-l border-border bg-background",children:["shortcuts","history"].map(e=>m.jsx("button",{onClick:()=>s(e),"aria-label":yi[e],className:g("flex-none px-1.5 py-3 text-[11px] font-medium transition-colors select-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-blue-500",i===e?"text-blue-400 bg-muted/50 border-l-2 border-blue-500 -ml-px":"text-muted-foreground hover:text-foreground hover:bg-muted/30"),style:{writingMode:"vertical-rl"},children:yi[e]},e))})]})}function ki({status:e}){return m.jsxs("span",{className:g("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-full border",{running:"bg-green-500/10 text-green-600 border-green-500/20",stopped:"bg-muted text-muted-foreground border-border",restarting:"bg-yellow-500/10 text-yellow-600 border-yellow-500/20"}[e]),children:[m.jsx("span",{className:g("w-1.5 h-1.5 rounded-full",{"bg-green-500":"running"===e,"bg-muted-foreground":"stopped"===e,"bg-yellow-400 animate-pulse":"restarting"===e})}),e.charAt(0).toUpperCase()+e.slice(1)]})}function Ei({project:e,projectId:t,showFileTree:i,showShortcuts:s,showChatOverlay:r,onToggleFileTree:n,onToggleShortcuts:o,onToggleChatOverlay:a,onProjectUpdate:h}){const c=Ee(),[d,u]=l.useState(!1),[f,_]=l.useState(!1),[v,b]=l.useState(!1);l.useEffect(()=>{const e=()=>b(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);return m.jsx("header",{className:"border-b border-border flex-shrink-0 bg-muted/50",children:m.jsxs("div",{className:"px-3 h-12 flex items-center gap-2",children:[m.jsx($,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c("/"),children:m.jsx(Ne,{className:"h-4 w-4"})}),m.jsx("button",{className:g("p-1 rounded transition-colors",i?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:n,title:"Toggle file tree",children:m.jsx(Tt,{className:"h-4 w-4"})}),m.jsx("button",{className:g("p-1 rounded transition-colors",s?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:o,title:"Toggle right panel",children:m.jsx(Pt,{className:"h-4 w-4"})}),"terminal"!==e.cliTool&&m.jsx("button",{className:g("p-1 rounded transition-colors",r?"text-foreground bg-muted":"text-muted-foreground hover:text-foreground hover:bg-muted"),onClick:a,title:"对话框 (Ctrl+I)",children:m.jsx(Rt,{className:"h-4 w-4"})}),m.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2 ml-1",children:[m.jsx("h1",{className:"font-semibold text-foreground truncate text-sm",children:e.name}),m.jsx(ki,{status:e.status}),m.jsx(Re,{variant:"outline",className:"text-xs",children:"unlimited"===e.permissionMode?"Unlimited":"Limited"}),m.jsx("span",{className:"text-xs text-muted-foreground font-mono truncate hidden lg:block",children:e.folderPath})]}),m.jsx(De,{}),m.jsx(Le,{}),m.jsx($,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>{document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()},title:v?"退出全屏":"全屏",children:v?m.jsx(S,{className:"h-3.5 w-3.5"}):m.jsx(x,{className:"h-3.5 w-3.5"})}),m.jsxs($,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{_(!0);try{await Te(t)}catch(e){p.error(e instanceof Error?e.message:"备份失败")}finally{_(!1)}})()},disabled:f,title:"备份到云盘",children:[f?m.jsx(Me,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}):m.jsx(zt,{className:"h-3.5 w-3.5 mr-1.5"}),"备份"]}),"stopped"===e.status&&m.jsxs($,{variant:"outline",size:"sm",className:"flex-shrink-0",onClick:()=>{(async()=>{u(!0);try{h(await Pe(e.id))}catch(t){console.error(t)}finally{u(!1)}})()},disabled:d,children:[m.jsx(Bt,{className:"h-3.5 w-3.5 mr-1.5"}),"Start"]})]})})}
16
16
  /**
17
17
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
18
18
  * @license MIT
@@ -1,4 +1,4 @@
1
- import{c as e,r as t,aC as n,aw as r,aO as o,j as s,ax as a,aA as i,az as l,b as c,aP as d,R as u,aQ as f,aB as p,ay as h,aR as m,aS as x,aT as g,aU as v,aV as y,aW as w,aX as b,z as j,aY as N,a7 as S,a8 as C,a9 as k,aa as R,ab as T,B as A,ac as D,I as E,ad as P,aZ as _,a_ as O,a$ as I,b0 as M,b1 as L,am as F,b2 as H,m as V,T as z,ak as W,b3 as B,f as $,S as K,b4 as U,al as q,b5 as G,G as X,A as Y,v as Z,X as Q,s as J,t as ee,b6 as te,b7 as ne,b8 as re,b9 as oe,ba as se,bb as ae,bc as ie,bd as le}from"./index-DQ7mnz7m.js";import{u as ce,c as de,S as ue}from"./index-DphnlW4X.js";import{C as fe}from"./chevron-down-Cv9xjJgZ.js";import{C as pe}from"./chevron-up-qCxvNc4B.js";
1
+ import{c as e,r as t,aC as n,aw as r,aO as o,j as s,ax as a,aA as i,az as l,b as c,aP as d,R as u,aQ as f,aB as p,ay as h,aR as m,aS as x,aT as g,aU as v,aV as y,aW as w,aX as b,z as j,aY as N,a7 as S,a8 as C,a9 as k,aa as R,ab as T,B as A,ac as D,I as E,ad as P,aZ as _,a_ as O,a$ as I,b0 as M,b1 as L,am as F,b2 as H,m as V,T as z,ak as W,b3 as B,f as $,S as K,b4 as U,al as q,b5 as G,G as X,A as Y,v as Z,X as Q,s as J,t as ee,b6 as te,b7 as ne,b8 as re,b9 as oe,ba as se,bb as ae,bc as ie,bd as le}from"./index-Zh30nEgA.js";import{u as ce,c as de,S as ue}from"./index-DqQCNofi.js";import{C as fe}from"./chevron-down-CAohmFqo.js";import{C as pe}from"./chevron-up-B6GEEk3k.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -1 +1 @@
1
- import{aK as e,r as s,bk as t,j as r,b as a}from"./index-DQ7mnz7m.js";import{U as n}from"./user-COizPgd6.js";import{B as c}from"./bot-BY0Gl0Ea.js";function l(){const{token:l}=e(),[i,d]=s.useState(!0),[m,x]=s.useState(null),[o,u]=s.useState(null),[g,h]=s.useState("");if(s.useEffect(()=>{l&&(d(!0),t(l).then(e=>{document.title=e.projectName+" — cc-web",u(e.session),h(e.projectName)}).catch(e=>x(e.message||"链接无效或已过期")).finally(()=>d(!1)))},[l]),i)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsx("span",{className:"text-muted-foreground text-sm",children:"加载中…"})});if(m||!o)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsxs("div",{className:"text-center space-y-2",children:[r.jsx("p",{className:"text-foreground font-medium",children:"无法加载会话"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:m??"链接无效或已过期"})]})});const f=new Date(o.startedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return r.jsx("div",{className:"min-h-screen bg-background text-foreground",children:r.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:g}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[r.jsx("span",{children:f}),r.jsx("span",{children:"·"}),r.jsxs("span",{children:[o.messageCount," 条消息"]})]})]}),r.jsxs("div",{className:"space-y-4",children:[0===o.messages.length&&r.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),o.messages.map((e,s)=>r.jsxs("div",{className:a("flex gap-2.5","user"===e.role?"flex-row-reverse":"flex-row"),children:[r.jsx("div",{className:a("flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center mt-0.5","user"===e.role?"bg-blue-500/10":"bg-muted"),children:"user"===e.role?r.jsx(n,{className:"h-3.5 w-3.5 text-blue-400"}):r.jsx(c,{className:"h-3.5 w-3.5 text-muted-foreground"})}),r.jsx("div",{className:a("max-w-[85%] text-sm rounded-lg px-3 py-2 whitespace-pre-wrap break-words","user"===e.role?"bg-blue-500/10 text-blue-400":"bg-muted text-foreground"),children:e.content})]},s))]})]})})}export{l as ShareViewPage};
1
+ import{aK as e,r as s,bk as t,j as r,b as a}from"./index-Zh30nEgA.js";import{U as n}from"./user-BRwUyQma.js";import{B as c}from"./bot-BPpxGUic.js";function l(){const{token:l}=e(),[i,d]=s.useState(!0),[m,x]=s.useState(null),[o,u]=s.useState(null),[g,h]=s.useState("");if(s.useEffect(()=>{l&&(d(!0),t(l).then(e=>{document.title=e.projectName+" — cc-web",u(e.session),h(e.projectName)}).catch(e=>x(e.message||"链接无效或已过期")).finally(()=>d(!1)))},[l]),i)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsx("span",{className:"text-muted-foreground text-sm",children:"加载中…"})});if(m||!o)return r.jsx("div",{className:"min-h-screen flex items-center justify-center bg-background",children:r.jsxs("div",{className:"text-center space-y-2",children:[r.jsx("p",{className:"text-foreground font-medium",children:"无法加载会话"}),r.jsx("p",{className:"text-muted-foreground text-sm",children:m??"链接无效或已过期"})]})});const f=new Date(o.startedAt).toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"});return r.jsx("div",{className:"min-h-screen bg-background text-foreground",children:r.jsxs("div",{className:"max-w-2xl mx-auto px-4 py-8",children:[r.jsxs("div",{className:"mb-6",children:[r.jsx("h1",{className:"text-lg font-semibold text-foreground",children:g}),r.jsxs("div",{className:"flex items-center gap-3 mt-1 text-sm text-muted-foreground",children:[r.jsx("span",{children:f}),r.jsx("span",{children:"·"}),r.jsxs("span",{children:[o.messageCount," 条消息"]})]})]}),r.jsxs("div",{className:"space-y-4",children:[0===o.messages.length&&r.jsx("p",{className:"text-xs text-muted-foreground text-center py-8",children:"本次会话暂无记录"}),o.messages.map((e,s)=>r.jsxs("div",{className:a("flex gap-2.5","user"===e.role?"flex-row-reverse":"flex-row"),children:[r.jsx("div",{className:a("flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center mt-0.5","user"===e.role?"bg-blue-500/10":"bg-muted"),children:"user"===e.role?r.jsx(n,{className:"h-3.5 w-3.5 text-blue-400"}):r.jsx(c,{className:"h-3.5 w-3.5 text-muted-foreground"})}),r.jsx("div",{className:a("max-w-[85%] text-sm rounded-lg px-3 py-2 whitespace-pre-wrap break-words","user"===e.role?"bg-blue-500/10 text-blue-400":"bg-muted text-foreground"),children:e.content})]},s))]})]})})}export{l as ShareViewPage};
@@ -1,4 +1,4 @@
1
- import{c as e,ak as s,r as t,be as a,bf as r,t as l,bg as n,bh as i,bi as d,j as c,B as o,al as m,b as x,I as u,T as h,v as p,D as g,a5 as f,A as j,bj as b}from"./index-DQ7mnz7m.js";import{S as N}from"./search-8rUOyB4F.js";import{U as v}from"./user-COizPgd6.js";import{C as y}from"./chevron-down-Cv9xjJgZ.js";
1
+ import{c as e,ak as s,r as t,be as a,bf as r,t as l,bg as n,bh as i,bi as d,j as c,B as o,al as m,b as x,I as u,T as h,v as p,D as g,a5 as f,A as j,bj as b}from"./index-Zh30nEgA.js";import{S as N}from"./search-D6FWxasF.js";import{U as v}from"./user-BRwUyQma.js";import{C as y}from"./chevron-down-CAohmFqo.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- import{c as t}from"./index-DQ7mnz7m.js";
1
+ import{c as t}from"./index-Zh30nEgA.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-DQ7mnz7m.js";
1
+ import{c as o}from"./index-Zh30nEgA.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *
@@ -1,4 +1,4 @@
1
- import{c as o}from"./index-DQ7mnz7m.js";
1
+ import{c as o}from"./index-Zh30nEgA.js";
2
2
  /**
3
3
  * @license lucide-react v0.309.0 - ISC
4
4
  *