wiki-viewer 2.9.0 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/build-manifest.json +3 -3
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/required-server-files.json +2 -2
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +1 -1
- package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/{08yt220_vis~5.js → 03zmegz1kvvod.js} +1 -1
- package/.next/standalone/next.config.ts +8 -0
- package/.next/standalone/node_modules/@vscode/ripgrep-linux-x64/bin/rg +0 -0
- package/.next/standalone/package.json +129 -129
- package/.next/standalone/server.js +1 -1
- package/bin/postbuild.js +30 -0
- package/package.json +123 -130
- package/.next/standalone/node_modules/@img/colour/color.cjs +0 -1596
- package/.next/standalone/node_modules/@img/colour/index.cjs +0 -1
- package/.next/standalone/node_modules/@img/colour/package.json +0 -58
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/README.md +0 -46
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/glib-2.0/include/glibconfig.h +0 -221
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/index.js +0 -1
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.17.3 +0 -0
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/package.json +0 -42
- package/.next/standalone/node_modules/@img/sharp-libvips-linux-x64/versions.json +0 -30
- package/.next/standalone/node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node +0 -0
- package/.next/standalone/node_modules/@img/sharp-linux-x64/package.json +0 -46
- package/.next/standalone/node_modules/sharp/lib/channel.js +0 -177
- package/.next/standalone/node_modules/sharp/lib/colour.js +0 -195
- package/.next/standalone/node_modules/sharp/lib/composite.js +0 -212
- package/.next/standalone/node_modules/sharp/lib/constructor.js +0 -499
- package/.next/standalone/node_modules/sharp/lib/index.js +0 -16
- package/.next/standalone/node_modules/sharp/lib/input.js +0 -809
- package/.next/standalone/node_modules/sharp/lib/is.js +0 -143
- package/.next/standalone/node_modules/sharp/lib/libvips.js +0 -207
- package/.next/standalone/node_modules/sharp/lib/operation.js +0 -1016
- package/.next/standalone/node_modules/sharp/lib/output.js +0 -1666
- package/.next/standalone/node_modules/sharp/lib/resize.js +0 -595
- package/.next/standalone/node_modules/sharp/lib/sharp.js +0 -121
- package/.next/standalone/node_modules/sharp/lib/utility.js +0 -291
- package/.next/standalone/node_modules/sharp/package.json +0 -202
- /package/.next/standalone/.next/static/{014EirzgOgUjO57zMiZrA → R2lG97g-a6HpbZZtS4qep}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{014EirzgOgUjO57zMiZrA → R2lG97g-a6HpbZZtS4qep}/_clientMiddlewareManifest.js +0 -0
- /package/.next/standalone/.next/static/{014EirzgOgUjO57zMiZrA → R2lG97g-a6HpbZZtS4qep}/_ssgManifest.js +0 -0
|
@@ -14,6 +14,6 @@ TOKEN=<paste token here>
|
|
|
14
14
|
# 3. Read snapshot
|
|
15
15
|
curl -s -H "Authorization: Bearer $TOKEN" \\
|
|
16
16
|
-H "X-Agent-Id: ai:claude" \\
|
|
17
|
-
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>dg,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=dh(q),v=dh(r),w=dh(s),x=dh(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch((0,bQ.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:dg}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:(0,bQ.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:(0,bQ.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c9,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c0,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(df,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:(0,bQ.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dj=a.i(503442),dk=a.i(670576),dl=/[\\\/_+.#"@\[\(\{&]/,dm=/[\\\/_+.#"@\[\(\{&]/g,dn=/[\s-]/,dp=/[\s-]/g;function dq(a){return a.toLowerCase().replace(dp," ")}var dr=a.i(105305),ds=a.i(359231),dt='[cmdk-group=""]',du='[cmdk-group-items=""]',dv='[cmdk-item=""]',dw=`${dv}:not([aria-disabled="true"])`,dx="cmdk-item-select",dy="data-value",dz=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dl.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,l.length))):dn.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dp))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dq(d),dq(b),0,0,{})},dA=T.createContext(void 0),dB=T.createContext(void 0),dC=T.createContext(void 0),dD=T.forwardRef((a,b)=>{let c=dN(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dN(()=>new Set),e=dN(()=>new Map),f=dN(()=>new Map),g=dN(()=>new Set),h=dL(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,ds.useId)(),t=(0,ds.useId)(),u=(0,ds.useId)(),v=T.useRef(null),w=dQ();dM(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dM(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dz;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(du);b?b.appendChild(a.parentElement===b?a:a.closest(`${du} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${du} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dt}[${dy}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dy);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dt))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dv}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(dw))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dy))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dy))}function I(a){let b=E(),c=null==b?void 0:b.closest(dt),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dt):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dt))?void 0:c.querySelector(dw);d?x.setState("value",d.getAttribute(dy)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dr.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dx);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dS},i),dR(a,a=>T.createElement(dB.Provider,{value:x},T.createElement(dA.Provider,{value:y},a))))}),dE=T.forwardRef((a,b)=>{var c,d;let e=(0,ds.useId)(),f=T.useRef(null),g=T.useContext(dC),h=T.useContext(dA),i=dL(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dM(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dP(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dB),m=dO(a=>a.value&&a.value===k.current),n=dO(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dx,o),()=>b.removeEventListener(dx,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dF=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,ds.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,ds.useId)(),k=T.useContext(dA),l=dO(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dM(()=>k.group(g),[]),dP(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dR(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dC.Provider,{value:m},a))))}),dG=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dO(a=>!a.search);return c||f?T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dH=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dB),g=dO(a=>a.search),h=dO(a=>a.selectedItemId),i=T.useContext(dA);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dr.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dI=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dO(a=>a.selectedItemId),i=T.useContext(dA);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dR(a,a=>T.createElement("div",{ref:(0,cg.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dJ=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bW.Root,{open:c,onOpenChange:d},T.createElement(bW.Portal,{container:g},T.createElement(bW.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bW.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dD,{ref:b,...h}))))}),dK=Object.assign(dD,{List:dI,Item:dE,Input:dH,Group:dF,Separator:dG,Dialog:dJ,Empty:T.forwardRef((a,b)=>dO(a=>0===a.filtered.count)?T.createElement(dr.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dr.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dR(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dL(a){let b=T.useRef(a);return dM(()=>{b.current=a}),b}var dM=T.useEffect;function dN(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dO(a){let b=T.useContext(dB),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dP(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dA);return dM(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dy,h),e.current=h}),e}var dQ=()=>{let[a,b]=T.useState(),c=dN(()=>new Map);return dM(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dR({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dS={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dT=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dV({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dU,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dU.displayName=dK.displayName;let dW=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dT,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dK.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dW.displayName=dK.Input.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dX.displayName=dK.List.displayName;let dY=T.forwardRef((a,c)=>(0,b.jsx)(dK.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dY.displayName=dK.Empty.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dZ.displayName=dK.Group.displayName;let d$=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));d$.displayName=dK.Separator.displayName;let d_=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));d_.displayName=dK.Item.displayName;let d0=null,d1=null,d2=(0,b3.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d1&&clearTimeout(d1),d0?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d1&&clearTimeout(d1),b.trim())?(a({loading:!0}),new Promise(c=>{d1=setTimeout(()=>{d3(a,b).finally(c)},150)})):(d0?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d3(a,b){d0?.abort();let c=new AbortController;d0=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d4=a.i(713033);function d5({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d6({onOpenFile:a,recents:c=[],onToggleSidebar:d=()=>void 0,onNewFile:f=()=>void 0,onCopyPath:g=()=>void 0}){let h=d2(a=>a.open),j=d2(a=>a.setOpen),k=d2(a=>a.query),l=d2(a=>a.setQuery),n=d2(a=>a.results),o=d2(a=>a.loading),p=d2(a=>a.truncated),q=d2(a=>a.search),{resolvedTheme:r,setTheme:s}=(0,bU.useTheme)(),t=(0,c1.useAIPanelStore)(a=>a.toggle),u=(0,d4.useViewWidthStore)(a=>a.width),v=(0,d4.useViewWidthStore)(a=>a.cycle),w=k.trimStart(),x=""===w||w.startsWith(">"),y=""===w&&c.length>0,z=x?"":k;function A(a){a(),j(!1),l("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),j(!h))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,j]),(0,T.useEffect)(()=>{if(!h||x)return;let a=setTimeout(()=>{q(z)},120);return()=>clearTimeout(a)},[z,x,h,q]);let B=(d4.VIEW_WIDTH_ORDER.indexOf(u)+1)%d4.VIEW_WIDTH_ORDER.length,D=d4.VIEW_WIDTH_LABEL[d4.VIEW_WIDTH_ORDER[B]];return(0,b.jsxs)(dV,{open:h,onOpenChange:a=>{j(a),a||l("")},shouldFilter:!1,children:[(0,b.jsx)(dW,{placeholder:"Search files… ( > for actions )",value:k,onValueChange:l}),(0,b.jsxs)(dX,{children:[y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dZ,{heading:"Recent",children:c.map(c=>(0,b.jsxs)(d_,{value:`recent:${c.path}`,onSelect:()=>{a(c.path),j(!1),l("")},children:[(0,b.jsx)(cd,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:c.name}),(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:c.path})]})]},c.path))}),(0,b.jsx)(d$,{})]}),x&&(0,b.jsxs)(dZ,{heading:"Actions",children:[(0,b.jsxs)(d_,{value:"toggle-dark-mode",onSelect:()=>A(()=>s("dark"===r?"light":"dark")),children:["dark"===r?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===r?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(d_,{value:"toggle-ai-panel",onSelect:()=>A(t),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(d_,{value:"toggle-sidebar",onSelect:()=>A(d),children:[(0,b.jsx)(dk.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(d_,{value:"new-file",onSelect:()=>A(f),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(d_,{value:"copy-path",onSelect:()=>A(g),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(d_,{value:"cycle-view-width",onSelect:()=>A(v),children:[(0,b.jsx)(dj.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d4.VIEW_WIDTH_LABEL[u]," → ",D,")"]})]})]})]}),!x&&(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!o&&""!==z.trim()&&0===n.length&&(0,b.jsx)(dY,{children:"No matches."}),n.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d$,{}),(0,b.jsx)(dZ,{heading:p?"Top results (refine query for more)":"Results",children:n.map(c=>(0,b.jsx)(d_,{value:c.path,onSelect:()=>{a(c.path),j(!1),l("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d5,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d7({onOpenFile:a}){let c=d2(a=>a.query),d=d2(a=>a.setQuery),e=d2(a=>a.results),f=d2(a=>a.loading),g=d2(a=>a.search),h=d2(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dT,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d5,{html:a.snippet})})]},a.path))]})]})}let d8=(0,b3.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d9=a.i(256233),ea=a.i(212588);let eb=(0,b3.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),ec=(0,b3.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ed(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let ee=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ef(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let eg=new Set(["image","media","pdf","fallback","app","node-app","html"]);function eh(a){return a.split(".").pop()?.toLowerCase()??""}function ei(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=eh(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let ej=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function ek(a){let b=ei(a,"file");return"editor"===b||"text"===b||ej.has(eh(a))}function el(a){return["md","markdown"].includes(eh(a))}function em(a){return"image"===ei(a,"file")}function en(a){return"html"===ei(a,"file")}async function eo(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let ep=new Map,eq=new Map;async function er(a){let b=ep.get(a);if(b)return ep.delete(a),b;let c=eq.get(a);if(c){let b=await c;return ep.delete(a),b}return null}function es(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:es(a.children,b,c)}:a)}let et={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function eu({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cX,{className:"w-48",children:[(0,b.jsxs)(cY,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(cY,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cY,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cY,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cY,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cZ,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cY,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cY,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cY,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cZ,{})]}),(0,b.jsxs)(cY,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cY,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cZ,{}),(0,b.jsxs)(cY,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function ev({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):en(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):em(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):ek(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let ew=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=ec(a=>a.humanize);return(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...et},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):en(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):em(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):ek(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ed(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bT,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(eu,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),ex=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=eb(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(ew,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...et},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...et},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...et},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d9.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d9.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{let a=(0,Y.getEphemeralRoot)();if(a){_([]),ae(!1),j(!0),O(a),X(`root:${a}`);return}try{let a=await fetch((0,bQ.apiUrl)("/api/system/workspaces"));if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,da.useEditorStore)(a=>a.currentPath),aB=c$(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=c_(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c1.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c1.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{c$.getState().loadForWorkspace(V),c_.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>el(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,da.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)(!1),[aO,aP]=(0,T.useState)(!1);(0,T.useEffect)(()=>{let a=new URLSearchParams(window.location.search),b="1"===a.get("embed");aN(b),aP(b&&"1"!==a.get("chrome"))},[]);let[aQ,aR]=(0,T.useState)([]),[aS,aT]=(0,T.useState)(!1),[aU,aV]=(0,T.useState)(!1),aW=(0,T.useRef)(!1),[aX,aY]=(0,T.useState)(!1),[aZ,a$]=(0,T.useState)(!1),[a_,a0]=(0,T.useState)(null),a1=(0,T.useRef)(null),a2=(0,T.useRef)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(""),[a7,a8]=(0,T.useState)(null),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(""),[bd,bf]=(0,T.useState)(null),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(!1),[bk,bl]=(0,T.useState)(null),[bm,bo]=(0,T.useState)(null),[bs,bt]=(0,T.useState)(!1),[bu,bv]=(0,T.useState)(0),[bw,bx]=(0,T.useState)(0),by=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bz,bA]=(0,T.useState)(!1),bB=d8(a=>a.width),bC=eb(a=>a.showHidden),bD=ec(a=>a.humanize),{resolvedTheme:bF,setTheme:bH}=(0,bU.useTheme)(),bI=d8(a=>a.setWidth);(0,T.useEffect)(()=>{by&&bA(!0)},[by]);let[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(!1),[bP,bS]=(0,T.useState)(!1),[bV,bW]=(0,T.useState)(null),[bX,bY]=(0,T.useState)(0),[bZ,b$]=(0,T.useState)(!1),[b_,b0]=(0,T.useState)(!1),[b2,b3]=(0,T.useState)(""),[b4,b5]=(0,T.useState)(!1),[b6,b7]=(0,T.useState)(!1),[b8,b9]=(0,T.useState)(null),ca=(0,T.useRef)(null),[cc,cd]=(0,T.useState)(null),ce=(0,T.useRef)(null),cf=(0,T.useRef)(!1),cg=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{!V||aS||aW.current||(aW.current=!0,aV(!0),eo("").then(a=>{aR(a),aT(!0),aV(!1)}).catch(()=>{aW.current=!1,aV(!1)}))},[aS,V]);let ch=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await eo(d)});aR(a=>{let b=a;for(let{prefix:a,children:d}of c)b=es(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),ci=(0,T.useCallback)(async a=>{let b=await eo(a);""===a?aR(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aR(c=>es(c,a,a=>({...a,children:b,expanded:!0})))},[]),[cj,ck]=(0,T.useState)(null),[cl,cm]=(0,T.useState)(null),[cn,co]=(0,T.useState)(!1),[cp,cq]=(0,T.useState)([]),[cr,cs]=(0,T.useState)(!1),[ct,cu]=(0,T.useState)(null),[cv,cw]=(0,T.useState)(null),[cz,cA]=(0,T.useState)(!1),[cB,cC]=(0,T.useState)({}),[cD,cE]=(0,T.useState)({}),[cF,cG]=(0,T.useState)(null),[cI,cK]=(0,T.useState)(null),[cL,cM]=(0,T.useState)(null),cN=(0,T.useCallback)(async(a,b)=>{if(!cj){ck(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b1.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b1.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await ci(b)}catch{(0,b1.showError)("Pull failed")}finally{ck(null)}}},[cj,ci]);(0,T.useEffect)(()=>{co(!1),cq([]),cu(null),cw(null)},[bk?.path]);let cO=bk?.path;(0,T.useEffect)(()=>{if(!cO)return void cm(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cO)}`);if(a)return;if(!b.ok)return void cm(null);let c=await b.json();a||cm(c.info)}catch{a||cm(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cO]);let cP=(0,T.useCallback)(async()=>{if(!bk)return;let a=bk.path;co(!0),cs(!0),cq([]),cu(null),cw(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b1.showError)("Could not load history");let c=await b.json();bk.path===a&&cq(c.commits)}catch{(0,b1.showError)("Could not load history")}finally{cs(!1)}},[bk]),cQ=(0,T.useCallback)(async a=>{if(!bk)return;if(ct===a){cu(null),cw(null);return}let b=bk.path;cu(a),cA(!0),cw(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b1.showError)("Could not load diff");let d=await c.json();bk.path===b&&ct===a&&cw(d.diff)}catch{(0,b1.showError)("Could not load diff")}finally{cA(!1)}},[bk,ct]),cR=(0,T.useCallback)(async a=>{if(cB[a]||cD[a])return;let b=!1;cE(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b1.showError)("Could not load branches");let d=await c.json();b||cC(b=>({...b,[a]:d.branches}))}catch{b||(0,b1.showError)("Could not load branches")}finally{b||cE(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cB,cD]),cS=(0,T.useCallback)(async(a,b,c)=>{if(!cF){cG(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b1.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b1.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b1.showSuccess)(`Switched to ${e.branch}`),cC(b=>{let c={...b};return delete c[a],c}),cK(null),cM(null),await ci(c)}catch{(0,b1.showError)("Checkout failed")}finally{cG(null)}}},[cF,ci]),cT=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cT(c.children)));return b},[]),cU=(0,T.useRef)([]);(0,T.useEffect)(()=>{cU.current=cT(aQ)},[aQ,cT]);let cV=(0,T.useMemo)(()=>cT(aQ).filter(a=>""!==a).slice(0,24).join("\n"),[aQ,cT]),[cW,cX]=(0,T.useState)("");(0,T.useEffect)(()=>{let a=setTimeout(()=>cX(cV),300);return()=>clearTimeout(a)},[cV]);let cY=(0,T.useCallback)(async()=>{aY(!0);try{let a=cT(aQ),b=await eo("");for(let c of(aR(b),a)){let a=await eo(c);aR(b=>es(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aY(!1)}},[aQ,cT]),cZ=(0,T.useCallback)(async()=>{if(bk){if(el(bk.name)){b$(!0);try{await da.useEditorStore.getState().loadPage(bk.path)}finally{b$(!1)}return}if(["editor","text"].includes(ei(bk.name,bk.nodeType))||ek(bk.name)){b$(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bk.path)}`);if(a.ok){let b=await a.json();bW(b.content),bY(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}b$(!1)}}},[bk]),c0=(0,T.useCallback)(()=>{bx(a=>a+1),cZ()},[cZ]);async function c2(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aR(b=>es(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await er(a.path);if(b)return void aR(c=>es(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aR(b=>es(b,a.path,a=>({...a,loading:!0})));let c=await eo(a.path);aR(b=>es(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aR(b=>es(b,a.path,a=>({...a,expanded:!0})))}async function c3(a){if("file"===a.type&&c$.getState().push({path:a.path,name:a.name},V),bl({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),b0(!1),b5(!1),b9(null),bW(null),bY(0),"file"===a.type&&el(a.name)){b$(!0);try{await da.useEditorStore.getState().loadPage(a.path)}finally{b$(!1)}return}if(["editor","text"].includes(ei(a.name,a.type))||ek(a.name)){b$(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bW(a.content),bY(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}b$(!1)}}(0,T.useEffect)(()=>{bk&&el(bk.name)&&da.useEditorStore.getState().currentPath!==bk.path&&da.useEditorStore.getState().loadPage(bk.path)},[bk]),(0,T.useEffect)(()=>{ce.current=bk},[bk]),(0,T.useEffect)(()=>{cf.current=b_},[b_]),(0,T.useEffect)(()=>{cg.current=cZ},[cZ]),(0,T.useEffect)(()=>{if(!d||(0,bQ.isLite)()||!V)return;let a=new Map;function b(b){a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),ci(b)},300))}let c=(cW?cW.split("\n"):[]).map(a=>`dir=${encodeURIComponent(a)}`).join("&"),e=new EventSource((0,Y.withWs)(c?`/api/wiki/watch?${c}`:"/api/wiki/watch"));return e.onmessage=c=>{let d;try{d=JSON.parse(c.data)}catch{return}let{type:e,path:f}=d;if("rescan"===e){for(let a of(ea.useBacklinksStore.getState().invalidateAll(),b(""),cU.current))b(a);return}("add"===e||"change"===e||"unlink"===e)&&ea.useBacklinksStore.getState().invalidateAll();let g=f.split("/");if(b(g.length>1?g.slice(0,-1).join("/"):""),"change"===e&&ce.current?.path===f&&!cf.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cg.current()},400))}},()=>{for(let b of(e.close(),a.values()))clearTimeout(b)}},[d,ci,V,cW]),(0,T.useEffect)(()=>{bt(!1)},[]);let c4=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;ch(a),c3({path:a,name:b,type:"file"})},[ch]),c5=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await eo(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await ch(a.path),await c2(c);return}if("app"===c.type||"node-app"===c.type){await ch(c.path),c3({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await c2(c),by&&bA(!0);return}c3({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),by&&bA(!0)}},[by,c3,ch,c2]);(0,T.useEffect)(()=>{if(!aA||bk&&bk.path===aA)return;let a=aA.split("/").pop()??aA;c3({path:aA,name:a,type:"file"})},[aA]);let c6=(0,T.useCallback)(async a=>{if(!a)return void bl(null);let b=(0,Y.toRootRelative)(a,(0,Y.getEphemeralRoot)()??p);if(null===b||!(a=b))return;let c=a.split("/"),d=c[c.length-1],e=c.slice(0,-1).join("/"),f=(await eo(e)).find(b=>b.path===a);f&&(await ch(a),c3({path:a,name:d,type:f.type,modifiedAt:f.modifiedAt}))},[ch,p]);(0,T.useEffect)(()=>{},[bk]),(0,T.useEffect)(()=>{},[c6]),(0,T.useEffect)(()=>{if(!aM)return;let a=a=>{a.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${a.origin}.`):a.data&&"open-file"===a.data.type&&"string"==typeof a.data.path&&c6(a.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[c6,aM]),(0,T.useEffect)(()=>{aL.current||aS&&(aL.current=!0,c6(aK.current))},[aS,c6]);let c7=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/open`),{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bl(null),bW(null),b0(!1),aR([]),aT(!1),aW.current=!1,d9.useWikiSlugsStore.getState().invalidate(),ea.useBacklinksStore.getState().invalidateAll();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c8=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${al}`),{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await c7(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,c7,az]),c9=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/refresh`),{method:"POST"});if(!b.ok){let a=await b.json();(0,b1.showError)(a.error??"Refresh failed")}await az()}catch{(0,b1.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),db=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/branch`));if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),dc=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b1.showError)(a.error??"Branch switch failed");return}(0,b1.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b1.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function dd(){if(!bk)return;b7(!0),b9(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bk.path,content:b2,baseRevision:bX})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bY(b.revision),bW(b2),b0(!1)}else b9((await a.json()).error??"Save failed");b7(!1)}let de=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){a$(!0),a0(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();a0(a.error??"Upload failed"),(0,b1.showError)(a.error??"Upload failed");break}}await ci(b)}catch{a0("Upload failed.")}finally{a$(!1),a1.current&&(a1.current.value="")}}},[ci]);function df(a){a2.current=a,a1.current?.click()}async function dg(){let a=a5.trim();if(!a||null===a3)return;a8(null);let b=a3?`${a3}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a4(null),a6(""),await ci(a3),""!==a3&&aR(a=>es(a,a3,a=>({...a,expanded:!0})))):a8((await c.json()).error??"Failed")}async function dh(){let a=bb.trim();if(!a||null===a9)return;bf(null);let b=a.includes(".")?a:`${a}.md`,c=a9?`${a9}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(ba(null),bc(""),await ci(a9),""!==a9&&aR(a=>es(a,a9,a=>({...a,expanded:!0}))),c3({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):bf((await d.json()).error??"Failed")}function dj(a){navigator.clipboard.writeText(a),(0,b1.showSuccess)("Path copied")}function dk(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b1.showSuccess)("Wiki link copied")}function dl(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b1.showSuccess)("URL copied")}async function dm(a){if(bk?.path===a&&null!==bV)return bV;if(da.useEditorStore.getState().currentPath===a)return da.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dn(a){try{let b=await dm(a);await navigator.clipboard.writeText(b),(0,b1.showSuccess)("Raw content copied")}catch{(0,b1.showError)("Could not copy file content")}}async function dp(a,b){try{let c=await dm(a);if(!el(b)){await navigator.clipboard.writeText(c),(0,b1.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b1.showSuccess)("Formatted content copied")}catch{(0,b1.showError)("Could not copy formatted content")}}function dq(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dj(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dk(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dn(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dp(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dr(){bg&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg})}),(bk?.path===bg||bk?.path.startsWith(`${bg}/`))&&(bl(null),bW(null)),aR(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bg)),bh(null))}function ds(a,b,c){a.preventDefault(),a.stopPropagation();let d=ca.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",cd("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",cd("root"===c?"":b))}async function dt(a,b){a.preventDefault(),a.stopPropagation(),cd(null);let c=ca.current;if(ca.current=null,!c){a.dataTransfer.files.length>0&&await de(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await ci(a),b!==a&&await ci(b),bk?.path===c.path&&bl({path:d,name:c.name,nodeType:bk.nodeType,size:bk.size})}}let du=bk?ei(bk.name,bk.nodeType):null,dv=!!bk&&null!==du&&!eg.has(du)&&(bk.size??0)>5242880&&bm!==bk.path,dw=(0,d4.useViewWidthStore)(a=>a.width),dx=(0,d4.useViewWidthStore)(a=>a.align),dy=(0,d4.useViewWidthStore)(a=>a.setWidth),dz=(0,d4.useViewWidthStore)(a=>a.setAlign),dA=null===du||"editor"===du||"text"===du||"source"===du||"notebook"===du||"fallback"===du,dB=dA?d4.VIEW_WIDTH_CLASS[dw]:"",dC=dA?d4.VIEW_ALIGN_CLASS[dx]:"",dD=(0,T.useRef)(null);dD.current={toggleFolder:a=>void c2(a),openViewer:a=>void c3(a),copyPath:dj,copyWikiLink:dk,copyUrl:dl,copyRawContent:a=>void dn(a),copyFormattedContent:(a,b)=>void dp(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:df,handleCreateFile:()=>void dh(),handleCreateFolder:()=>void dg(),handleDragStart:function(a,b){ca.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:ds,handleDropOnFolder:(a,b)=>void dt(a,b),handleGitPull:(a,b)=>void cN(a,b),handleCheckout:(a,b,c)=>void cS(a,b,c),loadBranches:a=>void cR(a),prefetch:a=>{"file"===a.type?el(a.name)&&(0,da.prefetchPage)(a.path):function(a){if(ep.has(a)||eq.has(a))return;let b=eo(a).then(b=>(ep.set(a,b),b)).finally(()=>eq.delete(a));eq.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>c_.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:cd,setSidebarCollapsed:bA,setBranchDropdownNode:cK,setBranchDropdownPos:cM,setNewFileParent:ba,setNewFileName:bc,setFileCreateError:bf,setNewFolderParent:a4,setNewFolderName:a6,setFolderError:a8,setDeletingPath:bh,setDeletingIsDir:bj};let dE=(0,T.useMemo)(()=>({toggleFolder:a=>dD.current.toggleFolder(a),openViewer:a=>dD.current.openViewer(a),copyPath:a=>dD.current.copyPath(a),copyWikiLink:a=>dD.current.copyWikiLink(a),copyUrl:a=>dD.current.copyUrl(a),copyRawContent:a=>dD.current.copyRawContent(a),copyFormattedContent:(a,b)=>dD.current.copyFormattedContent(a,b),handleDownload:a=>dD.current.handleDownload(a),triggerUpload:a=>dD.current.triggerUpload(a),handleCreateFile:()=>dD.current.handleCreateFile(),handleCreateFolder:()=>dD.current.handleCreateFolder(),handleDragStart:(a,b)=>dD.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>dD.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>dD.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>dD.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>dD.current.handleCheckout(a,b,c),loadBranches:a=>dD.current.loadBranches(a),prefetch:a=>dD.current.prefetch(a),togglePin:(a,b)=>dD.current.togglePin(a,b),setDragOverPath:a=>dD.current.setDragOverPath(a),setSidebarCollapsed:a=>dD.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>dD.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>dD.current.setBranchDropdownPos(a),setNewFileParent:a=>dD.current.setNewFileParent(a),setNewFileName:a=>dD.current.setNewFileName(a),setFileCreateError:a=>dD.current.setFileCreateError(a),setNewFolderParent:a=>dD.current.setNewFolderParent(a),setNewFolderName:a=>dD.current.setNewFolderName(a),setFolderError:a=>dD.current.setFolderError(a),setDeletingPath:a=>dD.current.setDeletingPath(a),setDeletingIsDir:a=>dD.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bR,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aT(!1),aW.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bR,{onSelect:a=>{aj(!1),az(),c7(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d6,{onOpenFile:c4,recents:aB,onToggleSidebar:()=>bA(a=>{let b=!a;return by&&!1===b&&c1.useAIPanelStore.getState().close(),b}),onNewFile:()=>ba(""),onCopyPath:()=>{bk&&navigator.clipboard.writeText(bk.path)}}),!aO&&!bz&&by&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bA(!0),"aria-hidden":!0}),!aO&&!bz&&(0,b.jsxs)(cy.Card,{style:by?void 0:{width:bB},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.9.0",children:[(0,b.jsx)("img",{src:(0,bQ.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bA(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aZ,children:[aZ?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ba(""),bc(""),bf(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a4(""),a6(""),a8(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>df(""),disabled:aZ,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cY,disabled:aX,children:aX?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c1.useAIPanelStore.getState().toggle(),by&&bA(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c9(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>eb.getState().toggle(),children:[bC?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),bC?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>ec.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bD?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bH("dark"===bF?"light":"dark"),children:["dark"===bF?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bF?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bO(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),a_]}),""===a3&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a5,onChange:a=>a6(a.target.value),onKeyDown:a=>{"Enter"===a.key&&dg(),"Escape"===a.key&&(a4(null),a6(""))}}),a7&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a7}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:dg,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a4(null),a6("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a9&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:bb,onChange:a=>bc(a.target.value),onKeyDown:a=>{"Enter"===a.key&&dh(),"Escape"===a.key&&(ba(null),bc(""))}}),bd&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:bd}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:dh,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{ba(null),bc("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d7,{onOpenFile:c4})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===cc&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>ds(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||cd(null)},onDrop:a=>dt(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bk?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{c5(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),c5(a))},children:[(0,b.jsx)(ev,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bD?a.name:void 0,children:bD?ed(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),c_.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(eu,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dE,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bk?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{c3({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),by&&bA(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),c3({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(ev,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bD?a.name:void 0,children:bD?ed(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(eu,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dE,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aU?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aQ.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>df(""),disabled:aZ,children:[aZ?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(ex,{ctx:dE,nodes:aQ,openPath:bk?.path??null,dragOverPath:cc,branchDropdownNode:cI,branchDropdownPos:cL,nodeBranches:cB,branchesLoading:cD,checkingOutBranch:cF,pullingRepo:cj,activePaths:aJ,pins:aG,isMobile:by,activeWorkspaceId:V,newFileParent:a9,newFileName:bb,fileCreateError:bd,newFolderParent:a3,newFolderName:a5,folderError:a7,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void c7(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),db(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ef(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ef(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c9(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bT,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{dc(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bM(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bI(bB+(a.clientX-b))},f=()=>{bM(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bI(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bI(bB-16)):"ArrowRight"===a.key&&(a.preventDefault(),bI(bB+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bB,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bK&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!aO&&bz&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bA(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),!aO&&(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bA(!1),c1.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bk?.path,children:[bk&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===du||"html"===du?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):em(bk.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):ek(bk.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bk?bk.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c1.useAIPanelStore.getState().open(),bA(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bk?"node-app"===du?(0,b.jsx)(bL,{path:bk.path,title:bk.name}):"app"===du||"html"===du?(a="html"===du?(0,Y.withWs)(`/api/assets/${bk.path}`):void 0,bs?(0,b.jsx)(bG,{path:bk.path,title:bk.name,src:a,fullscreen:!0,onExit:()=>bt(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!by&&bz&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bk.path,children:bk.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[dq(bk,(0,b.jsxs)(b.Fragment,{children:["html"===du&&!b_&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b5(a=>!a),children:[b4?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b4?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bv(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bt(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bS(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===du&&!b_&&null!==bV&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{b0(!0),b3(bV),b9(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bl(null),b0(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),b_&&"html"===du?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:b2,onChange:a=>b3(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b8&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b8}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{b0(!1),b9(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:dd,disabled:b6,children:[b6&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b4&&"html"===du?(0,b.jsx)(bE,{path:bk.path,title:bk.name}):(0,b.jsx)(bG,{path:bk.path,title:bk.name,src:a},bu)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!by&&bz&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:em(bk.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):ek(bk.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bk.path,children:bk.path}),cl&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cl.author}),(0,b.jsx)("span",{title:new Date(cl.date).toLocaleString(),className:"shrink-0",children:ef(cl.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[dq(bk,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{cn?co(!1):cP()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),cn?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bS(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!b_&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:c0,disabled:bZ,children:[bZ?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dA&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d4.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dy(a),className:"flex items-center justify-between text-xs",children:[d4.VIEW_WIDTH_LABEL[a],a===dw&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d4.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dz(a),className:"flex items-center justify-between text-xs",children:[d4.VIEW_ALIGN_LABEL[a],a===dx&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),ek(bk.name)&&!b_&&(null!==bV||el(bk.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{b0(!0),b3(bV??""),b9(null),el(bk.name)&&da.useEditorStore.getState().loadPage(bk.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),ek(bk.name)&&b_&&el(bk.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{b0(!1),b9(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bl(null),bW(null),b0(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),cn&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>co(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cr?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===cp.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:cp.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",ct===a.sha&&"bg-muted"),onClick:()=>void cQ(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ef(a.date)})]})}),ct===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cz?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cv?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cv}):null})]},a.sha))})]}),dv?(0,b.jsx)(ag,{path:bk.path,size:bk.size??0,onOpen:()=>bo(bk.path)}):b_?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:el(bk.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:b2,onChange:a=>b3(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):el(bk.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===du||"pdf"===du||"mermaid"===du||"notebook"===du||"image"===du||"media"===du||"docx"===du||"xlsx"===du||"pptx"===du||"source"===du||"fallback"===du?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===du?(0,b.jsx)(ab,{path:bk.path,title:bk.name}):"pdf"===du?(0,b.jsx)(ee,{path:bk.path,title:bk.name}):"mermaid"===du?(0,b.jsx)(ak,{path:bk.path,title:bk.name}):"notebook"===du?(0,b.jsx)(bn,{path:bk.path,title:bk.name}):"image"===du?(0,b.jsx)(ah,{path:bk.path,title:bk.name}):"media"===du?(0,b.jsx)(ai,{path:bk.path,title:bk.name,type:["mp4","webm","mov","m4v"].includes(eh(bk.name))?"video":"audio"}):"docx"===du?(0,b.jsx)(bp,{path:bk.path,title:bk.name}):"xlsx"===du?(0,b.jsx)(br,{path:bk.path,title:bk.name}):"pptx"===du?(0,b.jsx)(bq,{path:bk.path,title:bk.name}):"source"===du?(0,b.jsx)(bE,{path:bk.path,title:bk.name}):(0,b.jsx)(ad,{path:bk.path,title:bk.name})},bw):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dC,dB),children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bV?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bV}):ek(bk.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),b_&&!el(bk.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b8&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b8}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{b0(!1),b9(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:dd,disabled:b6,children:[b6&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cx,{open:bP,onOpenChange:bS,filePath:bk?.path??""}),!(0,bQ.isLite)()&&(0,b.jsx)(cb,{open:bN,onOpenChange:bO}),(0,b.jsx)(di,{currentPath:bk?.path}),(0,b.jsx)("input",{ref:a1,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&de(a.target.files,a2.current)}}),(0,b.jsx)(W,{open:!!bg,onOpenChange:a=>{a||bh(null)},title:bi?"Delete folder?":"Delete file?",description:bi?`"${bg?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bg?.split("/").pop()}" will be permanently removed.`,onConfirm:dr}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c8})]})]},V??"none")}],240777)}];
|
|
17
|
+
${b}/api/agent/files/${a??"<path/to/file.md>"}`;await navigator.clipboard.writeText(d),c(!0),setTimeout(()=>c(!1),1500)},[a])}}(a??null),[m,n]=(0,T.useState)(""),o=(0,T.useRef)(null),p="http://localhost:3000",q=(0,T.useCallback)(()=>dg,[]),r=(0,T.useCallback)(()=>m.replace(/\$WIKI_URL/g,p),[m,p]),s=(0,T.useCallback)(()=>`npx wiki-viewer-mcp register --url ${p} --id ai:myagent --name "My Agent"`,[p]),t=(0,T.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:p,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[p]),u=dh(q),v=dh(r),w=dh(s),x=dh(t);return((0,T.useEffect)(()=>{if(c)return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a);function a(a){"Escape"===a.key&&d()}},[c,d]),(0,T.useEffect)(()=>{c&&o.current?.focus()},[c]),(0,T.useEffect)(()=>{if(!c)return;j();let a=setInterval(()=>void j(),1e4);return()=>clearInterval(a)},[c,j]),(0,T.useEffect)(()=>{c&&fetch((0,bQ.apiUrl)("/api/agents/install")).then(a=>a.json()).then(a=>{a.bootstrapPrompt&&n(a.bootstrapPrompt)}).catch(()=>void 0)},[c]),c)?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:d,"aria-hidden":!0}),(0,b.jsxs)("aside",{ref:o,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(e,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:d,title:"Close panel (Esc)",children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,b.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,b.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,b.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,b.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,b.jsxs)("section",{className:"space-y-3",children:[(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,b.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:dg}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void u.copy(),children:u.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,b.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,b.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,b.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,b.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:s()}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void w.copy(),children:w.copied?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,b.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,b.jsx)(U.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void x.copy(),children:x.copied?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,b.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,b.jsxs)("button",{type:"button",onClick:()=>void l(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[k?(0,b.jsx)(f.Check,{className:"h-3 w-3 text-green-500"}):(0,b.jsx)(i.Copy,{className:"h-3 w-3"})," curl example"]}),(0,b.jsxs)("a",{href:(0,bQ.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,b.jsxs)("a",{href:(0,bQ.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,b.jsx)(ae.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,b.jsx)(c9,{}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,b.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===h.length?(0,b.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,b.jsx)(c0,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,b.jsx)("ul",{className:"space-y-1.5",children:h.map(a=>(0,b.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,b.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:a.by}),(0,b.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[a.opCount," op",1!==a.opCount?"s":""]})]},a.by))})})]}),(0,b.jsxs)("section",{className:"space-y-2",children:[(0,b.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,b.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,b.jsx)(df,{activity:g})})]}),(0,b.jsx)("section",{children:(0,b.jsx)("a",{href:(0,bQ.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var dj=a.i(503442),dk=a.i(670576),dl=/[\\\/_+.#"@\[\(\{&]/,dm=/[\\\/_+.#"@\[\(\{&]/g,dn=/[\s-]/,dp=/[\s-]/g;function dq(a){return a.toLowerCase().replace(dp," ")}var dr=a.i(105305),ds=a.i(359231),dt='[cmdk-group=""]',du='[cmdk-group-items=""]',dv='[cmdk-item=""]',dw=`${dv}:not([aria-disabled="true"])`,dx="cmdk-item-select",dy="data-value",dz=(a,b,c)=>{var d;return d=a,function a(b,c,d,e,f,g,h){if(g===c.length)return f===b.length?1:.99;var i=`${f},${g}`;if(void 0!==h[i])return h[i];for(var j,k,l,m,n=e.charAt(g),o=d.indexOf(n,f),p=0;o>=0;)(j=a(b,c,d,e,o+1,g+1,h))>p&&(o===f?j*=1:dl.test(b.charAt(o-1))?(j*=.8,(l=b.slice(f,o-1).match(dm))&&f>0&&(j*=Math.pow(.999,l.length))):dn.test(b.charAt(o-1))?(j*=.9,(m=b.slice(f,o-1).match(dp))&&f>0&&(j*=Math.pow(.999,m.length))):(j*=.17,f>0&&(j*=Math.pow(.999,o-f))),b.charAt(o)!==c.charAt(g)&&(j*=.9999)),(j<.1&&d.charAt(o-1)===e.charAt(g+1)||e.charAt(g+1)===e.charAt(g)&&d.charAt(o-1)!==e.charAt(g))&&.1*(k=a(b,c,d,e,o+1,g+2,h))>j&&(j=.1*k),j>p&&(p=j),o=d.indexOf(n,o+1);return h[i]=p,p}(d=c&&c.length>0?`${d+" "+c.join(" ")}`:d,b,dq(d),dq(b),0,0,{})},dA=T.createContext(void 0),dB=T.createContext(void 0),dC=T.createContext(void 0),dD=T.forwardRef((a,b)=>{let c=dN(()=>{var b,c;return{search:"",value:null!=(c=null!=(b=a.value)?b:a.defaultValue)?c:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),d=dN(()=>new Set),e=dN(()=>new Map),f=dN(()=>new Map),g=dN(()=>new Set),h=dL(a),{label:i,children:j,value:k,onValueChange:l,filter:m,shouldFilter:n,loop:o,disablePointerSelection:p=!1,vimBindings:q=!0,...r}=a,s=(0,ds.useId)(),t=(0,ds.useId)(),u=(0,ds.useId)(),v=T.useRef(null),w=dQ();dM(()=>{if(void 0!==k){let a=k.trim();c.current.value=a,x.emit()}},[k]),dM(()=>{w(6,D)},[]);let x=T.useMemo(()=>({subscribe:a=>(g.current.add(a),()=>g.current.delete(a)),snapshot:()=>c.current,setState:(a,b,d)=>{var e,f,g,i;if(!Object.is(c.current[a],b)){if(c.current[a]=b,"search"===a)C(),A(),w(1,B);else if("value"===a){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let a=document.getElementById(u);a?a.focus():null==(e=document.getElementById(s))||e.focus()}if(w(7,()=>{var a;c.current.selectedItemId=null==(a=E())?void 0:a.id,x.emit()}),d||w(5,D),(null==(f=h.current)?void 0:f.value)!==void 0){null==(i=(g=h.current).onValueChange)||i.call(g,null!=b?b:"");return}}x.emit()}},emit:()=>{g.current.forEach(a=>a())}}),[]),y=T.useMemo(()=>({value:(a,b,d)=>{var e;b!==(null==(e=f.current.get(a))?void 0:e.value)&&(f.current.set(a,{value:b,keywords:d}),c.current.filtered.items.set(a,z(b,d)),w(2,()=>{A(),x.emit()}))},item:(a,b)=>(d.current.add(a),b&&(e.current.has(b)?e.current.get(b).add(a):e.current.set(b,new Set([a]))),w(3,()=>{C(),A(),c.current.value||B(),x.emit()}),()=>{f.current.delete(a),d.current.delete(a),c.current.filtered.items.delete(a);let b=E();w(4,()=>{C(),(null==b?void 0:b.getAttribute("id"))===a&&B(),x.emit()})}),group:a=>(e.current.has(a)||e.current.set(a,new Set),()=>{f.current.delete(a),e.current.delete(a)}),filter:()=>h.current.shouldFilter,label:i||a["aria-label"],getDisablePointerSelection:()=>h.current.disablePointerSelection,listId:s,inputId:u,labelId:t,listInnerRef:v}),[]);function z(a,b){var d,e;let f=null!=(e=null==(d=h.current)?void 0:d.filter)?e:dz;return a?f(a,c.current.search,b):0}function A(){if(!c.current.search||!1===h.current.shouldFilter)return;let a=c.current.filtered.items,b=[];c.current.filtered.groups.forEach(c=>{let d=e.current.get(c),f=0;d.forEach(b=>{f=Math.max(a.get(b),f)}),b.push([c,f])});let d=v.current;F().sort((b,c)=>{var d,e;let f=b.getAttribute("id"),g=c.getAttribute("id");return(null!=(d=a.get(g))?d:0)-(null!=(e=a.get(f))?e:0)}).forEach(a=>{let b=a.closest(du);b?b.appendChild(a.parentElement===b?a:a.closest(`${du} > *`)):d.appendChild(a.parentElement===d?a:a.closest(`${du} > *`))}),b.sort((a,b)=>b[1]-a[1]).forEach(a=>{var b;let c=null==(b=v.current)?void 0:b.querySelector(`${dt}[${dy}="${encodeURIComponent(a[0])}"]`);null==c||c.parentElement.appendChild(c)})}function B(){let a=F().find(a=>"true"!==a.getAttribute("aria-disabled")),b=null==a?void 0:a.getAttribute(dy);x.setState("value",b||void 0)}function C(){var a,b,g,i;if(!c.current.search||!1===h.current.shouldFilter){c.current.filtered.count=d.current.size;return}c.current.filtered.groups=new Set;let j=0;for(let e of d.current){let d=z(null!=(b=null==(a=f.current.get(e))?void 0:a.value)?b:"",null!=(i=null==(g=f.current.get(e))?void 0:g.keywords)?i:[]);c.current.filtered.items.set(e,d),d>0&&j++}for(let[a,b]of e.current)for(let d of b)if(c.current.filtered.items.get(d)>0){c.current.filtered.groups.add(a);break}c.current.filtered.count=j}function D(){var a,b,c;let d=E();d&&((null==(a=d.parentElement)?void 0:a.firstChild)===d&&(null==(c=null==(b=d.closest(dt))?void 0:b.querySelector('[cmdk-group-heading=""]'))||c.scrollIntoView({block:"nearest"})),d.scrollIntoView({block:"nearest"}))}function E(){var a;return null==(a=v.current)?void 0:a.querySelector(`${dv}[aria-selected="true"]`)}function F(){var a;return Array.from((null==(a=v.current)?void 0:a.querySelectorAll(dw))||[])}function G(a){let b=F()[a];b&&x.setState("value",b.getAttribute(dy))}function H(a){var b;let c=E(),d=F(),e=d.findIndex(a=>a===c),f=d[e+a];null!=(b=h.current)&&b.loop&&(f=e+a<0?d[d.length-1]:e+a===d.length?d[0]:d[e+a]),f&&x.setState("value",f.getAttribute(dy))}function I(a){let b=E(),c=null==b?void 0:b.closest(dt),d;for(;c&&!d;)d=null==(c=a>0?function(a,b){let c=a.nextElementSibling;for(;c;){if(c.matches(b))return c;c=c.nextElementSibling}}(c,dt):function(a,b){let c=a.previousElementSibling;for(;c;){if(c.matches(b))return c;c=c.previousElementSibling}}(c,dt))?void 0:c.querySelector(dw);d?x.setState("value",d.getAttribute(dy)):H(a)}let J=()=>G(F().length-1),K=a=>{a.preventDefault(),a.metaKey?J():a.altKey?I(1):H(1)},L=a=>{a.preventDefault(),a.metaKey?G(0):a.altKey?I(-1):H(-1)};return T.createElement(dr.Primitive.div,{ref:b,tabIndex:-1,...r,"cmdk-root":"",onKeyDown:a=>{var b;null==(b=r.onKeyDown)||b.call(r,a);let c=a.nativeEvent.isComposing||229===a.keyCode;if(!(a.defaultPrevented||c))switch(a.key){case"n":case"j":q&&a.ctrlKey&&K(a);break;case"ArrowDown":K(a);break;case"p":case"k":q&&a.ctrlKey&&L(a);break;case"ArrowUp":L(a);break;case"Home":a.preventDefault(),G(0);break;case"End":a.preventDefault(),J();break;case"Enter":{a.preventDefault();let b=E();if(b){let a=new Event(dx);b.dispatchEvent(a)}}}}},T.createElement("label",{"cmdk-label":"",htmlFor:y.inputId,id:y.labelId,style:dS},i),dR(a,a=>T.createElement(dB.Provider,{value:x},T.createElement(dA.Provider,{value:y},a))))}),dE=T.forwardRef((a,b)=>{var c,d;let e=(0,ds.useId)(),f=T.useRef(null),g=T.useContext(dC),h=T.useContext(dA),i=dL(a),j=null!=(d=null==(c=i.current)?void 0:c.forceMount)?d:null==g?void 0:g.forceMount;dM(()=>{if(!j)return h.item(e,null==g?void 0:g.id)},[j]);let k=dP(e,f,[a.value,a.children,f],a.keywords),l=T.useContext(dB),m=dO(a=>a.value&&a.value===k.current),n=dO(a=>!!j||!1===h.filter()||!a.search||a.filtered.items.get(e)>0);function o(){var a,b;p(),null==(b=(a=i.current).onSelect)||b.call(a,k.current)}function p(){l.setState("value",k.current,!0)}if(T.useEffect(()=>{let b=f.current;if(!(!b||a.disabled))return b.addEventListener(dx,o),()=>b.removeEventListener(dx,o)},[n,a.onSelect,a.disabled]),!n)return null;let{disabled:q,value:r,onSelect:s,forceMount:t,keywords:u,...v}=a;return T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(f,b),...v,id:e,"cmdk-item":"",role:"option","aria-disabled":!!q,"aria-selected":!!m,"data-disabled":!!q,"data-selected":!!m,onPointerMove:q||h.getDisablePointerSelection()?void 0:p,onClick:q?void 0:o},a.children)}),dF=T.forwardRef((a,b)=>{let{heading:c,children:d,forceMount:e,...f}=a,g=(0,ds.useId)(),h=T.useRef(null),i=T.useRef(null),j=(0,ds.useId)(),k=T.useContext(dA),l=dO(a=>!!e||!1===k.filter()||!a.search||a.filtered.groups.has(g));dM(()=>k.group(g),[]),dP(g,h,[a.value,a.heading,i]);let m=T.useMemo(()=>({id:g,forceMount:e}),[e]);return T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(h,b),...f,"cmdk-group":"",role:"presentation",hidden:!l||void 0},c&&T.createElement("div",{ref:i,"cmdk-group-heading":"","aria-hidden":!0,id:j},c),dR(a,a=>T.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":c?j:void 0},T.createElement(dC.Provider,{value:m},a))))}),dG=T.forwardRef((a,b)=>{let{alwaysRender:c,...d}=a,e=T.useRef(null),f=dO(a=>!a.search);return c||f?T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(e,b),...d,"cmdk-separator":"",role:"separator"}):null}),dH=T.forwardRef((a,b)=>{let{onValueChange:c,...d}=a,e=null!=a.value,f=T.useContext(dB),g=dO(a=>a.search),h=dO(a=>a.selectedItemId),i=T.useContext(dA);return T.useEffect(()=>{null!=a.value&&f.setState("search",a.value)},[a.value]),T.createElement(dr.Primitive.input,{ref:b,...d,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":i.listId,"aria-labelledby":i.labelId,"aria-activedescendant":h,id:i.inputId,type:"text",value:e?a.value:g,onChange:a=>{e||f.setState("search",a.target.value),null==c||c(a.target.value)}})}),dI=T.forwardRef((a,b)=>{let{children:c,label:d="Suggestions",...e}=a,f=T.useRef(null),g=T.useRef(null),h=dO(a=>a.selectedItemId),i=T.useContext(dA);return T.useEffect(()=>{if(g.current&&f.current){let a=g.current,b=f.current,c,d=new ResizeObserver(()=>{c=requestAnimationFrame(()=>{let c=a.offsetHeight;b.style.setProperty("--cmdk-list-height",c.toFixed(1)+"px")})});return d.observe(a),()=>{cancelAnimationFrame(c),d.unobserve(a)}}},[]),T.createElement(dr.Primitive.div,{ref:(0,cg.composeRefs)(f,b),...e,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":h,"aria-label":d,id:i.listId},dR(a,a=>T.createElement("div",{ref:(0,cg.composeRefs)(g,i.listInnerRef),"cmdk-list-sizer":""},a)))}),dJ=T.forwardRef((a,b)=>{let{open:c,onOpenChange:d,overlayClassName:e,contentClassName:f,container:g,...h}=a;return T.createElement(bW.Root,{open:c,onOpenChange:d},T.createElement(bW.Portal,{container:g},T.createElement(bW.Overlay,{"cmdk-overlay":"",className:e}),T.createElement(bW.Content,{"aria-label":a.label,"cmdk-dialog":"",className:f},T.createElement(dD,{ref:b,...h}))))}),dK=Object.assign(dD,{List:dI,Item:dE,Input:dH,Group:dF,Separator:dG,Dialog:dJ,Empty:T.forwardRef((a,b)=>dO(a=>0===a.filtered.count)?T.createElement(dr.Primitive.div,{ref:b,...a,"cmdk-empty":"",role:"presentation"}):null),Loading:T.forwardRef((a,b)=>{let{progress:c,children:d,label:e="Loading...",...f}=a;return T.createElement(dr.Primitive.div,{ref:b,...f,"cmdk-loading":"",role:"progressbar","aria-valuenow":c,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e},dR(a,a=>T.createElement("div",{"aria-hidden":!0},a)))})});function dL(a){let b=T.useRef(a);return dM(()=>{b.current=a}),b}var dM=T.useEffect;function dN(a){let b=T.useRef();return void 0===b.current&&(b.current=a()),b}function dO(a){let b=T.useContext(dB),c=()=>a(b.snapshot());return T.useSyncExternalStore(b.subscribe,c,c)}function dP(a,b,c,d=[]){let e=T.useRef(),f=T.useContext(dA);return dM(()=>{var g;let h=(()=>{var a;for(let b of c){if("string"==typeof b)return b.trim();if("object"==typeof b&&"current"in b)return b.current?null==(a=b.current.textContent)?void 0:a.trim():e.current}})(),i=d.map(a=>a.trim());f.value(a,h,i),null==(g=b.current)||g.setAttribute(dy,h),e.current=h}),e}var dQ=()=>{let[a,b]=T.useState(),c=dN(()=>new Map);return dM(()=>{c.current.forEach(a=>a()),c.current=new Map},[a]),(a,d)=>{c.current.set(a,d),b({})}};function dR({asChild:a,children:b},c){let d;return a&&T.isValidElement(b)?T.cloneElement("function"==typeof(d=b.type)?d(b.props):"render"in d?d.render(b.props):b,{ref:b.ref},c(b.props.children)):c(b)}var dS={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let dT=(0,d.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),dU=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK,{ref:d,className:(0,Z.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",a),...c}));function dV({children:a,shouldFilter:c,...d}){return(0,b.jsx)(V.Dialog,{...d,children:(0,b.jsxs)(V.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,b.jsx)(V.DialogTitle,{className:"sr-only",children:"Search"}),(0,b.jsx)(dU,{shouldFilter:c,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:a})]})})}dU.displayName=dK.displayName;let dW=T.forwardRef(({className:a,...c},d)=>(0,b.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,b.jsx)(dT,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,b.jsx)(dK.Input,{ref:d,className:(0,Z.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",a),...c})]}));dW.displayName=dK.Input.displayName;let dX=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.List,{ref:d,className:(0,Z.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",a),...c}));dX.displayName=dK.List.displayName;let dY=T.forwardRef((a,c)=>(0,b.jsx)(dK.Empty,{ref:c,className:"py-6 text-center text-sm text-muted-foreground",...a}));dY.displayName=dK.Empty.displayName;let dZ=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Group,{ref:d,className:(0,Z.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",a),...c}));dZ.displayName=dK.Group.displayName;let d$=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Separator,{ref:d,className:(0,Z.cn)("-mx-1 h-px bg-border",a),...c}));d$.displayName=dK.Separator.displayName;let d_=T.forwardRef(({className:a,...c},d)=>(0,b.jsx)(dK.Item,{ref:d,className:(0,Z.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",a),...c}));d_.displayName=dK.Item.displayName;let d0=null,d1=null,d2=(0,b3.create)(a=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:b=>a({query:b}),setOpen:b=>a({open:b}),clear:()=>{d1&&clearTimeout(d1),d0?.abort(),a({query:"",results:[],loading:!1,truncated:!1})},search:b=>(d1&&clearTimeout(d1),b.trim())?(a({loading:!0}),new Promise(c=>{d1=setTimeout(()=>{d3(a,b).finally(c)},150)})):(d0?.abort(),a({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function d3(a,b){d0?.abort();let c=new AbortController;d0=c;try{let d=await (0,Y.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:b,limit:30}),signal:c.signal});if(!d.ok)return void a({results:[],loading:!1,truncated:!1});let e=await d.json();if(c.signal.aborted)return;a({results:e.matches??[],truncated:!!e.truncated,loading:!1})}catch(b){"AbortError"!==b.name&&a({loading:!1})}}var d4=a.i(713033);function d5({html:a}){let c=function(a){let b,c=[],d=/<mark>([\s\S]*?)<\/mark>/g,e=0;for(;null!==(b=d.exec(a));)b.index>e&&c.push({text:a.slice(e,b.index),mark:!1}),c.push({text:b[1]??"",mark:!0}),e=b.index+b[0].length;return e<a.length&&c.push({text:a.slice(e),mark:!1}),c}(a);return(0,b.jsx)(b.Fragment,{children:c.map((a,c)=>a.mark?(0,b.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:a.text},c):(0,b.jsx)("span",{children:a.text},c))})}function d6({onOpenFile:a,recents:c=[],onToggleSidebar:d=()=>void 0,onNewFile:f=()=>void 0,onCopyPath:g=()=>void 0}){let h=d2(a=>a.open),j=d2(a=>a.setOpen),k=d2(a=>a.query),l=d2(a=>a.setQuery),n=d2(a=>a.results),o=d2(a=>a.loading),p=d2(a=>a.truncated),q=d2(a=>a.search),{resolvedTheme:r,setTheme:s}=(0,bU.useTheme)(),t=(0,c1.useAIPanelStore)(a=>a.toggle),u=(0,d4.useViewWidthStore)(a=>a.width),v=(0,d4.useViewWidthStore)(a=>a.cycle),w=k.trimStart(),x=""===w||w.startsWith(">"),y=""===w&&c.length>0,z=x?"":k;function A(a){a(),j(!1),l("")}(0,T.useEffect)(()=>{function a(a){(a.metaKey||a.ctrlKey)&&"k"===a.key.toLowerCase()&&(a.preventDefault(),j(!h))}return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[h,j]),(0,T.useEffect)(()=>{if(!h||x)return;let a=setTimeout(()=>{q(z)},120);return()=>clearTimeout(a)},[z,x,h,q]);let B=(d4.VIEW_WIDTH_ORDER.indexOf(u)+1)%d4.VIEW_WIDTH_ORDER.length,D=d4.VIEW_WIDTH_LABEL[d4.VIEW_WIDTH_ORDER[B]];return(0,b.jsxs)(dV,{open:h,onOpenChange:a=>{j(a),a||l("")},shouldFilter:!1,children:[(0,b.jsx)(dW,{placeholder:"Search files… ( > for actions )",value:k,onValueChange:l}),(0,b.jsxs)(dX,{children:[y&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(dZ,{heading:"Recent",children:c.map(c=>(0,b.jsxs)(d_,{value:`recent:${c.path}`,onSelect:()=>{a(c.path),j(!1),l("")},children:[(0,b.jsx)(cd,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-medium",children:c.name}),(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:c.path})]})]},c.path))}),(0,b.jsx)(d$,{})]}),x&&(0,b.jsxs)(dZ,{heading:"Actions",children:[(0,b.jsxs)(d_,{value:"toggle-dark-mode",onSelect:()=>A(()=>s("dark"===r?"light":"dark")),children:["dark"===r?(0,b.jsx)(N.Sun,{className:"mr-2 h-4 w-4"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-4 w-4"}),"dark"===r?"Switch to light mode":"Switch to dark mode"]}),(0,b.jsxs)(d_,{value:"toggle-ai-panel",onSelect:()=>A(t),children:[(0,b.jsx)(e,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,b.jsxs)(d_,{value:"toggle-sidebar",onSelect:()=>A(d),children:[(0,b.jsx)(dk.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,b.jsxs)(d_,{value:"new-file",onSelect:()=>A(f),children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,b.jsxs)(d_,{value:"copy-path",onSelect:()=>A(g),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,b.jsxs)(d_,{value:"cycle-view-width",onSelect:()=>A(v),children:[(0,b.jsx)(dj.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,b.jsxs)("span",{children:["Change view width"," ",(0,b.jsxs)("span",{className:"text-muted-foreground",children:["(",d4.VIEW_WIDTH_LABEL[u]," → ",D,")"]})]})]})]}),!x&&(0,b.jsxs)(b.Fragment,{children:[o&&(0,b.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!o&&""!==z.trim()&&0===n.length&&(0,b.jsx)(dY,{children:"No matches."}),n.length>0&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d$,{}),(0,b.jsx)(dZ,{heading:p?"Top results (refine query for more)":"Results",children:n.map(c=>(0,b.jsx)(d_,{value:c.path,onSelect:()=>{a(c.path),j(!1),l("")},children:(0,b.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,b.jsx)("span",{className:"truncate font-mono text-xs",children:c.path}),c.snippet&&(0,b.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,b.jsx)(d5,{html:c.snippet})})]})},c.path))})]})]})]})]})}function d7({onOpenFile:a}){let c=d2(a=>a.query),d=d2(a=>a.setQuery),e=d2(a=>a.results),f=d2(a=>a.loading),g=d2(a=>a.search),h=d2(a=>a.clear),[i,j]=(0,T.useState)(0),k=(0,T.useRef)(null);function l(b){let c=e[b];c&&(a(c.path),h())}return(0,T.useEffect)(()=>{j(0)},[e]),(0,T.useEffect)(()=>{let a=k.current?.querySelector(`[data-idx="${i}"]`);a?.scrollIntoView({block:"nearest"})},[i]),(0,b.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(dT,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,b.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:c,onChange:a=>{d(a.target.value),g(a.target.value)},onKeyDown:a=>{"Escape"===a.key?h():0!==e.length&&("ArrowDown"===a.key?(a.preventDefault(),j(a=>(a+1)%e.length)):"ArrowUp"===a.key?(a.preventDefault(),j(a=>(a-1+e.length)%e.length)):"Enter"===a.key&&(a.preventDefault(),l(i)))}})]}),""!==c.trim()&&(0,b.jsxs)("div",{ref:k,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[f&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!f&&0===e.length&&(0,b.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),e.map((a,c)=>(0,b.jsxs)("button",{type:"button","data-idx":c,onClick:()=>l(c),onMouseEnter:()=>j(c),className:`block w-full px-2 py-1 text-left ${c===i?"bg-accent":"hover:bg-accent"}`,children:[(0,b.jsx)("div",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,b.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,b.jsx)(d5,{html:a.snippet})})]},a.path))]})]})}let d8=(0,b3.create)(a=>({width:288,setWidth:b=>{a({width:Number.isNaN(b)?288:Math.min(600,Math.max(200,Math.round(b)))})}}));var d9=a.i(256233),ea=a.i(212588);let eb=(0,b3.create)((a,b)=>({showHidden:!1,toggle:()=>{a({showHidden:!b().showHidden})}})),ec=(0,b3.create)((a,b)=>({humanize:!1,toggle:()=>{a({humanize:!b().humanize})}}));function ed(a){let b=a.lastIndexOf("."),c=b>0&&b<a.length-1,d=c?a.slice(0,b):a,e=c?a.slice(b):"",f=d.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(a=>/^[A-Z0-9]+$/.test(a)?a:a[0].toUpperCase()+a.slice(1));return f.length?f.join(" ")+e:a}let ee=(0,bs.default)(async()=>{},{loadableGenerated:{modules:[904378]},ssr:!1});function ef(a){let b=new Date(a).getTime();if(!Number.isFinite(b))return"";let c=Math.floor(Math.max(0,Date.now()-b)/1e3);if(c<60)return"just now";let d=Math.floor(c/60);if(d<60)return`${d}m ago`;let e=Math.floor(d/60);return e<24?`${e}h ago`:`${Math.floor(e/24)}d ago`}let eg=new Set(["image","media","pdf","fallback","app","node-app","html"]);function eh(a){return a.split(".").pop()?.toLowerCase()??""}function ei(a,b){if("node-app"===b)return"node-app";if("app"===b)return"app";if("dir"===b)return"fallback";let c=a.split("/").pop()??a;if(c.startsWith(".")&&-1===c.indexOf(".",1))return"source";let d=eh(a);return d?["md","markdown"].includes(d)?"editor":"txt"===d?"text":["csv","tsv"].includes(d)?"csv":"pdf"===d?"pdf":["mmd","mermaid"].includes(d)?"mermaid":"ipynb"===d?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(d)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(d)?"media":"docx"===d?"docx":["xlsx","xlsm"].includes(d)?"xlsx":"pptx"===d?"pptx":"html"===d?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(d),"source"):"source"}let ej=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function ek(a){let b=ei(a,"file");return"editor"===b||"text"===b||ej.has(eh(a))}function el(a){return["md","markdown"].includes(eh(a))}function em(a){return"image"===ei(a,"file")}function en(a){return"html"===ei(a,"file")}async function eo(a){let b=await (0,Y.wsFetch)(`/api/wiki?dir=${encodeURIComponent(a)}`);return b.ok?(await b.json()).entries.map(b=>({name:b.name,path:a?`${a}/${b.name}`:b.name,type:b.type,size:b.size,modifiedAt:b.modifiedAt,expanded:!1,git:b.git})):[]}let ep=new Map,eq=new Map;async function er(a){let b=ep.get(a);if(b)return ep.delete(a),b;let c=eq.get(a);if(c){let b=await c;return ep.delete(a),b}return null}function es(a,b,c){return a.map(a=>a.path===b?c(a):a.children?{...a,children:es(a.children,b,c)}:a)}let et={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function eu({node:a,ctx:c,isPinned:d,activeWorkspaceId:e}){return(0,b.jsxs)(cX,{className:"w-48",children:[(0,b.jsxs)(cY,{onSelect:()=>c.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(cY,{onSelect:()=>c.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(cY,{onSelect:()=>c.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cY,{onSelect:()=>c.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(cY,{onSelect:()=>c.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(cZ,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(cY,{onSelect:()=>{a.expanded||c.toggleFolder(a),c.setNewFileParent(a.path),c.setNewFileName(""),c.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(cY,{onSelect:()=>c.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(cY,{onSelect:()=>{c.setNewFolderParent(a.path),c.setNewFolderName(""),c.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(cZ,{})]}),(0,b.jsxs)(cY,{onSelect:()=>c.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(cY,{onSelect:()=>c.togglePin(a,e),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",d&&"fill-current text-amber-400")}),d?"Unpin":"Pin to top"]}),(0,b.jsx)(cZ,{}),(0,b.jsxs)(cY,{className:"text-destructive focus:text-destructive",onSelect:()=>{c.setDeletingPath(a.path),c.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function ev({name:a,type:c}){let d="h-3.5 w-3.5 shrink-0";return"dir"===c?(0,b.jsx)(o.Folder,{className:(0,Z.cn)(d,"text-warning")}):"app"===c?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/70")}):"node-app"===c?(0,b.jsx)(O,{className:(0,Z.cn)(d,"text-emerald-500")}):en(a)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)(d,"text-foreground/60")}):em(a)?(0,b.jsx)(x.default,{className:(0,Z.cn)(d,"text-sunshine-700")}):ek(a)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)(d,"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)(d,"text-foreground/60")})}let ew=(0,T.memo)(function({node:a,depth:c,ctx:d,isMobile:e,activeWorkspaceId:f,sidebarScrollRef:g,isActive:k,isDragOver:s,isPinned:t,isAgentActive:v,isPulling:w,branchOpen:A,branchPos:C,branches:D,branchLoading:E,checkingOut:F,onHoverEnter:G,onHoverLeave:H}){let J=ec(a=>a.humanize);return(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!e,onKeyDown:b=>{if("Enter"===b.key||" "===b.key)b.preventDefault(),"dir"===a.type?d.toggleFolder(a):"app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a);else if("ArrowDown"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else if("ArrowUp"===b.key){b.preventDefault();let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d-1]?.focus()}else if("ArrowRight"===b.key){if(b.preventDefault(),"dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=c.indexOf(b.currentTarget);c[d+1]?.focus()}else d.toggleFolder(a)}else if("ArrowLeft"===b.key){if(b.preventDefault(),("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded)d.toggleFolder(a);else if(c>0){let a=g.current;if(!a)return;let c=Array.from(a.querySelectorAll('[role="treeitem"]')),d=b.currentTarget,e=c.indexOf(d),f=Number.parseInt(d.style.paddingLeft??"0",10);for(let a=e-1;a>=0;a--)if(Number.parseInt(c[a].style.paddingLeft??"0",10)<f){c[a].focus();break}}}},onDragStart:b=>d.handleDragStart(b,a),onDragOver:b=>"dir"===a.type?d.handleDragOver(b,a.path,"dir"):b.preventDefault(),onDragLeave:()=>d.setDragOverPath(null),onDrop:b=>"dir"===a.type?d.handleDropOnFolder(b,a.path):b.preventDefault(),onMouseEnter:()=>G(a),onMouseLeave:H,className:(0,Z.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",k?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",s&&"ring-2 ring-primary bg-primary-soft",a.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*c+8}px`,...et},onClick:()=>{"dir"===a.type?d.toggleFolder(a):("app"===a.type||"node-app"===a.type?(d.openViewer(a),d.toggleFolder(a)):d.openViewer(a),e&&d.setSidebarCollapsed(!0))},children:["dir"===a.type||"app"===a.type||"node-app"===a.type?a.loading?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,b.jsx)(h.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:a.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===a.type?a.expanded?(0,b.jsx)(p,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):(0,b.jsx)(o.Folder,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-warning")}):"app"===a.type?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):"node-app"===a.type?(0,b.jsx)(O,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-emerald-500")}):en(a.name)?(0,b.jsx)(u.Globe,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")}):em(a.name)?(0,b.jsx)(x.default,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-sunshine-700")}):ek(a.name)?(0,b.jsx)(n.FileText,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/70")}):(0,b.jsx)(l.File,{className:(0,Z.cn)("h-4 w-4 shrink-0",!k&&"text-foreground/60")})}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate",title:J?a.name:void 0,children:J?ed(a.name):a.name}),a.git&&(0,b.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:b=>{if(b.stopPropagation(),A){d.setBranchDropdownNode(null),d.setBranchDropdownPos(null);return}let c=b.currentTarget.getBoundingClientRect();d.setBranchDropdownPos({top:c.bottom+4,left:c.left}),d.setBranchDropdownNode(a.path),d.loadBranches(a.path)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"}),a.git.branch,a.git.dirty&&(0,b.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),w?(0,b.jsx)(z.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,b.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation();let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleGitPull(a.path,c)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,b.jsx)(K,{className:"h-2.5 w-2.5"})}),A&&C&&(0,b.jsx)(bT,{pos:C,branches:D,loading:E,busyName:F,disabled:null!==F,onPick:b=>{let c=a.path.includes("/")?a.path.substring(0,a.path.lastIndexOf("/")):"";d.handleCheckout(a.path,b,c)},onClose:()=>{d.setBranchDropdownNode(null),d.setBranchDropdownPos(null)}})]}),v&&(0,b.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,b.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:a=>a.stopPropagation(),onKeyDown:a=>a.stopPropagation(),children:(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyPath(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyWikiLink(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyUrl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===a.type&&ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyRawContent(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.copyFormattedContent(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),"dir"===a.type&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:async()=>{a.expanded||d.toggleFolder(a),d.setNewFileParent(a.path),d.setNewFileName(""),d.setFileCreateError(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.triggerUpload(a.path),children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{d.setNewFolderParent(a.path),d.setNewFolderName(""),d.setFolderError(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{})]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.handleDownload(a),children:[(0,b.jsx)(j.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===a.type?"Download":"Download as zip"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>d.togglePin(a,f),children:[(0,b.jsx)(I,{className:(0,Z.cn)("mr-2 h-3.5 w-3.5",t&&"fill-current text-amber-400")}),t?"Unpin":"Pin to top"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{d.setDeletingPath(a.path),d.setDeletingIsDir("file"!==a.type)},children:[(0,b.jsx)(Q.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,b.jsx)(eu,{node:a,ctx:d,isPinned:t,activeWorkspaceId:f})]})}),ex=(0,T.memo)(function(a){let{ctx:c,openPath:d,dragOverPath:e,branchDropdownNode:g,branchDropdownPos:h,nodeBranches:i,branchesLoading:j,checkingOutBranch:k,pullingRepo:l,activePaths:m,pins:p,isMobile:q,activeWorkspaceId:r,newFileParent:s,newFileName:t,fileCreateError:u,newFolderParent:v,newFolderName:w,folderError:x,sidebarScrollRef:y}=a,z=eb(a=>a.showHidden),A=(0,T.useRef)(null),B=(0,T.useCallback)(a=>{let b=("dir"===a.type||"app"===a.type||"node-app"===a.type)&&!a.expanded&&void 0===a.children;("file"===a.type||b)&&(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>c.prefetch(a),120))},[c]),C=(0,T.useCallback)(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),D=(0,T.useMemo)(()=>{let b=[],c=(a,d)=>{for(let e of a)!(!z&&e.name.startsWith("."))&&(b.push({kind:"row",node:e,depth:d}),"dir"===e.type&&(v===e.path&&b.push({kind:"newfolder",node:e,depth:d}),s===e.path&&b.push({kind:"newfile",node:e,depth:d})),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded&&(e.children&&e.children.length>0?c(e.children,d+1):e.children?.length===0&&b.push({kind:"empty",node:e,depth:d})))};return c(a.nodes,0),b},[a.nodes,s,v,z]);return(0,b.jsx)(b.Fragment,{children:D.map(a=>{let{node:s,depth:v}=a;if("row"===a.kind){let a=g===s.path;return(0,b.jsx)(ew,{node:s,depth:v,ctx:c,isMobile:q,activeWorkspaceId:r,sidebarScrollRef:y,isActive:d===s.path,isDragOver:e===s.path,isPinned:p.some(a=>a.path===s.path),isAgentActive:m.has(s.path),isPulling:l===s.path,branchOpen:a,branchPos:a?h:null,branches:s.git?i[s.path]??[]:[],branchLoading:!!s.git&&!!j[s.path],checkingOut:a?k:null,onHoverEnter:B,onHoverLeave:C},s.path)}return"newfolder"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...et},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:w,onChange:a=>c.setNewFolderName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFolder(),"Escape"===a.key&&(c.setNewFolderParent(null),c.setNewFolderName(""))}}),x&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:x}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFolder,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFolderParent(null),c.setNewFolderName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`nf-${s.path}`):"newfile"===a.kind?(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...et},children:[(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:t,onChange:a=>c.setNewFileName(a.target.value),onKeyDown:a=>{"Enter"===a.key&&c.handleCreateFile(),"Escape"===a.key&&(c.setNewFileParent(null),c.setNewFileName(""))}}),u&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:u}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c.handleCreateFile,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{c.setNewFileParent(null),c.setNewFileName("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]},`ff-${s.path}`):(0,b.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...et},children:"Empty"},`empty-${s.path}`)})})});a.s(["default",0,function(){let a;(0,d9.useWikiSlugsStore)(a=>a.loadedAt),(0,T.useEffect)(()=>{d9.useWikiSlugsStore.getState().load()},[]);let[d,j]=(0,T.useState)(null),[p,O]=(0,T.useState)(null),[V,X]=(0,T.useState)(()=>null),[$,_]=(0,T.useState)([]),[aa,ae]=(0,T.useState)(!1),[af,aj]=(0,T.useState)(!1),[al,am]=(0,T.useState)(null),[an,ao]=(0,T.useState)(null),[ap,aq]=(0,T.useState)({}),[ar,as]=(0,T.useState)(null),[at,au]=(0,T.useState)(null),[av,aw]=(0,T.useState)(null),[ax,ay]=(0,T.useState)(null),az=(0,T.useCallback)(async()=>{let a=(0,Y.getEphemeralRoot)();if(a){_([]),ae(!1),j(!0),O(a),X(`root:${a}`);return}try{let a=await fetch((0,bQ.apiUrl)("/api/system/workspaces"));if(!a.ok)throw Error("Failed");let b=await a.json();if(_(b.workspaces),ae(b.isAdmin),b.workspaces.length>0){j(!0);let a=new URLSearchParams(window.location.search).get("ws"),c=a?b.workspaces.find(b=>b.id===a):null,d=c??[...b.workspaces].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];if(X(d.id),O(d.rootDir),!c){let a=new URL(location.href);a.searchParams.set("ws",d.id),history.replaceState(null,"",a.toString())}}else j(!1)}catch{j(!1)}},[]);(0,T.useEffect)(()=>{az()},[az]);let aA=(0,da.useEditorStore)(a=>a.currentPath),aB=c$(a=>a.recents),[aC,aD]=(0,T.useState)(!1),[aE,aF]=(0,T.useState)(!0),aG=c_(a=>a.pins),aH=(0,T.useRef)(null),aI=(0,c1.useAIPanelStore)(a=>a.activity),aJ=(0,T.useMemo)(()=>{let a=new Date(Date.now()-6e4).toISOString(),b=new Set;for(let c of aI)c.at>=a&&c.path&&c.by?.startsWith("ai:")&&b.add(c.path);return b},[aI]);(0,T.useEffect)(()=>{let a=()=>{c1.useAIPanelStore.getState().loadActivity()};a();let b=setInterval(a,1e4);return()=>clearInterval(b)},[]),(0,T.useEffect)(()=>{c$.getState().loadForWorkspace(V),c_.getState().loadForWorkspace(V)},[V]),(0,T.useEffect)(()=>{let a,b=[...aG.map(a=>a.path),...aB.slice(0,8).map(a=>a.path)].filter((a,b,c)=>el(a)&&c.indexOf(a)===b).slice(0,12);if(0===b.length)return;let c=(a=()=>{for(let a of b)(0,da.prefetchPage)(a)},window.setTimeout(a,400));return()=>{clearTimeout(c)}},[aG,aB]);let aK=(0,T.useRef)(null),aL=(0,T.useRef)(!1),[aM,aN]=(0,T.useState)(!1),[aO,aP]=(0,T.useState)(!1);(0,T.useEffect)(()=>{let a=new URLSearchParams(window.location.search),b="1"===a.get("embed");aN(b),aP(b&&"1"!==a.get("chrome"))},[]);let[aQ,aR]=(0,T.useState)([]),[aS,aT]=(0,T.useState)(!1),[aU,aV]=(0,T.useState)(!1),aW=(0,T.useRef)(!1),[aX,aY]=(0,T.useState)(!1),[aZ,a$]=(0,T.useState)(!1),[a_,a0]=(0,T.useState)(null),a1=(0,T.useRef)(null),a2=(0,T.useRef)(""),[a3,a4]=(0,T.useState)(null),[a5,a6]=(0,T.useState)(""),[a7,a8]=(0,T.useState)(null),[a9,ba]=(0,T.useState)(null),[bb,bc]=(0,T.useState)(""),[bd,bf]=(0,T.useState)(null),[bg,bh]=(0,T.useState)(null),[bi,bj]=(0,T.useState)(!1),[bk,bl]=(0,T.useState)(null),[bm,bo]=(0,T.useState)(null),[bs,bt]=(0,T.useState)(!1),[bu,bv]=(0,T.useState)(0),[bw,bx]=(0,T.useState)(0),by=function(a="(max-width: 767px)"){let[b,c]=(0,T.useState)(!1);return(0,T.useEffect)(()=>{let b=window.matchMedia(a),d=()=>c(b.matches);return d(),b.addEventListener("change",d),()=>b.removeEventListener("change",d)},[a]),b}(),[bz,bA]=(0,T.useState)(!1),bB=d8(a=>a.width),bC=eb(a=>a.showHidden),bD=ec(a=>a.humanize),{resolvedTheme:bF,setTheme:bH}=(0,bU.useTheme)(),bI=d8(a=>a.setWidth);(0,T.useEffect)(()=>{by&&bA(!0)},[by]);let[bK,bM]=(0,T.useState)(!1),[bN,bO]=(0,T.useState)(!1),[bP,bS]=(0,T.useState)(!1),[bV,bW]=(0,T.useState)(null),[bX,bY]=(0,T.useState)(0),[bZ,b$]=(0,T.useState)(!1),[b_,b0]=(0,T.useState)(!1),[b2,b3]=(0,T.useState)(""),[b4,b5]=(0,T.useState)(!1),[b6,b7]=(0,T.useState)(!1),[b8,b9]=(0,T.useState)(null),ca=(0,T.useRef)(null),[cc,cd]=(0,T.useState)(null),ce=(0,T.useRef)(null),cf=(0,T.useRef)(!1),cg=(0,T.useRef)(async()=>{});(0,T.useEffect)(()=>{!V||aS||aW.current||(aW.current=!0,aV(!0),eo("").then(a=>{aR(a),aT(!0),aV(!1)}).catch(()=>{aW.current=!1,aV(!1)}))},[aS,V]);let ch=(0,T.useCallback)(async a=>{let b=a.split("/");if(b.length<=1)return;let c=[],d="";for(let a=0;a<b.length-1;a++)d=d?`${d}/${b[a]}`:b[a],c.push({prefix:d,children:await eo(d)});aR(a=>{let b=a;for(let{prefix:a,children:d}of c)b=es(b,a,a=>({...a,children:d,expanded:!0}));return b})},[]),ci=(0,T.useCallback)(async a=>{let b=await eo(a);""===a?aR(a=>{let c=new Map(a.map(a=>[a.path,a]));return b.map(a=>{let b=c.get(a.path);return b&&("dir"===b.type||"app"===b.type)?{...a,expanded:b.expanded,children:b.children}:a})}):aR(c=>es(c,a,a=>({...a,children:b,expanded:!0})))},[]),[cj,ck]=(0,T.useState)(null),[cl,cm]=(0,T.useState)(null),[cn,co]=(0,T.useState)(!1),[cp,cq]=(0,T.useState)([]),[cr,cs]=(0,T.useState)(!1),[ct,cu]=(0,T.useState)(null),[cv,cw]=(0,T.useState)(null),[cz,cA]=(0,T.useState)(!1),[cB,cC]=(0,T.useState)({}),[cD,cE]=(0,T.useState)({}),[cF,cG]=(0,T.useState)(null),[cI,cK]=(0,T.useState)(null),[cL,cM]=(0,T.useState)(null),cN=(0,T.useCallback)(async(a,b)=>{if(!cj){ck(a);try{let c=await (0,Y.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:a})});if(!c.ok){let a=await c.json();(0,b1.showError)(a.message??a.error??"Pull failed");return}let d=await c.json();(0,b1.showSuccess)(`Pulled ${a} (${d.branch} @ ${d.sha.slice(0,7)})`),await ci(b)}catch{(0,b1.showError)("Pull failed")}finally{ck(null)}}},[cj,ci]);(0,T.useEffect)(()=>{co(!1),cq([]),cu(null),cw(null)},[bk?.path]);let cO=bk?.path;(0,T.useEffect)(()=>{if(!cO)return void cm(null);let a=!1,b=setTimeout(()=>{(async()=>{try{let b=await (0,Y.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(cO)}`);if(a)return;if(!b.ok)return void cm(null);let c=await b.json();a||cm(c.info)}catch{a||cm(null)}})()},200);return()=>{a=!0,clearTimeout(b)}},[cO]);let cP=(0,T.useCallback)(async()=>{if(!bk)return;let a=bk.path;co(!0),cs(!0),cq([]),cu(null),cw(null);try{let b=await (0,Y.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(a)}`);if(!b.ok)return void(0,b1.showError)("Could not load history");let c=await b.json();bk.path===a&&cq(c.commits)}catch{(0,b1.showError)("Could not load history")}finally{cs(!1)}},[bk]),cQ=(0,T.useCallback)(async a=>{if(!bk)return;if(ct===a){cu(null),cw(null);return}let b=bk.path;cu(a),cA(!0),cw(null);try{let c=await (0,Y.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(b)}&sha=${encodeURIComponent(a)}`);if(!c.ok)return void(0,b1.showError)("Could not load diff");let d=await c.json();bk.path===b&&ct===a&&cw(d.diff)}catch{(0,b1.showError)("Could not load diff")}finally{cA(!1)}},[bk,ct]),cR=(0,T.useCallback)(async a=>{if(cB[a]||cD[a])return;let b=!1;cE(b=>({...b,[a]:!0}));try{let c=await (0,Y.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(a)}`);if(b)return;if(!c.ok)return void(0,b1.showError)("Could not load branches");let d=await c.json();b||cC(b=>({...b,[a]:d.branches}))}catch{b||(0,b1.showError)("Could not load branches")}finally{b||cE(b=>({...b,[a]:!1}))}return()=>{b=!0}},[cB,cD]),cS=(0,T.useCallback)(async(a,b,c)=>{if(!cF){cG(b);try{let d=await (0,Y.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:a,branch:b})});if(409===d.status)return void(0,b1.showError)("Repository has uncommitted changes");if(!d.ok){let a=await d.json();(0,b1.showError)(a.error??"Checkout failed");return}let e=await d.json();(0,b1.showSuccess)(`Switched to ${e.branch}`),cC(b=>{let c={...b};return delete c[a],c}),cK(null),cM(null),await ci(c)}catch{(0,b1.showError)("Checkout failed")}finally{cG(null)}}},[cF,ci]),cT=(0,T.useCallback)(a=>{let b=[];for(let c of a)("dir"===c.type||"app"===c.type||"node-app"===c.type)&&c.expanded&&c.children&&(b.push(c.path),b.push(...cT(c.children)));return b},[]),cU=(0,T.useRef)([]);(0,T.useEffect)(()=>{cU.current=cT(aQ)},[aQ,cT]);let cV=(0,T.useMemo)(()=>cT(aQ).filter(a=>""!==a).slice(0,24).join("\n"),[aQ,cT]),[cW,cX]=(0,T.useState)("");(0,T.useEffect)(()=>{let a=setTimeout(()=>cX(cV),300);return()=>clearTimeout(a)},[cV]);let cY=(0,T.useCallback)(async()=>{aY(!0);try{let a=cT(aQ),b=await eo("");for(let c of(aR(b),a)){let a=await eo(c);aR(b=>es(b,c,b=>({...b,children:a,expanded:!0})))}}finally{aY(!1)}},[aQ,cT]),cZ=(0,T.useCallback)(async()=>{if(bk){if(el(bk.name)){b$(!0);try{await da.useEditorStore.getState().loadPage(bk.path)}finally{b$(!1)}return}if(["editor","text"].includes(ei(bk.name,bk.nodeType))||ek(bk.name)){b$(!0);try{let a=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(bk.path)}`);if(a.ok){let b=await a.json();bW(b.content),bY(Number(a.headers.get("X-Wiki-Revision")??0))}}catch{}b$(!1)}}},[bk]),c0=(0,T.useCallback)(()=>{bx(a=>a+1),cZ()},[cZ]);async function c2(a){if("dir"===a.type||"app"===a.type||"node-app"===a.type)if(a.expanded)aR(b=>es(b,a.path,a=>({...a,expanded:!1})));else if(void 0===a.children){let b=await er(a.path);if(b)return void aR(c=>es(c,a.path,a=>({...a,loading:!1,children:b,expanded:!0})));aR(b=>es(b,a.path,a=>({...a,loading:!0})));let c=await eo(a.path);aR(b=>es(b,a.path,a=>({...a,loading:!1,children:c,expanded:!0})))}else aR(b=>es(b,a.path,a=>({...a,expanded:!0})))}async function c3(a){if("file"===a.type&&c$.getState().push({path:a.path,name:a.name},V),bl({path:a.path,name:a.name,size:a.size,nodeType:"app"===a.type?"app":"node-app"===a.type?"node-app":"file"}),b0(!1),b5(!1),b9(null),bW(null),bY(0),"file"===a.type&&el(a.name)){b$(!0);try{await da.useEditorStore.getState().loadPage(a.path)}finally{b$(!1)}return}if(["editor","text"].includes(ei(a.name,a.type))||ek(a.name)){b$(!0);try{let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a.path)}`);if(b.ok){let a=await b.json();bW(a.content),bY(Number(b.headers.get("X-Wiki-Revision")??0))}}catch{}b$(!1)}}(0,T.useEffect)(()=>{bk&&el(bk.name)&&da.useEditorStore.getState().currentPath!==bk.path&&da.useEditorStore.getState().loadPage(bk.path)},[bk]),(0,T.useEffect)(()=>{ce.current=bk},[bk]),(0,T.useEffect)(()=>{cf.current=b_},[b_]),(0,T.useEffect)(()=>{cg.current=cZ},[cZ]),(0,T.useEffect)(()=>{if(!d||(0,bQ.isLite)()||!V)return;let a=new Map;function b(b){a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),ci(b)},300))}let c=(cW?cW.split("\n"):[]).map(a=>`dir=${encodeURIComponent(a)}`).join("&"),e=new EventSource((0,Y.withWs)(c?`/api/wiki/watch?${c}`:"/api/wiki/watch"));return e.onmessage=c=>{let d;try{d=JSON.parse(c.data)}catch{return}let{type:e,path:f}=d;if("rescan"===e){for(let a of(ea.useBacklinksStore.getState().invalidateAll(),b(""),cU.current))b(a);return}("add"===e||"change"===e||"unlink"===e)&&ea.useBacklinksStore.getState().invalidateAll();let g=f.split("/");if(b(g.length>1?g.slice(0,-1).join("/"):""),"change"===e&&ce.current?.path===f&&!cf.current){let b=`__file__${f}`;a.has(b)&&clearTimeout(a.get(b)),a.set(b,setTimeout(()=>{a.delete(b),cg.current()},400))}},()=>{for(let b of(e.close(),a.values()))clearTimeout(b)}},[d,ci,V,cW]),(0,T.useEffect)(()=>{bt(!1)},[]);let c4=(0,T.useCallback)(a=>{let b=a.split("/").pop()??a;ch(a),c3({path:a,name:b,type:"file"})},[ch]),c5=(0,T.useCallback)(async a=>{let b=a.path.split("/").slice(0,-1).join("/"),c=(await eo(b)).find(b=>b.path===a.path);if(c){if("dir"===c.type){await ch(a.path),await c2(c);return}if("app"===c.type||"node-app"===c.type){await ch(c.path),c3({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),await c2(c),by&&bA(!0);return}c3({path:c.path,name:c.name,type:c.type,modifiedAt:c.modifiedAt}),by&&bA(!0)}},[by,c3,ch,c2]);(0,T.useEffect)(()=>{if(!aA||bk&&bk.path===aA)return;let a=aA.split("/").pop()??aA;c3({path:aA,name:a,type:"file"})},[aA]);let c6=(0,T.useCallback)(async a=>{if(!a)return void bl(null);let b=(0,Y.toRootRelative)(a,(0,Y.getEphemeralRoot)()??p);if(null===b||!(a=b))return;let c=a.split("/"),d=c[c.length-1],e=c.slice(0,-1).join("/"),f=(await eo(e)).find(b=>b.path===a);f&&(await ch(a),c3({path:a,name:d,type:f.type,modifiedAt:f.modifiedAt}))},[ch,p]);(0,T.useEffect)(()=>{},[bk]),(0,T.useEffect)(()=>{},[c6]),(0,T.useEffect)(()=>{if(!aM)return;let a=a=>{a.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${a.origin}.`):a.data&&"open-file"===a.data.type&&"string"==typeof a.data.path&&c6(a.data.path)};return window.addEventListener("message",a),()=>window.removeEventListener("message",a)},[c6,aM]),(0,T.useEffect)(()=>{aL.current||aS&&(aL.current=!0,c6(aK.current))},[aS,c6]);let c7=(0,T.useCallback)(async a=>{if(a===V)return;try{await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/open`),{method:"POST"})}catch{}let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.pushState(null,"",b.toString()),bl(null),bW(null),b0(!1),aR([]),aT(!1),aW.current=!1,d9.useWikiSlugsStore.getState().invalidate(),ea.useBacklinksStore.getState().invalidateAll();let c=$.find(b=>b.id===a);c&&O(c.rootDir),X(a)},[V,$]),c8=(0,T.useCallback)(async()=>{if(al)try{if(!(await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${al}`),{method:"DELETE"})).ok)throw Error("Failed");if(al===V){let a=$.filter(a=>a.id!==al);if(a.length>0){let b=[...a].sort((a,b)=>(b.lastOpenedAt??b.createdAt).localeCompare(a.lastOpenedAt??a.createdAt))[0];await c7(b.id)}else j(!1)}await az()}catch{}finally{am(null)}},[al,V,$,c7,az]),c9=(0,T.useCallback)(async a=>{if(!an){ao(a);try{let b=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/refresh`),{method:"POST"});if(!b.ok){let a=await b.json();(0,b1.showError)(a.error??"Refresh failed")}await az()}catch{(0,b1.showError)("Refresh failed")}finally{ao(null)}}},[an,az]),db=(0,T.useCallback)(async a=>{if(!ap[a])try{let b=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/branch`));if(!b.ok)return;let c=await b.json();aq(b=>({...b,[a]:c.branches??[]}))}catch{}},[ap]),dc=(0,T.useCallback)(async(a,b)=>{if(!ar){as(a),au(b);try{let c=await fetch((0,bQ.apiUrl)(`/api/system/workspaces/${a}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:b})});if(!c.ok){let a=await c.json();(0,b1.showError)(a.error??"Branch switch failed");return}(0,b1.showSuccess)(`Switched to ${b}`),aw(null),ay(null),await az()}catch{(0,b1.showError)("Branch switch failed")}finally{as(null),au(null)}}},[ar,az]);async function dd(){if(!bk)return;b7(!0),b9(null);let a=await (0,Y.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bk.path,content:b2,baseRevision:bX})});if(a.ok){let b=await a.json();"number"==typeof b.revision&&bY(b.revision),bW(b2),b0(!1)}else b9((await a.json()).error??"Save failed");b7(!1)}let de=(0,T.useCallback)(async(a,b)=>{let c=Array.from(a);if(c.length){a$(!0),a0(null);try{for(let a of c){let c=new FormData;c.append("file",a),c.append("dir",b);let d=await (0,Y.wsFetch)("/api/wiki/upload",{method:"POST",body:c});if(!d.ok){let a=await d.json();a0(a.error??"Upload failed"),(0,b1.showError)(a.error??"Upload failed");break}}await ci(b)}catch{a0("Upload failed.")}finally{a$(!1),a1.current&&(a1.current.value="")}}},[ci]);function df(a){a2.current=a,a1.current?.click()}async function dg(){let a=a5.trim();if(!a||null===a3)return;a8(null);let b=a3?`${a3}/${a}`:a,c=await (0,Y.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:b})});c.ok?(a4(null),a6(""),await ci(a3),""!==a3&&aR(a=>es(a,a3,a=>({...a,expanded:!0})))):a8((await c.json()).error??"Failed")}async function dh(){let a=bb.trim();if(!a||null===a9)return;bf(null);let b=a.includes(".")?a:`${a}.md`,c=a9?`${a9}/${b}`:b,d=await (0,Y.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:c})});d.ok?(ba(null),bc(""),await ci(a9),""!==a9&&aR(a=>es(a,a9,a=>({...a,expanded:!0}))),c3({path:c,name:b,type:"file",modifiedAt:new Date().toISOString()})):bf((await d.json()).error??"Failed")}function dj(a){navigator.clipboard.writeText(a),(0,b1.showSuccess)("Path copied")}function dk(a){let b=a.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${b}]]`),(0,b1.showSuccess)("Wiki link copied")}function dl(a){let b=new URL(location.href);b.searchParams.set("path",a),V&&b.searchParams.set("ws",V),navigator.clipboard.writeText(b.toString()),(0,b1.showSuccess)("URL copied")}async function dm(a){if(bk?.path===a&&null!==bV)return bV;if(da.useEditorStore.getState().currentPath===a)return da.useEditorStore.getState().content;let b=await (0,Y.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(a)}`);if(!b.ok)throw Error("Cannot copy content");return(await b.json()).content}async function dn(a){try{let b=await dm(a);await navigator.clipboard.writeText(b),(0,b1.showSuccess)("Raw content copied")}catch{(0,b1.showError)("Could not copy file content")}}async function dp(a,b){try{let c=await dm(a);if(!el(b)){await navigator.clipboard.writeText(c),(0,b1.showSuccess)("Content copied");return}let d=await (0,be.markdownToHtml)(c,{pagePath:a,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([d],{type:"text/html"}),"text/plain":new Blob([c],{type:"text/plain"})})]):await navigator.clipboard.writeText(c),(0,b1.showSuccess)("Formatted content copied")}catch{(0,b1.showError)("Could not copy formatted content")}}function dq(a,c){return(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dj(a.path),children:[(0,b.jsx)(i.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),el(a.name)&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dk(a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dl(a.path),children:[(0,b.jsx)(y.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),ek(a.name)&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dn(a.path),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void dp(a.path,a.name),children:[(0,b.jsx)(n.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),c&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),c]})]})]})}async function dr(){bg&&(await (0,Y.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:bg})}),(bk?.path===bg||bk?.path.startsWith(`${bg}/`))&&(bl(null),bW(null)),aR(a=>(function a(b,c){return b.filter(a=>a.path!==c).map(b=>b.children?{...b,children:a(b.children,c)}:b)})(a,bg)),bh(null))}function ds(a,b,c){a.preventDefault(),a.stopPropagation();let d=ca.current;if(!d){Array.from(a.dataTransfer.types).includes("Files")&&(a.dataTransfer.dropEffect="copy",cd("root"===c?"":b));return}d.path===b||b.startsWith(`${d.path}/`)||(a.dataTransfer.dropEffect="move",cd("root"===c?"":b))}async function dt(a,b){a.preventDefault(),a.stopPropagation(),cd(null);let c=ca.current;if(ca.current=null,!c){a.dataTransfer.files.length>0&&await de(a.dataTransfer.files,b);return}if(c.path===b||b.startsWith(`${c.path}/`))return;let d=b?`${b}/${c.name}`:c.name;if(d!==c.path&&(await (0,Y.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:c.path,to:d})})).ok){let a=c.path.includes("/")?c.path.split("/").slice(0,-1).join("/"):"";await ci(a),b!==a&&await ci(b),bk?.path===c.path&&bl({path:d,name:c.name,nodeType:bk.nodeType,size:bk.size})}}let du=bk?ei(bk.name,bk.nodeType):null,dv=!!bk&&null!==du&&!eg.has(du)&&(bk.size??0)>5242880&&bm!==bk.path,dw=(0,d4.useViewWidthStore)(a=>a.width),dx=(0,d4.useViewWidthStore)(a=>a.align),dy=(0,d4.useViewWidthStore)(a=>a.setWidth),dz=(0,d4.useViewWidthStore)(a=>a.setAlign),dA=null===du||"editor"===du||"text"===du||"source"===du||"notebook"===du||"fallback"===du,dB=dA?d4.VIEW_WIDTH_CLASS[dw]:"",dC=dA?d4.VIEW_ALIGN_CLASS[dx]:"",dD=(0,T.useRef)(null);dD.current={toggleFolder:a=>void c2(a),openViewer:a=>void c3(a),copyPath:dj,copyWikiLink:dk,copyUrl:dl,copyRawContent:a=>void dn(a),copyFormattedContent:(a,b)=>void dp(a,b),handleDownload:function(a){let b=(0,Y.withWs)(`/api/wiki/download?path=${encodeURIComponent(a.path)}`),c=document.createElement("a");c.href=b,c.download="file"===a.type?a.name:`${a.name}.zip`,document.body.appendChild(c),c.click(),c.remove()},triggerUpload:df,handleCreateFile:()=>void dh(),handleCreateFolder:()=>void dg(),handleDragStart:function(a,b){ca.current=b,a.dataTransfer.effectAllowed="move",a.dataTransfer.setData("text/plain",b.path)},handleDragOver:ds,handleDropOnFolder:(a,b)=>void dt(a,b),handleGitPull:(a,b)=>void cN(a,b),handleCheckout:(a,b,c)=>void cS(a,b,c),loadBranches:a=>void cR(a),prefetch:a=>{"file"===a.type?el(a.name)&&(0,da.prefetchPage)(a.path):function(a){if(ep.has(a)||eq.has(a))return;let b=eo(a).then(b=>(ep.set(a,b),b)).finally(()=>eq.delete(a));eq.set(a,b),b.catch(()=>{})}(a.path)},togglePin:(a,b)=>c_.getState().toggle({path:a.path,name:a.name,type:a.type},b),setDragOverPath:cd,setSidebarCollapsed:bA,setBranchDropdownNode:cK,setBranchDropdownPos:cM,setNewFileParent:ba,setNewFileName:bc,setFileCreateError:bf,setNewFolderParent:a4,setNewFolderName:a6,setFolderError:a8,setDeletingPath:bh,setDeletingIsDir:bj};let dE=(0,T.useMemo)(()=>({toggleFolder:a=>dD.current.toggleFolder(a),openViewer:a=>dD.current.openViewer(a),copyPath:a=>dD.current.copyPath(a),copyWikiLink:a=>dD.current.copyWikiLink(a),copyUrl:a=>dD.current.copyUrl(a),copyRawContent:a=>dD.current.copyRawContent(a),copyFormattedContent:(a,b)=>dD.current.copyFormattedContent(a,b),handleDownload:a=>dD.current.handleDownload(a),triggerUpload:a=>dD.current.triggerUpload(a),handleCreateFile:()=>dD.current.handleCreateFile(),handleCreateFolder:()=>dD.current.handleCreateFolder(),handleDragStart:(a,b)=>dD.current.handleDragStart(a,b),handleDragOver:(a,b,c)=>dD.current.handleDragOver(a,b,c),handleDropOnFolder:(a,b)=>dD.current.handleDropOnFolder(a,b),handleGitPull:(a,b)=>dD.current.handleGitPull(a,b),handleCheckout:(a,b,c)=>dD.current.handleCheckout(a,b,c),loadBranches:a=>dD.current.loadBranches(a),prefetch:a=>dD.current.prefetch(a),togglePin:(a,b)=>dD.current.togglePin(a,b),setDragOverPath:a=>dD.current.setDragOverPath(a),setSidebarCollapsed:a=>dD.current.setSidebarCollapsed(a),setBranchDropdownNode:a=>dD.current.setBranchDropdownNode(a),setBranchDropdownPos:a=>dD.current.setBranchDropdownPos(a),setNewFileParent:a=>dD.current.setNewFileParent(a),setNewFileName:a=>dD.current.setNewFileName(a),setFileCreateError:a=>dD.current.setFileCreateError(a),setNewFolderParent:a=>dD.current.setNewFolderParent(a),setNewFolderName:a=>dD.current.setNewFolderName(a),setFolderError:a=>dD.current.setFolderError(a),setDeletingPath:a=>dD.current.setDeletingPath(a),setDeletingIsDir:a=>dD.current.setDeletingIsDir(a)}),[]);return(0,b.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===d&&(0,b.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===d&&(0,b.jsx)(bR,{onSelect:a=>{let b=new URL(location.href);b.searchParams.set("ws",a),b.searchParams.delete("path"),history.replaceState(null,"",b.toString()),aT(!1),aW.current=!1,X(a),j(!0),az()}}),!0===d&&af&&(0,b.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,b.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>aj(!1),children:[(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,b.jsx)(bR,{onSelect:a=>{aj(!1),az(),c7(a)}})]}),!0===d&&!af&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(d6,{onOpenFile:c4,recents:aB,onToggleSidebar:()=>bA(a=>{let b=!a;return by&&!1===b&&c1.useAIPanelStore.getState().close(),b}),onNewFile:()=>ba(""),onCopyPath:()=>{bk&&navigator.clipboard.writeText(bk.path)}}),!aO&&!bz&&by&&(0,b.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>bA(!0),"aria-hidden":!0}),!aO&&!bz&&(0,b.jsxs)(cy.Card,{style:by?void 0:{width:bB},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,b.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.9.2",children:[(0,b.jsx)("img",{src:(0,bQ.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,b.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>bA(!0),children:(0,b.jsx)(D,{className:"h-3.5 w-3.5"})})]}),(0,b.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:aZ,children:[aZ?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(J,{className:"h-3.5 w-3.5"}),"New",(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{ba(""),bc(""),bf(null)},children:[(0,b.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{a4(""),a6(""),a8(null)},children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>df(""),disabled:aZ,children:[(0,b.jsx)(R.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:cY,disabled:aX,children:aX?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{c1.useAIPanelStore.getState().toggle(),by&&bA(!0)},children:(0,b.jsx)(e,{className:"h-3.5 w-3.5"})}),(0,b.jsxs)(bJ.DropdownMenu,{children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,b.jsx)(B,{className:"h-3.5 w-3.5"})})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"end",className:"w-48",children:[aa&&$.find(a=>a.id===V)?.git&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{V&&c9(V)},disabled:an===V,children:[an===V?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(k,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>eb.getState().toggle(),children:[bC?(0,b.jsx)(H,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(G.Eye,{className:"mr-2 h-3.5 w-3.5"}),bC?"Hide hidden files":"Show hidden files"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>ec.getState().toggle(),children:[(0,b.jsx)(P.Type,{className:"mr-2 h-3.5 w-3.5"}),bD?"Raw file names":"Humanize names"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bH("dark"===bF?"light":"dark"),children:["dark"===bF?(0,b.jsx)(N.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(C.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===bF?"Light mode":"Dark mode"]}),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bO(!0),children:[(0,b.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),a_&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,b.jsx)(c.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),a_]}),""===a3&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(o.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,b.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:a5,onChange:a=>a6(a.target.value),onKeyDown:a=>{"Enter"===a.key&&dg(),"Escape"===a.key&&(a4(null),a6(""))}}),a7&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:a7}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:dg,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a4(null),a6("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),""===a9&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,b.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:bb,onChange:a=>bc(a.target.value),onKeyDown:a=>{"Enter"===a.key&&dh(),"Escape"===a.key&&(ba(null),bc(""))}}),bd&&(0,b.jsx)("span",{className:"text-xs text-destructive",children:bd}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:dh,children:(0,b.jsx)(f.Check,{className:"h-3 w-3"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{ba(null),bc("")},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]}),(0,b.jsx)("div",{className:"border-b",children:(0,b.jsx)(d7,{onOpenFile:c4})}),(0,b.jsxs)("div",{ref:aH,className:(0,Z.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===cc&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:a=>ds(a,"","root"),onDragLeave:a=>{a.currentTarget.contains(a.relatedTarget)||cd(null)},onDrop:a=>dt(a,""),children:[aG.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aD(a=>!a),children:[aC?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aG.length})]}),!aC&&aG.map(a=>(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bk?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{c5(a)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),c5(a))},children:[(0,b.jsx)(ev,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:bD?a.name:void 0,children:bD?ed(a.name):a.name}),(0,b.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:a.path.split("/").slice(0,-1).join("/")}),(0,b.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:b=>{b.stopPropagation(),c_.getState().toggle({path:a.path,name:a.name},V)},children:(0,b.jsx)(S.X,{className:"h-3 w-3"})})]})}),(0,b.jsx)(eu,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dE,isPinned:!0,activeWorkspaceId:V})]},a.path))]}),aB.length>0&&(0,b.jsxs)("div",{className:"border-b mb-1",children:[(0,b.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>aF(a=>!a),children:[aE?(0,b.jsx)(h.ChevronRight,{className:"h-3 w-3"}):(0,b.jsx)(g.ChevronDown,{className:"h-3 w-3"}),(0,b.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,b.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:aB.length})]}),!aE&&aB.slice(0,8).map(a=>(0,b.jsxs)(cH,{children:[(0,b.jsx)(cJ,{asChild:!0,children:(0,b.jsxs)("div",{role:"button",tabIndex:0,className:(0,Z.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",bk?.path===a.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{c3({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}),by&&bA(!0)},onKeyDown:b=>{("Enter"===b.key||" "===b.key)&&(b.preventDefault(),c3({path:a.path,name:a.name,type:a.type??"file",modifiedAt:""}))},children:[(0,b.jsx)(ev,{name:a.name,type:a.type??"file"}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",title:bD?a.name:void 0,children:bD?ed(a.name):a.name}),(0,b.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:a.path.split("/").slice(0,-1).join("/")})]})}),(0,b.jsx)(eu,{node:{path:a.path,name:a.name,type:a.type??"file"},ctx:dE,isPinned:aG.some(b=>b.path===a.path),activeWorkspaceId:V})]},a.path))]}),aU?(0,b.jsx)("div",{className:"flex justify-center py-6",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===aQ.length?(0,b.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,b.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,b.jsx)(n.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,b.jsxs)("div",{className:"space-y-1",children:[(0,b.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,b.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,b.jsxs)(U.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>df(""),disabled:aZ,children:[aZ?(0,b.jsx)(z.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(R.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,b.jsx)(ex,{ctx:dE,nodes:aQ,openPath:bk?.path??null,dragOverPath:cc,branchDropdownNode:cI,branchDropdownPos:cL,nodeBranches:cB,branchesLoading:cD,checkingOutBranch:cF,pullingRepo:cj,activePaths:aJ,pins:aG,isMobile:by,activeWorkspaceId:V,newFileParent:a9,newFileName:bb,fileCreateError:bd,newFolderParent:a3,newFolderName:a5,folderError:a7,sidebarScrollRef:aH})]}),(0,b.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,b.jsxs)(bJ.DropdownMenu,{modal:!1,onOpenChange:a=>{a||(aw(null),ay(null))},children:[(0,b.jsx)(bJ.DropdownMenuTrigger,{asChild:!0,children:(0,b.jsxs)(U.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:p??"",children:[(0,b.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,b.jsx)("span",{className:"truncate text-xs font-medium",children:$.find(a=>a.id===V)?.name??"Workspace"}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:p??""})]}),(0,b.jsx)(g.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,b.jsxs)(bJ.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:a=>{a.target?.closest?.("[data-branch-portal]")&&a.preventDefault()},children:[$.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>void c7(a.id),onPointerMove:a=>a.preventDefault(),onPointerLeave:a=>a.preventDefault(),className:(0,Z.cn)("gap-2",a.id===V&&"font-medium"),children:[a.id===V?(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,b.jsx)("span",{className:"w-3.5 shrink-0"}),(0,b.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,b.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,b.jsx)("span",{className:"truncate",children:a.name}),a.git?aa?(0,b.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ar===a.id,onClick:b=>{if(b.stopPropagation(),b.preventDefault(),av===a.id){aw(null),ay(null);return}let c=b.currentTarget.getBoundingClientRect();ay({top:c.bottom+4,left:c.left}),aw(a.id),db(a.id)},children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"branch"]}):(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," ",a.git.branch??"read-only"]}):a.ssh?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(s,{className:"h-2.5 w-2.5"})," ",a.ssh.host]}):a.readOnly?(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,b.jsx)(r,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,b.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:a.rootDir}),a.git?.lastPulledAt&&ef(a.git.lastPulledAt)&&(0,b.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",ef(a.git.lastPulledAt)]})]}),aa&&a.git&&(0,b.jsx)("button",{className:(0,Z.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",a.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:a.git.lastError?`Last refresh failed: ${a.git.lastError}`:"Refresh",disabled:an===a.id,onClick:b=>{b.stopPropagation(),b.preventDefault(),c9(a.id)},children:(0,b.jsx)(K,{className:(0,Z.cn)("h-3.5 w-3.5",an===a.id&&"animate-spin")})}),aa&&(0,b.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:b=>{b.stopPropagation(),am(a.id)},children:(0,b.jsx)(Q.Trash2,{className:"h-3.5 w-3.5"})})]},a.id)),aa&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>aj(!0),children:[(0,b.jsx)(q,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!av||!ax)return null;let a=$.find(a=>a.id===av);return a?(0,b.jsx)(bT,{pos:ax,branches:(ap[a.id]??[]).map(b=>({name:b,current:b===a.git?.branch})),loading:!ap[a.id],busyName:ar===a.id?at:null,disabled:ar===a.id,onPick:b=>{dc(a.id,b)},onClose:()=>{aw(null),ay(null)}}):null})()]}),(0,b.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:a=>{a.preventDefault();let b=a.clientX;bM(!0);let c=document.body.style.cursor,d=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let e=a=>{bI(bB+(a.clientX-b))},f=()=>{bM(!1),document.body.style.cursor=c,document.body.style.userSelect=d,window.removeEventListener("mousemove",e),window.removeEventListener("mouseup",f)};window.addEventListener("mousemove",e),window.addEventListener("mouseup",f)},onDoubleClick:()=>bI(288),onKeyDown:a=>{"ArrowLeft"===a.key?(a.preventDefault(),bI(bB-16)):"ArrowRight"===a.key&&(a.preventDefault(),bI(bB+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":bB,className:(0,Z.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",bK&&"bg-primary/60")})]}),(0,b.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!aO&&bz&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>bA(!1),children:(0,b.jsx)(E,{className:"h-3.5 w-3.5"})}),!aO&&(0,b.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{bA(!1),c1.useAIPanelStore.getState().close()},children:(0,b.jsx)(E,{className:"h-4 w-4"})}),(0,b.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:bk?.path,children:[bk&&(0,b.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===du||"html"===du?(0,b.jsx)(u.Globe,{className:"h-4 w-4 text-foreground/70"}):em(bk.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 text-sunshine-700"}):ek(bk.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 text-foreground/60"})}),(0,b.jsx)("span",{className:"truncate",children:bk?bk.name:"Wiki Viewer"})]}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{c1.useAIPanelStore.getState().open(),bA(!0)},children:(0,b.jsx)(e,{className:"h-4 w-4"})})]}),bk?"node-app"===du?(0,b.jsx)(bL,{path:bk.path,title:bk.name}):"app"===du||"html"===du?(a="html"===du?(0,Y.withWs)(`/api/assets/${bk.path}`):void 0,bs?(0,b.jsx)(bG,{path:bk.path,title:bk.name,src:a,fullscreen:!0,onExit:()=>bt(!1)}):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!by&&bz&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:(0,b.jsx)(u.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bk.path,children:bk.path})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[dq(bk,(0,b.jsxs)(b.Fragment,{children:["html"===du&&!b_&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>b5(a=>!a),children:[b4?(0,b.jsx)(u.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,b.jsx)(t.Code2,{className:"mr-2 h-3.5 w-3.5"}),b4?"Show preview":"Show source"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bv(a=>a+1),children:[(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bt(!0),children:[(0,b.jsx)(A,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bS(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===du&&!b_&&null!==bV&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{b0(!0),b3(bV),b9(null)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bl(null),b0(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),b_&&"html"===du?(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,b.jsx)("textarea",{value:b2,onChange:a=>b3(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b8&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b8}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{b0(!1),b9(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:dd,disabled:b6,children:[b6&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):b4&&"html"===du?(0,b.jsx)(bE,{path:bk.path,title:bk.name}):(0,b.jsx)(bG,{path:bk.path,title:bk.name,src:a},bu)]})):(0,b.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,b.jsxs)("div",{className:(0,Z.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!by&&bz&&"pl-11"),children:[(0,b.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,b.jsx)("span",{className:"hidden md:inline-flex",children:(0,b.jsx)("span",{className:"editorial-tree-typeicon",children:em(bk.name)?(0,b.jsx)(x.default,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):ek(bk.name)?(0,b.jsx)(n.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,b.jsx)(l.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,b.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:bk.path,children:bk.path}),cl&&(0,b.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,b.jsx)(w,{className:"h-3 w-3 shrink-0"}),(0,b.jsx)("span",{className:"truncate max-w-[100px]",children:cl.author}),(0,b.jsx)("span",{title:new Date(cl.date).toLocaleString(),className:"shrink-0",children:ef(cl.date)})]})]}),(0,b.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[dq(bk,(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>{cn?co(!1):cP()},children:[(0,b.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),cn?"Hide history":"File history"]}),(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>bS(!0),children:[(0,b.jsx)(M,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!b_&&(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:c0,disabled:bZ,children:[bZ?(0,b.jsx)(z.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,b.jsx)(K,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),dA&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),d4.VIEW_WIDTH_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dy(a),className:"flex items-center justify-between text-xs",children:[d4.VIEW_WIDTH_LABEL[a],a===dw&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a)),(0,b.jsx)(bJ.DropdownMenuSeparator,{}),(0,b.jsx)(bJ.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),d4.VIEW_ALIGN_ORDER.map(a=>(0,b.jsxs)(bJ.DropdownMenuItem,{onClick:()=>dz(a),className:"flex items-center justify-between text-xs",children:[d4.VIEW_ALIGN_LABEL[a],a===dx&&(0,b.jsx)(f.Check,{className:"h-3.5 w-3.5"})]},a))]})]})),ek(bk.name)&&!b_&&(null!==bV||el(bk.name))&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{b0(!0),b3(bV??""),b9(null),el(bk.name)&&da.useEditorStore.getState().loadPage(bk.path)},children:(0,b.jsx)(F,{className:"h-3.5 w-3.5"})}),ek(bk.name)&&b_&&el(bk.name)&&(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{b0(!1),b9(null)},children:(0,b.jsx)(G.Eye,{className:"h-3.5 w-3.5"})}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{bl(null),bW(null),b0(!1)},children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]})]}),cn&&(0,b.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,b.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,b.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>co(!1),children:(0,b.jsx)(S.X,{className:"h-3.5 w-3.5"})})]}),cr?(0,b.jsx)("div",{className:"flex justify-center py-4",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===cp.length?(0,b.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,b.jsx)("div",{children:cp.map(a=>(0,b.jsxs)("div",{children:[(0,b.jsx)("button",{type:"button",className:(0,Z.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",ct===a.sha&&"bg-muted"),onClick:()=>void cQ(a.sha),children:(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:a.shortSha}),(0,b.jsx)("span",{className:"flex-1 truncate text-xs",children:a.message}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:a.author}),(0,b.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(a.date).toLocaleString(),children:ef(a.date)})]})}),ct===a.sha&&(0,b.jsx)("div",{className:"border-t",children:cz?(0,b.jsx)("div",{className:"flex justify-center py-3",children:(0,b.jsx)(z.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==cv?(0,b.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:cv}):null})]},a.sha))})]}),dv?(0,b.jsx)(ag,{path:bk.path,size:bk.size??0,onOpen:()=>bo(bk.path)}):b_?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:el(bk.name)?(0,b.jsx)(ac.KBEditor,{}):(0,b.jsx)("textarea",{value:b2,onChange:a=>b3(a.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):el(bk.name)?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,b.jsx)(ac.KBEditor,{mode:"viewing"})}):"csv"===du||"pdf"===du||"mermaid"===du||"notebook"===du||"image"===du||"media"===du||"docx"===du||"xlsx"===du||"pptx"===du||"source"===du||"fallback"===du?(0,b.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===du?(0,b.jsx)(ab,{path:bk.path,title:bk.name}):"pdf"===du?(0,b.jsx)(ee,{path:bk.path,title:bk.name}):"mermaid"===du?(0,b.jsx)(ak,{path:bk.path,title:bk.name}):"notebook"===du?(0,b.jsx)(bn,{path:bk.path,title:bk.name}):"image"===du?(0,b.jsx)(ah,{path:bk.path,title:bk.name}):"media"===du?(0,b.jsx)(ai,{path:bk.path,title:bk.name,type:["mp4","webm","mov","m4v"].includes(eh(bk.name))?"video":"audio"}):"docx"===du?(0,b.jsx)(bp,{path:bk.path,title:bk.name}):"xlsx"===du?(0,b.jsx)(br,{path:bk.path,title:bk.name}):"pptx"===du?(0,b.jsx)(bq,{path:bk.path,title:bk.name}):"source"===du?(0,b.jsx)(bE,{path:bk.path,title:bk.name}):(0,b.jsx)(ad,{path:bk.path,title:bk.name})},bw):(0,b.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,b.jsx)("div",{className:(0,Z.cn)("w-full",dC,dB),children:bZ?(0,b.jsx)("div",{className:"flex justify-center py-8",children:(0,b.jsx)(z.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==bV?(0,b.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:bV}):ek(bk.name)?(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),b_&&!el(bk.name)&&(0,b.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[b8&&(0,b.jsx)("span",{className:"text-xs text-destructive mr-auto",children:b8}),(0,b.jsx)(U.Button,{size:"sm",variant:"ghost",onClick:()=>{b0(!1),b9(null)},children:"Cancel"}),(0,b.jsxs)(U.Button,{size:"sm",className:"gap-1",onClick:dd,disabled:b6,children:[b6&&(0,b.jsx)(z.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,b.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,b.jsx)(n.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,b.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,b.jsx)(cx,{open:bP,onOpenChange:bS,filePath:bk?.path??""}),!(0,bQ.isLite)()&&(0,b.jsx)(cb,{open:bN,onOpenChange:bO}),(0,b.jsx)(di,{currentPath:bk?.path}),(0,b.jsx)("input",{ref:a1,type:"file",multiple:!0,className:"hidden",onChange:a=>{a.target.files&&de(a.target.files,a2.current)}}),(0,b.jsx)(W,{open:!!bg,onOpenChange:a=>{a||bh(null)},title:bi?"Delete folder?":"Delete file?",description:bi?`"${bg?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${bg?.split("/").pop()}" will be permanently removed.`,onConfirm:dr}),(0,b.jsx)(W,{open:!!al,onOpenChange:a=>{a||am(null)},title:"Delete workspace?",description:`"${$.find(a=>a.id===al)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:c8})]})]},V??"none")}],240777)}];
|
|
18
18
|
|
|
19
19
|
//# sourceMappingURL=_0v4uz-4._.js.map
|
|
@@ -7,9 +7,9 @@ globalThis.__BUILD_MANIFEST = {
|
|
|
7
7
|
"static/chunks/03~yq9q893hmn.js"
|
|
8
8
|
],
|
|
9
9
|
"lowPriorityFiles": [
|
|
10
|
-
"static/
|
|
11
|
-
"static/
|
|
12
|
-
"static/
|
|
10
|
+
"static/R2lG97g-a6HpbZZtS4qep/_buildManifest.js",
|
|
11
|
+
"static/R2lG97g-a6HpbZZtS4qep/_ssgManifest.js",
|
|
12
|
+
"static/R2lG97g-a6HpbZZtS4qep/_clientMiddlewareManifest.js"
|
|
13
13
|
],
|
|
14
14
|
"rootMainFiles": [
|
|
15
15
|
"static/chunks/057l2ju6dh43x.js",
|