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,O as o,Q as s,at as c,k as l,nt as u,pt as d,rt as f,w as p}from"./vendor-mui-Ckcy4Lfd.js";import"./vendor-md-editor-DC6xr_29.js";import{R as m}from"./vendor-mui-icons-606Bohdn.js";import{a as h,g,h as _,l as v,p as y,v as b}from"./ui-BLXHSX1T.js";import{t as x}from"./useProjectDir-C1ezZgRd.js";import{n as S,t as C}from"./api-DqPuu8Cs.js";var w=e(n(),1),T=t();function E(){let{projectId:e,docId:t}=i(),n=r(),{palette:E}=d(),[D,O]=(0,w.useState)(null),[k,A]=(0,w.useState)([]),j=x(e),[M,N]=(0,w.useState)(!0),[P,F]=(0,w.useState)(null);if((0,w.useEffect)(()=>{if(!e||!t)return;N(!0);let n=decodeURIComponent(t);Promise.all([C(e,n),C(e,n).then(t=>S(e,t.fileId).catch(()=>[]))]).then(([e,t])=>{O(e),A(t),F(null)}).catch(e=>F(e instanceof Error?e.message:String(e))).finally(()=>N(!1))},[e,t]),M)return(0,T.jsx)(s,{sx:{display:`flex`,justifyContent:`center`,py:4},children:(0,T.jsx)(c,{})});if(P||!D)return(0,T.jsx)(f,{severity:`error`,children:P||`Doc node not found`});let I=decodeURIComponent(t);return(0,T.jsxs)(s,{children:[(0,T.jsx)(y,{breadcrumbs:[{label:`Docs`,to:`/${e}/docs`},{label:D.title||D.id}]}),(0,T.jsx)(h,{main:(0,T.jsxs)(T.Fragment,{children:[D.content&&(0,T.jsx)(b,{title:`Content`,sx:{mb:3},children:(0,T.jsx)(u,{variant:`body2`,sx:{whiteSpace:`pre-wrap`,fontFamily:D.language?`monospace`:`inherit`,fontSize:D.language?`0.85rem`:void 0},children:D.content})}),k.length>1&&(0,T.jsx)(b,{title:`In this file`,children:(0,T.jsx)(l,{dense:!0,disablePadding:!0,children:k.map(t=>(0,T.jsx)(o,{selected:t.id===I,onClick:()=>n(`/${e}/docs/${encodeURIComponent(t.id)}`),sx:{borderRadius:1,py:.25,...t.id===I&&{bgcolor:`${E.primary.main}14`}},children:(0,T.jsx)(p,{primary:(0,T.jsx)(u,{variant:`body2`,sx:{pl:(t.level-1)*2},fontWeight:t.id===I?700:400,children:t.title||t.id})})},t.id))})})]}),sidebar:(0,T.jsxs)(b,{title:`Details`,children:[(0,T.jsx)(v,{label:`ID`,children:(0,T.jsxs)(s,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,T.jsx)(u,{variant:`body2`,sx:{fontFamily:`monospace`},children:D.id}),(0,T.jsx)(_,{value:D.id})]})}),(0,T.jsx)(v,{label:`File`,children:(0,T.jsxs)(s,{sx:{display:`flex`,alignItems:`center`,gap:.5},children:[(0,T.jsx)(a,{component:`button`,variant:`body2`,onClick:()=>n(`/${e}/files/${D.fileId}`),children:D.fileId}),j&&(0,T.jsx)(a,{href:`vscode://file/${j}/${D.fileId}`,sx:{display:`inline-flex`,color:E.custom.textMuted},title:`Open in VS Code`,children:(0,T.jsx)(m,{sx:{fontSize:14}})})]})}),(0,T.jsx)(v,{label:`Level`,children:(0,T.jsx)(u,{variant:`body2`,children:D.level})}),D.language&&(0,T.jsx)(v,{label:`Language`,children:(0,T.jsx)(u,{variant:`body2`,children:D.language})}),D.symbols&&D.symbols.length>0&&(0,T.jsx)(v,{label:`Symbols`,divider:!1,children:(0,T.jsx)(g,{tags:D.symbols})})]})})]})}export{E as default};