@pi-chamber/web 1.0.6-rc.5 → 1.0.6
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/dist/assets/{DiagramView--XO16VPB.js → DiagramView-DsCdfDOP.js} +1 -1
- package/dist/assets/{DiffView-Duy2_7Gp.js → DiffView-BWo7yT-P.js} +6 -6
- package/dist/assets/{FileSaveConflictDialog-B1DvL9zy.js → FileSaveConflictDialog-IFbuQCcP.js} +1 -1
- package/dist/assets/{FilesView-CjjPpE4c.js → FilesView-DLIQkVep.js} +4 -4
- package/dist/assets/{GitHubDetailScaffold-DqxAKqCT.js → GitHubDetailScaffold-CxGg6x7R.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-ELF_chia.js → GitHubLinkPicker-BmqbTUpE.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-C2nGTntk.js → GitHubListPrimitives-a1DxU6Zp.js} +1 -1
- package/dist/assets/{GitView-5fIq2nzM.js → GitView-DbqM8Qi1.js} +5 -5
- package/dist/assets/{IssuesSurface-Dq5A_bWq.js → IssuesSurface-B2EfICtZ.js} +3 -3
- package/dist/assets/{JsonTreeView-BjFFSUwi.js → JsonTreeView-DzVqgwz-.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-B9Cu4TCh.js → MarkdownRendererImpl-7yTzCIEI.js} +3 -3
- package/dist/assets/PatchDiff-Dvfm6eOV.js +1 -0
- package/dist/assets/{PierreDiffViewer-H2f4pJ1k.js → PierreDiffViewer-ByYaUifK.js} +2 -2
- package/dist/assets/{PullRequestsSurface-DPpb2RW_.js → PullRequestsSurface-1IP_dDn8.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-B5DaBWZU.js → SessionSwitcherContent-DVxWhG4x.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-D86FaZg_.js → SessionSwitcherDropdown-DiBGmmtD.js} +2 -2
- package/dist/assets/{SessionUnreadDot-CY9-1iV2.js → SessionUnreadDot-qw67HcBO.js} +1 -1
- package/dist/assets/SettingsView-CMTIIpWD.js +6 -0
- package/dist/assets/{SettingsWindow-Bw1dUoJ1.js → SettingsWindow-DZUSs5Is.js} +1 -1
- package/dist/assets/{ToolOutputDialog-aR4kcgKL.js → ToolOutputDialog-pgTNzNPN.js} +5 -5
- package/dist/assets/{ToolPartDiffPreview-B_wWmhtE.js → ToolPartDiffPreview-Cvnr4JkU.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BYby097w.js → VirtualizedFileDiff-D8dSHI_H.js} +3 -3
- package/dist/assets/{collapsible-Dz0bPrJ_.js → collapsible-ZT74WYMA.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-8MuwxSC6.js → computeVirtualFileMetrics-g1aOl5nF.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-fZ2NIQMQ.js → contextFileOpenGuard-IWdho_6z.js} +1 -1
- package/dist/assets/{fileTreeStatus-BzhMMLA9.js → fileTreeStatus-trDHgX4B.js} +2 -2
- package/dist/assets/{gitStatusPredicates-Cyh9UhYX.js → gitStatusPredicates-CfBh9Rne.js} +1 -1
- package/dist/assets/{githubLink-D2PznPcI.js → githubLink-CuQ2WFBa.js} +1 -1
- package/dist/assets/index-BaLCg7tL.css +1 -0
- package/dist/assets/{index-BX5pAOQX.js → index-CK9t5Znh.js} +1 -1
- package/dist/assets/{index-Cs2nBW_t.js → index-fmzQmSSv.js} +3 -3
- package/dist/assets/{main-BI6qe8pz.js → main-DOlk_lfi.js} +2 -2
- package/dist/assets/{main-7vBNPBMb.js → main-UnRe9F68.js} +4 -4
- package/dist/assets/{markdownCore-D5jiabKe.js → markdownCore-DuZmdypZ.js} +2 -2
- package/dist/assets/{miniChat-B3up4Bnz.js → miniChat-Dy9h0B6G.js} +2 -2
- package/dist/assets/{mobile-B4vLFgBc.js → mobile-CWrtn0Si.js} +2 -2
- package/dist/assets/{nativeFileSave-DpBH1Sa3.js → nativeFileSave-B4Rg6n8u.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-BrB72skF.js → pi-session-focus-preference-q-s-Bhf0.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-B6T04JGG.js → renderDiffWithHighlighter-HRnE6vfE.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CX10w321.js → renderElectronMiniChatApp-OZ2fG5eY.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-DtAcGyJr.js → renderFileWithHighlighter-tJRUQWjE.js} +1 -1
- package/dist/assets/{renderMobileApp-C9n-BhPZ.js → renderMobileApp-D1nkBJLP.js} +3 -3
- package/dist/assets/runtimeEndpointReset-Bby2E_Je.js +62 -0
- package/dist/assets/{runtimeSurface-DiP2a57a.js → runtimeSurface-X62LLBLv.js} +1 -1
- package/dist/assets/{useAppFontEffects-Oyin3dgQ.js → useAppFontEffects-BFgKpDYT.js} +86 -86
- package/dist/assets/{useGitHubRemoteSearch-CZ9Hauw0.js → useGitHubRemoteSearch-MxC4J-VO.js} +1 -1
- package/dist/assets/{useSwitcherItems-BSqDA1IF.js → useSwitcherItems-D5TsQEbM.js} +1 -1
- package/dist/assets/{web-components-CkTNGkJ2.js → web-components-B_NMC-2c.js} +4 -4
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/lib/pi/routes.js +5 -1
- package/server/lib/pi/routes.test.js +3 -0
- package/server/lib/pi/session-daemon/DOCUMENTATION.md +1 -1
- package/server/lib/pi/session-daemon/session-daemon-list-live.test.js +60 -1
- package/server/lib/pi/session-daemon/session-daemon.js +34 -10
- package/server/lib/pi/session-daemon/session-engine-router.js +5 -1
- package/server/lib/pi/session-daemon/session-engine-router.test.js +21 -0
- package/dist/assets/PatchDiff-CTqTTcg7.js +0 -1
- package/dist/assets/SettingsView-CiIuOi_E.js +0 -6
- package/dist/assets/index-tmO0fZa4.css +0 -1
- package/dist/assets/runtimeEndpointReset-aGyXPXPs.js +0 -62
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{aj as Po,cg as zt,ch as $n,E as c,ah as Fs,Q as we,ci as Io,cj as $o,O as Es,M as Tt,ap as Hn,S as Bo,aq as an,j as e,ak as Vo,c6 as Wo,af as _o,ck as Ko,c9 as ut,cl as Vr,c5 as Ho,J as qo,U as zn,cm as Go,cn as Uo,c8 as Xo,aP as Jo,co as Yo,X as Qo,L as Zo}from"./vendor-boot-3SaHYVb1.js";import{R as a,a as w}from"./vendor-react-Bz1tRBxM.js";import{f as X,a as zs,aa as Ms,$ as ei,k as ti,cE as ni,M as ri,cF as si,h as ye,cG as Ds,au as Oe,b as ai,p as oi,H as ii,cx as bt,cz as ci,bN as li,A as Wr,cH as ui,_ as _r,z as Kr,O as Mn,an as di}from"./index-Cs2nBW_t.js";import{dC as fi,cQ as jt,B as U,I as F,b2 as Dt,dD as mi,av as Ts,aw as As,aB as Os,ax as Ls,ay as Ps,aC as Is,a$ as on,b0 as cn,b1 as ln,ah as nn,t as he,bv as fe,bT as Bn,dE as rn,aP as $s,E as Hr,aQ as pi,dF as Bs,da as Vs,dG as Ws,d9 as _s,d8 as Vn,db as hi,aR as it,aS as ct,aT as lt,dH as gi,dI as xi,dJ as vi,z as bi,bU as yi,as as wi,y as ji,cR as ki,dK as qr,cS as Gr,az as Ci,dL as Ur,a as Ni,bW as Si}from"./useAppFontEffects-Oyin3dgQ.js";import{javascript as yt}from"./vendor-codemirror-lang-javascript-Bx_FIyZF.js";import{json as Ks}from"./vendor-codemirror-lang-json-DIvqf9Pb.js";import{css as Hs}from"./vendor-codemirror-lang-css-D1wpUg3Z.js";import{html as Wn}from"./vendor-codemirror-lang-html-DbL8oT9H.js";import{markdown as qs}from"./vendor-codemirror-lang-markdown-v3yG2sbf.js";import{l as Gs}from"./vendor-codemirror-language-data-B03xgzP2.js";import{python as Us}from"./vendor-codemirror-lang-python-b-JqEwQy.js";import{shell as Ri}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Xr,getResolvedShikiTheme as Fi}from"./appThemeRegistry-Ca8eGRB9.js";import{D as Ei,i as Xs,b as Js,s as zi,F as Mi}from"./FileSaveConflictDialog-B1DvL9zy.js";import{h as Jr,aG as Di,aH as Ti,aI as Ai,aJ as Oi,aK as Li,aQ as en}from"./runtimeEndpointReset-aGyXPXPs.js";import{e as _n,g as Ys,h as Qs}from"./SessionUnreadDot-CY9-1iV2.js";import{F as Zs,a as Pi,g as kt,j as ea,k as ta,l as un,n as Ii,m as $i,M as Mt,o as ce,p as Bi,i as Vi,s as Wi,b as _i,c as Ki,q as Hi,f as qi,t as tn,r as Dn,d as Gi,v as Ui,u as Xi,w as Yr,x as Ji,e as Qr,y as Yi,h as Qi}from"./fileTreeStatus-BzhMMLA9.js";import{J as Zi,F as ec}from"./JsonTreeView-BjFFSUwi.js";import{a as Zr,g as sn,b as es,c as ts,o as tc,d as nc}from"./vendor-codemirror-search-Dw3Wpu15.js";import{v as rc,g as sc}from"./vendor-replit-codemirror-vim-D1Fe7FiY.js";import{P as ac,S as oc}from"./StickyHorizontalScrollbar-DNsbTLS7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./runtimeSurface-DiP2a57a.js";import"./nativeFileSave-DpBH1Sa3.js";import"./vendor-lezer-javascript-BH2Etgoy.js";import"./vendor-lezer-lr-HY6Yc0Vr.js";import"./vendor-codemirror-autocomplete-WThuuUAz.js";import"./vendor-lezer-json-CE-QUCwM.js";import"./vendor-lezer-css-Cb8vp67u.js";import"./vendor-lezer-html-UQMsUwj-.js";import"./vendor-lezer-markdown-xFL3Evwf.js";import"./vendor-lezer-python-BNRFWCb0.js";import"./registerCustomTheme-C-h6lsYW.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-react-drawio-IYnLUY5N.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./web-components-CkTNGkJ2.js";import"./computeVirtualFileMetrics-8MuwxSC6.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-okhy9Aq3.js";import"./renderFileWithHighlighter-DtAcGyJr.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";const Kn=Po.define(Ri);function ic(t){const n=t.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return Kn;case"json":case"jsonc":case"json5":return Ks().language;case"js":case"javascript":return yt().language;case"jsx":return yt({jsx:!0}).language;case"ts":case"typescript":return yt({typescript:!0}).language;case"tsx":return yt({typescript:!0,jsx:!0}).language;case"html":return Wn().language;case"css":return Hs().language;case"py":case"python":return Us().language;case"md":case"markdown":case"mdown":case"mkd":return qs().language;case"heex":case"eex":case"leex":return Wn().language;default:return Fs.matchLanguageName(Gs,n,!0)}}const na=t=>t.split("/").pop()?.toLowerCase()??"",cc=t=>{const n=na(t);return n?Fs.matchFilename(Gs,n):null},lc=()=>zt($n.define([{tag:[c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],fontWeight:"600"},{tag:c.strong,fontWeight:"600"},{tag:c.emphasis,fontStyle:"italic"},{tag:c.strikethrough,textDecoration:"line-through"},{tag:[c.link,c.url],color:"var(--markdown-link, currentColor)",textDecoration:"underline"},{tag:c.monospace,color:"var(--markdown-inline-code, currentColor)",backgroundColor:"var(--markdown-inline-code-bg, transparent)"},{tag:c.quote,color:"var(--markdown-blockquote, currentColor)",fontStyle:"italic"},{tag:c.list,color:"color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)"},{tag:c.heading,color:"var(--markdown-heading1, currentColor)"}]));function uc(t){const n=t.toLowerCase();switch(na(n)){case"makefile":case"gnumakefile":return Kn}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return yt({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return yt({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Ks();case"css":case"scss":case"sass":case"less":return Hs();case"html":case"htm":case"xml":case"drawio":case"dio":return Wn();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[qs({codeLanguages:ic}),lc()];case"sh":case"bash":case"zsh":case"fish":case"env":return Kn;case"py":case"pyw":case"pyi":return Us();default:return null}}async function dc(t){const n=cc(t);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function ns(t,n){const s=t.metadata.variant==="dark",i=t.config?.fonts?.mono||"monospace",o=t.colors.syntax.highlights||{},u=t.colors.syntax.tokens||{},f=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",d=we.theme({"&":{backgroundColor:"var(--background)",color:t.colors.syntax.base.foreground,fontSize:f,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:t.colors.syntax.base.comment},".cm-keyword":{color:t.colors.syntax.base.keyword},".cm-string":{color:t.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||t.colors.syntax.base.string},".cm-number":{color:t.colors.syntax.base.number},".cm-operator":{color:t.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||t.colors.syntax.base.comment},".cm-atom":{color:u.boolean||t.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||t.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||t.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||t.colors.syntax.base.operator},".cm-meta":{color:t.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||t.colors.syntax.base.keyword},".cm-variable":{color:t.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||t.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||t.colors.syntax.base.type},".cm-tag":{color:u.tag||t.colors.syntax.base.keyword},".cm-link":{color:u.url||t.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:t.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:t.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||"var(--subtle-foreground)",borderRight:`1px solid ${t.colors.interactive.border}`,position:"sticky",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"10px",minWidth:"2ch",boxSizing:"content-box"},".cm-activeLineGutter":{color:o.lineNumberActive||t.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:t.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:t.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.elevated,color:t.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${t.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${t.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${t.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.background,color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:t.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:t.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:t.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:t.colors.interactive.hover,borderColor:t.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:t.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:t.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:t.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:t.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:t.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:t.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${t.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:t.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:t.colors.interactive.hover,color:t.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:t.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${t.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:t.colors.interactive.selection,color:t.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${t.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:s}),h=$n.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],class:"cm-comment"},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],class:"cm-keyword"},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],class:"cm-operator"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],class:"cm-punctuation"},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],class:"cm-string"},{tag:c.escape,class:"cm-string-2"},{tag:[c.number,c.bool,c.atom,c.null,c.self],class:"cm-number"},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],class:"cm-builtin"},{tag:c.definition(c.variableName),class:"cm-def"},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],class:"cm-variable"},{tag:c.propertyName,class:"cm-property"},{tag:c.attributeName,class:"cm-attribute"},{tag:[c.className,c.typeName,c.namespace],class:"cm-variable-3"},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],class:"cm-tag"},{tag:c.link,class:"cm-link"},{tag:[c.heading,c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],class:"cm-keyword"}]),C=$n.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:t.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:t.colors.syntax.base.keyword},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],color:t.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:t.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||t.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:t.colors.syntax.base.number},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],color:t.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||t.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:t.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||t.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||t.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:t.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||t.colors.syntax.base.keyword},{tag:c.link,color:u.url||t.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||t.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[d]:[d,zt(Io,{fallback:!0}),zt($o),zt(h),zt(C)]}const fc=180,ra=Bo.define(),mc=1,pc=2,hc=4,rs=new Map,gc=(t,n)=>{const s=`${t}|${n}`,i=rs.get(s);if(i)return i;let o="";t&&(o+=`color:${t};`),n&mc&&(o+="font-style:italic;"),n&pc&&(o+="font-weight:bold;"),n&hc&&(o+="text-decoration:underline;");const u=Tt.mark({attributes:{style:o}});return rs.set(s,u),u},xc=(t,n)=>{const s=new an,i=t.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const f=n[u];if(!f||f.length===0)continue;const d=i.line(u+1);let h=d.from;for(const[C,z,b]of f){if(C<=0)continue;const v=h,k=Math.min(h+C,d.to);h+=C,!(k<=v)&&(!z&&!b||s.add(v,k,gc(z,b)))}}return s.finish()},vc=Es.define({create(){return Tt.none},update(t,n){let s=t.map(n.changes);for(const i of n.effects)i.is(ra)&&(s=i.value);return s},provide:t=>we.decorations.from(t)}),bc=t=>Hn.fromClass(class{timer;generation=0;constructor(n){this.tokenize(n)}update(n){n.docChanged&&this.schedule(n.view)}schedule(n){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(n)},fc)}async tokenize(n){const s=++this.generation,i=n.state.doc.toString(),o=await fi(i,t.language,t.themeName,t.theme);o&&s===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:ra.of(xc(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),yc=t=>[vc,bc(t)],Ue=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/g,""),wt=t=>{const n=Ue(t);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},sa=t=>{const n=Ue(t);if(!n||n==="/")return null;const s=n.lastIndexOf("/");if(s<0)return null;if(s===0)return"/";const i=n.slice(0,s);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},ss=(t,n)=>{const s=Ue(t),i=Ue(n);return!s||!i?!1:s===i||s.startsWith(`${i}/`)},as=(t,n)=>{const s=Ue(t);if(!s)return Ue(n);if(s.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(s))return s;const i=Ue(n);return i?`${i}/${s}`:s},wc=(t,n)=>{const s=Ue(t),i=Ue(n);if(!s||s===i)return!1;const o=sa(s);return o?i&&ss(s,i)?ss(o,i):!0:!1},jc=t=>{if(typeof t!="number"||!Number.isFinite(t)||t<0)return"";if(t<1024)return`${t} B`;const n=["KB","MB","GB"];let s=t/1024;for(const i of n){if(s<1024||i===n[n.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},kc=(t,n)=>!n||t===n?wt(t):t.startsWith(`${n}/`)?t.slice(n.length+1):t,Cc=({root:t,directory:n,entries:s,query:i,searchResults:o,isSearching:u,searchFailed:f,directoryError:d,refreshing:h,editorPath:C,editor:z,onClose:b,onQueryChange:v,onOpenDirectory:k,onOpenFile:j,onBackFromEditor:y,onRefresh:P})=>{if(!t)return e.jsx(Ct,{message:"Select a project to browse files."});if(C)return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Jr,{leading:e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:y,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:e.jsx(jt,{filePath:C,className:"size-4 shrink-0"}),title:wt(C)}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:z})]});const K=n===t?"Project files":wt(n),l=wc(n,t)?sa(n):null,$=!!l&&!i.trim(),H=l===t?"Project files":wt(l??""),I=b||$&&l?e.jsxs(e.Fragment,{children:[b?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:b,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"close",className:"size-4"})}):null,$&&l?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${wt(l)}`,onClick:()=>k(l),style:{touchAction:"manipulation"},children:e.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Jr,{leading:I,icon:n===t?"file-text":"folder",title:K,actions:e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:P,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"refresh",className:X("size-4",h&&"animate-spin")})})}),e.jsx("div",{className:"shrink-0 px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Dt,{value:i,onChange:M=>v(M.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),e.jsx(mi,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?e.jsx(Ct,{message:d}):i.trim()?e.jsx(Nc,{root:t,results:o,isSearching:u,failed:f,onOpenFile:j}):s===void 0?e.jsx(Ct,{loading:!0,message:"Loading..."}):e.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[$&&l?e.jsxs("button",{type:"button",className:X(Qs,"px-2"),"aria-label":`Up one level to ${H}`,onClick:()=>k(l),style:{touchAction:"manipulation"},children:[e.jsx(F,{name:"arrow-left",className:X(_n(!0),"text-muted-foreground")}),e.jsx("span",{className:X(Ys(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,s.length===0?e.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,s.map(M=>e.jsx(aa,{name:M.name,path:M.path,directory:M.type==="directory",meta:M.type==="directory"?void 0:jc(M.size),onClick:()=>M.type==="directory"?k(as(M.path,n||t)):j(as(M.path,n||t))},M.path))]})})]})},aa=({name:t,path:n,directory:s,meta:i,onClick:o})=>e.jsxs("button",{type:"button",className:X(Qs,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[s?e.jsx(F,{name:"folder-3-fill",className:X(_n(!0),"text-primary/80")}):e.jsx(jt,{filePath:n,className:_n(!0)}),e.jsx("span",{className:X(Ys(!0),"flex-1 text-foreground"),children:t}),i?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,s?e.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-subtle-foreground"}):null]}),Nc=({root:t,results:n,isSearching:s,failed:i,onOpenFile:o})=>s?e.jsx(Ct,{loading:!0,message:"Loading..."}):i?e.jsx(Ct,{message:"Search failed. Edit the search to try again."}):n.length===0?e.jsx(Ct,{message:"No files found."}):e.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(u=>e.jsx(aa,{name:wt(u.path),path:u.path,directory:!1,meta:u.relativePath??kc(u.path,t),onClick:()=>o(u.path)},u.path))}),Ct=({message:t,loading:n=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?e.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):e.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:t})]})}),Sc=({activeDialog:t,dialogData:n,dialogInputValue:s,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:f,inputRef:d})=>e.jsx(Ts,{open:!!t,onOpenChange:h=>!h&&f(),children:e.jsxs(As,{initialFocus:d,children:[e.jsxs(Os,{children:[e.jsxs(Ls,{children:[t==="createFile"&&"Create file",t==="createFolder"&&"Create folder",t==="rename"&&"Rename",t==="delete"&&"Delete"]}),e.jsxs(Ps,{children:[t==="createFile"&&`Create a new file in ${n?.path??"root"}`,t==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,t==="rename"&&`Rename ${n?.name??""}`,t==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),t!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx(Dt,{value:s,onChange:h=>i(h.target.value),placeholder:t==="rename"?"New name":"Name",onKeyDown:h=>{h.key==="Enter"&&u()},ref:d})}),e.jsxs(Is,{children:[e.jsx(U,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),e.jsx(U,{variant:t==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||t!=="delete"&&!s.trim(),children:o?e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):t==="delete"?"Delete":"Confirm"})]})]})}),oa=({label:t,iconDataUrl:n})=>{const[s,i]=a.useState(!1),o=t.trim().slice(0,1).toUpperCase()||"?";return n&&!s?e.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):e.jsx("span",{className:X("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Rc=({filePath:t,extension:n})=>e.jsx(jt,{filePath:t,extension:n}),os=({name:t})=>{const n=a.useRef(null),s=a.useRef(null),[i,o]=a.useState(!1);return a.useLayoutEffect(()=>{const u=n.current,f=s.current;if(!u||!f)return;const d=()=>{o(f.scrollWidth>u.clientWidth+1)};d();const h=new ResizeObserver(d);return h.observe(u),h.observe(f),()=>{h.disconnect()}},[t]),e.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{ref:s,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),i?e.jsxs("span",{className:"open-file-name-marquee-track",children:[e.jsx("span",{className:"open-file-name-marquee-item",children:t}),e.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):e.jsx("span",{className:"block min-w-0 truncate",children:t})]})},Fc=({node:t,root:n,isExpanded:s,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:f,status:d,badge:h,permissions:C,downloadFile:z,contextMenuPath:b,setContextMenuPath:v,rightClickMenuPath:k,setRightClickMenuPath:j,onSelect:y,onToggle:P,onRevealPath:K,onOpenDialog:l})=>{const $=t.type==="directory",{canRename:H,canCreateFile:I,canCreateFolder:M,canDelete:q,canReveal:_}=C,J=!$&&!!z,A=zs()&&Ms(),D=_&&!u&&A,x=H||I||M||q||J||D,V=a.useCallback(R=>{x&&(R?.preventDefault(),j(t.path))},[x,t.path,j]),N=a.useCallback(()=>{$?P(t.path):y(t)},[$,t,y,P]),S=a.useCallback(R=>{R.stopPropagation(),j(null),v(t.path)},[t.path,v,j]),g=({Item:R,Separator:E})=>e.jsxs(e.Fragment,{children:[H&&e.jsxs(R,{onClick:L=>{L.stopPropagation(),l("rename",t)},children:[e.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),e.jsxs(R,{onClick:L=>{L.stopPropagation(),nn(t.path).then(Y=>{if(Y.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[e.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy path"]}),e.jsxs(R,{onClick:L=>{L.stopPropagation();const Y=kt(n,t.path)||t.path;nn(Y).then(G=>{if(G.ok){he.success("Relative path copied");return}he.error("Copy failed")})},children:[e.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy relative path"]}),!$&&z&&e.jsxs(R,{onClick:L=>{L.stopPropagation(),z(t.path).catch(Y=>{console.error("Download failed:",Y),he.error("Operation failed")})},children:[e.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),D&&e.jsxs(R,{onClick:L=>{L.stopPropagation(),K(t.path)},children:[e.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",ei()]}),$&&(I||M)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),I&&e.jsxs(R,{onClick:L=>{L.stopPropagation(),l("createFile",t)},children:[e.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New file"]}),M&&e.jsxs(R,{onClick:L=>{L.stopPropagation(),l("createFolder",t)},children:[e.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New folder"]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs(R,{onClick:L=>{L.stopPropagation(),l("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return e.jsxs(Di,{open:k===t.path,onOpenChange:R=>j(R?t.path:null),children:[e.jsxs(Ti,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:V}),children:[e.jsxs("button",{type:"button",onClick:N,onContextMenu:o?void 0:V,className:X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors select-none",x&&f&&"pr-8",x&&!f&&"group-hover:pr-8 group-focus-within:pr-8",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[$?s?e.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(Rc,{filePath:t.path,extension:t.extension}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!$&&d&&e.jsx(Zs,{status:d,className:x&&!f?"group-hover:invisible group-focus-within:invisible":void 0}),$&&h&&e.jsx(Pi,{badge:h,className:x&&!f?"group-hover:invisible group-focus-within:invisible":void 0})]}),x&&e.jsx("div",{className:X("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:e.jsxs(on,{open:b===t.path,onOpenChange:R=>v(R?t.path:null),children:[e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"size-6",onClick:S,children:e.jsx(F,{name:"more-2-fill",className:"size-4"})})}),e.jsx(ln,{align:"end",side:"bottom",onCloseAutoFocus:()=>v(null),children:g({Item:fe,Separator:Bn})})]})})]}),e.jsx(Ai,{className:"min-w-[180px]",children:g({Item:Oi,Separator:Li})})]})},Tn=(t,n,s)=>{const[i,o]=a.useState(""),[u,f]=a.useState(0);return a.useEffect(()=>{if(!t){o("");return}let d=!1;o("");const h=ti(),C=ni(h);ri(h).then(b=>{d||!b||(o(t),n(null))}).catch(b=>{d||(n(b instanceof Error?b.message:s),o(t))});const z=si(()=>{d||(o(t),f(b=>b+1),n(null))});return()=>{d=!0,C(),z()}},[t,n,s]),{readyKey:i,nonce:u}},Ec=t=>t!==null&&typeof t=="object"&&"updateStatus"in t&&typeof t.updateStatus=="function",zc=t=>{const n=document.createElement("div");n.className="cm-vim-panel";const s=sc(t);if(!s)return{top:!1,dom:n};s.state.statusbar=n;const i=s.state.vimPlugin;return Ec(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){s.state.statusbar===n&&(s.state.statusbar=null)}}};function is(t){return t?[rc(),Vo.of(zc),Wo()]:[]}const Mc={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Dc={case:"Match case",re:"Regular expression",word:"Match whole word"};function Tc(t){const n=t.querySelector(".cm-search");if(n){for(const[s,i]of Object.entries(Mc)){const o=n.querySelector(`button[name="${s}"]`);o&&!o.title&&(o.title=i)}for(const[s,i]of Object.entries(Dc)){const u=n.querySelector(`input[name="${s}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const An=new WeakMap;function Ac(t,n){const s=sn(t.state);if(!s.valid)return An.delete(t),0;const i=An.get(t);if(!n&&i?.doc===t.state.doc&&i.query.eq(s))return i.total;const o=s.getCursor(t.state);let u=0;for(let f=o.next();!f.done;f=o.next())u+=1;return An.set(t,{query:s,doc:t.state.doc,total:u}),u}function Oc(t){const n=sn(t.state);if(!n.valid)return 0;const s=t.state.selection.main,i=n.getCursor(t.state);let o=0,u=0;for(let f=i.next();!f.done;f=i.next()){const d=f.value;if(o+=1,u===0&&(u=o),s.from===d.from&&s.to===d.to||s.from<d.to&&s.to>d.from||d.from>=s.head)return o}return u}function cs(t,n,s=!1){const i=t.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const d=i.querySelector('button[name="next"]'),h=d?.parentNode===i?d:i.firstChild;i.insertBefore(o,h)}const u=Ac(n,s),f=u===0?0:Oc(n);o.textContent=u===0?"":`${f}/${u}`}const ls=new ut,us=new ut,ds=new ut,fs=new ut,ms=new ut,ps=new ut,hs=new ut,gs=t=>t,On=Yo,Lc=tc,Pc=nc;class Ic extends Qo{constructor(n,s){super(),this.id=n,this.containerMap=s}id;containerMap;toDOM(){let n=this.containerMap.get(this.id);return n||(n=document.createElement("div"),n.className="oc-block-widget",n.dataset.widgetId=this.id,this.containerMap.set(this.id,n)),n}eq(n){return n.id===this.id}destroy(){}}const xs=(t,n)=>!t||t.length===0?[]:Es.define({create(s){const i=new an,o=[...t].sort((u,f)=>u.afterLine-f.afterLine);for(const u of o){const f=s.doc.lines;if(u.afterLine>f)continue;const d=s.doc.line(u.afterLine);i.add(d.to,d.to,Tt.widget({widget:new Ic(u.id,n),block:!0,side:1}))}return i.finish()},update(s,i){return s.map(i.changes)},provide:s=>we.decorations.from(s)}),vs=t=>{if(!t)return[];const n=Math.max(1,t.start),s=Math.max(n,t.end);return Hn.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new an;for(let u=n;u<=s&&u<=i.state.doc.lines;u+=1){const f=i.state.doc.line(u);o.add(f.from,f.from,Tt.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function $c({value:t,onChange:n,extensions:s,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:f,onViewReady:d,onViewDestroy:h,blockWidgets:C,enableSearch:z,searchOpen:b,onSearchOpenChange:v,vimMode:k}){const j=a.useRef(null),y=a.useRef(null),P=a.useRef(t),K=a.useRef(n),l=a.useRef(d),$=a.useRef(h),H=a.useRef(v),I=a.useRef(C),M=a.useRef(k),q=a.useRef(new Map),[_,J]=a.useState([]),A=a.useCallback(x=>{const V=(x??[]).map(N=>{const S=q.current.get(N.id);return S?{id:N.id,content:N.content,container:S}:null}).filter(N=>N!==null);J(N=>N.length===V.length&&N.every((S,g)=>{const R=V[g];return S.id===R.id&&S.content===R.content&&S.container===R.container})?N:V)},[]),D=a.useCallback(x=>{const V=j.current,N=x??y.current;if(!V||!N)return;const S=N.dom.querySelector(".cm-gutters"),g=S instanceof HTMLElement?S.getBoundingClientRect().width:0;V.style.setProperty("--oc-editor-gutter-width",`${g}px`)},[]);return a.useEffect(()=>{P.current=t},[t]),a.useEffect(()=>{K.current=n},[n]),a.useEffect(()=>{l.current=d,$.current=h},[d,h]),a.useEffect(()=>{H.current=v},[v]),a.useEffect(()=>{I.current=C,A(C)},[C,A]),a.useEffect(()=>{if(!j.current)return;const x=(()=>{if(typeof document>"u")return null;const N=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(N)return N;const S=window.__PICHAMBER_CSP_NONCE__;return typeof S=="string"&&S.length>0?S:null})(),V=_o.create({doc:P.current,extensions:[...x?[we.cspNonce.of(x)]:[],Ko({fixed:!0}),ls.of(Vr(u)),Ho(),qo.of(" "),hs.of(is(k)),zn.of([Go,...Uo,...Xo]),we.updateListener.of(N=>{D(N.view),(N.viewportChanged||N.geometryChanged)&&A(I.current);const S=Zr(N.startState),g=Zr(N.state);S!==g&&H.current?.(g);const R=!sn(N.startState).eq(sn(N.state));if(g&&(S!==g||R||N.docChanged||N.selectionSet)&&cs(N.view.dom,N.view,S!==g||R||N.docChanged),!N.docChanged)return;const E=N.state.doc.toString();P.current=E,K.current(E),A(I.current)}),us.of(we.editable.of(!o)),ds.of(s??[]),fs.of(vs(f)),ms.of(xs(C,q.current)),ps.of(z?[es({top:!0}),zn.of(gs(ts))]:[])]});return y.current=new we({state:V,parent:j.current}),On(y.current,y.current.state.doc.length,200),y.current.requestMeasure(),requestAnimationFrame(()=>{D(y.current),A(I.current)}),y.current&&l.current?.(y.current),()=>{$.current?.(),y.current?.destroy(),y.current=null,J([])}},[I,D,A]),a.useEffect(()=>{const x=y.current;x&&(x.dispatch({effects:[ls.reconfigure(Vr(u)),us.reconfigure(we.editable.of(!o)),ds.reconfigure(s??[]),fs.reconfigure(vs(f)),ms.reconfigure(xs(C,q.current)),ps.reconfigure(z?[es({top:!0}),zn.of(gs(ts))]:[])]}),On(x,x.state.doc.length,200),x.requestMeasure(),requestAnimationFrame(()=>{D(x),A(I.current)}))},[s,f,u,o,C,z,D,A]),a.useEffect(()=>{const x=y.current;if(!x){M.current=k;return}M.current!==k&&(M.current=k,x.dispatch({effects:hs.reconfigure(is(k))}))},[k]),a.useEffect(()=>{const x=y.current;!x||z===!1||(b?(Lc(x),requestAnimationFrame(()=>{Tc(x.dom),cs(x.dom,x,!0)})):Pc(x))},[b,z]),a.useEffect(()=>{const x=y.current;if(!x)return;const V=x.state.doc.toString();V!==t&&(x.dispatch({changes:{from:0,to:V.length,insert:t}}),On(x,x.state.doc.length,300),x.requestMeasure(),requestAnimationFrame(()=>D(x)))},[t,D]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:j,className:X("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",i)}),_.map(x=>Jo.createPortal(x.content,x.container,x.id))]})}const bs=({variant:t,selectedFile:n,loading:s,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:f,imagePreviewNonce:d,isSelectedPdf:h,pdfSrc:C,pdfPreviewNonce:z,isUnsupportedBinary:b,onDownload:v,enableRichPreviews:k,drawioViewMode:j,drawioRemountNonce:y,diagramEditorRef:P,diagramEditorXml:K,onDiagramChange:l,jsonViewMode:$,markdownViewMode:H,htmlViewMode:I,htmlLoading:M,htmlPreviewNonce:q,htmlPreviewSrc:_,fileContent:J,canUseShikiFileView:A,textViewMode:D,draftContent:x,onDraftChange:V,canEdit:N,vimMode:S,editorExtensions:g,editorWrapperRef:R,shouldMaskEditorForPendingNavigation:E,onEditorViewReady:L,onEditorViewDestroy:Y,enableSearch:G=!1,searchOpen:Z,onSearchOpenChange:ie,pierreTheme:W,shikiThemeType:te,wrapLines:Le})=>{const xe=t==="fullscreen",le=xe?"p-4":"p-3",Fe=!!(n?.path&&rn(n.path)),se=!!(n?.path&&ea(n.path)),me=!!(n?.path&&ta(n.path)),Ce=!!(n?.path&&un(n.path)),ne=a.useRef(null),re=()=>n?e.jsxs("div",{className:"relative h-full",ref:ne,children:[e.jsx(ec,{file:{name:n.name,contents:x,lang:Bs(n.path)||void 0},options:{disableFileHeader:!0,overflow:Le?"wrap":"scroll",theme:W,themeType:te,...Le?{}:{unsafeCSS:ac}},className:"block h-full w-full",style:{height:"100%"}}),e.jsx(oc,{hostRef:ne,enabled:!Le})]}):null;return e.jsx($s,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?s?i?e.jsx("div",{className:le}):e.jsxs("div",{className:`${le} flex items-center gap-2 typography-ui text-muted-foreground`,children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),xe?"Loading…":"Loading..."]}):o?e.jsx("div",{className:`${le} typography-ui text-[color:var(--status-error)]`,children:o}):u?e.jsx("div",{className:X("flex h-full items-center justify-center",le),children:e.jsx("img",{src:f,alt:n.name||"Image",className:X("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",xe?"max-h-full":"max-h-[70vh]")},d)}):h?e.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:e.jsx("iframe",{src:C,className:"h-full w-full border-0",title:n.name},z)}):b?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),e.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:"This file is binary and cannot be edited in PiChamber. Download it to open with another app."}),v?e.jsxs(U,{type:"button",variant:"outline",size:"sm",onClick:v,children:[e.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):k&&Fe&&j==="preview"?e.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:e.jsx(Ei,{ref:P,xml:K,onChange:l},`${n.path}:${y}`)}):k&&se&&$==="tree"?e.jsx(Hr,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:e.jsx("div",{className:"h-full overflow-auto",children:e.jsx(Zi,{jsonString:J,maxHeight:"100%",initiallyExpandedDepth:2})})}):me&&H==="preview"?e.jsxs("div",{className:X("h-full overflow-auto",le),children:[J.length>500*1024?e.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:`This file is large (${Math.round(J.length/1024)}KB). Preview may be limited.`}):null,e.jsx(Hr,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:e.jsx(pi,{content:J,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):k&&Ce&&I==="preview"?M?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx("iframe",{src:_,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML preview"},q)}):A&&D==="view"?re():e.jsxs("div",{className:X("relative h-full",E&&"overflow-hidden"),ref:R,children:[e.jsx("div",{className:X("h-full",E&&"invisible"),children:e.jsx($c,{value:x,onChange:V,readOnly:!N,vimMode:S,extensions:g,className:"h-full",onViewReady:L,onViewDestroy:Y,...G?{enableSearch:!0,searchOpen:Z,onSearchOpenChange:ie}:{}})}),E?e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):e.jsx("div",{className:`${le} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function Bc(t,n,s){if(Vs(t)&&!Ws(t))return{kind:n?"desktop-image":"asset-image"};if(_s(t))return{kind:"pdf"};if(Vn(t))return{kind:"binary",detectedFromContent:!1};const o=await s(t);if(hi(o))return{kind:"binary",detectedFromContent:!0};const u=Ii(o);return{kind:"text",content:u,draft:u.length>Mt?`${u.slice(0,Mt)}
|
|
1
|
+
import{aj as Lo,cg as zt,ch as $n,E as c,ah as Fs,Q as we,ci as Io,cj as $o,O as Es,M as Tt,ap as Hn,S as Bo,aq as an,j as e,ak as Vo,c6 as Wo,af as _o,ck as Ko,c9 as ut,cl as Vr,c5 as Ho,J as qo,U as zn,cm as Go,cn as Uo,c8 as Xo,aP as Jo,co as Yo,X as Zo,L as Qo}from"./vendor-boot-3SaHYVb1.js";import{R as a,a as w}from"./vendor-react-Bz1tRBxM.js";import{f as X,a as zs,aa as Ms,$ as ei,k as ti,cE as ni,M as ri,cF as si,h as ye,cG as Ds,au as Oe,b as ai,p as oi,H as ii,cx as bt,cz as ci,bN as li,A as Wr,cH as ui,_ as _r,z as Kr,O as Mn,an as di}from"./index-fmzQmSSv.js";import{dF as fi,cT as jt,B as U,I as F,b2 as Dt,dG as mi,av as Ts,aw as As,aB as Os,ax as Ps,ay as Ls,aC as Is,a$ as on,b0 as cn,b1 as ln,ah as nn,t as he,bv as fe,bT as Bn,dH as rn,aP as $s,E as Hr,aQ as pi,dI as Bs,dd as Vs,dJ as Ws,dc as _s,db as Vn,de as hi,aR as it,aS as ct,aT as lt,dK as gi,dL as xi,dM as vi,z as bi,bU as yi,as as wi,y as ji,cU as ki,dN as qr,cV as Gr,az as Ci,dO as Ur,a as Ni,bW as Si}from"./useAppFontEffects-BFgKpDYT.js";import{javascript as yt}from"./vendor-codemirror-lang-javascript-Bx_FIyZF.js";import{json as Ks}from"./vendor-codemirror-lang-json-DIvqf9Pb.js";import{css as Hs}from"./vendor-codemirror-lang-css-D1wpUg3Z.js";import{html as Wn}from"./vendor-codemirror-lang-html-DbL8oT9H.js";import{markdown as qs}from"./vendor-codemirror-lang-markdown-v3yG2sbf.js";import{l as Gs}from"./vendor-codemirror-language-data-B03xgzP2.js";import{python as Us}from"./vendor-codemirror-lang-python-b-JqEwQy.js";import{shell as Ri}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Xr,getResolvedShikiTheme as Fi}from"./appThemeRegistry-Ca8eGRB9.js";import{D as Ei,i as Xs,b as Js,s as zi,F as Mi}from"./FileSaveConflictDialog-IFbuQCcP.js";import{h as Jr,aF as Di,aG as Ti,aH as Ai,aI as Oi,aJ as Pi,aP as en}from"./runtimeEndpointReset-Bby2E_Je.js";import{e as _n,h as Ys,i as Zs}from"./SessionUnreadDot-qw67HcBO.js";import{F as Qs,a as Li,g as kt,j as ea,k as ta,l as un,n as Ii,m as $i,M as Mt,o as ce,p as Bi,i as Vi,s as Wi,b as _i,c as Ki,q as Hi,f as qi,t as tn,r as Dn,d as Gi,v as Ui,u as Xi,w as Yr,x as Ji,e as Zr,y as Yi,h as Zi}from"./fileTreeStatus-trDHgX4B.js";import{J as Qi,F as ec}from"./JsonTreeView-DzVqgwz-.js";import{a as Qr,g as sn,b as es,c as ts,o as tc,d as nc}from"./vendor-codemirror-search-Dw3Wpu15.js";import{v as rc,g as sc}from"./vendor-replit-codemirror-vim-D1Fe7FiY.js";import{P as ac,S as oc}from"./StickyHorizontalScrollbar-DNsbTLS7.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./runtimeSurface-X62LLBLv.js";import"./nativeFileSave-B4Rg6n8u.js";import"./vendor-lezer-javascript-BH2Etgoy.js";import"./vendor-lezer-lr-HY6Yc0Vr.js";import"./vendor-codemirror-autocomplete-WThuuUAz.js";import"./vendor-lezer-json-CE-QUCwM.js";import"./vendor-lezer-css-Cb8vp67u.js";import"./vendor-lezer-html-UQMsUwj-.js";import"./vendor-lezer-markdown-xFL3Evwf.js";import"./vendor-lezer-python-BNRFWCb0.js";import"./registerCustomTheme-C-h6lsYW.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.js";import"./vendor-shikijs-core-Ck_OPM_T.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-DPFxvYtK.js";import"./vendor-hast-util-to-html-O3stl53j.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-C40bX6nM.js";import"./vendor-zwitch-C2o2j-tx.js";import"./vendor-stringify-entities-CsH1VEn9.js";import"./vendor-character-entities-legacy-BpoLgcEt.js";import"./vendor-character-entities-html4-D7taRCQ7.js";import"./vendor-ccount-c2V3InAJ.js";import"./vendor-comma-separated-tokens-D8TqSuIK.js";import"./vendor-space-separated-tokens-DD3iYX1K.js";import"./vendor-hast-util-whitespace-D4Wp6AEg.js";import"./vendor-react-drawio-IYnLUY5N.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./web-components-B_NMC-2c.js";import"./computeVirtualFileMetrics-g1aOl5nF.js";import"./vendor-shiki-BEwTOAFg.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-DL394yyj.js";import"./vendor-oniguruma-to-es-DgwFOwdE.js";import"./vendor-oniguruma-parser-BrbMHgHx.js";import"./vendor-regex-BBWcyTkg.js";import"./vendor-regex-utilities-2BQyy0xI.js";import"./vendor-regex-recursion-JU4mF-dD.js";import"./vendor-shikijs-transformers-CZWsLLKm.js";import"./Virtualizer-okhy9Aq3.js";import"./renderFileWithHighlighter-tJRUQWjE.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";const Kn=Lo.define(Ri);function ic(t){const n=t.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return Kn;case"json":case"jsonc":case"json5":return Ks().language;case"js":case"javascript":return yt().language;case"jsx":return yt({jsx:!0}).language;case"ts":case"typescript":return yt({typescript:!0}).language;case"tsx":return yt({typescript:!0,jsx:!0}).language;case"html":return Wn().language;case"css":return Hs().language;case"py":case"python":return Us().language;case"md":case"markdown":case"mdown":case"mkd":return qs().language;case"heex":case"eex":case"leex":return Wn().language;default:return Fs.matchLanguageName(Gs,n,!0)}}const na=t=>t.split("/").pop()?.toLowerCase()??"",cc=t=>{const n=na(t);return n?Fs.matchFilename(Gs,n):null},lc=()=>zt($n.define([{tag:[c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],fontWeight:"600"},{tag:c.strong,fontWeight:"600"},{tag:c.emphasis,fontStyle:"italic"},{tag:c.strikethrough,textDecoration:"line-through"},{tag:[c.link,c.url],color:"var(--markdown-link, currentColor)",textDecoration:"underline"},{tag:c.monospace,color:"var(--markdown-inline-code, currentColor)",backgroundColor:"var(--markdown-inline-code-bg, transparent)"},{tag:c.quote,color:"var(--markdown-blockquote, currentColor)",fontStyle:"italic"},{tag:c.list,color:"color-mix(in srgb, var(--muted-foreground) 40%, var(--foreground) 60%)"},{tag:c.heading,color:"var(--markdown-heading1, currentColor)"}]));function uc(t){const n=t.toLowerCase();switch(na(n)){case"makefile":case"gnumakefile":return Kn}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return yt({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return yt({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Ks();case"css":case"scss":case"sass":case"less":return Hs();case"html":case"htm":case"xml":case"drawio":case"dio":return Wn();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[qs({codeLanguages:ic}),lc()];case"sh":case"bash":case"zsh":case"fish":case"env":return Kn;case"py":case"pyw":case"pyi":return Us();default:return null}}async function dc(t){const n=cc(t);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function ns(t,n){const s=t.metadata.variant==="dark",i=t.config?.fonts?.mono||"monospace",o=t.colors.syntax.highlights||{},u=t.colors.syntax.tokens||{},f=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",d=we.theme({"&":{backgroundColor:"var(--background)",color:t.colors.syntax.base.foreground,fontSize:f,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:t.colors.syntax.base.comment},".cm-keyword":{color:t.colors.syntax.base.keyword},".cm-string":{color:t.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||t.colors.syntax.base.string},".cm-number":{color:t.colors.syntax.base.number},".cm-operator":{color:t.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||t.colors.syntax.base.comment},".cm-atom":{color:u.boolean||t.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||t.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||t.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||t.colors.syntax.base.operator},".cm-meta":{color:t.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||t.colors.syntax.base.keyword},".cm-variable":{color:t.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||t.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||t.colors.syntax.base.type},".cm-tag":{color:u.tag||t.colors.syntax.base.keyword},".cm-link":{color:u.url||t.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:t.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:t.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||"var(--subtle-foreground)",borderRight:`1px solid ${t.colors.interactive.border}`,position:"sticky",left:0,zIndex:2,boxShadow:"0 0 0 var(--background)"},".cm-gutter":{backgroundColor:"var(--background)"},".cm-gutterElement":{backgroundColor:"var(--background)"},".cm-lineNumbers":{backgroundColor:"var(--background)"},".cm-lineNumbers .cm-gutterElement":{paddingLeft:"8px",paddingRight:"10px",minWidth:"2ch",boxSizing:"content-box"},".cm-activeLineGutter":{color:o.lineNumberActive||t.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:t.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:t.colors.surface.foreground,position:"absolute",top:"0",right:"0",left:"auto",width:"auto",zIndex:10,pointerEvents:"none"},".cm-panels-top":{borderBottom:"none",position:"absolute",top:"6px",right:"14px",left:"auto",width:"auto"},".cm-panels-bottom":{position:"static",width:"100%",pointerEvents:"auto"},".cm-panels-bottom .cm-vim-panel":{borderTop:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.elevated,color:t.colors.surface.mutedForeground,fontFamily:"var(--font-mono)",fontSize:"12px",minHeight:"22px",padding:"2px 8px"},".cm-panel.cm-search":{pointerEvents:"auto",padding:"4px",backgroundColor:`color-mix(in srgb, ${t.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${t.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${t.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"13px",lineHeight:"1"},".cm-search br":{display:"none"},".cm-search .cm-textfield":{appearance:"none",height:"26px",margin:0,padding:"0 8px",borderRadius:"6px !important",border:`1px solid ${t.colors.interactive.border}`,backgroundColor:t.colors.surface.background,color:t.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:t.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:t.colors.primary.base},'.cm-search .cm-textfield[name="search"]':{order:1,flex:"1 1 120px",maxWidth:"calc(100% - 142px)",minWidth:"100px"},".cm-search label":{order:2,display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"1px solid transparent",backgroundColor:"transparent",color:"transparent",cursor:"pointer",userSelect:"none",fontSize:"1px",lineHeight:"0",overflow:"hidden",position:"relative",transition:"background-color 120ms ease, border-color 120ms ease"},".cm-search label:hover":{backgroundColor:t.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:t.colors.interactive.hover,borderColor:t.colors.interactive.border},'.cm-search [type="checkbox"]':{appearance:"none",WebkitAppearance:"none",width:"0",height:"0",margin:"0",padding:"0",border:"none",position:"absolute",opacity:"0",pointerEvents:"none"},".cm-search label::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"13px",fontWeight:"600",lineHeight:"1",fontFamily:"inherit",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:t.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:t.colors.surface.foreground},'.cm-search label:has(input[name="case"])::after':{content:'"Aa"',fontSize:"12px",letterSpacing:"-0.5px"},'.cm-search label:has(input[name="re"])::after':{content:'".*"',fontSize:"13px",fontFamily:"monospace"},'.cm-search label:has(input[name="word"])::after':{content:'"ab"',fontSize:"12px",textDecoration:"underline",textUnderlineOffset:"2px"},".cm-search .cm-search-message":{order:3,color:t.colors.surface.mutedForeground,backgroundColor:"transparent",border:"none",borderRadius:"0",padding:"0 6px",fontSize:"11px",whiteSpace:"nowrap",lineHeight:"26px"},".cm-search .cm-button":{appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:0,marginLeft:"1px",padding:0,borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:"transparent",cursor:"pointer",fontSize:"1px",fontWeight:"400",lineHeight:"0",overflow:"hidden",position:"relative",boxShadow:"none",transition:"background-color 120ms ease"},".cm-search .cm-button::after":{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",fontSize:"15px",lineHeight:"1",color:t.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:t.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:t.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:t.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${t.colors.interactive.focusRing}`},".cm-search .cm-button:disabled":{opacity:.4,cursor:"default",pointerEvents:"none"},'.cm-search .cm-button[name="prev"]':{order:21,marginTop:"2px"},'.cm-search .cm-button[name="prev"]::after':{content:'"↑"'},'.cm-search .cm-button[name="next"]':{order:22,marginTop:"2px"},'.cm-search .cm-button[name="next"]::after':{content:'"↓"'},'.cm-search .cm-button[name="select"]':{order:23,marginTop:"2px"},'.cm-search .cm-button[name="select"]::after':{content:'"≡"',fontSize:"17px"},'.cm-panel.cm-search button[name="close"]':{order:5,appearance:"none",WebkitAppearance:"none",display:"inline-flex",alignItems:"center",justifyContent:"center",width:"26px",height:"26px",minWidth:"26px",flexShrink:"0",margin:"0 0 0 auto",padding:"0",borderRadius:"4px",border:"none",backgroundColor:"transparent",backgroundImage:"none",color:t.colors.surface.mutedForeground,cursor:"pointer",fontSize:"16px",lineHeight:"1",boxShadow:"none",position:"relative",overflow:"visible",transition:"background-color 120ms ease, color 120ms ease"},'.cm-panel.cm-search button[name="close"]:hover':{backgroundColor:t.colors.interactive.hover,color:t.colors.surface.foreground},'.cm-search .cm-button[name="replace"]':{order:24,marginTop:"2px"},'.cm-search .cm-button[name="replace"]::after':{content:'"⇄"'},'.cm-search .cm-button[name="replaceAll"], .cm-search .cm-button[name="replace-all"]':{order:25,marginTop:"2px"},'.cm-search .cm-button[name="replaceAll"]::after, .cm-search .cm-button[name="replace-all"]::after':{content:'"⇉"'},'.cm-search .cm-textfield[name="replace"]':{order:20,flex:"1 1 100%",maxWidth:"calc(100% - 142px)",minWidth:"80px",marginTop:"2px"},".cm-searchMatch":{backgroundColor:t.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${t.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:t.colors.interactive.selection,color:t.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${t.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:s}),h=$n.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],class:"cm-comment"},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],class:"cm-keyword"},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],class:"cm-operator"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],class:"cm-punctuation"},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],class:"cm-string"},{tag:c.escape,class:"cm-string-2"},{tag:[c.number,c.bool,c.atom,c.null,c.self],class:"cm-number"},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],class:"cm-builtin"},{tag:c.definition(c.variableName),class:"cm-def"},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],class:"cm-variable"},{tag:c.propertyName,class:"cm-property"},{tag:c.attributeName,class:"cm-attribute"},{tag:[c.className,c.typeName,c.namespace],class:"cm-variable-3"},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],class:"cm-tag"},{tag:c.link,class:"cm-link"},{tag:[c.heading,c.heading1,c.heading2,c.heading3,c.heading4,c.heading5,c.heading6],class:"cm-keyword"}]),C=$n.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:t.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:t.colors.syntax.base.keyword},{tag:[c.operatorKeyword,c.operator,c.derefOperator,c.updateOperator,c.definitionOperator,c.typeOperator,c.controlOperator,c.logicOperator,c.bitwiseOperator,c.arithmeticOperator,c.compareOperator],color:t.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:t.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||t.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:t.colors.syntax.base.number},{tag:[c.function(c.variableName),c.function(c.definition(c.variableName)),c.function(c.propertyName),c.standard(c.variableName),c.special(c.variableName)],color:t.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||t.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:t.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||t.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||t.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:t.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||t.colors.syntax.base.keyword},{tag:c.link,color:u.url||t.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||t.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[d]:[d,zt(Io,{fallback:!0}),zt($o),zt(h),zt(C)]}const fc=180,ra=Bo.define(),mc=1,pc=2,hc=4,rs=new Map,gc=(t,n)=>{const s=`${t}|${n}`,i=rs.get(s);if(i)return i;let o="";t&&(o+=`color:${t};`),n&mc&&(o+="font-style:italic;"),n&pc&&(o+="font-weight:bold;"),n&hc&&(o+="text-decoration:underline;");const u=Tt.mark({attributes:{style:o}});return rs.set(s,u),u},xc=(t,n)=>{const s=new an,i=t.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const f=n[u];if(!f||f.length===0)continue;const d=i.line(u+1);let h=d.from;for(const[C,z,b]of f){if(C<=0)continue;const v=h,k=Math.min(h+C,d.to);h+=C,!(k<=v)&&(!z&&!b||s.add(v,k,gc(z,b)))}}return s.finish()},vc=Es.define({create(){return Tt.none},update(t,n){let s=t.map(n.changes);for(const i of n.effects)i.is(ra)&&(s=i.value);return s},provide:t=>we.decorations.from(t)}),bc=t=>Hn.fromClass(class{timer;generation=0;constructor(n){this.tokenize(n)}update(n){n.docChanged&&this.schedule(n.view)}schedule(n){this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.timer=void 0,this.tokenize(n)},fc)}async tokenize(n){const s=++this.generation,i=n.state.doc.toString(),o=await fi(i,t.language,t.themeName,t.theme);o&&s===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:ra.of(xc(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),yc=t=>[vc,bc(t)],Ue=t=>(t||"").replace(/\\/g,"/").replace(/\/+$/g,""),wt=t=>{const n=Ue(t);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},sa=t=>{const n=Ue(t);if(!n||n==="/")return null;const s=n.lastIndexOf("/");if(s<0)return null;if(s===0)return"/";const i=n.slice(0,s);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},ss=(t,n)=>{const s=Ue(t),i=Ue(n);return!s||!i?!1:s===i||s.startsWith(`${i}/`)},as=(t,n)=>{const s=Ue(t);if(!s)return Ue(n);if(s.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(s))return s;const i=Ue(n);return i?`${i}/${s}`:s},wc=(t,n)=>{const s=Ue(t),i=Ue(n);if(!s||s===i)return!1;const o=sa(s);return o?i&&ss(s,i)?ss(o,i):!0:!1},jc=t=>{if(typeof t!="number"||!Number.isFinite(t)||t<0)return"";if(t<1024)return`${t} B`;const n=["KB","MB","GB"];let s=t/1024;for(const i of n){if(s<1024||i===n[n.length-1])return`${s.toFixed(s>=10?0:1)} ${i}`;s/=1024}return""},kc=(t,n)=>!n||t===n?wt(t):t.startsWith(`${n}/`)?t.slice(n.length+1):t,Cc=({root:t,directory:n,entries:s,query:i,searchResults:o,isSearching:u,searchFailed:f,directoryError:d,refreshing:h,editorPath:C,editor:z,onClose:b,onQueryChange:v,onOpenDirectory:k,onOpenFile:j,onBackFromEditor:y,onRefresh:L})=>{if(!t)return e.jsx(Ct,{message:"Select a project to browse files."});if(C)return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Jr,{leading:e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:y,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:e.jsx(jt,{filePath:C,className:"size-4 shrink-0"}),title:wt(C)}),e.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:z})]});const K=n===t?"Project files":wt(n),l=wc(n,t)?sa(n):null,$=!!l&&!i.trim(),H=l===t?"Project files":wt(l??""),I=b||$&&l?e.jsxs(e.Fragment,{children:[b?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:b,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"close",className:"size-4"})}):null,$&&l?e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${wt(l)}`,onClick:()=>k(l),style:{touchAction:"manipulation"},children:e.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return e.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[e.jsx(Jr,{leading:I,icon:n===t?"file-text":"folder",title:K,actions:e.jsx(U,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:L,style:{touchAction:"manipulation"},children:e.jsx(F,{name:"refresh",className:X("size-4",h&&"animate-spin")})})}),e.jsx("div",{className:"shrink-0 px-3 py-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(Dt,{value:i,onChange:M=>v(M.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),e.jsx(mi,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?e.jsx(Ct,{message:d}):i.trim()?e.jsx(Nc,{root:t,results:o,isSearching:u,failed:f,onOpenFile:j}):s===void 0?e.jsx(Ct,{loading:!0,message:"Loading..."}):e.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[$&&l?e.jsxs("button",{type:"button",className:X(Zs,"px-2"),"aria-label":`Up one level to ${H}`,onClick:()=>k(l),style:{touchAction:"manipulation"},children:[e.jsx(F,{name:"arrow-left",className:X(_n(!0),"text-muted-foreground")}),e.jsx("span",{className:X(Ys(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,s.length===0?e.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,s.map(M=>e.jsx(aa,{name:M.name,path:M.path,directory:M.type==="directory",meta:M.type==="directory"?void 0:jc(M.size),onClick:()=>M.type==="directory"?k(as(M.path,n||t)):j(as(M.path,n||t))},M.path))]})})]})},aa=({name:t,path:n,directory:s,meta:i,onClick:o})=>e.jsxs("button",{type:"button",className:X(Zs,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[s?e.jsx(F,{name:"folder-3-fill",className:X(_n(!0),"text-primary/80")}):e.jsx(jt,{filePath:n,className:_n(!0)}),e.jsx("span",{className:X(Ys(!0),"flex-1 text-foreground"),children:t}),i?e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,s?e.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-subtle-foreground"}):null]}),Nc=({root:t,results:n,isSearching:s,failed:i,onOpenFile:o})=>s?e.jsx(Ct,{loading:!0,message:"Loading..."}):i?e.jsx(Ct,{message:"Search failed. Edit the search to try again."}):n.length===0?e.jsx(Ct,{message:"No files found."}):e.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(u=>e.jsx(aa,{name:wt(u.path),path:u.path,directory:!1,meta:u.relativePath??kc(u.path,t),onClick:()=>o(u.path)},u.path))}),Ct=({message:t,loading:n=!1})=>e.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:e.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?e.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):e.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),e.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:t})]})}),Sc=({activeDialog:t,dialogData:n,dialogInputValue:s,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:f,inputRef:d})=>e.jsx(Ts,{open:!!t,onOpenChange:h=>!h&&f(),children:e.jsxs(As,{initialFocus:d,children:[e.jsxs(Os,{children:[e.jsxs(Ps,{children:[t==="createFile"&&"Create file",t==="createFolder"&&"Create folder",t==="rename"&&"Rename",t==="delete"&&"Delete"]}),e.jsxs(Ls,{children:[t==="createFile"&&`Create a new file in ${n?.path??"root"}`,t==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,t==="rename"&&`Rename ${n?.name??""}`,t==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),t!=="delete"&&e.jsx("div",{className:"py-4",children:e.jsx(Dt,{value:s,onChange:h=>i(h.target.value),placeholder:t==="rename"?"New name":"Name",onKeyDown:h=>{h.key==="Enter"&&u()},ref:d})}),e.jsxs(Is,{children:[e.jsx(U,{variant:"outline",onClick:f,disabled:o,children:"Cancel"}),e.jsx(U,{variant:t==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||t!=="delete"&&!s.trim(),children:o?e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):t==="delete"?"Delete":"Confirm"})]})]})}),oa=({label:t,iconDataUrl:n})=>{const[s,i]=a.useState(!1),o=t.trim().slice(0,1).toUpperCase()||"?";return n&&!s?e.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):e.jsx("span",{className:X("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Rc=({filePath:t,extension:n})=>e.jsx(jt,{filePath:t,extension:n}),os=({name:t})=>{const n=a.useRef(null),s=a.useRef(null),[i,o]=a.useState(!1);return a.useLayoutEffect(()=>{const u=n.current,f=s.current;if(!u||!f)return;const d=()=>{o(f.scrollWidth>u.clientWidth+1)};d();const h=new ResizeObserver(d);return h.observe(u),h.observe(f),()=>{h.disconnect()}},[t]),e.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[e.jsx("span",{ref:s,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:t}),i?e.jsxs("span",{className:"open-file-name-marquee-track",children:[e.jsx("span",{className:"open-file-name-marquee-item",children:t}),e.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:t})]}):e.jsx("span",{className:"block min-w-0 truncate",children:t})]})},Fc=({node:t,root:n,isExpanded:s,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:f,status:d,badge:h,permissions:C,downloadFile:z,contextMenuPath:b,setContextMenuPath:v,rightClickMenuPath:k,setRightClickMenuPath:j,onSelect:y,onToggle:L,onRevealPath:K,onOpenDialog:l})=>{const $=t.type==="directory",{canRename:H,canCreateFile:I,canCreateFolder:M,canDelete:q,canReveal:_}=C,J=!$&&!!z,A=zs()&&Ms(),D=_&&!u&&A,x=H||I||M||q||J||D,V=a.useCallback(R=>{x&&(R?.preventDefault(),j(t.path))},[x,t.path,j]),N=a.useCallback(()=>{$?L(t.path):y(t)},[$,t,y,L]),S=a.useCallback(R=>{R.stopPropagation(),j(null),v(t.path)},[t.path,v,j]),g=({Item:R,Separator:E})=>e.jsxs(e.Fragment,{children:[H&&e.jsxs(R,{onClick:P=>{P.stopPropagation(),l("rename",t)},children:[e.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),e.jsxs(R,{onClick:P=>{P.stopPropagation(),nn(t.path).then(Y=>{if(Y.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[e.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy path"]}),e.jsxs(R,{onClick:P=>{P.stopPropagation();const Y=kt(n,t.path)||t.path;nn(Y).then(G=>{if(G.ok){he.success("Relative path copied");return}he.error("Copy failed")})},children:[e.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy relative path"]}),!$&&z&&e.jsxs(R,{onClick:P=>{P.stopPropagation(),z(t.path).catch(Y=>{console.error("Download failed:",Y),he.error("Operation failed")})},children:[e.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),D&&e.jsxs(R,{onClick:P=>{P.stopPropagation(),K(t.path)},children:[e.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",ei()]}),$&&(I||M)&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),I&&e.jsxs(R,{onClick:P=>{P.stopPropagation(),l("createFile",t)},children:[e.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New file"]}),M&&e.jsxs(R,{onClick:P=>{P.stopPropagation(),l("createFolder",t)},children:[e.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New folder"]})]}),q&&e.jsxs(e.Fragment,{children:[e.jsx(E,{}),e.jsxs(R,{onClick:P=>{P.stopPropagation(),l("delete",t)},className:"text-destructive focus:text-destructive",children:[e.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return e.jsxs(Di,{open:k===t.path,onOpenChange:R=>j(R?t.path:null),children:[e.jsxs(Ti,{render:e.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:V}),children:[e.jsxs("button",{type:"button",onClick:N,onContextMenu:o?void 0:V,className:X("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors select-none",x&&f&&"pr-8",x&&!f&&"group-hover:pr-8 group-focus-within:pr-8",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[$?s?e.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):e.jsx(Rc,{filePath:t.path,extension:t.extension}),e.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:t.path,children:t.name}),!$&&d&&e.jsx(Qs,{status:d,className:x&&!f?"group-hover:invisible group-focus-within:invisible":void 0}),$&&h&&e.jsx(Li,{badge:h,className:x&&!f?"group-hover:invisible group-focus-within:invisible":void 0})]}),x&&e.jsx("div",{className:X("absolute right-1 top-1/2 -translate-y-1/2",f?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:e.jsxs(on,{open:b===t.path,onOpenChange:R=>v(R?t.path:null),children:[e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"icon",className:"size-6",onClick:S,children:e.jsx(F,{name:"more-2-fill",className:"size-4"})})}),e.jsx(ln,{align:"end",side:"bottom",onCloseAutoFocus:()=>v(null),children:g({Item:fe,Separator:Bn})})]})})]}),e.jsx(Ai,{className:"min-w-[180px]",children:g({Item:Oi,Separator:Pi})})]})},Tn=(t,n,s)=>{const[i,o]=a.useState(""),[u,f]=a.useState(0);return a.useEffect(()=>{if(!t){o("");return}let d=!1;o("");const h=ti(),C=ni(h);ri(h).then(b=>{d||!b||(o(t),n(null))}).catch(b=>{d||(n(b instanceof Error?b.message:s),o(t))});const z=si(()=>{d||(o(t),f(b=>b+1),n(null))});return()=>{d=!0,C(),z()}},[t,n,s]),{readyKey:i,nonce:u}},Ec=t=>t!==null&&typeof t=="object"&&"updateStatus"in t&&typeof t.updateStatus=="function",zc=t=>{const n=document.createElement("div");n.className="cm-vim-panel";const s=sc(t);if(!s)return{top:!1,dom:n};s.state.statusbar=n;const i=s.state.vimPlugin;return Ec(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){s.state.statusbar===n&&(s.state.statusbar=null)}}};function is(t){return t?[rc(),Vo.of(zc),Wo()]:[]}const Mc={next:"Next match",prev:"Previous match",select:"Select all matches",replace:"Replace",replaceAll:"Replace all",close:"Close"},Dc={case:"Match case",re:"Regular expression",word:"Match whole word"};function Tc(t){const n=t.querySelector(".cm-search");if(n){for(const[s,i]of Object.entries(Mc)){const o=n.querySelector(`button[name="${s}"]`);o&&!o.title&&(o.title=i)}for(const[s,i]of Object.entries(Dc)){const u=n.querySelector(`input[name="${s}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const An=new WeakMap;function Ac(t,n){const s=sn(t.state);if(!s.valid)return An.delete(t),0;const i=An.get(t);if(!n&&i?.doc===t.state.doc&&i.query.eq(s))return i.total;const o=s.getCursor(t.state);let u=0;for(let f=o.next();!f.done;f=o.next())u+=1;return An.set(t,{query:s,doc:t.state.doc,total:u}),u}function Oc(t){const n=sn(t.state);if(!n.valid)return 0;const s=t.state.selection.main,i=n.getCursor(t.state);let o=0,u=0;for(let f=i.next();!f.done;f=i.next()){const d=f.value;if(o+=1,u===0&&(u=o),s.from===d.from&&s.to===d.to||s.from<d.to&&s.to>d.from||d.from>=s.head)return o}return u}function cs(t,n,s=!1){const i=t.querySelector(".cm-search");if(!i)return;let o=i.querySelector(".cm-search-message");if(!o){o=document.createElement("span"),o.className="cm-search-message",o.setAttribute("aria-live","polite");const d=i.querySelector('button[name="next"]'),h=d?.parentNode===i?d:i.firstChild;i.insertBefore(o,h)}const u=Ac(n,s),f=u===0?0:Oc(n);o.textContent=u===0?"":`${f}/${u}`}const ls=new ut,us=new ut,ds=new ut,fs=new ut,ms=new ut,ps=new ut,hs=new ut,gs=t=>t,On=Yo,Pc=tc,Lc=nc;class Ic extends Zo{constructor(n,s){super(),this.id=n,this.containerMap=s}id;containerMap;toDOM(){let n=this.containerMap.get(this.id);return n||(n=document.createElement("div"),n.className="oc-block-widget",n.dataset.widgetId=this.id,this.containerMap.set(this.id,n)),n}eq(n){return n.id===this.id}destroy(){}}const xs=(t,n)=>!t||t.length===0?[]:Es.define({create(s){const i=new an,o=[...t].sort((u,f)=>u.afterLine-f.afterLine);for(const u of o){const f=s.doc.lines;if(u.afterLine>f)continue;const d=s.doc.line(u.afterLine);i.add(d.to,d.to,Tt.widget({widget:new Ic(u.id,n),block:!0,side:1}))}return i.finish()},update(s,i){return s.map(i.changes)},provide:s=>we.decorations.from(s)}),vs=t=>{if(!t)return[];const n=Math.max(1,t.start),s=Math.max(n,t.end);return Hn.fromClass(class{decorations;constructor(i){this.decorations=this.build(i)}update(i){(i.docChanged||i.viewportChanged)&&(this.decorations=this.build(i.view))}build(i){const o=new an;for(let u=n;u<=s&&u<=i.state.doc.lines;u+=1){const f=i.state.doc.line(u);o.add(f.from,f.from,Tt.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function $c({value:t,onChange:n,extensions:s,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:f,onViewReady:d,onViewDestroy:h,blockWidgets:C,enableSearch:z,searchOpen:b,onSearchOpenChange:v,vimMode:k}){const j=a.useRef(null),y=a.useRef(null),L=a.useRef(t),K=a.useRef(n),l=a.useRef(d),$=a.useRef(h),H=a.useRef(v),I=a.useRef(C),M=a.useRef(k),q=a.useRef(new Map),[_,J]=a.useState([]),A=a.useCallback(x=>{const V=(x??[]).map(N=>{const S=q.current.get(N.id);return S?{id:N.id,content:N.content,container:S}:null}).filter(N=>N!==null);J(N=>N.length===V.length&&N.every((S,g)=>{const R=V[g];return S.id===R.id&&S.content===R.content&&S.container===R.container})?N:V)},[]),D=a.useCallback(x=>{const V=j.current,N=x??y.current;if(!V||!N)return;const S=N.dom.querySelector(".cm-gutters"),g=S instanceof HTMLElement?S.getBoundingClientRect().width:0;V.style.setProperty("--oc-editor-gutter-width",`${g}px`)},[]);return a.useEffect(()=>{L.current=t},[t]),a.useEffect(()=>{K.current=n},[n]),a.useEffect(()=>{l.current=d,$.current=h},[d,h]),a.useEffect(()=>{H.current=v},[v]),a.useEffect(()=>{I.current=C,A(C)},[C,A]),a.useEffect(()=>{if(!j.current)return;const x=(()=>{if(typeof document>"u")return null;const N=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(N)return N;const S=window.__PICHAMBER_CSP_NONCE__;return typeof S=="string"&&S.length>0?S:null})(),V=_o.create({doc:L.current,extensions:[...x?[we.cspNonce.of(x)]:[],Ko({fixed:!0}),ls.of(Vr(u)),Ho(),qo.of(" "),hs.of(is(k)),zn.of([Go,...Uo,...Xo]),we.updateListener.of(N=>{D(N.view),(N.viewportChanged||N.geometryChanged)&&A(I.current);const S=Qr(N.startState),g=Qr(N.state);S!==g&&H.current?.(g);const R=!sn(N.startState).eq(sn(N.state));if(g&&(S!==g||R||N.docChanged||N.selectionSet)&&cs(N.view.dom,N.view,S!==g||R||N.docChanged),!N.docChanged)return;const E=N.state.doc.toString();L.current=E,K.current(E),A(I.current)}),us.of(we.editable.of(!o)),ds.of(s??[]),fs.of(vs(f)),ms.of(xs(C,q.current)),ps.of(z?[es({top:!0}),zn.of(gs(ts))]:[])]});return y.current=new we({state:V,parent:j.current}),On(y.current,y.current.state.doc.length,200),y.current.requestMeasure(),requestAnimationFrame(()=>{D(y.current),A(I.current)}),y.current&&l.current?.(y.current),()=>{$.current?.(),y.current?.destroy(),y.current=null,J([])}},[I,D,A]),a.useEffect(()=>{const x=y.current;x&&(x.dispatch({effects:[ls.reconfigure(Vr(u)),us.reconfigure(we.editable.of(!o)),ds.reconfigure(s??[]),fs.reconfigure(vs(f)),ms.reconfigure(xs(C,q.current)),ps.reconfigure(z?[es({top:!0}),zn.of(gs(ts))]:[])]}),On(x,x.state.doc.length,200),x.requestMeasure(),requestAnimationFrame(()=>{D(x),A(I.current)}))},[s,f,u,o,C,z,D,A]),a.useEffect(()=>{const x=y.current;if(!x){M.current=k;return}M.current!==k&&(M.current=k,x.dispatch({effects:hs.reconfigure(is(k))}))},[k]),a.useEffect(()=>{const x=y.current;!x||z===!1||(b?(Pc(x),requestAnimationFrame(()=>{Tc(x.dom),cs(x.dom,x,!0)})):Lc(x))},[b,z]),a.useEffect(()=>{const x=y.current;if(!x)return;const V=x.state.doc.toString();V!==t&&(x.dispatch({changes:{from:0,to:V.length,insert:t}}),On(x,x.state.doc.length,300),x.requestMeasure(),requestAnimationFrame(()=>D(x)))},[t,D]),e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:j,className:X("h-full w-full","[&_.cm-editor]:h-full [&_.cm-editor]:w-full","[&_.cm-scroller]:font-mono [&_.cm-scroller]:text-[var(--text-code)] [&_.cm-scroller]:leading-6","[&_.cm-lineNumbers]:text-[var(--tools-edit-line-number)]",i)}),_.map(x=>Jo.createPortal(x.content,x.container,x.id))]})}const bs=({variant:t,selectedFile:n,loading:s,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:f,imagePreviewNonce:d,isSelectedPdf:h,pdfSrc:C,pdfPreviewNonce:z,isUnsupportedBinary:b,onDownload:v,enableRichPreviews:k,drawioViewMode:j,drawioRemountNonce:y,diagramEditorRef:L,diagramEditorXml:K,onDiagramChange:l,jsonViewMode:$,markdownViewMode:H,htmlViewMode:I,htmlLoading:M,htmlPreviewNonce:q,htmlPreviewSrc:_,fileContent:J,canUseShikiFileView:A,textViewMode:D,draftContent:x,onDraftChange:V,canEdit:N,vimMode:S,editorExtensions:g,editorWrapperRef:R,shouldMaskEditorForPendingNavigation:E,onEditorViewReady:P,onEditorViewDestroy:Y,enableSearch:G=!1,searchOpen:Q,onSearchOpenChange:ie,pierreTheme:W,shikiThemeType:te,wrapLines:Pe})=>{const xe=t==="fullscreen",le=xe?"p-4":"p-3",Fe=!!(n?.path&&rn(n.path)),se=!!(n?.path&&ea(n.path)),me=!!(n?.path&&ta(n.path)),Ce=!!(n?.path&&un(n.path)),ne=a.useRef(null),re=()=>n?e.jsxs("div",{className:"relative h-full",ref:ne,children:[e.jsx(ec,{file:{name:n.name,contents:x,lang:Bs(n.path)||void 0},options:{disableFileHeader:!0,overflow:Pe?"wrap":"scroll",theme:W,themeType:te,...Pe?{}:{unsafeCSS:ac}},className:"block h-full w-full",style:{height:"100%"}}),e.jsx(oc,{hostRef:ne,enabled:!Pe})]}):null;return e.jsx($s,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?s?i?e.jsx("div",{className:le}):e.jsxs("div",{className:`${le} flex items-center gap-2 typography-ui text-muted-foreground`,children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),xe?"Loading…":"Loading..."]}):o?e.jsx("div",{className:`${le} typography-ui text-[color:var(--status-error)]`,children:o}):u?e.jsx("div",{className:X("flex h-full items-center justify-center",le),children:e.jsx("img",{src:f,alt:n.name||"Image",className:X("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",xe?"max-h-full":"max-h-[70vh]")},d)}):h?e.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:e.jsx("iframe",{src:C,className:"h-full w-full border-0",title:n.name},z)}):b?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[e.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),e.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:"This file is binary and cannot be edited in PiChamber. Download it to open with another app."}),v?e.jsxs(U,{type:"button",variant:"outline",size:"sm",onClick:v,children:[e.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):k&&Fe&&j==="preview"?e.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:e.jsx(Ei,{ref:L,xml:K,onChange:l},`${n.path}:${y}`)}):k&&se&&$==="tree"?e.jsx(Hr,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:e.jsx("div",{className:"h-full overflow-auto",children:e.jsx(Qi,{jsonString:J,maxHeight:"100%",initiallyExpandedDepth:2})})}):me&&H==="preview"?e.jsxs("div",{className:X("h-full overflow-auto",le),children:[J.length>500*1024?e.jsx("div",{className:"mb-3 rounded-md border border-status-warning/20 bg-status-warning/10 px-3 py-2 text-sm text-status-warning",children:`This file is large (${Math.round(J.length/1024)}KB). Preview may be limited.`}):null,e.jsx(Hr,{fallback:e.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[e.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:e.jsx(pi,{content:J,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):k&&Ce&&I==="preview"?M?e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):e.jsx("div",{className:"h-full overflow-hidden",children:e.jsx("iframe",{src:_,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML preview"},q)}):A&&D==="view"?re():e.jsxs("div",{className:X("relative h-full",E&&"overflow-hidden"),ref:R,children:[e.jsx("div",{className:X("h-full",E&&"invisible"),children:e.jsx($c,{value:x,onChange:V,readOnly:!N,vimMode:S,extensions:g,className:"h-full",onViewReady:P,onViewDestroy:Y,...G?{enableSearch:!0,searchOpen:Q,onSearchOpenChange:ie}:{}})}),E?e.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:e.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):e.jsx("div",{className:`${le} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function Bc(t,n,s){if(Vs(t)&&!Ws(t))return{kind:n?"desktop-image":"asset-image"};if(_s(t))return{kind:"pdf"};if(Vn(t))return{kind:"binary",detectedFromContent:!1};const o=await s(t);if(hi(o))return{kind:"binary",detectedFromContent:!0};const u=Ii(o);return{kind:"text",content:u,draft:u.length>Mt?`${u.slice(0,Mt)}
|
|
2
2
|
|
|
3
|
-
… truncated …`:u,lineEnding:$i(o)}}function Vc({isDirty:t,saveDraft:n}){const s=ye(v=>v.setMainTabGuard),[i,o]=w.useState(!1),u=w.useRef(null),f=w.useRef(!1),d=w.useCallback(v=>f.current?(f.current=!1,!1):t?(u.current=v,o(!0),!0):!1,[t]);w.useEffect(()=>{if(!t){s(null);return}const v=k=>!d({kind:"tab",tab:k});return s(v),()=>{ye.getState().mainTabGuard===v&&s(null)}},[t,d,s]);const h=w.useCallback(()=>{const v=u.current;return u.current=null,f.current=!0,o(!1),v?.kind==="tab"&&s(null),v},[s]),C=w.useCallback(()=>h(),[h]),z=w.useCallback(async()=>await n()?h():(f.current=!1,null),[n,h]),b=w.useCallback(v=>{v||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:C,keepModalOpen:b,requestNavigation:d,saveAndTakeIntent:z}}function Wc(t,n){if(t.state.doc.length!==n.length)return!1;if(n.length===0)return!0;const s=Math.min(128,n.length);if(t.state.sliceDoc(0,s)!==n.slice(0,s))return!1;const i=Math.max(0,n.length-s);return t.state.sliceDoc(i,n.length)===n.slice(i)}function _c({root:t,selectedPath:n,loadedPath:s,fileLoading:i,fileError:o,isImage:u,isPdf:f,isUnsupportedBinary:d,canEdit:h,textViewMode:C,setTextViewMode:z,draftContent:b,confirmDiscardOpen:v,selectFilePath:k}){const j=ye(A=>A.pendingFileNavigation),y=ye(A=>A.setPendingFileNavigation),P=ye(A=>A.pendingFileFocusPath),K=ye(A=>A.setPendingFileFocusPath),l=w.useRef(null),[$,H]=w.useState(0),I=w.useRef(null),M=w.useRef({key:"",attempts:0}),q=w.useCallback(()=>{H(A=>A+1)},[]);w.useEffect(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current)},[]),w.useEffect(()=>{if(!j||!t)return;const A=()=>{I.current===null&&(I.current=window.requestAnimationFrame(()=>{I.current=null,q()}))},D=()=>{y(null),M.current={key:"",attempts:0}},x=ce(j.path);if(!x){D();return}const V=`${x}:${j.line}:${j.column??1}`;if(M.current.key!==V&&(M.current={key:V,attempts:0}),n!==x){v||k(x);return}if(i||s!==x)return;if(o||u||f||d){D();return}if(!h)return;if(C!=="edit"){z("edit");return}const N=l.current;if(!N||!Wc(N,b)){A();return}const S=Math.max(1,Math.min(j.line,N.state.doc.lines)),g=N.state.doc.line(S),R=Math.max(1,j.column||1),E=g.from+Math.min(Math.max(0,g.to-g.from),R-1);if(!(N.state.selection.main.head===E)||M.current.attempts===0){M.current.attempts+=1,N.dispatch({selection:{anchor:E},effects:we.scrollIntoView(E,{y:"center"})}),N.focus(),A();return}window.requestAnimationFrame(()=>{const Y=l.current;Y&&(Y.dispatch({selection:{anchor:E},effects:we.scrollIntoView(E,{y:"center"})}),Y.focus())}),D()},[h,v,b,$,o,i,u,f,d,s,q,j,t,n,k,y,z,C]),w.useEffect(()=>{if(!P||!t)return;const A=ce(P);if(!A){K(null);return}n!==A||i||s!==A||(!o&&!u&&!f&&!d&&h&&C==="edit"&&l.current?.focus(),K(null))},[h,o,i,u,f,d,s,P,t,n,K,C]);const _=ce(j?.path??"");return{editorViewRef:l,notifyEditorViewChanged:q,shouldMaskEditor:!!(j&&_&&n===_&&!i&&!o&&!u&&!f&&!d)}}function Kc(t){return!(!t.autoSaveEnabled||!t.isDirty||!t.canWrite||t.isSaving||t.fileLoading||t.isNonEditableBinary||!t.selectedFilePath||t.loadedFilePath!==t.selectedFilePath)}function Hc(t){return t.selectedFilePath?t.isDirty?!(t.fileLoading||t.loadedFilePath!==t.selectedFilePath||t.isNonEditableBinary||t.draftContent===""&&t.fileContent!==""&&t.loadedFilePath!==t.selectedFilePath):!0:!1}const qc=1500,Gc=2e3;function Uc({autoSaveEnabled:t,selectedPath:n,loadedPath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,lineEnding:d,isNonEditableBinary:h,writeFile:C,expectedRevision:z,onSaved:b,captureSaveScope:v,currentSaveScope:k,onConflict:j}){const[y,P]=w.useState(!1),[K,l]=w.useState("idle"),[$,H]=w.useState(null),I=w.useRef(null),M=w.useRef(null),q=w.useRef(j);q.current=j;const _=w.useRef(v);_.current=v;const J=w.useRef(k);J.current=k;const A=w.useCallback(S=>S?Xs(S,J.current?.()??null):!0,[]),D=w.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null)},[]),x=w.useCallback(()=>{l("saved"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=null,l("idle")},Gc)},[]),V=w.useCallback(async S=>{if(!n||!C)return he.error("Saving not supported"),!1;if(!Hc({selectedFilePath:n,loadedFilePath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,isNonEditableBinary:h}))return h?console.warn(`[saveDraft] refusing to save binary file "${n}".`):u===""&&f!==""&&s!==n&&console.warn(`[saveDraft] refusing to save empty draft for "${n}" (${f.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!o)return!0;P(!0);const g=_.current?.()??null;try{const R=Bi(u,d),E=Js(z,S?.overwrite),L=await C(n,R,E);return L?.success?A(g)?(H(null),b(n,u,L?.revision,g),!0):!1:(he.error("Failed to write file"),!1)}catch(R){if(Ds(R)){if(!A(g))return!1;const E={path:n,currentRevision:R.currentRevision??null,exists:R.exists};return H(E),q.current?.(E),!1}return he.error(R instanceof Error?R.message:"Save failed"),!1}finally{P(!1)}},[u,z,f,i,o,h,A,d,s,b,n,C]),N=w.useCallback(async S=>{if(D(),y)return!1;const g=await V(S);return g&&x(),g},[D,y,V,x]);return w.useEffect(()=>{t||(l("idle"),D())},[t,D]),w.useEffect(()=>{if(Kc({autoSaveEnabled:t,isDirty:o,canWrite:!!(n&&C),isSaving:y,fileLoading:i,selectedFilePath:n,loadedFilePath:s,isNonEditableBinary:h}))return I.current=setTimeout(()=>{I.current=null,V().then(S=>{S&&x()})},qc),D},[t,D,u,i,o,h,y,s,V,n,x,C]),w.useEffect(()=>{l("idle"),P(!1),H(null)},[n]),w.useEffect(()=>()=>{D(),M.current&&clearTimeout(M.current)},[D]),{autoSaveStatus:K,cancelPendingAutosave:D,isSaving:y,saveConflict:$,clearSaveConflict:()=>H(null),saveDraft:V,saveNow:N}}function Xc(t,n){return typeof t.revision=="string"&&typeof n.revision=="string"&&t.revision!==n.revision?!0:n.mtimeMs!==void 0&&t.mtimeMs!==void 0&&n.mtimeMs!==t.mtimeMs||n.size!==t.size}function Jc({selectedPath:t,loadedPath:n,isDirty:s,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const f=w.useRef(null),d=w.useRef(s);d.current=s;const h=w.useCallback(C=>{f.current=C},[]);return w.useEffect(()=>{if(!t||n!==t)return;let C=!1;const z=window.setInterval(()=>{if(document.hidden)return;const b=f.current,v=b&&b.path===t&&typeof b.revision=="string"?b.revision:null;i(t,{knownRevision:v}).then(k=>{if(C||!k)return;const j=f.current;if(!j||j.path!==t){f.current=k;return}!Xc(j,k)||d.current||(f.current=k,o())}).catch(()=>{})},u);return()=>{C=!0,window.clearInterval(z)}},[n,o,u,i,t]),{recordStat:h}}const ys="pichamber:files:md-viewer-mode",ws="pichamber:files:html-viewer-mode",js="pichamber:files:json-viewer-mode",Yc=1500,Qc=1500;function Ln(t,n,s){try{const i=localStorage.getItem(t);if(i&&n.includes(i))return i}catch{}return s}function Pn(t,n){try{localStorage.setItem(t,n)}catch{}}function Zc({root:t,selectedPath:n,fileContent:s,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:f,expectedRevision:d,captureSaveScope:h,currentSaveScope:C,onSaved:z,onConflict:b}){const[v,k]=w.useState("edit"),[j,y]=w.useState("edit"),[P,K]=w.useState("text"),[l,$]=w.useState("edit"),[H,I]=w.useState("edit"),[M,q]=w.useState(0),[_,J]=w.useState(!1),A=w.useRef({}),D=w.useRef({}),x=w.useRef({}),V=w.useRef({}),N=w.useRef(""),S=w.useRef(""),g=w.useRef(null),R=w.useRef(null),E=w.useRef(null),L=w.useRef(d);L.current=d;const Y=w.useRef(h);Y.current=h;const G=w.useRef(C);G.current=C;const Z=w.useRef(z);Z.current=z;const ie=w.useRef(b);ie.current=b;const W=w.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null),E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)},[]),te=w.useCallback(B=>{N.current=B,S.current=B},[]),Le=w.useCallback(()=>te(""),[te]);w.useEffect(()=>{n&&(k(A.current[n]??"edit"),y(D.current[n]??Ln(ys,["preview","edit"],"edit")),$(x.current[n]??Ln(ws,["preview","edit"],"edit")),I(V.current[n]??"edit"),K(Ln(js,["tree","text"],"text")))},[n]);const xe=w.useCallback(B=>{n&&(A.current[n]=B),k(B)},[n]),le=w.useCallback(B=>{n&&(D.current[n]=B),y(B),Pn(ys,B)},[n]),Fe=w.useCallback(B=>{n&&(x.current[n]=B),$(B),Pn(ws,B)},[n]),se=w.useCallback(B=>{K(B),Pn(js,B)},[]),me=w.useCallback(B=>{if(n&&(V.current[n]=B),W(),B==="edit"){o(N.current||s),I(B);return}N.current=i;const ue=n;I("edit"),E.current=requestAnimationFrame(()=>{E.current=requestAnimationFrame(()=>{E.current=null,!(t&&ue&&Oe.getState().byRoot[t]?.selectedPath!==ue)&&(q(ae=>ae+1),I("preview"))})})},[W,i,s,t,n,o]),Ce=w.useCallback(B=>B?Xs(B,G.current?.()??null):!0,[]),ne=w.useCallback(async(B,ue,ae)=>{if(!f||ue===S.current)return!1;const Q=Y.current?.()??null;if(Q&&Q.path!==B)return!1;try{const pe=await f(B,ue,Js(L.current,ae?.overwrite));return pe?.success?Ce(Q)?(te(ue),o(ue),Z.current?.(B,ue,pe?.revision,Q),!0):!1:(he.error("Failed to write file"),!1)}catch(pe){return Ds(pe)?(Ce(Q)&&ie.current?.({path:B,currentRevision:pe.currentRevision??null,exists:pe.exists,xml:ue}),!1):(he.error(pe instanceof Error?pe.message:"Save failed"),!1)}},[Ce,te,o,f]),re=w.useCallback(()=>{J(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>J(!1),Qc)},[]),We=w.useCallback(async(B,ue,ae)=>{g.current&&(clearTimeout(g.current),g.current=null);const Q=await ne(B,ue,ae);return Q&&re(),Q},[ne,re]),ve=w.useCallback(B=>{N.current=B,!(!u||!n||H!=="preview"||!f)&&(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,ne(n,B).then(ue=>{ue&&re()})},Yc))},[u,H,ne,n,re,f]);w.useEffect(()=>W,[W,H,n]),w.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const je=rn(n??"")&&(N.current||i)||s;return{clearDiagramContent:Le,diagramEditorXml:je,diagramSaved:_,drawioRemountNonce:M,drawioViewMode:H,handleDiagramChange:ve,htmlViewMode:l,jsonViewMode:P,mdViewMode:j,recordDiagramContent:te,saveDiagramNow:We,saveDiagramXml:ne,saveDrawioViewMode:me,saveHtmlViewMode:Fe,saveJsonViewMode:se,saveMdViewMode:le,saveTextViewMode:xe,setTextViewMode:k,textViewMode:v}}function el(t,n){return t==="mobile"?!0:n==="full"}function tl(t,n){if(t===n)return!0;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s+=1){const i=t[s],o=n[s];if(i.name!==o.name||i.path!==o.path||i.type!==o.type||i.extension!==o.extension||i.relativePath!==o.relativePath||i.size!==o.size)return!1}return!0}function nl({files:t,root:n,activeDirectory:s,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:f,enabled:d=!0,visible:h=!0}){const[C,z]=a.useState({}),[b,v]=a.useState({}),k=a.useRef(new Set),j=a.useRef(new Set),y=a.useRef(new Map),P=a.useRef(new Map),K=a.useRef(0),l=a.useRef(!1),[$,H]=a.useState(()=>ai());a.useEffect(()=>oi(S=>{H(S.runtimeKey)}),[]),a.useEffect(()=>(l.current=!1,()=>{l.current=!0,P.current=new Map,j.current=new Set,y.current=new Map}),[]);const I=a.useCallback((S,g)=>{const R=[];for(const E of g){if(!E?.name||Vi(E.name)||o==="desktop"&&!u&&Wi(E.name))continue;const L=ce(E.path||""),Y=L?_i(L)?L:ce(`${S}/${L}`):ce(`${S}/${E.name}`),G=E.isDirectory?"directory":"file";R.push({name:E.name,path:Y,type:G,extension:G==="file"&&E.name.includes(".")?E.name.split(".").pop()?.toLowerCase():void 0,size:E.size})}return Ki(R)},[o,u]),M=`${$}|${n}|g${u?"1":"0"}|${o}`,q=a.useRef(M);q.current=M;const _=a.useCallback(async S=>{if(!d)return;const g=ce(S.trim());if(!g||k.current.has(g))return;const R=y.current.get(g);if(R){await R;return}const E=q.current,L=K.current+1;K.current=L,P.current=new Map(P.current).set(g,L),j.current=new Set(j.current).add(g);const Y=()=>!l.current&&q.current===E&&P.current.get(g)===L,G=(async()=>{try{const Z=t.listDirectory?(await t.listDirectory(g)).entries.map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory,size:W.size})):(await ii(g)).map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory}));if(!Y())return;k.current=new Set(k.current).add(g),v(W=>{if(!W[g])return W;const te={...W};return delete te[g],te});const ie=I(g,Z);z(W=>{const te=W[g];return te&&tl(te,ie)?W:{...W,[g]:ie}})}catch(Z){if(!Y())return;const ie=Z instanceof Error?Z.message:String(Z??"");ie==="Directory not found"&&n&&g!==n?(f(n,g),v(W=>{if(!W[g])return W;const te={...W};return delete te[g],te})):(console.error("Failed to load files directory:",Z),v(W=>({...W,[g]:ie})))}finally{P.current.get(g)===L&&(P.current=new Map(P.current),P.current.delete(g))}})();y.current.set(g,G);try{await G}finally{y.current.get(g)===G&&(y.current.delete(g),j.current=new Set(j.current),j.current.delete(g))}},[d,t,I,f,n]),J=a.useCallback(()=>{k.current=new Set,j.current=new Set,y.current=new Map,P.current=new Map,v({}),z(S=>Object.keys(S).length===0?S:{})},[]),A=a.useCallback(async()=>{!d||!n||(J(),await _(n))},[d,_,J,n]),D=a.useCallback(async S=>{if(!d)return;if(!S){await A();return}const g=ce(S);k.current=new Set(k.current),k.current.delete(g),j.current=new Set(j.current),j.current.delete(g),y.current.delete(g),P.current=new Map(P.current),P.current.delete(g),await _(g)},[d,_,A]),x=a.useRef("");a.useEffect(()=>{x.current!==M&&(x.current=M,J())},[J,M]),a.useEffect(()=>{!d||!h||!n||k.current.has(ce(n))||_(n)},[d,_,n,M,h]),a.useEffect(()=>{!d||!h||!s||_(s)},[s,d,_,h]),a.useEffect(()=>{if(!d||!h||!t.listDirectory)return;const S=L=>{const Y=ce(L);return y.current.has(Y)||j.current.has(Y)},g=()=>{if(!(typeof document<"u"&&document.hidden))for(const L of i)S(L)||D(L)},R=()=>{typeof document<"u"&&document.hidden||g()};typeof document<"u"&&document.addEventListener("visibilitychange",R);const E=i.length>0?window.setInterval(g,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",R),E!==null&&window.clearInterval(E)}},[d,i,t.listDirectory,D,h]);const V=a.useRef(d&&h);a.useEffect(()=>{const S=d&&h,g=V.current;if(V.current=S,!(!S||g)){if(!t.listDirectory){n&&!k.current.has(ce(n))&&_(n);return}if(i.length===0){n&&!k.current.has(ce(n))&&_(n);return}for(const R of i){const E=ce(R);y.current.has(E)||j.current.has(E)||D(R)}}},[d,i,t.listDirectory,_,D,n,h]);const N=a.useCallback(S=>k.current.has(ce(S)),[]);return{childrenByDir:C,loadErrorsByDir:b,isLoaded:N,loadDirectory:_,refreshDirectory:D,refreshRoot:A}}const rl=({showEditorTabsRow:t,isMobile:n,showMobilePageContent:s,onBackMobile:i,selectedFile:o,openFiles:u,root:f,alwaysShowActions:d,editorTabsOverflow:h,editorTabsScrollRef:C,onSelectFile:z,onCloseFile:b})=>t?e.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[n&&s&&e.jsx("button",{type:"button",onClick:i,"aria-label":"Back",className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:e.jsx(F,{name:"arrow-left-s",className:"size-5"})}),n?o?e.jsxs(on,{children:[e.jsx(cn,{asChild:!0,children:e.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":"Open files",children:[e.jsx(jt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(os,{name:o.name}),e.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),e.jsx(ln,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(v=>{const k=o?.path===v.path;return e.jsxs(fe,{onSelect:j=>{if(j.target.closest("[data-close-open-file]")){j.preventDefault();return}k||z(v)},className:X("flex min-w-0 items-center justify-between gap-2 overflow-hidden",k&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[e.jsx(jt,{filePath:v.path,extension:v.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(os,{name:v.name})]}),e.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:j=>{j.preventDefault(),j.stopPropagation()},onClick:j=>{j.preventDefault(),j.stopPropagation(),b(v.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":`Close ${v.name}`,children:e.jsx(F,{name:"close",className:"size-3.5"})})]},v.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?e.jsxs("div",{className:"relative min-w-0 flex-1",children:[h.left&&e.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),h.right&&e.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),e.jsx("div",{ref:C,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},"data-no-drawer-swipe":"true",children:u.map(v=>{const k=o?.path===v.path;return e.jsxs("div",{title:kt(f,v.path),className:X("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",k?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[e.jsx(jt,{filePath:v.path,extension:v.extension,className:"size-3.5 flex-shrink-0"}),e.jsx("button",{type:"button",onClick:()=>{k||z(v)},className:"max-w-[12rem] truncate text-left",children:v.name}),e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),b(v.path)},className:X("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!k&&!d&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${v.name}`,children:e.jsx(F,{name:"close",className:"size-3.5"})})]},v.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,sl=(t,n)=>{if(!n)return null;const s=Number.parseInt(t.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,n.state.doc.lines)},ks=(t,n)=>{const s=t.state.doc.lineAt(n.main.head);return{lineNumber:s.number,character:n.main.head-s.from+1,selection:n}},Cs=(t,n,s)=>{const i=t.state.doc.line(n),o=Math.max(1,Math.min(s,i.length+1)),u=i.from+o-1;t.dispatch({selection:Zo.cursor(u),effects:we.scrollIntoView(u,{y:"center"})})};function ia({open:t,onOpenChange:n,view:s,variant:i="overlay"}){const[o,u]=a.useState(""),f=a.useRef(null),d=a.useRef(!1),h=a.useRef(null),C=a.useRef(null),z=a.useMemo(()=>sl(o,s),[o,s]);a.useEffect(()=>{!t||!s||(d.current=!1,f.current=ks(s,s.state.selection),u(""))},[t,s]),a.useEffect(()=>{t&&window.requestAnimationFrame(()=>{C.current?.focus(),C.current?.select()})},[t]),a.useEffect(()=>{if(!(!t||!s||!f.current)){if(z===null){const{selection:y}=f.current;s.dispatch({selection:y,effects:we.scrollIntoView(y.main.from,{y:"center"})});return}Cs(s,z,f.current.character)}},[z,t,s]);const b=a.useCallback(()=>{if(!s||d.current||!f.current)return;const{selection:y}=f.current;s.dispatch({selection:y,effects:we.scrollIntoView(y.main.from,{y:"center"})})},[s]),v=a.useCallback(y=>{y||b(),n(y)},[n,b]),k=a.useCallback(()=>{!s||z===null||!f.current||(d.current=!0,Cs(s,z,f.current.character),n(!1),s.focus())},[z,n,s]);a.useEffect(()=>{if(!t)return;const y=K=>{const l=h.current,$=K.target;!l||!($ instanceof Node)||l.contains($)||v(!1)},P=K=>{K.key==="Escape"&&(K.preventDefault(),v(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",P,!0)}},[v,t,i]);const j=a.useMemo(()=>s?z===null?`Current Line: ${(f.current??ks(s,s.state.selection)).lineNumber}. Type a line number between 1 and ${s.state.doc.lines} to navigate to.`:`Go to line ${z}`:"Editor unavailable.",[z,s]);return i==="inline"?t?e.jsxs("div",{ref:h,className:"ml-1 flex h-6 items-center gap-1",children:[e.jsx(Dt,{ref:C,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:y=>u(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),k())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),e.jsx(U,{variant:"outline",size:"xs",onClick:k,disabled:!s||z===null,className:"h-6 px-2",children:"Go"})]}):null:e.jsx("div",{ref:h,className:X("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",t?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx(Dt,{ref:C,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:y=>u(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),k())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),e.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground",children:j})]})})}const In=({currentMode:t,onToggle:n})=>{const s=t==="preview",i=s?"Switch to edit mode":"Switch to preview mode",o=s?"Edit":"Preview";return e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",onClick:n,"aria-label":i,className:"h-5 w-5 p-0",children:s?e.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):e.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),e.jsx(lt,{sideOffset:8,children:o})]})},al=({selectedFile:t,displaySelectedPath:n,layout:s="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:f,autoSaveEnabled:d,autoSaveStatus:h,isDirty:C,onSaveDraft:z,onToggleAutoSave:b,canOpenInDesktopApp:v=!0,openInApps:k,openInCacheStale:j,onOpenInApp:y,onRefreshOpenInApps:P,onToolbarDropdownOpenChange:K,isSelectedImage:l,isSelectedPdf:$,isUnsupportedBinary:H,wrapLines:I,onToggleWrapLines:M,textViewMode:q,onToggleSearch:_,isGoToLineOpen:J,onOpenGoToLineChange:A,editorView:D,canUseShikiFileView:x,isJson:V,isHtml:N,onToggleTextViewMode:S,isMarkdown:g,mdViewMode:R,onToggleMdViewMode:E,isDrawio:L,drawioViewMode:Y,onToggleDrawioViewMode:G,diagramSaved:Z,onSaveDiagram:ie,jsonViewMode:W,onToggleJsonViewMode:te,canCopy:Le,copiedContent:xe,onCopyContent:le,canCopyPath:Fe,copiedPath:se,onCopyPath:me,onDownloadFile:Ce,isMobile:ne,mode:re,isFullscreen:We,onToggleFullscreen:ve,onExitFullscreen:je})=>{if(!t)return null;const ue=s==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",ae=(Q,pe)=>e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:pe})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:Q})]});return e.jsxs("div",{className:ue,children:[o&&u&&e.jsxs(e.Fragment,{children:[f?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[e.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):d&&h==="saved"&&!C?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[e.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):C?ae(d?`Save now (${bt()}+S) - auto-saves after 1.5s`:`Save now (${bt()}+S)`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{z()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:d?`Save now (${bt()}+S) - auto-saves after 1.5s`:`Save now (${bt()}+S)`,"aria-label":`Save (${bt()}+S)`,children:e.jsx(F,{name:"save-3",className:"size-4"})})):null,ae(d?"Auto-save on":"Manual save",e.jsx(U,{variant:"ghost",size:"sm",onClick:b,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",d?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:d?"Auto-save on":"Manual save","aria-label":d?"Auto-save on":"Manual save",children:d?e.jsx(F,{name:"file-check-fill",className:"size-4"}):e.jsx(F,{name:"file-check",className:"size-4"})}))]}),v?e.jsxs(on,{onOpenChange:K,children:[e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Open in desktop app","aria-label":"Open in desktop app",children:e.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),e.jsxs(ln,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[k.map(Q=>e.jsxs(fe,{className:"flex items-center gap-2",onClick:()=>{y(Q)},children:[e.jsx(oa,{label:Q.label,iconDataUrl:Q.iconDataUrl}),e.jsx("span",{className:"typography-ui-label text-foreground",children:Q.label})]},Q.id)),j?e.jsxs(fe,{className:"flex items-center gap-2",onClick:()=>{P()},children:[e.jsx(F,{name:"refresh",className:"size-4"}),e.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh apps"})]}):null]})]}):null,!l&&!$&&!H&&e.jsxs(e.Fragment,{children:[ae(I?"Disable line wrap":"Enable line wrap",e.jsx(U,{variant:"ghost",size:"sm",onClick:M,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",I?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:I?"Disable line wrap":"Enable line wrap",children:e.jsx(F,{name:"text-wrap",className:"size-4"})})),q==="edit"&&e.jsxs(e.Fragment,{children:[ae("Find in file",e.jsx(U,{variant:"ghost",size:"sm",onClick:Q=>{_(),Q.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Find in file",children:e.jsx(F,{name:"search",className:"size-4"})})),ae("Go to line",e.jsx(U,{variant:"ghost",size:"sm",onClick:Q=>{A(!J),Q.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Go to line",children:e.jsx(F,{name:"menu-fold-2",className:"size-4"})})),e.jsx(ia,{open:J,onOpenChange:A,view:D,variant:"inline"})]})]}),x&&o&&!V&&!N&&e.jsx(In,{currentMode:q==="view"?"preview":"edit",onToggle:S}),g&&ae(R==="preview"?"Switch to edit mode":"Switch to preview mode",e.jsx(U,{variant:"ghost",size:"sm",onClick:E,className:X("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",R==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:R==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":R==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(F,{name:R==="preview"?"eye":"eye-off",className:"size-4"})})),un(t?.path??"")&&e.jsx(In,{currentMode:N?"preview":"edit",onToggle:S}),L&&e.jsxs(e.Fragment,{children:[e.jsx(In,{currentMode:Y,onToggle:G}),Y==="preview"&&e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{ie()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:Z?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"save-3",className:"size-4"})})]}),V&&ae(W==="tree"?"Switch to text view":"Switch to tree view",e.jsx(U,{variant:"ghost",size:"sm",onClick:te,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:W==="tree"?"Switch to text view":"Switch to tree view",children:W==="tree"?e.jsx(F,{name:"code-sslash",className:"size-4"}):e.jsx(F,{name:"node-tree",className:"size-4"})})),Le&&ae("Copy file contents",e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{le()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Copy file contents","aria-label":"Copy file contents",children:xe?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"clipboard",className:"size-4"})})),Fe&&ae(`Copy file path (${n})`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{me()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:`Copy file path (${n})`,"aria-label":`Copy file path (${n})`,children:se?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"file-copy-2",className:"size-4"})})),Ce&&ae("Save file",e.jsx(U,{variant:"ghost",size:"sm",onClick:Ce,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:e.jsx(F,{name:"download",className:"size-4"})})),i?ae("Exit fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:je,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:e.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!ne&&re==="full"&&ae(We?"Exit fullscreen":"Fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:ve,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:We?"Exit fullscreen":"Fullscreen","aria-label":We?"Exit fullscreen":"Fullscreen",children:We?e.jsx(F,{name:"fullscreen-exit",className:"size-4"}):e.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},ol=({open:t,onOpenChange:n,isSaving:s,onSaveAndContinue:i,onDiscardAndContinue:o})=>e.jsx(Ts,{open:t,onOpenChange:n,children:e.jsxs(As,{showCloseButton:!1,className:"max-w-md",children:[e.jsxs(Os,{children:[e.jsx(Ls,{children:"Unsaved changes"}),e.jsx(Ps,{children:"Save your edits before continuing?"})]}),e.jsxs(Is,{children:[e.jsx(U,{variant:"outline",onClick:i,disabled:s,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:"Save changes"}),e.jsx(U,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),il=({root:t,isMobile:n,searchQuery:s,onSearchQueryChange:i,searchInputRef:o,searching:u,searchFailed:f,searchResults:d,selectedFile:h,onSelectFile:C,onOpenDialog:z,currentDirectory:b,refreshRoot:v,childrenByDir:k,loadErrorsByDir:j,expandedPaths:y,isBrowserClient:P,alwaysShowActions:K,getFileStatus:l,getFolderBadge:$,fileRowPermissions:H,downloadFile:I,contextMenuPath:M,setContextMenuPath:q,rightClickMenuPath:_,setRightClickMenuPath:J,toggleDirectory:A,handleRevealPath:D,refreshDirectory:x})=>{const V=!!(t&&k[t]),N=s.trim().length>0,S=t?j[t]:null,g=a.useMemo(()=>Hi(y),[y]);function R(E,L){return(k[E]??[]).map(G=>{const Z=G.type==="directory",ie=Z&&g.has(G.path),W=h?.path===G.path;return e.jsxs("li",{className:"relative",children:[e.jsx(Fc,{node:G,root:t,isExpanded:ie,isActive:W,isMobile:n,isBrowserClient:P,alwaysShowActions:K,status:Z?void 0:l(G.path),badge:Z?$(G.path):void 0,permissions:H,downloadFile:I,contextMenuPath:M,setContextMenuPath:q,rightClickMenuPath:_,setRightClickMenuPath:J,onSelect:C,onToggle:A,onRevealPath:D,onOpenDialog:z}),Z&&ie&&e.jsxs("ul",{className:"relative ml-[15px] flex flex-col border-l border-border/50 pl-1.5",children:[j[G.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[G.path],children:j[G.path]}),e.jsxs(U,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{x(G.path)},children:[e.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(G.path)]})]},G.path)})}return e.jsxs("section",{className:X("flex min-h-0 flex-col overflow-hidden",n?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[e.jsx("div",{className:X("flex flex-col gap-2 py-2",n?"px-3":"px-2"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),e.jsx(Dt,{ref:o,value:s,onChange:E=>i(E.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),s.trim().length>0&&e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{i(""),o.current?.focus()},children:e.jsx(F,{name:"close",className:"size-4"})})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>z("createFile",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New file","aria-label":"New file",children:e.jsx(F,{name:"file-add",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"New File"})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>z("createFolder",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New folder","aria-label":"New folder",children:e.jsx(F,{name:"folder-add",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{v()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(F,{name:"refresh",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),e.jsx($s,{outerClassName:"flex-1 min-h-0",className:X("py-2",n?"px-3":"px-2"),children:e.jsx("ul",{className:"flex flex-col",children:N&&u?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):N&&f?e.jsx("li",{className:"px-2 py-1 typography-meta text-[var(--status-error)]",children:"Search failed. Edit the search to try again."}):N&&d.length===0?e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground text-pretty",children:`No files match “${s.trim()}”.`}):N?d.map(E=>e.jsx("li",{children:e.jsx(qi,{path:E.relativePath||kt(t,E.path)||E.path,status:l(E.path),active:h?.path===E.path,match:s,onClick:()=>{C(E)}})},E.path)):S?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"text-[var(--status-error)]",children:S}),e.jsxs(U,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{v()},children:[e.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):V?R(t):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},Ns="min-w-0 truncate rounded px-1 py-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",cl=({path:t,status:n,className:s,rootLabel:i,onRevealFolder:o,onShowChanges:u,children:f})=>{const d=t.split("/").filter(Boolean),h=d.pop()??t,C=e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-subtle-foreground",children:"/"});return e.jsxs("div",{className:X("flex h-9 min-w-0 shrink-0 items-center gap-2 pl-2 pr-1",s),children:[e.jsxs("nav",{"aria-label":"File path",className:"flex min-w-0 flex-1 items-center gap-1.5 typography-meta",title:t,children:[e.jsxs("span",{className:"flex min-w-0 items-center",children:[o?e.jsxs(e.Fragment,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:X(Ns,"max-w-[10rem] shrink"),onClick:()=>o(""),title:`Show ${i} in the tree`,children:i}),C]}):null,d.map((z,b)=>{const v=d.slice(0,b+1).join("/");return e.jsxs(a.Fragment,{children:[e.jsx("button",{type:"button",className:X(Ns,"shrink-[100]"),onClick:()=>o(v),title:`Show ${v} in the tree`,children:z}),C]},v)})]}):d.length>0?e.jsx("span",{className:"min-w-0 shrink-[100] truncate pl-1 text-muted-foreground [direction:rtl] [text-align:left]",children:e.jsx("bdi",{children:`${d.join("/")}/`})}):null,e.jsx("span",{"aria-current":"page",className:X("min-w-0 truncate font-medium text-foreground",o?"px-1":d.length===0&&"pl-1"),children:h})]}),n&&n!=="open"?e.jsx(Zs,{status:n}):null]}),u&&n&&n!=="open"?e.jsx(U,{type:"button",variant:"outline",size:"xs",onClick:u,className:"shrink-0",title:"Show this file's changes",children:"Changes"}):null,f?e.jsx("div",{className:"flex shrink-0 items-center gap-0.5",children:f}):null]})},Ae=({label:t,hint:n,checked:s})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1",children:t}),n?e.jsx("span",{className:"ml-4 typography-micro text-muted-foreground",children:n}):null,s?e.jsx(F,{name:"check",className:"ml-4 size-4 text-foreground"}):null]}),ll=({selectedFile:t,displaySelectedPath:n,canEdit:s,isEditingFile:i,isSaving:o,autoSaveEnabled:u,isDirty:f,onSaveDraft:d,onToggleAutoSave:h,canOpenInDesktopApp:C=!0,openInApps:z,openInCacheStale:b,onOpenInApp:v,onRefreshOpenInApps:k,onToolbarDropdownOpenChange:j,isSelectedImage:y,isSelectedPdf:P,isUnsupportedBinary:K,wrapLines:l,onToggleWrapLines:$,textViewMode:H,onToggleSearch:I,onOpenGoToLineChange:M,canUseShikiFileView:q,isJson:_,isHtml:J,onToggleTextViewMode:A,isDrawio:D,drawioViewMode:x,onToggleDrawioViewMode:V,diagramSaved:N,onSaveDiagram:S,jsonViewMode:g,onToggleJsonViewMode:R,canCopy:E,onCopyContent:L,canCopyPath:Y,onCopyPath:G,onDownloadFile:Z,isMobile:ie,mode:W,isFullscreen:te,onToggleFullscreen:Le})=>{if(!t)return null;const xe=bt(),le=!y&&!P&&!K,Fe=s&&i,se=le&&H==="edit",me=D?{label:x==="preview"?"Edit diagram source":"Show diagram",onSelect:V}:un(t.path)?{label:J?"Show source":"Show page preview",onSelect:A}:q&&s&&!_&&!J?{label:H==="view"?"Edit file":"Read only",onSelect:A}:null,Ce=Fe?e.jsxs(e.Fragment,{children:[f&&!o?e.jsx(fe,{onSelect:()=>{d()},children:e.jsx(Ae,{label:"Save now",hint:`${xe}+S`})}):null,e.jsx(fe,{onSelect:h,children:e.jsx(Ae,{label:"Save automatically",checked:u})})]}):null,ne=[];me&&ne.push(e.jsx(fe,{onSelect:me.onSelect,children:e.jsx(Ae,{label:me.label})},"view")),_&&ne.push(e.jsx(fe,{onSelect:R,children:e.jsx(Ae,{label:g==="tree"?"Show as text":"Show as tree"})},"json")),D&&x==="preview"&&ne.push(e.jsx(fe,{onSelect:()=>{S()},children:e.jsx(Ae,{label:N?"Diagram saved":"Save diagram"})},"diagram")),le&&ne.push(e.jsx(fe,{onSelect:$,children:e.jsx(Ae,{label:"Wrap long lines",checked:l})},"wrap")),se&&ne.push(e.jsx(fe,{onSelect:I,children:e.jsx(Ae,{label:"Find in file",hint:`${xe}+F`})},"find"),e.jsx(fe,{onSelect:()=>M(!0),children:e.jsx(Ae,{label:"Go to line"})},"line"));const re=[];E&&re.push(e.jsx(fe,{onSelect:()=>{L()},children:e.jsx(Ae,{label:"Copy contents"})},"copy")),Y&&re.push(e.jsx(fe,{onSelect:()=>{G()},children:e.jsx(Ae,{label:"Copy path"})},"path")),Z&&re.push(e.jsx(fe,{onSelect:Z,children:e.jsx(Ae,{label:"Download"})},"download")),C&&z.length>0&&re.push(e.jsxs(gi,{children:[e.jsx(xi,{children:"Open in"}),e.jsxs(vi,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[z.map(je=>e.jsxs(fe,{className:"flex items-center gap-2",onSelect:()=>{v(je)},children:[e.jsx(oa,{label:je.label,iconDataUrl:je.iconDataUrl}),e.jsx("span",{className:"typography-ui-label text-foreground",children:je.label})]},je.id)),b?e.jsx(fe,{onSelect:()=>{k()},children:"Refresh apps"}):null]})]},"open-in"));const We=!ie&&W==="full",ve=[Ce,ne.length?ne:null,re.length?re:null].filter(Boolean);return e.jsxs(on,{onOpenChange:j,children:[e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:X("size-7 p-0 text-muted-foreground hover:text-foreground data-[popup-open]:bg-interactive-active data-[popup-open]:text-foreground"),"aria-label":"File actions",title:"File actions",children:e.jsx(F,{name:"more-fill",className:"size-4"})})}),e.jsxs(ln,{align:"end",className:"min-w-[13rem]","aria-label":`Actions for ${n}`,children:[ve.map((je,B)=>e.jsxs(a.Fragment,{children:[B>0?e.jsx(Bn,{}):null,je]},B)),We?e.jsxs(e.Fragment,{children:[ve.length>0?e.jsx(Bn,{}):null,e.jsx(fe,{onSelect:Le,children:e.jsx(Ae,{label:te?"Exit full screen":"Full screen"})})]}):null]})]})},ul=2,dl=24,fl=6,ml=(t,n)=>{let s=0;for(const i of t)if(i===" ")s+=1;else if(i===" ")s+=n-s%n;else break;return s},Ss=new Map,pl=t=>{let n=Ss.get(t);if(!n){const s=t+ul;n=Tt.line({attributes:{style:`padding-left: calc(${fl}px + ${s}ch); text-indent: -${s}ch`}}),Ss.set(t,n)}return n},Rs=t=>{const n=new an,{doc:s,tabSize:i}=t.state;for(const{from:o,to:u}of t.visibleRanges){let f=o;for(;f<=u;){const d=s.lineAt(f),h=Math.min(ml(d.text,i),dl);n.add(d.from,d.from,pl(h)),f=d.to+1}}return n.finish()},hl=Hn.fromClass(class{decorations;constructor(t){this.decorations=Rs(t)}update(t){(t.docChanged||t.viewportChanged)&&(this.decorations=Rs(t.view))}},{decorations:t=>t.decorations}),Du=({mode:t="full",chrome:n="desktop",onClose:s,isVisible:i=!0})=>{const{files:o,runtime:u}=bi(),f=n==="mobile",{currentTheme:d,availableThemes:h,lightThemeId:C,darkThemeId:z}=yi(),{isMobile:b,isTablet:v,screenWidth:k}=wi(),j=ci(u.platform),y=b||v,P=li(),K=ji()??"",l=ce(K.trim()),$=el(n,t),H=t!=="editor-only",I=t==="editor-only"&&!b,M=ki(K),[q,_]=a.useState(""),J=a.useRef(null),[A,D]=a.useState(!1),[x,V]=a.useState(l),[N,S]=a.useState(!1),[g,R]=a.useState(null),E=ye(r=>r.wrapLinesByDefault),L=g??E,Y=a.useCallback(r=>{R(r)},[]),[G,Z]=a.useState(!1),[ie,W]=a.useState(!1);a.useEffect(()=>{f&&(V(l),_(""),D(!1))},[f,l]);const te=a.useRef(0),Le=a.useCallback(r=>{te.current=Math.max(0,te.current+(r?1:-1))},[]),xe=a.useMemo(()=>h.find(r=>r.metadata.id===C)??Wr(!1),[h,C]),le=a.useMemo(()=>h.find(r=>r.metadata.id===z)??Wr(!0),[h,z]);a.useEffect(()=>{Xr(xe),Xr(le)},[xe,le]);const Fe=a.useMemo(()=>[],[]),se=Oe(r=>l?r.byRoot[l]?.openPaths??Fe:Fe),me=Oe(r=>l?r.byRoot[l]?.selectedPath??null:null),Ce=Oe(r=>l?r.byRoot[l]?.expandedPaths??Fe:Fe),ne=Oe(r=>r.removeOpenPath),re=Oe(r=>r.removeOpenPathsByPrefix),We=Oe(r=>r.removeExpandedPathsByPrefix),ve=Oe(r=>r.setSelectedPath),je=Oe(r=>r.toggleExpandedPath),B=Oe(r=>r.expandPaths),{childrenByDir:ue,loadErrorsByDir:ae,isLoaded:Q,loadDirectory:pe,refreshDirectory:At,refreshRoot:ca}=nl({files:o,root:l,activeDirectory:f?x:void 0,expandedPaths:Ce,chrome:n,showGitignored:P,removeExpandedPathsByPrefix:We,enabled:$,visible:i}),Xe=a.useCallback(r=>{const p=ce(r),O=p.split("/"),T=O[O.length-1]||p,oe=T.includes(".")?T.split(".").pop()?.toLowerCase():void 0;return{name:T,path:p,type:"file",extension:oe}},[]),Ot=a.useMemo(()=>se.map(Xe),[se,Xe]),dn=a.useMemo(()=>{if(me){const r=tn(me);if(se.some(p=>tn(p)===r))return me}return se[0]??null},[se,me]),m=a.useMemo(()=>dn?Xe(dn):null,[dn,Xe]),He=m?.path??"";a.useEffect(()=>{if(!l||!me)return;const r=tn(me);se.some(O=>tn(O)===r)||ve(l,se[0]??null)},[se,l,me,ve]);const Lt=!!(l&&He&&!Dn(He,l)),qn=Lt?qr(He):void 0,ge=a.useMemo(()=>({allowOutsideWorkspace:t==="editor-only"&&Lt,outsideFileGrant:qn,directory:l||void 0}),[t,Lt,qn,l]),fn=a.useRef(null),[la,ua]=a.useState({left:!1,right:!1}),Gn=a.useCallback(()=>{const r=fn.current;r&&ua({left:r.scrollLeft>2,right:r.scrollLeft+r.clientWidth<r.scrollWidth-2})},[]),Un=a.useRef(Gn);Un.current=Gn,a.useEffect(()=>{const r=fn.current;if(!r)return;const p=()=>Un.current();p(),r.addEventListener("scroll",p,{passive:!0});const O=new ResizeObserver(p);return O.observe(r),()=>{r.removeEventListener("scroll",p),O.disconnect()}},[Ot.length]);const[Ee,_e]=a.useState(""),[mn,dt]=a.useState(!1),[Xn,Ne]=a.useState(null),[da,Je]=a.useState(""),Se=a.useRef(""),[et,ze]=a.useState(null),[ft,Me]=a.useState(void 0),[Jn,De]=a.useState(null),Re=Oe(r=>r.activeRuntimeKey),[be,Ke]=a.useState(null),[pn,Yn]=a.useState(!1),[fa,Pe]=a.useState(!1),[mt,Te]=a.useState(""),[ma,pa]=a.useState(`
|
|
4
|
-
`),
|
|
3
|
+
… truncated …`:u,lineEnding:$i(o)}}function Vc({isDirty:t,saveDraft:n}){const s=ye(v=>v.setMainTabGuard),[i,o]=w.useState(!1),u=w.useRef(null),f=w.useRef(!1),d=w.useCallback(v=>f.current?(f.current=!1,!1):t?(u.current=v,o(!0),!0):!1,[t]);w.useEffect(()=>{if(!t){s(null);return}const v=k=>!d({kind:"tab",tab:k});return s(v),()=>{ye.getState().mainTabGuard===v&&s(null)}},[t,d,s]);const h=w.useCallback(()=>{const v=u.current;return u.current=null,f.current=!0,o(!1),v?.kind==="tab"&&s(null),v},[s]),C=w.useCallback(()=>h(),[h]),z=w.useCallback(async()=>await n()?h():(f.current=!1,null),[n,h]),b=w.useCallback(v=>{v||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:C,keepModalOpen:b,requestNavigation:d,saveAndTakeIntent:z}}function Wc(t,n){if(t.state.doc.length!==n.length)return!1;if(n.length===0)return!0;const s=Math.min(128,n.length);if(t.state.sliceDoc(0,s)!==n.slice(0,s))return!1;const i=Math.max(0,n.length-s);return t.state.sliceDoc(i,n.length)===n.slice(i)}function _c({root:t,selectedPath:n,loadedPath:s,fileLoading:i,fileError:o,isImage:u,isPdf:f,isUnsupportedBinary:d,canEdit:h,textViewMode:C,setTextViewMode:z,draftContent:b,confirmDiscardOpen:v,selectFilePath:k}){const j=ye(A=>A.pendingFileNavigation),y=ye(A=>A.setPendingFileNavigation),L=ye(A=>A.pendingFileFocusPath),K=ye(A=>A.setPendingFileFocusPath),l=w.useRef(null),[$,H]=w.useState(0),I=w.useRef(null),M=w.useRef({key:"",attempts:0}),q=w.useCallback(()=>{H(A=>A+1)},[]);w.useEffect(()=>()=>{I.current!==null&&window.cancelAnimationFrame(I.current)},[]),w.useEffect(()=>{if(!j||!t)return;const A=()=>{I.current===null&&(I.current=window.requestAnimationFrame(()=>{I.current=null,q()}))},D=()=>{y(null),M.current={key:"",attempts:0}},x=ce(j.path);if(!x){D();return}const V=`${x}:${j.line}:${j.column??1}`;if(M.current.key!==V&&(M.current={key:V,attempts:0}),n!==x){v||k(x);return}if(i||s!==x)return;if(o||u||f||d){D();return}if(!h)return;if(C!=="edit"){z("edit");return}const N=l.current;if(!N||!Wc(N,b)){A();return}const S=Math.max(1,Math.min(j.line,N.state.doc.lines)),g=N.state.doc.line(S),R=Math.max(1,j.column||1),E=g.from+Math.min(Math.max(0,g.to-g.from),R-1);if(!(N.state.selection.main.head===E)||M.current.attempts===0){M.current.attempts+=1,N.dispatch({selection:{anchor:E},effects:we.scrollIntoView(E,{y:"center"})}),N.focus(),A();return}window.requestAnimationFrame(()=>{const Y=l.current;Y&&(Y.dispatch({selection:{anchor:E},effects:we.scrollIntoView(E,{y:"center"})}),Y.focus())}),D()},[h,v,b,$,o,i,u,f,d,s,q,j,t,n,k,y,z,C]),w.useEffect(()=>{if(!L||!t)return;const A=ce(L);if(!A){K(null);return}n!==A||i||s!==A||(!o&&!u&&!f&&!d&&h&&C==="edit"&&l.current?.focus(),K(null))},[h,o,i,u,f,d,s,L,t,n,K,C]);const _=ce(j?.path??"");return{editorViewRef:l,notifyEditorViewChanged:q,shouldMaskEditor:!!(j&&_&&n===_&&!i&&!o&&!u&&!f&&!d)}}function Kc(t){return!(!t.autoSaveEnabled||!t.isDirty||!t.canWrite||t.isSaving||t.fileLoading||t.isNonEditableBinary||!t.selectedFilePath||t.loadedFilePath!==t.selectedFilePath)}function Hc(t){return t.selectedFilePath?t.isDirty?!(t.fileLoading||t.loadedFilePath!==t.selectedFilePath||t.isNonEditableBinary||t.draftContent===""&&t.fileContent!==""&&t.loadedFilePath!==t.selectedFilePath):!0:!1}const qc=1500,Gc=2e3;function Uc({autoSaveEnabled:t,selectedPath:n,loadedPath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,lineEnding:d,isNonEditableBinary:h,writeFile:C,expectedRevision:z,onSaved:b,captureSaveScope:v,currentSaveScope:k,onConflict:j}){const[y,L]=w.useState(!1),[K,l]=w.useState("idle"),[$,H]=w.useState(null),I=w.useRef(null),M=w.useRef(null),q=w.useRef(j);q.current=j;const _=w.useRef(v);_.current=v;const J=w.useRef(k);J.current=k;const A=w.useCallback(S=>S?Xs(S,J.current?.()??null):!0,[]),D=w.useCallback(()=>{I.current&&(clearTimeout(I.current),I.current=null)},[]),x=w.useCallback(()=>{l("saved"),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{M.current=null,l("idle")},Gc)},[]),V=w.useCallback(async S=>{if(!n||!C)return he.error("Saving not supported"),!1;if(!Hc({selectedFilePath:n,loadedFilePath:s,fileLoading:i,isDirty:o,draftContent:u,fileContent:f,isNonEditableBinary:h}))return h?console.warn(`[saveDraft] refusing to save binary file "${n}".`):u===""&&f!==""&&s!==n&&console.warn(`[saveDraft] refusing to save empty draft for "${n}" (${f.length} bytes were expected). The file may have been read during a concurrent write (O_TRUNC race). Try again after content finishes loading if the save was intentional.`),!1;if(!o)return!0;L(!0);const g=_.current?.()??null;try{const R=Bi(u,d),E=Js(z,S?.overwrite),P=await C(n,R,E);return P?.success?A(g)?(H(null),b(n,u,P?.revision,g),!0):!1:(he.error("Failed to write file"),!1)}catch(R){if(Ds(R)){if(!A(g))return!1;const E={path:n,currentRevision:R.currentRevision??null,exists:R.exists};return H(E),q.current?.(E),!1}return he.error(R instanceof Error?R.message:"Save failed"),!1}finally{L(!1)}},[u,z,f,i,o,h,A,d,s,b,n,C]),N=w.useCallback(async S=>{if(D(),y)return!1;const g=await V(S);return g&&x(),g},[D,y,V,x]);return w.useEffect(()=>{t||(l("idle"),D())},[t,D]),w.useEffect(()=>{if(Kc({autoSaveEnabled:t,isDirty:o,canWrite:!!(n&&C),isSaving:y,fileLoading:i,selectedFilePath:n,loadedFilePath:s,isNonEditableBinary:h}))return I.current=setTimeout(()=>{I.current=null,V().then(S=>{S&&x()})},qc),D},[t,D,u,i,o,h,y,s,V,n,x,C]),w.useEffect(()=>{l("idle"),L(!1),H(null)},[n]),w.useEffect(()=>()=>{D(),M.current&&clearTimeout(M.current)},[D]),{autoSaveStatus:K,cancelPendingAutosave:D,isSaving:y,saveConflict:$,clearSaveConflict:()=>H(null),saveDraft:V,saveNow:N}}function Xc(t,n){return typeof t.revision=="string"&&typeof n.revision=="string"&&t.revision!==n.revision?!0:n.mtimeMs!==void 0&&t.mtimeMs!==void 0&&n.mtimeMs!==t.mtimeMs||n.size!==t.size}function Jc({selectedPath:t,loadedPath:n,isDirty:s,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const f=w.useRef(null),d=w.useRef(s);d.current=s;const h=w.useCallback(C=>{f.current=C},[]);return w.useEffect(()=>{if(!t||n!==t)return;let C=!1;const z=window.setInterval(()=>{if(document.hidden)return;const b=f.current,v=b&&b.path===t&&typeof b.revision=="string"?b.revision:null;i(t,{knownRevision:v}).then(k=>{if(C||!k)return;const j=f.current;if(!j||j.path!==t){f.current=k;return}!Xc(j,k)||d.current||(f.current=k,o())}).catch(()=>{})},u);return()=>{C=!0,window.clearInterval(z)}},[n,o,u,i,t]),{recordStat:h}}const ys="pichamber:files:md-viewer-mode",ws="pichamber:files:html-viewer-mode",js="pichamber:files:json-viewer-mode",Yc=1500,Zc=1500;function Pn(t,n,s){try{const i=localStorage.getItem(t);if(i&&n.includes(i))return i}catch{}return s}function Ln(t,n){try{localStorage.setItem(t,n)}catch{}}function Qc({root:t,selectedPath:n,fileContent:s,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:f,expectedRevision:d,captureSaveScope:h,currentSaveScope:C,onSaved:z,onConflict:b}){const[v,k]=w.useState("edit"),[j,y]=w.useState("edit"),[L,K]=w.useState("text"),[l,$]=w.useState("edit"),[H,I]=w.useState("edit"),[M,q]=w.useState(0),[_,J]=w.useState(!1),A=w.useRef({}),D=w.useRef({}),x=w.useRef({}),V=w.useRef({}),N=w.useRef(""),S=w.useRef(""),g=w.useRef(null),R=w.useRef(null),E=w.useRef(null),P=w.useRef(d);P.current=d;const Y=w.useRef(h);Y.current=h;const G=w.useRef(C);G.current=C;const Q=w.useRef(z);Q.current=z;const ie=w.useRef(b);ie.current=b;const W=w.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null),E.current!==null&&(cancelAnimationFrame(E.current),E.current=null)},[]),te=w.useCallback(B=>{N.current=B,S.current=B},[]),Pe=w.useCallback(()=>te(""),[te]);w.useEffect(()=>{n&&(k(A.current[n]??"edit"),y(D.current[n]??Pn(ys,["preview","edit"],"edit")),$(x.current[n]??Pn(ws,["preview","edit"],"edit")),I(V.current[n]??"edit"),K(Pn(js,["tree","text"],"text")))},[n]);const xe=w.useCallback(B=>{n&&(A.current[n]=B),k(B)},[n]),le=w.useCallback(B=>{n&&(D.current[n]=B),y(B),Ln(ys,B)},[n]),Fe=w.useCallback(B=>{n&&(x.current[n]=B),$(B),Ln(ws,B)},[n]),se=w.useCallback(B=>{K(B),Ln(js,B)},[]),me=w.useCallback(B=>{if(n&&(V.current[n]=B),W(),B==="edit"){o(N.current||s),I(B);return}N.current=i;const ue=n;I("edit"),E.current=requestAnimationFrame(()=>{E.current=requestAnimationFrame(()=>{E.current=null,!(t&&ue&&Oe.getState().byRoot[t]?.selectedPath!==ue)&&(q(ae=>ae+1),I("preview"))})})},[W,i,s,t,n,o]),Ce=w.useCallback(B=>B?Xs(B,G.current?.()??null):!0,[]),ne=w.useCallback(async(B,ue,ae)=>{if(!f||ue===S.current)return!1;const Z=Y.current?.()??null;if(Z&&Z.path!==B)return!1;try{const pe=await f(B,ue,Js(P.current,ae?.overwrite));return pe?.success?Ce(Z)?(te(ue),o(ue),Q.current?.(B,ue,pe?.revision,Z),!0):!1:(he.error("Failed to write file"),!1)}catch(pe){return Ds(pe)?(Ce(Z)&&ie.current?.({path:B,currentRevision:pe.currentRevision??null,exists:pe.exists,xml:ue}),!1):(he.error(pe instanceof Error?pe.message:"Save failed"),!1)}},[Ce,te,o,f]),re=w.useCallback(()=>{J(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>J(!1),Zc)},[]),We=w.useCallback(async(B,ue,ae)=>{g.current&&(clearTimeout(g.current),g.current=null);const Z=await ne(B,ue,ae);return Z&&re(),Z},[ne,re]),ve=w.useCallback(B=>{N.current=B,!(!u||!n||H!=="preview"||!f)&&(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,ne(n,B).then(ue=>{ue&&re()})},Yc))},[u,H,ne,n,re,f]);w.useEffect(()=>W,[W,H,n]),w.useEffect(()=>()=>{R.current&&clearTimeout(R.current)},[]);const je=rn(n??"")&&(N.current||i)||s;return{clearDiagramContent:Pe,diagramEditorXml:je,diagramSaved:_,drawioRemountNonce:M,drawioViewMode:H,handleDiagramChange:ve,htmlViewMode:l,jsonViewMode:L,mdViewMode:j,recordDiagramContent:te,saveDiagramNow:We,saveDiagramXml:ne,saveDrawioViewMode:me,saveHtmlViewMode:Fe,saveJsonViewMode:se,saveMdViewMode:le,saveTextViewMode:xe,setTextViewMode:k,textViewMode:v}}function el(t,n){return t==="mobile"?!0:n==="full"}function tl(t,n){if(t===n)return!0;if(t.length!==n.length)return!1;for(let s=0;s<t.length;s+=1){const i=t[s],o=n[s];if(i.name!==o.name||i.path!==o.path||i.type!==o.type||i.extension!==o.extension||i.relativePath!==o.relativePath||i.size!==o.size)return!1}return!0}function nl({files:t,root:n,activeDirectory:s,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:f,enabled:d=!0,visible:h=!0}){const[C,z]=a.useState({}),[b,v]=a.useState({}),k=a.useRef(new Set),j=a.useRef(new Set),y=a.useRef(new Map),L=a.useRef(new Map),K=a.useRef(0),l=a.useRef(!1),[$,H]=a.useState(()=>ai());a.useEffect(()=>oi(S=>{H(S.runtimeKey)}),[]),a.useEffect(()=>(l.current=!1,()=>{l.current=!0,L.current=new Map,j.current=new Set,y.current=new Map}),[]);const I=a.useCallback((S,g)=>{const R=[];for(const E of g){if(!E?.name||Vi(E.name)||o==="desktop"&&!u&&Wi(E.name))continue;const P=ce(E.path||""),Y=P?_i(P)?P:ce(`${S}/${P}`):ce(`${S}/${E.name}`),G=E.isDirectory?"directory":"file";R.push({name:E.name,path:Y,type:G,extension:G==="file"&&E.name.includes(".")?E.name.split(".").pop()?.toLowerCase():void 0,size:E.size})}return Ki(R)},[o,u]),M=`${$}|${n}|g${u?"1":"0"}|${o}`,q=a.useRef(M);q.current=M;const _=a.useCallback(async S=>{if(!d)return;const g=ce(S.trim());if(!g||k.current.has(g))return;const R=y.current.get(g);if(R){await R;return}const E=q.current,P=K.current+1;K.current=P,L.current=new Map(L.current).set(g,P),j.current=new Set(j.current).add(g);const Y=()=>!l.current&&q.current===E&&L.current.get(g)===P,G=(async()=>{try{const Q=t.listDirectory?(await t.listDirectory(g)).entries.map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory,size:W.size})):(await ii(g)).map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory}));if(!Y())return;k.current=new Set(k.current).add(g),v(W=>{if(!W[g])return W;const te={...W};return delete te[g],te});const ie=I(g,Q);z(W=>{const te=W[g];return te&&tl(te,ie)?W:{...W,[g]:ie}})}catch(Q){if(!Y())return;const ie=Q instanceof Error?Q.message:String(Q??"");ie==="Directory not found"&&n&&g!==n?(f(n,g),v(W=>{if(!W[g])return W;const te={...W};return delete te[g],te})):(console.error("Failed to load files directory:",Q),v(W=>({...W,[g]:ie})))}finally{L.current.get(g)===P&&(L.current=new Map(L.current),L.current.delete(g))}})();y.current.set(g,G);try{await G}finally{y.current.get(g)===G&&(y.current.delete(g),j.current=new Set(j.current),j.current.delete(g))}},[d,t,I,f,n]),J=a.useCallback(()=>{k.current=new Set,j.current=new Set,y.current=new Map,L.current=new Map,v({}),z(S=>Object.keys(S).length===0?S:{})},[]),A=a.useCallback(async()=>{!d||!n||(J(),await _(n))},[d,_,J,n]),D=a.useCallback(async S=>{if(!d)return;if(!S){await A();return}const g=ce(S);k.current=new Set(k.current),k.current.delete(g),j.current=new Set(j.current),j.current.delete(g),y.current.delete(g),L.current=new Map(L.current),L.current.delete(g),await _(g)},[d,_,A]),x=a.useRef("");a.useEffect(()=>{x.current!==M&&(x.current=M,J())},[J,M]),a.useEffect(()=>{!d||!h||!n||k.current.has(ce(n))||_(n)},[d,_,n,M,h]),a.useEffect(()=>{!d||!h||!s||_(s)},[s,d,_,h]),a.useEffect(()=>{if(!d||!h||!t.listDirectory)return;const S=P=>{const Y=ce(P);return y.current.has(Y)||j.current.has(Y)},g=()=>{if(!(typeof document<"u"&&document.hidden))for(const P of i)S(P)||D(P)},R=()=>{typeof document<"u"&&document.hidden||g()};typeof document<"u"&&document.addEventListener("visibilitychange",R);const E=i.length>0?window.setInterval(g,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",R),E!==null&&window.clearInterval(E)}},[d,i,t.listDirectory,D,h]);const V=a.useRef(d&&h);a.useEffect(()=>{const S=d&&h,g=V.current;if(V.current=S,!(!S||g)){if(!t.listDirectory){n&&!k.current.has(ce(n))&&_(n);return}if(i.length===0){n&&!k.current.has(ce(n))&&_(n);return}for(const R of i){const E=ce(R);y.current.has(E)||j.current.has(E)||D(R)}}},[d,i,t.listDirectory,_,D,n,h]);const N=a.useCallback(S=>k.current.has(ce(S)),[]);return{childrenByDir:C,loadErrorsByDir:b,isLoaded:N,loadDirectory:_,refreshDirectory:D,refreshRoot:A}}const rl=({showEditorTabsRow:t,isMobile:n,showMobilePageContent:s,onBackMobile:i,selectedFile:o,openFiles:u,root:f,alwaysShowActions:d,editorTabsOverflow:h,editorTabsScrollRef:C,onSelectFile:z,onCloseFile:b})=>t?e.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[n&&s&&e.jsx("button",{type:"button",onClick:i,"aria-label":"Back",className:"inline-flex size-7 flex-shrink-0 items-center justify-center mr-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",children:e.jsx(F,{name:"arrow-left-s",className:"size-5"})}),n?o?e.jsxs(on,{children:[e.jsx(cn,{asChild:!0,children:e.jsxs("button",{type:"button",className:"inline-flex min-w-0 max-w-full items-center gap-1 text-left typography-ui-label font-medium","aria-label":"Open files",children:[e.jsx(jt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(os,{name:o.name}),e.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),e.jsx(ln,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(v=>{const k=o?.path===v.path;return e.jsxs(fe,{onSelect:j=>{if(j.target.closest("[data-close-open-file]")){j.preventDefault();return}k||z(v)},className:X("flex min-w-0 items-center justify-between gap-2 overflow-hidden",k&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[e.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[e.jsx(jt,{filePath:v.path,extension:v.extension,className:"size-3.5 flex-shrink-0"}),e.jsx(os,{name:v.name})]}),e.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:j=>{j.preventDefault(),j.stopPropagation()},onClick:j=>{j.preventDefault(),j.stopPropagation(),b(v.path)},className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]","aria-label":`Close ${v.name}`,children:e.jsx(F,{name:"close",className:"size-3.5"})})]},v.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?e.jsxs("div",{className:"relative min-w-0 flex-1",children:[h.left&&e.jsx("div",{className:"pointer-events-none absolute left-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-r from-background to-transparent"}),h.right&&e.jsx("div",{className:"pointer-events-none absolute right-0 top-0 bottom-0 w-6 z-10 bg-gradient-to-l from-background to-transparent"}),e.jsx("div",{ref:C,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},"data-no-drawer-swipe":"true",children:u.map(v=>{const k=o?.path===v.path;return e.jsxs("div",{title:kt(f,v.path),className:X("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",k?"bg-[var(--interactive-selection)] border-[var(--primary-muted)] text-[var(--interactive-selection-foreground)]":"bg-transparent border-[var(--interactive-border)] text-[var(--surface-muted-foreground)] hover:bg-[var(--interactive-hover)] hover:text-[var(--surface-foreground)]"),children:[e.jsx(jt,{filePath:v.path,extension:v.extension,className:"size-3.5 flex-shrink-0"}),e.jsx("button",{type:"button",onClick:()=>{k||z(v)},className:"max-w-[12rem] truncate text-left",children:v.name}),e.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),b(v.path)},className:X("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!k&&!d&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${v.name}`,children:e.jsx(F,{name:"close",className:"size-3.5"})})]},v.path)})})]}):e.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,sl=(t,n)=>{if(!n)return null;const s=Number.parseInt(t.trim(),10);return!Number.isFinite(s)||s<1?null:Math.min(s,n.state.doc.lines)},ks=(t,n)=>{const s=t.state.doc.lineAt(n.main.head);return{lineNumber:s.number,character:n.main.head-s.from+1,selection:n}},Cs=(t,n,s)=>{const i=t.state.doc.line(n),o=Math.max(1,Math.min(s,i.length+1)),u=i.from+o-1;t.dispatch({selection:Qo.cursor(u),effects:we.scrollIntoView(u,{y:"center"})})};function ia({open:t,onOpenChange:n,view:s,variant:i="overlay"}){const[o,u]=a.useState(""),f=a.useRef(null),d=a.useRef(!1),h=a.useRef(null),C=a.useRef(null),z=a.useMemo(()=>sl(o,s),[o,s]);a.useEffect(()=>{!t||!s||(d.current=!1,f.current=ks(s,s.state.selection),u(""))},[t,s]),a.useEffect(()=>{t&&window.requestAnimationFrame(()=>{C.current?.focus(),C.current?.select()})},[t]),a.useEffect(()=>{if(!(!t||!s||!f.current)){if(z===null){const{selection:y}=f.current;s.dispatch({selection:y,effects:we.scrollIntoView(y.main.from,{y:"center"})});return}Cs(s,z,f.current.character)}},[z,t,s]);const b=a.useCallback(()=>{if(!s||d.current||!f.current)return;const{selection:y}=f.current;s.dispatch({selection:y,effects:we.scrollIntoView(y.main.from,{y:"center"})})},[s]),v=a.useCallback(y=>{y||b(),n(y)},[n,b]),k=a.useCallback(()=>{!s||z===null||!f.current||(d.current=!0,Cs(s,z,f.current.character),n(!1),s.focus())},[z,n,s]);a.useEffect(()=>{if(!t)return;const y=K=>{const l=h.current,$=K.target;!l||!($ instanceof Node)||l.contains($)||v(!1)},L=K=>{K.key==="Escape"&&(K.preventDefault(),v(!1))};return document.addEventListener("pointerdown",y,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",y,!0),document.removeEventListener("keydown",L,!0)}},[v,t,i]);const j=a.useMemo(()=>s?z===null?`Current Line: ${(f.current??ks(s,s.state.selection)).lineNumber}. Type a line number between 1 and ${s.state.doc.lines} to navigate to.`:`Go to line ${z}`:"Editor unavailable.",[z,s]);return i==="inline"?t?e.jsxs("div",{ref:h,className:"ml-1 flex h-6 items-center gap-1",children:[e.jsx(Dt,{ref:C,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:y=>u(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),k())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),e.jsx(U,{variant:"outline",size:"xs",onClick:k,disabled:!s||z===null,className:"h-6 px-2",children:"Go"})]}):null:e.jsx("div",{ref:h,className:X("absolute left-3 top-3 z-40 w-[min(32rem,calc(100%-1.5rem))] rounded-xl border border-[var(--interactive-border)] bg-[color:color-mix(in_srgb,var(--surface-elevated)_94%,transparent)] p-2.5 shadow-lg backdrop-blur-sm transition-all",t?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:e.jsxs("div",{className:"min-w-0",children:[e.jsx(Dt,{ref:C,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:y=>u(y.target.value),onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),k())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),e.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground",children:j})]})})}const In=({currentMode:t,onToggle:n})=>{const s=t==="preview",i=s?"Switch to edit mode":"Switch to preview mode",o=s?"Edit":"Preview";return e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",onClick:n,"aria-label":i,className:"h-5 w-5 p-0",children:s?e.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):e.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),e.jsx(lt,{sideOffset:8,children:o})]})},al=({selectedFile:t,displaySelectedPath:n,layout:s="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:f,autoSaveEnabled:d,autoSaveStatus:h,isDirty:C,onSaveDraft:z,onToggleAutoSave:b,canOpenInDesktopApp:v=!0,openInApps:k,openInCacheStale:j,onOpenInApp:y,onRefreshOpenInApps:L,onToolbarDropdownOpenChange:K,isSelectedImage:l,isSelectedPdf:$,isUnsupportedBinary:H,wrapLines:I,onToggleWrapLines:M,textViewMode:q,onToggleSearch:_,isGoToLineOpen:J,onOpenGoToLineChange:A,editorView:D,canUseShikiFileView:x,isJson:V,isHtml:N,onToggleTextViewMode:S,isMarkdown:g,mdViewMode:R,onToggleMdViewMode:E,isDrawio:P,drawioViewMode:Y,onToggleDrawioViewMode:G,diagramSaved:Q,onSaveDiagram:ie,jsonViewMode:W,onToggleJsonViewMode:te,canCopy:Pe,copiedContent:xe,onCopyContent:le,canCopyPath:Fe,copiedPath:se,onCopyPath:me,onDownloadFile:Ce,isMobile:ne,mode:re,isFullscreen:We,onToggleFullscreen:ve,onExitFullscreen:je})=>{if(!t)return null;const ue=s==="docked"?"pointer-events-auto flex flex-wrap items-center gap-1":"pointer-events-auto flex items-center gap-1 rounded-lg border border-[var(--interactive-border)] bg-[var(--surface-elevated)] p-1 shadow-sm",ae=(Z,pe)=>e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:pe})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:Z})]});return e.jsxs("div",{className:ue,children:[o&&u&&e.jsxs(e.Fragment,{children:[f?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[e.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):d&&h==="saved"&&!C?e.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[e.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):C?ae(d?`Save now (${bt()}+S) - auto-saves after 1.5s`:`Save now (${bt()}+S)`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{z()},className:"h-6 gap-1 px-1 text-muted-foreground opacity-80 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:d?`Save now (${bt()}+S) - auto-saves after 1.5s`:`Save now (${bt()}+S)`,"aria-label":`Save (${bt()}+S)`,children:e.jsx(F,{name:"save-3",className:"size-4"})})):null,ae(d?"Auto-save on":"Manual save",e.jsx(U,{variant:"ghost",size:"sm",onClick:b,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",d?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:d?"Auto-save on":"Manual save","aria-label":d?"Auto-save on":"Manual save",children:d?e.jsx(F,{name:"file-check-fill",className:"size-4"}):e.jsx(F,{name:"file-check",className:"size-4"})}))]}),v?e.jsxs(on,{onOpenChange:K,children:[e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Open in desktop app","aria-label":"Open in desktop app",children:e.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),e.jsxs(ln,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[k.map(Z=>e.jsxs(fe,{className:"flex items-center gap-2",onClick:()=>{y(Z)},children:[e.jsx(oa,{label:Z.label,iconDataUrl:Z.iconDataUrl}),e.jsx("span",{className:"typography-ui-label text-foreground",children:Z.label})]},Z.id)),j?e.jsxs(fe,{className:"flex items-center gap-2",onClick:()=>{L()},children:[e.jsx(F,{name:"refresh",className:"size-4"}),e.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh apps"})]}):null]})]}):null,!l&&!$&&!H&&e.jsxs(e.Fragment,{children:[ae(I?"Disable line wrap":"Enable line wrap",e.jsx(U,{variant:"ghost",size:"sm",onClick:M,className:X("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",I?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:I?"Disable line wrap":"Enable line wrap",children:e.jsx(F,{name:"text-wrap",className:"size-4"})})),q==="edit"&&e.jsxs(e.Fragment,{children:[ae("Find in file",e.jsx(U,{variant:"ghost",size:"sm",onClick:Z=>{_(),Z.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Find in file",children:e.jsx(F,{name:"search",className:"size-4"})})),ae("Go to line",e.jsx(U,{variant:"ghost",size:"sm",onClick:Z=>{A(!J),Z.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Go to line",children:e.jsx(F,{name:"menu-fold-2",className:"size-4"})})),e.jsx(ia,{open:J,onOpenChange:A,view:D,variant:"inline"})]})]}),x&&o&&!V&&!N&&e.jsx(In,{currentMode:q==="view"?"preview":"edit",onToggle:S}),g&&ae(R==="preview"?"Switch to edit mode":"Switch to preview mode",e.jsx(U,{variant:"ghost",size:"sm",onClick:E,className:X("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",R==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)] focus-visible:bg-[var(--interactive-selection)] active:bg-[var(--interactive-selection)]":"text-muted-foreground opacity-65 hover:opacity-100"),title:R==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":R==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(F,{name:R==="preview"?"eye":"eye-off",className:"size-4"})})),un(t?.path??"")&&e.jsx(In,{currentMode:N?"preview":"edit",onToggle:S}),P&&e.jsxs(e.Fragment,{children:[e.jsx(In,{currentMode:Y,onToggle:G}),Y==="preview"&&e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{ie()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:Q?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"save-3",className:"size-4"})})]}),V&&ae(W==="tree"?"Switch to text view":"Switch to tree view",e.jsx(U,{variant:"ghost",size:"sm",onClick:te,className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:W==="tree"?"Switch to text view":"Switch to tree view",children:W==="tree"?e.jsx(F,{name:"code-sslash",className:"size-4"}):e.jsx(F,{name:"node-tree",className:"size-4"})})),Pe&&ae("Copy file contents",e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{le()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Copy file contents","aria-label":"Copy file contents",children:xe?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"clipboard",className:"size-4"})})),Fe&&ae(`Copy file path (${n})`,e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{me()},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:`Copy file path (${n})`,"aria-label":`Copy file path (${n})`,children:se?e.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):e.jsx(F,{name:"file-copy-2",className:"size-4"})})),Ce&&ae("Save file",e.jsx(U,{variant:"ghost",size:"sm",onClick:Ce,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:e.jsx(F,{name:"download",className:"size-4"})})),i?ae("Exit fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:je,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:e.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!ne&&re==="full"&&ae(We?"Exit fullscreen":"Fullscreen",e.jsx(U,{variant:"ghost",size:"sm",onClick:ve,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:We?"Exit fullscreen":"Fullscreen","aria-label":We?"Exit fullscreen":"Fullscreen",children:We?e.jsx(F,{name:"fullscreen-exit",className:"size-4"}):e.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},ol=({open:t,onOpenChange:n,isSaving:s,onSaveAndContinue:i,onDiscardAndContinue:o})=>e.jsx(Ts,{open:t,onOpenChange:n,children:e.jsxs(As,{showCloseButton:!1,className:"max-w-md",children:[e.jsxs(Os,{children:[e.jsx(Ps,{children:"Unsaved changes"}),e.jsx(Ls,{children:"Save your edits before continuing?"})]}),e.jsxs(Is,{children:[e.jsx(U,{variant:"outline",onClick:i,disabled:s,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:"Save changes"}),e.jsx(U,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),il=({root:t,isMobile:n,searchQuery:s,onSearchQueryChange:i,searchInputRef:o,searching:u,searchFailed:f,searchResults:d,selectedFile:h,onSelectFile:C,onOpenDialog:z,currentDirectory:b,refreshRoot:v,childrenByDir:k,loadErrorsByDir:j,expandedPaths:y,isBrowserClient:L,alwaysShowActions:K,getFileStatus:l,getFolderBadge:$,fileRowPermissions:H,downloadFile:I,contextMenuPath:M,setContextMenuPath:q,rightClickMenuPath:_,setRightClickMenuPath:J,toggleDirectory:A,handleRevealPath:D,refreshDirectory:x})=>{const V=!!(t&&k[t]),N=s.trim().length>0,S=t?j[t]:null,g=a.useMemo(()=>Hi(y),[y]);function R(E,P){return(k[E]??[]).map(G=>{const Q=G.type==="directory",ie=Q&&g.has(G.path),W=h?.path===G.path;return e.jsxs("li",{className:"relative",children:[e.jsx(Fc,{node:G,root:t,isExpanded:ie,isActive:W,isMobile:n,isBrowserClient:L,alwaysShowActions:K,status:Q?void 0:l(G.path),badge:Q?$(G.path):void 0,permissions:H,downloadFile:I,contextMenuPath:M,setContextMenuPath:q,rightClickMenuPath:_,setRightClickMenuPath:J,onSelect:C,onToggle:A,onRevealPath:D,onOpenDialog:z}),Q&&ie&&e.jsxs("ul",{className:"relative ml-[15px] flex flex-col border-l border-border/50 pl-1.5",children:[j[G.path]?e.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[G.path],children:j[G.path]}),e.jsxs(U,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{x(G.path)},children:[e.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(G.path)]})]},G.path)})}return e.jsxs("section",{className:X("flex min-h-0 flex-col overflow-hidden",n?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[e.jsx("div",{className:X("flex flex-col gap-2 py-2",n?"px-3":"px-2"),children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1 min-w-0",children:[e.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),e.jsx(Dt,{ref:o,value:s,onChange:E=>i(E.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),s.trim().length>0&&e.jsx("button",{type:"button","aria-label":"Clear search",className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{i(""),o.current?.focus()},children:e.jsx(F,{name:"close",className:"size-4"})})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>z("createFile",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New file","aria-label":"New file",children:e.jsx(F,{name:"file-add",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"New File"})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>z("createFolder",{path:b,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New folder","aria-label":"New folder",children:e.jsx(F,{name:"folder-add",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"New Folder"})]}),e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex flex-shrink-0",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>{v()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:e.jsx(F,{name:"refresh",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),e.jsx($s,{outerClassName:"flex-1 min-h-0",className:X("py-2",n?"px-3":"px-2"),children:e.jsx("ul",{className:"flex flex-col",children:N&&u?e.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):N&&f?e.jsx("li",{className:"px-2 py-1 typography-meta text-[var(--status-error)]",children:"Search failed. Edit the search to try again."}):N&&d.length===0?e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground text-pretty",children:`No files match “${s.trim()}”.`}):N?d.map(E=>e.jsx("li",{children:e.jsx(qi,{path:E.relativePath||kt(t,E.path)||E.path,status:l(E.path),active:h?.path===E.path,match:s,onClick:()=>{C(E)}})},E.path)):S?e.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[e.jsx("span",{className:"text-[var(--status-error)]",children:S}),e.jsxs(U,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{v()},children:[e.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):V?R(t):e.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},Ns="min-w-0 truncate rounded px-1 py-0.5 text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50",cl=({path:t,status:n,className:s,rootLabel:i,onRevealFolder:o,onShowChanges:u,children:f})=>{const d=t.split("/").filter(Boolean),h=d.pop()??t,C=e.jsx("span",{"aria-hidden":"true",className:"shrink-0 text-subtle-foreground",children:"/"});return e.jsxs("div",{className:X("flex h-9 min-w-0 shrink-0 items-center gap-2 pl-2 pr-1",s),children:[e.jsxs("nav",{"aria-label":"File path",className:"flex min-w-0 flex-1 items-center gap-1.5 typography-meta",title:t,children:[e.jsxs("span",{className:"flex min-w-0 items-center",children:[o?e.jsxs(e.Fragment,{children:[i?e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:X(Ns,"max-w-[10rem] shrink"),onClick:()=>o(""),title:`Show ${i} in the tree`,children:i}),C]}):null,d.map((z,b)=>{const v=d.slice(0,b+1).join("/");return e.jsxs(a.Fragment,{children:[e.jsx("button",{type:"button",className:X(Ns,"shrink-[100]"),onClick:()=>o(v),title:`Show ${v} in the tree`,children:z}),C]},v)})]}):d.length>0?e.jsx("span",{className:"min-w-0 shrink-[100] truncate pl-1 text-muted-foreground [direction:rtl] [text-align:left]",children:e.jsx("bdi",{children:`${d.join("/")}/`})}):null,e.jsx("span",{"aria-current":"page",className:X("min-w-0 truncate font-medium text-foreground",o?"px-1":d.length===0&&"pl-1"),children:h})]}),n&&n!=="open"?e.jsx(Qs,{status:n}):null]}),u&&n&&n!=="open"?e.jsx(U,{type:"button",variant:"outline",size:"xs",onClick:u,className:"shrink-0",title:"Show this file's changes",children:"Changes"}):null,f?e.jsx("div",{className:"flex shrink-0 items-center gap-0.5",children:f}):null]})},Ae=({label:t,hint:n,checked:s})=>e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex-1",children:t}),n?e.jsx("span",{className:"ml-4 typography-micro text-muted-foreground",children:n}):null,s?e.jsx(F,{name:"check",className:"ml-4 size-4 text-foreground"}):null]}),ll=({selectedFile:t,displaySelectedPath:n,canEdit:s,isEditingFile:i,isSaving:o,autoSaveEnabled:u,isDirty:f,onSaveDraft:d,onToggleAutoSave:h,canOpenInDesktopApp:C=!0,openInApps:z,openInCacheStale:b,onOpenInApp:v,onRefreshOpenInApps:k,onToolbarDropdownOpenChange:j,isSelectedImage:y,isSelectedPdf:L,isUnsupportedBinary:K,wrapLines:l,onToggleWrapLines:$,textViewMode:H,onToggleSearch:I,onOpenGoToLineChange:M,canUseShikiFileView:q,isJson:_,isHtml:J,onToggleTextViewMode:A,isDrawio:D,drawioViewMode:x,onToggleDrawioViewMode:V,diagramSaved:N,onSaveDiagram:S,jsonViewMode:g,onToggleJsonViewMode:R,canCopy:E,onCopyContent:P,canCopyPath:Y,onCopyPath:G,onDownloadFile:Q,isMobile:ie,mode:W,isFullscreen:te,onToggleFullscreen:Pe})=>{if(!t)return null;const xe=bt(),le=!y&&!L&&!K,Fe=s&&i,se=le&&H==="edit",me=D?{label:x==="preview"?"Edit diagram source":"Show diagram",onSelect:V}:un(t.path)?{label:J?"Show source":"Show page preview",onSelect:A}:q&&s&&!_&&!J?{label:H==="view"?"Edit file":"Read only",onSelect:A}:null,Ce=Fe?e.jsxs(e.Fragment,{children:[f&&!o?e.jsx(fe,{onSelect:()=>{d()},children:e.jsx(Ae,{label:"Save now",hint:`${xe}+S`})}):null,e.jsx(fe,{onSelect:h,children:e.jsx(Ae,{label:"Save automatically",checked:u})})]}):null,ne=[];me&&ne.push(e.jsx(fe,{onSelect:me.onSelect,children:e.jsx(Ae,{label:me.label})},"view")),_&&ne.push(e.jsx(fe,{onSelect:R,children:e.jsx(Ae,{label:g==="tree"?"Show as text":"Show as tree"})},"json")),D&&x==="preview"&&ne.push(e.jsx(fe,{onSelect:()=>{S()},children:e.jsx(Ae,{label:N?"Diagram saved":"Save diagram"})},"diagram")),le&&ne.push(e.jsx(fe,{onSelect:$,children:e.jsx(Ae,{label:"Wrap long lines",checked:l})},"wrap")),se&&ne.push(e.jsx(fe,{onSelect:I,children:e.jsx(Ae,{label:"Find in file",hint:`${xe}+F`})},"find"),e.jsx(fe,{onSelect:()=>M(!0),children:e.jsx(Ae,{label:"Go to line"})},"line"));const re=[];E&&re.push(e.jsx(fe,{onSelect:()=>{P()},children:e.jsx(Ae,{label:"Copy contents"})},"copy")),Y&&re.push(e.jsx(fe,{onSelect:()=>{G()},children:e.jsx(Ae,{label:"Copy path"})},"path")),Q&&re.push(e.jsx(fe,{onSelect:Q,children:e.jsx(Ae,{label:"Download"})},"download")),C&&z.length>0&&re.push(e.jsxs(gi,{children:[e.jsx(xi,{children:"Open in"}),e.jsxs(vi,{className:"w-56 max-h-[70vh] overflow-y-auto",children:[z.map(je=>e.jsxs(fe,{className:"flex items-center gap-2",onSelect:()=>{v(je)},children:[e.jsx(oa,{label:je.label,iconDataUrl:je.iconDataUrl}),e.jsx("span",{className:"typography-ui-label text-foreground",children:je.label})]},je.id)),b?e.jsx(fe,{onSelect:()=>{k()},children:"Refresh apps"}):null]})]},"open-in"));const We=!ie&&W==="full",ve=[Ce,ne.length?ne:null,re.length?re:null].filter(Boolean);return e.jsxs(on,{onOpenChange:j,children:[e.jsx(cn,{asChild:!0,children:e.jsx(U,{variant:"ghost",size:"sm",className:X("size-7 p-0 text-muted-foreground hover:text-foreground data-[popup-open]:bg-interactive-active data-[popup-open]:text-foreground"),"aria-label":"File actions",title:"File actions",children:e.jsx(F,{name:"more-fill",className:"size-4"})})}),e.jsxs(ln,{align:"end",className:"min-w-[13rem]","aria-label":`Actions for ${n}`,children:[ve.map((je,B)=>e.jsxs(a.Fragment,{children:[B>0?e.jsx(Bn,{}):null,je]},B)),We?e.jsxs(e.Fragment,{children:[ve.length>0?e.jsx(Bn,{}):null,e.jsx(fe,{onSelect:Pe,children:e.jsx(Ae,{label:te?"Exit full screen":"Full screen"})})]}):null]})]})},ul=2,dl=24,fl=6,ml=(t,n)=>{let s=0;for(const i of t)if(i===" ")s+=1;else if(i===" ")s+=n-s%n;else break;return s},Ss=new Map,pl=t=>{let n=Ss.get(t);if(!n){const s=t+ul;n=Tt.line({attributes:{style:`padding-left: calc(${fl}px + ${s}ch); text-indent: -${s}ch`}}),Ss.set(t,n)}return n},Rs=t=>{const n=new an,{doc:s,tabSize:i}=t.state;for(const{from:o,to:u}of t.visibleRanges){let f=o;for(;f<=u;){const d=s.lineAt(f),h=Math.min(ml(d.text,i),dl);n.add(d.from,d.from,pl(h)),f=d.to+1}}return n.finish()},hl=Hn.fromClass(class{decorations;constructor(t){this.decorations=Rs(t)}update(t){(t.docChanged||t.viewportChanged)&&(this.decorations=Rs(t.view))}},{decorations:t=>t.decorations}),Du=({mode:t="full",chrome:n="desktop",onClose:s,isVisible:i=!0})=>{const{files:o,runtime:u}=bi(),f=n==="mobile",{currentTheme:d,availableThemes:h,lightThemeId:C,darkThemeId:z}=yi(),{isMobile:b,isTablet:v,screenWidth:k}=wi(),j=ci(u.platform),y=b||v,L=li(),K=ji()??"",l=ce(K.trim()),$=el(n,t),H=t!=="editor-only",I=t==="editor-only"&&!b,M=ki(K),[q,_]=a.useState(""),J=a.useRef(null),[A,D]=a.useState(!1),[x,V]=a.useState(l),[N,S]=a.useState(!1),[g,R]=a.useState(null),E=ye(r=>r.wrapLinesByDefault),P=g??E,Y=a.useCallback(r=>{R(r)},[]),[G,Q]=a.useState(!1),[ie,W]=a.useState(!1);a.useEffect(()=>{f&&(V(l),_(""),D(!1))},[f,l]);const te=a.useRef(0),Pe=a.useCallback(r=>{te.current=Math.max(0,te.current+(r?1:-1))},[]),xe=a.useMemo(()=>h.find(r=>r.metadata.id===C)??Wr(!1),[h,C]),le=a.useMemo(()=>h.find(r=>r.metadata.id===z)??Wr(!0),[h,z]);a.useEffect(()=>{Xr(xe),Xr(le)},[xe,le]);const Fe=a.useMemo(()=>[],[]),se=Oe(r=>l?r.byRoot[l]?.openPaths??Fe:Fe),me=Oe(r=>l?r.byRoot[l]?.selectedPath??null:null),Ce=Oe(r=>l?r.byRoot[l]?.expandedPaths??Fe:Fe),ne=Oe(r=>r.removeOpenPath),re=Oe(r=>r.removeOpenPathsByPrefix),We=Oe(r=>r.removeExpandedPathsByPrefix),ve=Oe(r=>r.setSelectedPath),je=Oe(r=>r.toggleExpandedPath),B=Oe(r=>r.expandPaths),{childrenByDir:ue,loadErrorsByDir:ae,isLoaded:Z,loadDirectory:pe,refreshDirectory:At,refreshRoot:ca}=nl({files:o,root:l,activeDirectory:f?x:void 0,expandedPaths:Ce,chrome:n,showGitignored:L,removeExpandedPathsByPrefix:We,enabled:$,visible:i}),Xe=a.useCallback(r=>{const p=ce(r),O=p.split("/"),T=O[O.length-1]||p,oe=T.includes(".")?T.split(".").pop()?.toLowerCase():void 0;return{name:T,path:p,type:"file",extension:oe}},[]),Ot=a.useMemo(()=>se.map(Xe),[se,Xe]),dn=a.useMemo(()=>{if(me){const r=tn(me);if(se.some(p=>tn(p)===r))return me}return se[0]??null},[se,me]),m=a.useMemo(()=>dn?Xe(dn):null,[dn,Xe]),He=m?.path??"";a.useEffect(()=>{if(!l||!me)return;const r=tn(me);se.some(O=>tn(O)===r)||ve(l,se[0]??null)},[se,l,me,ve]);const Pt=!!(l&&He&&!Dn(He,l)),qn=Pt?qr(He):void 0,ge=a.useMemo(()=>({allowOutsideWorkspace:t==="editor-only"&&Pt,outsideFileGrant:qn,directory:l||void 0}),[t,Pt,qn,l]),fn=a.useRef(null),[la,ua]=a.useState({left:!1,right:!1}),Gn=a.useCallback(()=>{const r=fn.current;r&&ua({left:r.scrollLeft>2,right:r.scrollLeft+r.clientWidth<r.scrollWidth-2})},[]),Un=a.useRef(Gn);Un.current=Gn,a.useEffect(()=>{const r=fn.current;if(!r)return;const p=()=>Un.current();p(),r.addEventListener("scroll",p,{passive:!0});const O=new ResizeObserver(p);return O.observe(r),()=>{r.removeEventListener("scroll",p),O.disconnect()}},[Ot.length]);const[Ee,_e]=a.useState(""),[mn,dt]=a.useState(!1),[Xn,Ne]=a.useState(null),[da,Je]=a.useState(""),Se=a.useRef(""),[et,ze]=a.useState(null),[ft,Me]=a.useState(void 0),[Jn,De]=a.useState(null),Re=Oe(r=>r.activeRuntimeKey),[be,Ke]=a.useState(null),[pn,Yn]=a.useState(!1),[fa,Le]=a.useState(!1),[mt,Te]=a.useState(""),[ma,pa]=a.useState(`
|
|
4
|
+
`),Zn=a.useRef(null),Ie=a.useRef(0),pt=a.useRef(null),[Qn,hn]=a.useState(!1),Lt=ye(r=>r.autoSaveEnabled),ha=ye(r=>r.setAutoSaveEnabled),ga=a.useRef(null),[xa,va]=a.useState(null),[ba,ya]=a.useState(null),{value:wa,show:ja}=Gr(!1,1200),{value:ka,show:Ca}=Gr(!1,1200),[er,tr]=a.useState(!1),Nt=a.useCallback(()=>{l&&ve(l,null),_e(""),Ne(null),Je(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),b&&D(!1)},[b,l,ve]),{operation:Na,target:Sa,inputValue:Ra,setInputValue:Fa,submitting:Ea,inputRef:za,open:Ma,close:Da,submit:Ta,capabilities:{canCreateFile:nr,canCreateFolder:rr,canRename:sr,canDelete:ar}}=Gi({files:o,root:l,selectedPath:m?.path??"",refreshDirectory:At,removeOpenPathsByPrefix:re,clearSelectedPath:Nt}),or=!!o.revealPath,gn=zs()&&Ms(),Aa=en(r=>r.availableApps),Oa=en(r=>r.isCacheStale),ir=en(r=>r.initialize),Pa=en(r=>r.loadInstalledApps);a.useEffect(()=>{gn&&ir()},[gn,ir]);const La=a.useCallback(r=>{o.revealPath&&o.revealPath(r).catch(()=>{he.error("Failed to reveal path")})},[o]),Ia=a.useCallback(async r=>{if(!m?.path||await ui(m.path,r.id,r.appName)||await _r(m.path,r.appName))return;const T=Ui(m.path)||l;T&&await _r(T,r.appName)||he.error(`Failed to open in ${r.appName}`)},[l,m?.path]),$a=ye(r=>r.fileEditorKeymap),cr=ye(r=>r.expandedEditorToolbar);a.useEffect(()=>{Te("")},[m?.path]);const lr=a.useRef("");a.useEffect(()=>{!l||lr.current===l||(lr.current=l,_e(""),Ne(null),Je(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),D(!1))},[l]);const ur=a.useRef(Re);a.useEffect(()=>{ur.current!==Re&&(ur.current=Re,Ie.current+=1,pt.current=null,_e(""),Te(""),Ne(null),dt(!1),Je(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),hn(!1))},[Re]);const Ba=f?x:K,{results:dr,searching:fr,failed:mr}=Xi({directory:Ba,query:q,chrome:n,showGitignored:L}),It=a.useCallback(async(r,p)=>{if(o.readFile){const Ve=await o.readFile(r,{...p??{},directory:l||void 0});return{content:Ve.content??"",revision:Ve.revision,exists:Ve.exists}}const O=new URLSearchParams({path:r});p?.allowOutsideWorkspace&&O.set("allowOutsideWorkspace","true"),p?.outsideFileGrant&&O.set("outsideFileGrant",p.outsideFileGrant),p?.optional&&O.set("optional","true"),l&&O.set("directory",l);const T=await Kr(`/api/fs/read?${O.toString()}`,{cache:p?.optional?"no-store":"default"});if(!T.ok){const Ve=await T.json().catch(()=>({error:T.statusText}));throw new Error(Ve.error||"Failed to read file")}const oe=await T.text(),ee=T.headers?.get?.("x-pichamber-file-revision"),Be=T.headers?.get?.("x-pichamber-file-exists")!=="false";return{content:oe,revision:typeof ee=="string"&&ee.length>0?ee:Be?void 0:null,exists:Be}},[o,l]),ht=a.useCallback(async(r,p)=>{if(o.statFile){const O=await o.statFile(r,{...p??{},directory:l||void 0});return{path:O.path,size:O.size,mtimeMs:O.mtimeMs,revision:O.revision}}return null},[o,l]);a.useEffect(()=>{if(!l||!o.statFile||se.length===0)return;let r=!1;const p=[...se];return Promise.all(p.map(async O=>{try{const T=await o.statFile?.(O,{directory:l||void 0});!r&&T&&!T.isFile&&re(l,O)}catch(T){!r&&Yr(T)&&re(l,O)}})),()=>{r=!0}},[o,se,re,l]);const xn=a.useMemo(()=>Ee.length>Mt?`${Ee.slice(0,Mt)}
|
|
5
5
|
|
|
6
|
-
… truncated …`:Ee,[Ee]),$t=mt!==xn,Va=a.useCallback((r,p)=>ht(r,{...ge,...p}),[ht,ge]),Wa=a.useCallback(()=>{ze(null),Me(void 0),De(null)},[]),{recordStat:tt}=Jc({selectedPath:m?.path??null,loadedPath:et,isDirty:$t,readStat:Va,onExternalChange:Wa}),pr=a.useRef(null),hr=a.useCallback((r,p,O,T)=>{_e(p);const oe=T?.generation??Ie.current;if(typeof O<"u"&&(Me(O),De({runtimeKey:T?.runtimeKey??Re,root:T?.root??l,path:r,generation:oe})),l&&Dn(r,l)){const ee=kt(l,r);ee&&Ci.requestGitRefresh({directory:l,paths:[ee]})}rn(r)&&pr.current?.(p),ht(r).then(ee=>{ee&&Ie.current===oe&&tt(ee)}).catch(()=>{})},[Re,ht,tt,l]),vn=a.useCallback(()=>m?.path?{runtimeKey:Re,root:l,path:m.path,generation:Ie.current}:null,[Re,l,m?.path]),gr=vn,xr=a.useCallback(async(r,p=null)=>{const O=Ie.current,T=r.path;let oe=null,ee=r.currentRevision,Ge=r.exists;try{if(Ge){const Be=await It(T,ge);oe=Be.content,typeof Be.revision=="string"&&(ee=Be.revision),Ge=Be.exists!==!1}}catch{}Ie.current===O&&(Ke({path:T,displayPath:kt(l,T)||T,exists:Ge,currentRevision:ee,currentContent:oe,diagramXml:p}),Pe(!1))},[It,l,ge]),vr=a.useMemo(()=>{if(!m?.path||et!==m.path)return;const r=Jn;if(r){if(zi({...r},{runtimeKey:Re,root:l,path:m.path,generation:Ie.current}))return typeof ft=="string"||ft===null?"__stale__":void 0;if(typeof ft=="string"||ft===null)return ft}},[Re,et,ft,Jn,l,m?.path]),{clearDiagramContent:br,diagramEditorXml:_a,diagramSaved:Ka,drawioRemountNonce:Ha,drawioViewMode:bn,handleDiagramChange:qa,htmlViewMode:Bt,jsonViewMode:Vt,mdViewMode:Wt,recordDiagramContent:yn,saveDiagramNow:wn,saveDrawioViewMode:Ga,saveJsonViewMode:Ua,saveMdViewMode:yr,saveTextViewMode:Xa,setTextViewMode:jn,textViewMode:nt}=Zc({root:l,selectedPath:m?.path??null,fileContent:Ee,draftContent:mt,setDraftContent:Te,autoSaveEnabled:Pt,writeFile:o.writeFile,expectedRevision:vr,captureSaveScope:vn,currentSaveScope:gr,onSaved:hr,onConflict:r=>{xr(r,r.xml)}});pr.current=yn;const rt=a.useCallback(()=>Wt,[Wt]),{autoSaveStatus:Ja,isSaving:_t,clearSaveConflict:st,saveDraft:wr,saveNow:Kt}=Uc({autoSaveEnabled:Pt,selectedPath:m?.path??null,loadedPath:et,fileLoading:mn,isDirty:$t,draftContent:mt,fileContent:Ee,lineEnding:ma,isNonEditableBinary:!!(m?.path&&(Vn(m.path)||Zn)),writeFile:o.writeFile,expectedRevision:vr,onSaved:hr,captureSaveScope:vn,currentSaveScope:gr,onConflict:r=>{xr(r)}}),{confirmOpen:jr,discardAndTakeIntent:kr,keepModalOpen:Ya,requestNavigation:Ht,saveAndTakeIntent:Cr}=Vc({isDirty:$t,saveDraft:wr});a.useEffect(()=>{const r=p=>{di(p)&&(p.key.toLowerCase()==="s"?(p.preventDefault(),Kt()):p.key.toLowerCase()==="f"&&(p.preventDefault(),W(!0)))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[Kt]);const Nr=a.useCallback(async r=>{const p=Ie.current+1;Ie.current=p;const O=Re,T=l,oe=()=>{if(!l||O!==Re||T!==l)return!1;const de=Oe.getState().byRoot[l],Ze=de?.selectedPath??de?.openPaths[0]??null;return Ie.current===p&&Ze===r.path};Ne(null),Je(""),ze(null),Me(void 0),De(null),Ke(null),Pe(!1),st(),hn(!1),b&&D(!0);const ee=qr(r.path),Ge={allowOutsideWorkspace:t==="editor-only"&&!!l&&!Dn(r.path,l),outsideFileGrant:ee};let Be=!1;dt(!0);let Ve;await Bc(r.path,u.isDesktop,de=>It(de,Ge).then(Ze=>(Ve=Ze.revision,Ze.content))).then(de=>{if(oe()){if(de.kind!=="text"){if(_e(""),Te(""),de.kind==="desktop-image"){Be=!0;return}de.kind==="binary"&&hn(de.detectedFromContent),ze(r.path);return}pa(de.lineEnding),_e(de.content),yn(de.content),Te(de.draft),ze(r.path),Me(Ve),De({runtimeKey:O,root:T,path:r.path,generation:p}),ht(r.path,Ge).then(Ze=>{Ze&&oe()&&tt(Ze)}).catch(()=>{})}}).catch(de=>{if(oe()){if(Ji(de)){if(dt(!1),l&&ve(l,null),Ne(null),_e(""),Te(""),ze(null),Me(void 0),De(null),tt(null),q.trim().length>0&&_(""),b&&D(!1),l){const En=[...Qr(r.path,l),r.path];En.length>0&&B(l,En);for(const Br of En)Q(Br)||pe(Br)}return}if(Yr(de)){l&&re(l,r.path),_e(""),Te(""),Ne(null),Me(void 0),De(null),tt(null),b&&D(!1);return}_e(""),Te(""),Ne(de instanceof Error?de.message:"Failed to read file"),Me(void 0),De(null),tt(null)}}).finally(()=>{oe()&&!Be&&dt(!1)})},[Re,st,B,Q,b,pe,t,It,ht,yn,tt,re,l,u.isDesktop,q,ve]),gt=a.useCallback(async(r,p)=>{if(!l||!$)return;const O=Qr(r,l),T=p?[...O,r]:O;T.length>0&&B(l,T);const oe=T.map(ee=>{if(!Q(ee))return pe(ee)}).filter(Boolean);await Promise.all(oe)},[B,Q,pe,$,l]),Sr=a.useCallback((r,p)=>{const O=p.findIndex(T=>T.path===r);return O===-1||p.length<=1?null:p[O+1]??p[O-1]??null},[]),qe=a.useCallback(async r=>{Ht({kind:"select",file:r})||(l&&(ve(l,r.path),gt(r.path,!1)),Ne(null),Je(""),_e(""),br(),Te(""),ze(null),Me(void 0),De(null),Ke(null),Pe(!1),st(),b&&D(!0))},[br,st,gt,b,Ht,l,ve]),Qa=a.useCallback(r=>{qe(Xe(r))},[qe,Xe]),Za=a.useCallback(r=>{const p=ce(r);p&&(_(""),V(p),D(!1))},[]),eo=a.useCallback(r=>{const p=ce(r);p&&(D(!0),qe(Xe(p)))},[qe,Xe]),to=a.useCallback(async()=>{if(!(!x||N)){S(!0);try{await At(x)}finally{S(!1)}}},[x,N,At]),no=a.useCallback(()=>{const r=be;if(r){if(!r.exists){l&&ne(l,r.path),Nt(),Ke(null),Pe(!1),st();return}Te(""),ze(null),Me(void 0),De(null),Ke(null),Pe(!1),st()}},[st,Nt,ne,l,be]),ro=a.useCallback(async()=>{if(!(!be||pn)){Yn(!0);try{(be.diagramXml!==null?await wn(be.path,be.diagramXml,{overwrite:!0}):await Kt({overwrite:!0}))&&(Ke(null),Pe(!1))}finally{Yn(!1)}}},[pn,be,wn,Kt]),so=a.useCallback(()=>{Ke(null),Pe(!1)},[]);a.useEffect(()=>{!m?.path||!$||!i||gt(m.path,!1)},[gt,i,$,m?.path]),a.useEffect(()=>{if(!m){Ie.current+=1,pt.current=null,dt(!1);return}if(et===m.path||pt.current===m.path)return;const r=m.path;pt.current=r,Nr(m).finally(()=>{pt.current===r&&(pt.current=null)})},[Nr,et,m]);const xt=a.useCallback(async r=>{if(r.kind==="select"){await qe(r.file);return}if(r.kind==="tab"){ye.getState().setActiveMainTab(r.tab);return}l&&ne(l,r.path),m?.path===r.path&&(r.nextFile?await qe(r.nextFile):Nt())},[Nt,qe,ne,l,m?.path]),ao=a.useCallback(()=>{const r=kr();Te(xn),r&&xt(r)},[xt,kr,xn]),oo=a.useCallback(async()=>{const r=await Cr();r&&await xt(r)},[xt,Cr]),io=a.useCallback(r=>{const p=m?.path===r,O={kind:"close",path:r,nextFile:Sr(r,Ot)};p&&Ht(O)||xt(O)},[xt,Sr,Ot,Ht,m?.path]),qt=a.useMemo(()=>Yi({root:l,openPaths:se,gitFiles:M?.files}),[l,se,M]),co=a.useCallback(r=>qt.getFileStatus(r),[qt]),lo=a.useCallback(r=>qt.getFolderBadge(r),[qt]),uo=a.useCallback(async r=>{const p=ce(r);!l||!$||(je(l,p),Q(p)||await pe(p))},[Q,pe,$,l,je]),fo=a.useMemo(()=>({canRename:sr,canCreateFile:nr,canCreateFolder:rr,canDelete:ar,canReveal:or}),[sr,nr,rr,ar,or]),$e=!!(m?.path&&Vs(m.path)),vt=!!(m?.path&&Ws(m.path)),at=!!(m?.path&&_s(m.path)),kn=!!(m?.path&&(Vn(m.path)||Zn)),Gt=kn&&!$e&&!at,ot=a.useMemo(()=>kt(l,He),[He,l]),Ye=a.useMemo(()=>ot&&M?.files?.find(r=>r.path===ot)||null,[ot,M?.files]),Rr=Ye?Qi(Ye):null,mo=a.useCallback(()=>{if(!Ye||!l)return;const r=Ye.index!==" "&&Ye.index!=="?"&&Ye.working_dir===" ";ye.getState().openContextDiff(l,Ye.path,r)},[l,Ye]),po=!!(m&&(!$e||vt)&&!at&&!Gt&&Ee.length>0),ho=!!(m&&ot.length>0),St=!!(m&&!Lt&&!kn&&!$e&&o.writeFile&&Ee.length<=Mt),Rt=!!(m?.path&&ta(m.path)),Cn=!!(m?.path&&ea(m.path)),Ft=!!(m?.path&&un(m.path)),Fr=!!(m?.path&&rn(m.path)),go=!!(m&&!kn&&!$e),{editorViewRef:ke,notifyEditorViewChanged:Ut,shouldMaskEditor:xo}=_c({root:l,selectedPath:He||null,loadedPath:et,fileLoading:mn,fileError:Xn,isImage:$e,isPdf:at,isUnsupportedBinary:Gt,canEdit:St,textViewMode:nt,setTextViewMode:jn,draftContent:mt,confirmDiscardOpen:jr,selectFilePath:Qa}),Er=go&&!Rt&&!Fr&&!(Ft&&Bt==="preview"),vo=Rt&&Wt==="edit"||Ft&&Bt==="edit"||Cn&&Vt==="text"||!Rt&&!Ft&&!Cn&&nt==="edit",Xt=a.useMemo(()=>He?uc(He):null,[He]),[zr,Nn]=a.useState(null);a.useEffect(()=>{let r=!1;const p=m?.path;if(!p||Xt){Nn(null);return}return Nn(null),dc(p).then(O=>{r||Nn(O)}),()=>{r=!0}},[m?.path,Xt]),a.useEffect(()=>{!St&&nt==="edit"&&jn("view")},[St,jn,nt]);const Qe=a.useCallback(r=>{if(!b||!r||!r.hasFocus||typeof window>"u")return;const p=window.visualViewport;if(!p)return;const O=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,O-(p.offsetTop+p.height))<=0)return;const oe=r.state.selection.main.head,ee=r.coordsAtPos(oe);if(!ee)return;const Ge=Math.round(p.offsetTop+p.height),Ve=ee.bottom+20-Ge;Ve<=0||(r.scrollDOM.scrollTop+=Ve)},[b]);a.useEffect(()=>{if(!b||typeof window>"u")return;const r=()=>{window.requestAnimationFrame(()=>{Qe(ke.current)})},p=window.visualViewport;return p?.addEventListener("resize",r),p?.addEventListener("scroll",r,{passive:!0}),document.addEventListener("selectionchange",r),()=>{p?.removeEventListener("resize",r),p?.removeEventListener("scroll",r),document.removeEventListener("selectionchange",r)}},[ke,b,Qe]);const Jt=ye(r=>r.editorFontSize),bo=a.useMemo(()=>{if(!m?.path)return[ns(d,{fontSize:Jt})];const r=Bs(m.path),p=[ns(d,r?{syntaxColors:!1,fontSize:Jt}:{fontSize:Jt})],O=Xt??zr;return O&&p.push(O),r&&p.push(yc({language:r,themeName:d.metadata.id,theme:Fi(d)})),L&&p.push(we.lineWrapping,hl),b&&p.push(we.updateListener.of(T=>{T.view.hasFocus&&(T.selectionSet||T.focusChanged||T.viewportChanged||T.geometryChanged)&&window.requestAnimationFrame(()=>{Qe(T.view)})})),p},[d,m?.path,Xt,zr,L,b,Qe,Jt]),yo=a.useMemo(()=>({light:xe.metadata.id,dark:le.metadata.id}),[xe.metadata.id,le.metadata.id]),Yt=m?.path&&$e&&!u.isDesktop&&!vt?`${m.path}|${ge.allowOutsideWorkspace?"outside":"workspace"}|${ge.outsideFileGrant??""}`:"",Qt=m?.path&&at?`${m.path}|${ge.allowOutsideWorkspace?"outside":"workspace"}|${ge.outsideFileGrant??""}`:"",Et=m?.path&&Ft&&Bt==="preview"?m.path:"",Sn="Failed to read file",{readyKey:Mr,nonce:wo}=Tn(Yt,Ne,Sn),{readyKey:Dr,nonce:jo}=Tn(Et,Ne,Sn),{readyKey:Tr,nonce:ko}=Tn(Qt,Ne,Sn),Co=!!(Yt&&Mr!==Yt),No=!!(Et&&Dr!==Et),So=!!(Qt&&Tr!==Qt),Ro=m?.path&&$e?u.isDesktop?vt?`data:${Ur(m.path)};utf8,${encodeURIComponent(Ee)}`:da:vt?`data:${Ur(m.path)};utf8,${encodeURIComponent(Ee)}`:Mr===Yt?Mn().authenticatedAsset("/api/fs/raw",{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}):"":"",Fo=m?.path&&at&&Tr===Qt?Mn().authenticatedAsset("/api/fs/raw",{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}):"",Eo=Et&&Dr===Et&&m?.path?(()=>{const r=m.path.split("/").map(p=>encodeURIComponent(p)).join("/");return Mn().authenticatedAsset(`/api/fs/serve${r.startsWith("/")?r:`/${r}`}`)})():void 0;a.useEffect(()=>{let r=!1;return(async()=>{if(!u.isDesktop||!m?.path||!$e||vt){Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),Je("");return}Ne(null),Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),await(o.readFileBinary?o.readFileBinary(m.path,ge).then(T=>T.dataUrl):(async()=>{const T=await Kr("/api/fs/raw",{query:{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}});if(!T.ok)throw new Error("Failed to read file");const oe=await T.blob(),ee=URL.createObjectURL(oe);return r?(URL.revokeObjectURL(ee),""):(Se.current=ee,ee)})()).then(T=>{r||(Je(T),ze(m.path))}).catch(T=>{Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),r||(Je(""),Ne(T instanceof Error?T.message:"Failed to read file"),ze(null))}).finally(()=>{r||dt(!1)})})(),()=>{r=!0}},[o,$e,vt,l,u.isDesktop,m?.path,ge]),a.useEffect(()=>()=>{Se.current&&(URL.revokeObjectURL(Se.current),Se.current="")},[]);const Ar=a.useCallback(()=>{const r=o.downloadFile,p=m?.path;!r||!p||r(p).catch(O=>{console.error("Download failed:",O),he.error("Operation failed")})},[o.downloadFile,m?.path]),Rn=!b&&!cr,Or=Ni(a.useCallback(r=>r.projects.find(p=>ce(p.path)===l)??null,[l])),zo=Or?Si(Or):l?l.split("/").filter(Boolean).pop()??l:void 0,Lr=ye(r=>r.revealInFileTree),Mo=a.useCallback(r=>{if(!l)return;const p=r?`${l.replace(/\/+$/,"")}/${r}`:l;if(t==="editor-only"){Lr(p);return}r&>(p,!0)},[gt,t,Lr,l]),Pr={selectedFile:m,displaySelectedPath:ot,canEdit:St,isEditingFile:vo,isSaving:_t,autoSaveEnabled:Pt,autoSaveStatus:Ja,isDirty:$t,onSaveDraft:wr,onToggleAutoSave:()=>ha(!Pt),canOpenInDesktopApp:gn,openInApps:Aa,openInCacheStale:Oa,onOpenInApp:Ia,onRefreshOpenInApps:()=>La(!0),onToolbarDropdownOpenChange:Le,isSelectedImage:$e,isSelectedPdf:at,isUnsupportedBinary:Gt,wrapLines:L,onToggleWrapLines:()=>Y(!L),textViewMode:nt,onToggleSearch:()=>W(!ie),isGoToLineOpen:er,onOpenGoToLineChange:tr,editorView:ke.current,canUseShikiFileView:Er,isJson:Cn,isHtml:Ft,onToggleTextViewMode:()=>{Xa(nt==="view"?"edit":"view")},isMarkdown:Rt,mdViewMode:rt(),onToggleMdViewMode:()=>yr(rt()==="preview"?"edit":"preview"),isDrawio:Fr,drawioViewMode:bn,onToggleDrawioViewMode:()=>Ga(bn==="preview"?"edit":"preview"),diagramSaved:Ka,onSaveDiagram:async()=>{const r=Qn.current?.getXml();m?.path&&r&&await wn(m.path,r)},jsonViewMode:Vt,onToggleJsonViewMode:()=>Ua(Vt==="tree"?"text":"tree"),canCopy:po,copiedContent:wa,onCopyContent:async()=>{(await nn(Ee)).ok?(ja(!0),Rn&&he.success("Contents copied")):he.error("Copy failed")},canCopyPath:ho,copiedPath:ka,onCopyPath:async()=>{(await nn(ot)).ok?(Ca(!0),Rn&&he.success("Path copied")):he.error("Copy failed")},onDownloadFile:o.downloadFile&&m?Ar:void 0,isMobile:b,mode:t,isFullscreen:G,onToggleFullscreen:()=>Z(!G),onExitFullscreen:()=>Z(!1)},Fn=({exitFullscreenOnly:r=!1,layout:p="floating"}={})=>e.jsx(al,{...Pr,layout:p,exitFullscreenOnly:r}),Do=a.useCallback(r=>{ke.current=r,Ut(),window.requestAnimationFrame(()=>{Qe(r)})},[ke,Ut,Qe]),To=a.useCallback(()=>{ke.current&&(ke.current=null),Ut()},[ke,Ut]),Ao=a.useCallback(r=>{ke.current=r,window.requestAnimationFrame(()=>{Qe(r)})},[ke,Qe]),Oo=a.useCallback(()=>{ke.current&&(ke.current=null)},[ke]),Ir={selectedFile:m,loading:mn||Co||So,suppressLoadingIndicator:I,fileError:Xn,isSelectedImage:$e,imageSrc:Ro,imagePreviewNonce:wo,isSelectedPdf:at,pdfSrc:Fo,pdfPreviewNonce:ko,isUnsupportedBinary:Gt,onDownload:o.downloadFile&&m?Ar:void 0,drawioViewMode:bn,drawioRemountNonce:Ha,diagramEditorRef:Qn,diagramEditorXml:_a,onDiagramChange:qa,jsonViewMode:Vt,markdownViewMode:Wt,htmlViewMode:Bt,htmlLoading:No,htmlPreviewNonce:jo,htmlPreviewSrc:Eo,fileContent:Ee,canUseShikiFileView:Er,textViewMode:nt,draftContent:mt,onDraftChange:Te,canEdit:St,vimMode:$a==="vim",editorExtensions:bo,shouldMaskEditorForPendingNavigation:xo,pierreTheme:yo,shikiThemeType:d.metadata.variant==="dark"?"dark":"light",wrapLines:L},Zt=e.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[e.jsx(ol,{open:jr,onOpenChange:Ya,isSaving:_t,onSaveAndContinue:()=>{oo()},onDiscardAndContinue:ao}),e.jsx(Mi,{open:!!be,conflict:be?{path:be.path,displayPath:be.displayPath,exists:be.exists,currentRevision:be.currentRevision,currentContent:be.currentContent,dirtyContent:be.diagramXml??mt}:null,isResolving:pn||_t,showCompare:fa,onToggleCompare:()=>Pe(r=>!r),onReload:no,onOverwrite:()=>{ro()},onClose:so}),e.jsxs("div",{className:X("flex flex-col flex-shrink-0",(H||!b&&m)&&"border-b border-border/60"),children:[e.jsx(rl,{showEditorTabsRow:H,isMobile:b,showMobilePageContent:A,onBackMobile:()=>D(!1),selectedFile:m,openFiles:Ot,root:l,alwaysShowActions:y,editorTabsOverflow:la,editorTabsScrollRef:fn,onSelectFile:qe,onCloseFile:io}),b&&m?e.jsx("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:e.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Fn({layout:"docked"})})}):null,!b&&m?e.jsx(cl,{path:ot,status:Rr,rootLabel:zo,onRevealFolder:Mo,onShowChanges:t==="editor-only"&&Rr!=="git-deleted"?mo:void 0,className:X(H&&"border-t border-border/40"),children:cr?e.jsx("div",{className:"min-w-0 overflow-x-auto",children:Fn({layout:"docked"})}):e.jsxs("div",{className:"flex items-center gap-0.5",children:[_t?e.jsx("span",{className:"px-1 typography-micro text-muted-foreground",children:"Saving…"}):null,Rt?e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>yr(rt()==="preview"?"edit":"preview"),className:X("size-7 p-0",rt()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":rt()==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(F,{name:rt()==="preview"?"eye":"eye-off",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:rt()==="preview"?"Switch to edit mode":"Switch to preview mode"})]}):null,e.jsx(ll,{...Pr})]})}):null]}),e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[Rn&&m?e.jsx(ia,{open:er,onOpenChange:tr,view:ke.current}):null,e.jsx(bs,{variant:"embedded",...Ir,enableRichPreviews:!0,editorWrapperRef:ga,onEditorViewReady:Do,onEditorViewDestroy:To,enableSearch:!0,searchOpen:ie,onSearchOpenChange:W})]})]}),$r=e.jsx(il,{root:l,isMobile:b,searchQuery:q,onSearchQueryChange:_,searchInputRef:J,searching:fr,searchFailed:mr,searchResults:dr,selectedFile:m,onSelectFile:qe,onOpenDialog:Ma,currentDirectory:K,refreshRoot:ca,childrenByDir:ue,loadErrorsByDir:ae,expandedPaths:Ce,isBrowserClient:j,alwaysShowActions:y,getFileStatus:co,getFolderBadge:lo,fileRowPermissions:fo,downloadFile:o.downloadFile,contextMenuPath:xa,setContextMenuPath:va,rightClickMenuPath:ba,setRightClickMenuPath:ya,toggleDirectory:uo,handleRevealPath:Pa,refreshDirectory:At}),Lo=t==="full"&&G&&m&&e.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[e.jsx("div",{className:"absolute right-4 top-4 z-30",children:Fn({exitFullscreenOnly:!0})}),e.jsx(bs,{variant:"fullscreen",...Ir,enableRichPreviews:!1,onEditorViewReady:Ao,onEditorViewDestroy:Oo})]})});return f?e.jsx(Cc,{root:l,directory:x||l,entries:x||l?ue[x||l]:void 0,query:q,searchResults:dr,isSearching:fr,searchFailed:mr,directoryError:x||l?ae[x||l]??null:null,refreshing:N,editorPath:A?m?.path??null:null,editor:Zt,onClose:s,onQueryChange:_,onOpenDirectory:Za,onOpenFile:eo,onBackFromEditor:()=>D(!1),onRefresh:()=>{to()}}):e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[e.jsx(Sc,{activeDialog:Na,dialogData:Sa,dialogInputValue:Ra,onDialogInputChange:Fa,isDialogSubmitting:Ea,onDialogSubmit:Ta,onClose:Da,inputRef:za}),Lo,b?A?Zt:$r:t==="editor-only"?e.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zt})}):e.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[k>=700&&e.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:$r}),e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zt})]})]})};export{Du as FilesView};
|
|
6
|
+
… truncated …`:Ee,[Ee]),$t=mt!==xn,Va=a.useCallback((r,p)=>ht(r,{...ge,...p}),[ht,ge]),Wa=a.useCallback(()=>{ze(null),Me(void 0),De(null)},[]),{recordStat:tt}=Jc({selectedPath:m?.path??null,loadedPath:et,isDirty:$t,readStat:Va,onExternalChange:Wa}),pr=a.useRef(null),hr=a.useCallback((r,p,O,T)=>{_e(p);const oe=T?.generation??Ie.current;if(typeof O<"u"&&(Me(O),De({runtimeKey:T?.runtimeKey??Re,root:T?.root??l,path:r,generation:oe})),l&&Dn(r,l)){const ee=kt(l,r);ee&&Ci.requestGitRefresh({directory:l,paths:[ee]})}rn(r)&&pr.current?.(p),ht(r).then(ee=>{ee&&Ie.current===oe&&tt(ee)}).catch(()=>{})},[Re,ht,tt,l]),vn=a.useCallback(()=>m?.path?{runtimeKey:Re,root:l,path:m.path,generation:Ie.current}:null,[Re,l,m?.path]),gr=vn,xr=a.useCallback(async(r,p=null)=>{const O=Ie.current,T=r.path;let oe=null,ee=r.currentRevision,Ge=r.exists;try{if(Ge){const Be=await It(T,ge);oe=Be.content,typeof Be.revision=="string"&&(ee=Be.revision),Ge=Be.exists!==!1}}catch{}Ie.current===O&&(Ke({path:T,displayPath:kt(l,T)||T,exists:Ge,currentRevision:ee,currentContent:oe,diagramXml:p}),Le(!1))},[It,l,ge]),vr=a.useMemo(()=>{if(!m?.path||et!==m.path)return;const r=Jn;if(r){if(zi({...r},{runtimeKey:Re,root:l,path:m.path,generation:Ie.current}))return typeof ft=="string"||ft===null?"__stale__":void 0;if(typeof ft=="string"||ft===null)return ft}},[Re,et,ft,Jn,l,m?.path]),{clearDiagramContent:br,diagramEditorXml:_a,diagramSaved:Ka,drawioRemountNonce:Ha,drawioViewMode:bn,handleDiagramChange:qa,htmlViewMode:Bt,jsonViewMode:Vt,mdViewMode:Wt,recordDiagramContent:yn,saveDiagramNow:wn,saveDrawioViewMode:Ga,saveJsonViewMode:Ua,saveMdViewMode:yr,saveTextViewMode:Xa,setTextViewMode:jn,textViewMode:nt}=Qc({root:l,selectedPath:m?.path??null,fileContent:Ee,draftContent:mt,setDraftContent:Te,autoSaveEnabled:Lt,writeFile:o.writeFile,expectedRevision:vr,captureSaveScope:vn,currentSaveScope:gr,onSaved:hr,onConflict:r=>{xr(r,r.xml)}});pr.current=yn;const rt=a.useCallback(()=>Wt,[Wt]),{autoSaveStatus:Ja,isSaving:_t,clearSaveConflict:st,saveDraft:wr,saveNow:Kt}=Uc({autoSaveEnabled:Lt,selectedPath:m?.path??null,loadedPath:et,fileLoading:mn,isDirty:$t,draftContent:mt,fileContent:Ee,lineEnding:ma,isNonEditableBinary:!!(m?.path&&(Vn(m.path)||Qn)),writeFile:o.writeFile,expectedRevision:vr,onSaved:hr,captureSaveScope:vn,currentSaveScope:gr,onConflict:r=>{xr(r)}}),{confirmOpen:jr,discardAndTakeIntent:kr,keepModalOpen:Ya,requestNavigation:Ht,saveAndTakeIntent:Cr}=Vc({isDirty:$t,saveDraft:wr});a.useEffect(()=>{const r=p=>{di(p)&&(p.key.toLowerCase()==="s"?(p.preventDefault(),Kt()):p.key.toLowerCase()==="f"&&(p.preventDefault(),W(!0)))};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[Kt]);const Nr=a.useCallback(async r=>{const p=Ie.current+1;Ie.current=p;const O=Re,T=l,oe=()=>{if(!l||O!==Re||T!==l)return!1;const de=Oe.getState().byRoot[l],Qe=de?.selectedPath??de?.openPaths[0]??null;return Ie.current===p&&Qe===r.path};Ne(null),Je(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),st(),hn(!1),b&&D(!0);const ee=qr(r.path),Ge={allowOutsideWorkspace:t==="editor-only"&&!!l&&!Dn(r.path,l),outsideFileGrant:ee};let Be=!1;dt(!0);let Ve;await Bc(r.path,u.isDesktop,de=>It(de,Ge).then(Qe=>(Ve=Qe.revision,Qe.content))).then(de=>{if(oe()){if(de.kind!=="text"){if(_e(""),Te(""),de.kind==="desktop-image"){Be=!0;return}de.kind==="binary"&&hn(de.detectedFromContent),ze(r.path);return}pa(de.lineEnding),_e(de.content),yn(de.content),Te(de.draft),ze(r.path),Me(Ve),De({runtimeKey:O,root:T,path:r.path,generation:p}),ht(r.path,Ge).then(Qe=>{Qe&&oe()&&tt(Qe)}).catch(()=>{})}}).catch(de=>{if(oe()){if(Ji(de)){if(dt(!1),l&&ve(l,null),Ne(null),_e(""),Te(""),ze(null),Me(void 0),De(null),tt(null),q.trim().length>0&&_(""),b&&D(!1),l){const En=[...Zr(r.path,l),r.path];En.length>0&&B(l,En);for(const Br of En)Z(Br)||pe(Br)}return}if(Yr(de)){l&&re(l,r.path),_e(""),Te(""),Ne(null),Me(void 0),De(null),tt(null),b&&D(!1);return}_e(""),Te(""),Ne(de instanceof Error?de.message:"Failed to read file"),Me(void 0),De(null),tt(null)}}).finally(()=>{oe()&&!Be&&dt(!1)})},[Re,st,B,Z,b,pe,t,It,ht,yn,tt,re,l,u.isDesktop,q,ve]),gt=a.useCallback(async(r,p)=>{if(!l||!$)return;const O=Zr(r,l),T=p?[...O,r]:O;T.length>0&&B(l,T);const oe=T.map(ee=>{if(!Z(ee))return pe(ee)}).filter(Boolean);await Promise.all(oe)},[B,Z,pe,$,l]),Sr=a.useCallback((r,p)=>{const O=p.findIndex(T=>T.path===r);return O===-1||p.length<=1?null:p[O+1]??p[O-1]??null},[]),qe=a.useCallback(async r=>{Ht({kind:"select",file:r})||(l&&(ve(l,r.path),gt(r.path,!1)),Ne(null),Je(""),_e(""),br(),Te(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),st(),b&&D(!0))},[br,st,gt,b,Ht,l,ve]),Za=a.useCallback(r=>{qe(Xe(r))},[qe,Xe]),Qa=a.useCallback(r=>{const p=ce(r);p&&(_(""),V(p),D(!1))},[]),eo=a.useCallback(r=>{const p=ce(r);p&&(D(!0),qe(Xe(p)))},[qe,Xe]),to=a.useCallback(async()=>{if(!(!x||N)){S(!0);try{await At(x)}finally{S(!1)}}},[x,N,At]),no=a.useCallback(()=>{const r=be;if(r){if(!r.exists){l&&ne(l,r.path),Nt(),Ke(null),Le(!1),st();return}Te(""),ze(null),Me(void 0),De(null),Ke(null),Le(!1),st()}},[st,Nt,ne,l,be]),ro=a.useCallback(async()=>{if(!(!be||pn)){Yn(!0);try{(be.diagramXml!==null?await wn(be.path,be.diagramXml,{overwrite:!0}):await Kt({overwrite:!0}))&&(Ke(null),Le(!1))}finally{Yn(!1)}}},[pn,be,wn,Kt]),so=a.useCallback(()=>{Ke(null),Le(!1)},[]);a.useEffect(()=>{!m?.path||!$||!i||gt(m.path,!1)},[gt,i,$,m?.path]),a.useEffect(()=>{if(!m){Ie.current+=1,pt.current=null,dt(!1);return}if(et===m.path||pt.current===m.path)return;const r=m.path;pt.current=r,Nr(m).finally(()=>{pt.current===r&&(pt.current=null)})},[Nr,et,m]);const xt=a.useCallback(async r=>{if(r.kind==="select"){await qe(r.file);return}if(r.kind==="tab"){ye.getState().setActiveMainTab(r.tab);return}l&&ne(l,r.path),m?.path===r.path&&(r.nextFile?await qe(r.nextFile):Nt())},[Nt,qe,ne,l,m?.path]),ao=a.useCallback(()=>{const r=kr();Te(xn),r&&xt(r)},[xt,kr,xn]),oo=a.useCallback(async()=>{const r=await Cr();r&&await xt(r)},[xt,Cr]),io=a.useCallback(r=>{const p=m?.path===r,O={kind:"close",path:r,nextFile:Sr(r,Ot)};p&&Ht(O)||xt(O)},[xt,Sr,Ot,Ht,m?.path]),qt=a.useMemo(()=>Yi({root:l,openPaths:se,gitFiles:M?.files}),[l,se,M]),co=a.useCallback(r=>qt.getFileStatus(r),[qt]),lo=a.useCallback(r=>qt.getFolderBadge(r),[qt]),uo=a.useCallback(async r=>{const p=ce(r);!l||!$||(je(l,p),Z(p)||await pe(p))},[Z,pe,$,l,je]),fo=a.useMemo(()=>({canRename:sr,canCreateFile:nr,canCreateFolder:rr,canDelete:ar,canReveal:or}),[sr,nr,rr,ar,or]),$e=!!(m?.path&&Vs(m.path)),vt=!!(m?.path&&Ws(m.path)),at=!!(m?.path&&_s(m.path)),kn=!!(m?.path&&(Vn(m.path)||Qn)),Gt=kn&&!$e&&!at,ot=a.useMemo(()=>kt(l,He),[He,l]),Ye=a.useMemo(()=>ot&&M?.files?.find(r=>r.path===ot)||null,[ot,M?.files]),Rr=Ye?Zi(Ye):null,mo=a.useCallback(()=>{if(!Ye||!l)return;const r=Ye.index!==" "&&Ye.index!=="?"&&Ye.working_dir===" ";ye.getState().openContextDiff(l,Ye.path,r)},[l,Ye]),po=!!(m&&(!$e||vt)&&!at&&!Gt&&Ee.length>0),ho=!!(m&&ot.length>0),St=!!(m&&!Pt&&!kn&&!$e&&o.writeFile&&Ee.length<=Mt),Rt=!!(m?.path&&ta(m.path)),Cn=!!(m?.path&&ea(m.path)),Ft=!!(m?.path&&un(m.path)),Fr=!!(m?.path&&rn(m.path)),go=!!(m&&!kn&&!$e),{editorViewRef:ke,notifyEditorViewChanged:Ut,shouldMaskEditor:xo}=_c({root:l,selectedPath:He||null,loadedPath:et,fileLoading:mn,fileError:Xn,isImage:$e,isPdf:at,isUnsupportedBinary:Gt,canEdit:St,textViewMode:nt,setTextViewMode:jn,draftContent:mt,confirmDiscardOpen:jr,selectFilePath:Za}),Er=go&&!Rt&&!Fr&&!(Ft&&Bt==="preview"),vo=Rt&&Wt==="edit"||Ft&&Bt==="edit"||Cn&&Vt==="text"||!Rt&&!Ft&&!Cn&&nt==="edit",Xt=a.useMemo(()=>He?uc(He):null,[He]),[zr,Nn]=a.useState(null);a.useEffect(()=>{let r=!1;const p=m?.path;if(!p||Xt){Nn(null);return}return Nn(null),dc(p).then(O=>{r||Nn(O)}),()=>{r=!0}},[m?.path,Xt]),a.useEffect(()=>{!St&&nt==="edit"&&jn("view")},[St,jn,nt]);const Ze=a.useCallback(r=>{if(!b||!r||!r.hasFocus||typeof window>"u")return;const p=window.visualViewport;if(!p)return;const O=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,O-(p.offsetTop+p.height))<=0)return;const oe=r.state.selection.main.head,ee=r.coordsAtPos(oe);if(!ee)return;const Ge=Math.round(p.offsetTop+p.height),Ve=ee.bottom+20-Ge;Ve<=0||(r.scrollDOM.scrollTop+=Ve)},[b]);a.useEffect(()=>{if(!b||typeof window>"u")return;const r=()=>{window.requestAnimationFrame(()=>{Ze(ke.current)})},p=window.visualViewport;return p?.addEventListener("resize",r),p?.addEventListener("scroll",r,{passive:!0}),document.addEventListener("selectionchange",r),()=>{p?.removeEventListener("resize",r),p?.removeEventListener("scroll",r),document.removeEventListener("selectionchange",r)}},[ke,b,Ze]);const Jt=ye(r=>r.editorFontSize),bo=a.useMemo(()=>{if(!m?.path)return[ns(d,{fontSize:Jt})];const r=Bs(m.path),p=[ns(d,r?{syntaxColors:!1,fontSize:Jt}:{fontSize:Jt})],O=Xt??zr;return O&&p.push(O),r&&p.push(yc({language:r,themeName:d.metadata.id,theme:Fi(d)})),P&&p.push(we.lineWrapping,hl),b&&p.push(we.updateListener.of(T=>{T.view.hasFocus&&(T.selectionSet||T.focusChanged||T.viewportChanged||T.geometryChanged)&&window.requestAnimationFrame(()=>{Ze(T.view)})})),p},[d,m?.path,Xt,zr,P,b,Ze,Jt]),yo=a.useMemo(()=>({light:xe.metadata.id,dark:le.metadata.id}),[xe.metadata.id,le.metadata.id]),Yt=m?.path&&$e&&!u.isDesktop&&!vt?`${m.path}|${ge.allowOutsideWorkspace?"outside":"workspace"}|${ge.outsideFileGrant??""}`:"",Zt=m?.path&&at?`${m.path}|${ge.allowOutsideWorkspace?"outside":"workspace"}|${ge.outsideFileGrant??""}`:"",Et=m?.path&&Ft&&Bt==="preview"?m.path:"",Sn="Failed to read file",{readyKey:Mr,nonce:wo}=Tn(Yt,Ne,Sn),{readyKey:Dr,nonce:jo}=Tn(Et,Ne,Sn),{readyKey:Tr,nonce:ko}=Tn(Zt,Ne,Sn),Co=!!(Yt&&Mr!==Yt),No=!!(Et&&Dr!==Et),So=!!(Zt&&Tr!==Zt),Ro=m?.path&&$e?u.isDesktop?vt?`data:${Ur(m.path)};utf8,${encodeURIComponent(Ee)}`:da:vt?`data:${Ur(m.path)};utf8,${encodeURIComponent(Ee)}`:Mr===Yt?Mn().authenticatedAsset("/api/fs/raw",{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}):"":"",Fo=m?.path&&at&&Tr===Zt?Mn().authenticatedAsset("/api/fs/raw",{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}):"",Eo=Et&&Dr===Et&&m?.path?(()=>{const r=m.path.split("/").map(p=>encodeURIComponent(p)).join("/");return Mn().authenticatedAsset(`/api/fs/serve${r.startsWith("/")?r:`/${r}`}`)})():void 0;a.useEffect(()=>{let r=!1;return(async()=>{if(!u.isDesktop||!m?.path||!$e||vt){Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),Je("");return}Ne(null),Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),await(o.readFileBinary?o.readFileBinary(m.path,ge).then(T=>T.dataUrl):(async()=>{const T=await Kr("/api/fs/raw",{query:{path:m.path,allowOutsideWorkspace:ge.allowOutsideWorkspace?"true":void 0,outsideFileGrant:ge.outsideFileGrant,directory:l||void 0}});if(!T.ok)throw new Error("Failed to read file");const oe=await T.blob(),ee=URL.createObjectURL(oe);return r?(URL.revokeObjectURL(ee),""):(Se.current=ee,ee)})()).then(T=>{r||(Je(T),ze(m.path))}).catch(T=>{Se.current&&(URL.revokeObjectURL(Se.current),Se.current=""),r||(Je(""),Ne(T instanceof Error?T.message:"Failed to read file"),ze(null))}).finally(()=>{r||dt(!1)})})(),()=>{r=!0}},[o,$e,vt,l,u.isDesktop,m?.path,ge]),a.useEffect(()=>()=>{Se.current&&(URL.revokeObjectURL(Se.current),Se.current="")},[]);const Ar=a.useCallback(()=>{const r=o.downloadFile,p=m?.path;!r||!p||r(p).catch(O=>{console.error("Download failed:",O),he.error("Operation failed")})},[o.downloadFile,m?.path]),Rn=!b&&!cr,Or=Ni(a.useCallback(r=>r.projects.find(p=>ce(p.path)===l)??null,[l])),zo=Or?Si(Or):l?l.split("/").filter(Boolean).pop()??l:void 0,Pr=ye(r=>r.revealInFileTree),Mo=a.useCallback(r=>{if(!l)return;const p=r?`${l.replace(/\/+$/,"")}/${r}`:l;if(t==="editor-only"){Pr(p);return}r&>(p,!0)},[gt,t,Pr,l]),Lr={selectedFile:m,displaySelectedPath:ot,canEdit:St,isEditingFile:vo,isSaving:_t,autoSaveEnabled:Lt,autoSaveStatus:Ja,isDirty:$t,onSaveDraft:wr,onToggleAutoSave:()=>ha(!Lt),canOpenInDesktopApp:gn,openInApps:Aa,openInCacheStale:Oa,onOpenInApp:Ia,onRefreshOpenInApps:()=>Pa(!0),onToolbarDropdownOpenChange:Pe,isSelectedImage:$e,isSelectedPdf:at,isUnsupportedBinary:Gt,wrapLines:P,onToggleWrapLines:()=>Y(!P),textViewMode:nt,onToggleSearch:()=>W(!ie),isGoToLineOpen:er,onOpenGoToLineChange:tr,editorView:ke.current,canUseShikiFileView:Er,isJson:Cn,isHtml:Ft,onToggleTextViewMode:()=>{Xa(nt==="view"?"edit":"view")},isMarkdown:Rt,mdViewMode:rt(),onToggleMdViewMode:()=>yr(rt()==="preview"?"edit":"preview"),isDrawio:Fr,drawioViewMode:bn,onToggleDrawioViewMode:()=>Ga(bn==="preview"?"edit":"preview"),diagramSaved:Ka,onSaveDiagram:async()=>{const r=Zn.current?.getXml();m?.path&&r&&await wn(m.path,r)},jsonViewMode:Vt,onToggleJsonViewMode:()=>Ua(Vt==="tree"?"text":"tree"),canCopy:po,copiedContent:wa,onCopyContent:async()=>{(await nn(Ee)).ok?(ja(!0),Rn&&he.success("Contents copied")):he.error("Copy failed")},canCopyPath:ho,copiedPath:ka,onCopyPath:async()=>{(await nn(ot)).ok?(Ca(!0),Rn&&he.success("Path copied")):he.error("Copy failed")},onDownloadFile:o.downloadFile&&m?Ar:void 0,isMobile:b,mode:t,isFullscreen:G,onToggleFullscreen:()=>Q(!G),onExitFullscreen:()=>Q(!1)},Fn=({exitFullscreenOnly:r=!1,layout:p="floating"}={})=>e.jsx(al,{...Lr,layout:p,exitFullscreenOnly:r}),Do=a.useCallback(r=>{ke.current=r,Ut(),window.requestAnimationFrame(()=>{Ze(r)})},[ke,Ut,Ze]),To=a.useCallback(()=>{ke.current&&(ke.current=null),Ut()},[ke,Ut]),Ao=a.useCallback(r=>{ke.current=r,window.requestAnimationFrame(()=>{Ze(r)})},[ke,Ze]),Oo=a.useCallback(()=>{ke.current&&(ke.current=null)},[ke]),Ir={selectedFile:m,loading:mn||Co||So,suppressLoadingIndicator:I,fileError:Xn,isSelectedImage:$e,imageSrc:Ro,imagePreviewNonce:wo,isSelectedPdf:at,pdfSrc:Fo,pdfPreviewNonce:ko,isUnsupportedBinary:Gt,onDownload:o.downloadFile&&m?Ar:void 0,drawioViewMode:bn,drawioRemountNonce:Ha,diagramEditorRef:Zn,diagramEditorXml:_a,onDiagramChange:qa,jsonViewMode:Vt,markdownViewMode:Wt,htmlViewMode:Bt,htmlLoading:No,htmlPreviewNonce:jo,htmlPreviewSrc:Eo,fileContent:Ee,canUseShikiFileView:Er,textViewMode:nt,draftContent:mt,onDraftChange:Te,canEdit:St,vimMode:$a==="vim",editorExtensions:bo,shouldMaskEditorForPendingNavigation:xo,pierreTheme:yo,shikiThemeType:d.metadata.variant==="dark"?"dark":"light",wrapLines:P},Qt=e.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[e.jsx(ol,{open:jr,onOpenChange:Ya,isSaving:_t,onSaveAndContinue:()=>{oo()},onDiscardAndContinue:ao}),e.jsx(Mi,{open:!!be,conflict:be?{path:be.path,displayPath:be.displayPath,exists:be.exists,currentRevision:be.currentRevision,currentContent:be.currentContent,dirtyContent:be.diagramXml??mt}:null,isResolving:pn||_t,showCompare:fa,onToggleCompare:()=>Le(r=>!r),onReload:no,onOverwrite:()=>{ro()},onClose:so}),e.jsxs("div",{className:X("flex flex-col flex-shrink-0",(H||!b&&m)&&"border-b border-border/60"),children:[e.jsx(rl,{showEditorTabsRow:H,isMobile:b,showMobilePageContent:A,onBackMobile:()=>D(!1),selectedFile:m,openFiles:Ot,root:l,alwaysShowActions:y,editorTabsOverflow:la,editorTabsScrollRef:fn,onSelectFile:qe,onCloseFile:io}),b&&m?e.jsx("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:e.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:Fn({layout:"docked"})})}):null,!b&&m?e.jsx(cl,{path:ot,status:Rr,rootLabel:zo,onRevealFolder:Mo,onShowChanges:t==="editor-only"&&Rr!=="git-deleted"?mo:void 0,className:X(H&&"border-t border-border/40"),children:cr?e.jsx("div",{className:"min-w-0 overflow-x-auto",children:Fn({layout:"docked"})}):e.jsxs("div",{className:"flex items-center gap-0.5",children:[_t?e.jsx("span",{className:"px-1 typography-micro text-muted-foreground",children:"Saving…"}):null,Rt?e.jsxs(it,{children:[e.jsx(ct,{asChild:!0,children:e.jsx("span",{className:"inline-flex",children:e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>yr(rt()==="preview"?"edit":"preview"),className:X("size-7 p-0",rt()==="preview"?"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)] hover:bg-[var(--interactive-selection)]":"text-muted-foreground hover:text-foreground"),"aria-label":rt()==="preview"?"Switch to edit mode":"Switch to preview mode",children:e.jsx(F,{name:rt()==="preview"?"eye":"eye-off",className:"size-4"})})})}),e.jsx(lt,{side:"bottom",sideOffset:6,children:rt()==="preview"?"Switch to edit mode":"Switch to preview mode"})]}):null,e.jsx(ll,{...Lr})]})}):null]}),e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[Rn&&m?e.jsx(ia,{open:er,onOpenChange:tr,view:ke.current}):null,e.jsx(bs,{variant:"embedded",...Ir,enableRichPreviews:!0,editorWrapperRef:ga,onEditorViewReady:Do,onEditorViewDestroy:To,enableSearch:!0,searchOpen:ie,onSearchOpenChange:W})]})]}),$r=e.jsx(il,{root:l,isMobile:b,searchQuery:q,onSearchQueryChange:_,searchInputRef:J,searching:fr,searchFailed:mr,searchResults:dr,selectedFile:m,onSelectFile:qe,onOpenDialog:Ma,currentDirectory:K,refreshRoot:ca,childrenByDir:ue,loadErrorsByDir:ae,expandedPaths:Ce,isBrowserClient:j,alwaysShowActions:y,getFileStatus:co,getFolderBadge:lo,fileRowPermissions:fo,downloadFile:o.downloadFile,contextMenuPath:xa,setContextMenuPath:va,rightClickMenuPath:ba,setRightClickMenuPath:ya,toggleDirectory:uo,handleRevealPath:La,refreshDirectory:At}),Po=t==="full"&&G&&m&&e.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:e.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[e.jsx("div",{className:"absolute right-4 top-4 z-30",children:Fn({exitFullscreenOnly:!0})}),e.jsx(bs,{variant:"fullscreen",...Ir,enableRichPreviews:!1,onEditorViewReady:Ao,onEditorViewDestroy:Oo})]})});return f?e.jsx(Cc,{root:l,directory:x||l,entries:x||l?ue[x||l]:void 0,query:q,searchResults:dr,isSearching:fr,searchFailed:mr,directoryError:x||l?ae[x||l]??null:null,refreshing:N,editorPath:A?m?.path??null:null,editor:Qt,onClose:s,onQueryChange:_,onOpenDirectory:Qa,onOpenFile:eo,onBackFromEditor:()=>D(!1),onRefresh:()=>{to()}}):e.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[e.jsx(Sc,{activeDialog:Na,dialogData:Sa,dialogInputValue:Ra,onDialogInputChange:Fa,isDialogSubmitting:Ea,onDialogSubmit:Ta,onClose:Da,inputRef:za}),Po,b?A?Qt:$r:t==="editor-only"?e.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Qt})}):e.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[k>=700&&e.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:$r}),e.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Qt})]})]})};export{Du as FilesView};
|