import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{O as t,k as n}from"./vendor-markdown-DngssFHR.js";import{c as r,l as i}from"./vendor-react-Cts2Wj-s.js";import{A as a,Q as o,at as s,g as c,nt as l,pt as u,rt as d}from"./vendor-mui-Ckcy4Lfd.js";import"./vendor-md-editor-DC6xr_29.js";import{R as f}from"./vendor-mui-icons-606Bohdn.js";import{_ as p,a as m,h,l as g,p as _,v}from"./ui-BLXHSX1T.js";import{M as y,h as b,i as x,o as S}from"./index-JB73_g7R.js";import{t as C}from"./useProjectDir-C1ezZgRd.js";import{t as w}from"./api-DCKbsCUZ.js";var T=e(n(),1),E=t();function D(e){return e==null?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function O(){let{projectId:e,"*":t}=i(),n=r(),{palette:O}=u(),[k,A]=(0,T.useState)(null),j=C(e),[M,N]=(0,T.useState)([]),[P,F]=(0,T.useState)([]),[I,L]=(0,T.useState)(!0),[R,z]=(0,T.useState)(null);if((0,T.useEffect)(()=>{!e||!t||(L(!0),Promise.all([w(e,t),y(e,`files`,t).catch(()=>[]),b(e,`files`,t).catch(()=>[])]).then(([e,t,n])=>{A(e),N(t),F(n),z(null)}).catch(e=>z(e instanceof Error?e.message:String(e))).finally(()=>L(!1)))},[e,t]),I)return(0,E.jsx)(o,{sx:{display:`flex`,justifyContent:`center`,py:4},children:(0,E.jsx)(s,{})});if(R||!k)return(0,E.jsx)(d,{severity:`error`,children:R||`File not found`});let B=t.split(`/`).slice(0,-1).join(`/`)||`.`;return(0,E.jsxs)(o,{children:[(0,E.jsx)(_,{breadcrumbs:[{label:`Files`,to:`/${e}/files`},{label:k.fileName}]}),(0,E.jsx)(m,{main:(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(v,{title:`Linked Notes`,sx:{mb:3},children:M.length===0?(0,E.jsx)(l,{variant:`body2`,sx:{color:O.custom.textMuted},children:`No linked notes`}):(0,E.jsx)(c,{spacing:.5,children:M.map(t=>(0,E.jsxs)(o,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,E.jsx)(p,{label:t.kind,color:`neutral`,size:`small`}),(0,E.jsx)(a,{component:`button`,variant:`body2`,onClick:()=>n(`/${e}/knowledge/${t.noteId}`),children:t.title})]},t.noteId))})}),(0,E.jsx)(v,{title:`Linked Tasks`,children:P.length===0?(0,E.jsx)(l,{variant:`body2`,sx:{color:O.custom.textMuted},children:`No linked tasks`}):(0,E.jsx)(c,{spacing:.5,children:P.map(t=>(0,E.jsxs)(o,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,E.jsx)(p,{label:S(t.status),color:x[t.status]??`neutral`,size:`small`}),(0,E.jsx)(a,{component:`button`,variant:`body2`,onClick:()=>n(`/${e}/tasks/${t.taskId}`),children:t.title})]},t.taskId))})})]}),sidebar:(0,E.jsxs)(v,{title:`Metadata`,children:[(0,E.jsx)(g,{label:`Path`,children:(0,E.jsxs)(o,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,E.jsx)(l,{variant:`body2`,sx:{fontFamily:`monospace`},children:k.filePath}),(0,E.jsx)(h,{value:k.filePath}),j&&(0,E.jsx)(a,{href:`vscode://file/${j}/${k.filePath}`,sx:{display:`inline-flex`,color:O.custom.textMuted},title:`Open in VS Code`,children:(0,E.jsx)(f,{sx:{fontSize:14}})})]})}),(0,E.jsx)(g,{label:`Size`,children:(0,E.jsx)(l,{variant:`body2`,children:D(k.size)})}),k.language&&(0,E.jsx)(g,{label:`Language`,children:(0,E.jsx)(l,{variant:`body2`,children:k.language})}),k.mimeType&&(0,E.jsx)(g,{label:`MIME Type`,children:(0,E.jsx)(l,{variant:`body2`,sx:{fontFamily:`monospace`},children:k.mimeType})}),k.extension&&(0,E.jsx)(g,{label:`Extension`,children:(0,E.jsx)(l,{variant:`body2`,children:k.extension})}),(0,E.jsx)(g,{label:`Directory`,divider:!1,children:(0,E.jsx)(a,{component:`button`,variant:`body2`,onClick:()=>n(`/${e}/files?dir=${B}`),children:B})})]})})]})}export{O as default};