@pi-chamber/web 1.0.8-rc.2 → 1.0.8-rc.3
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/{AgentsSurface-CcWBqAWV.js → AgentsSurface-wsW9VCRp.js} +1 -1
- package/dist/assets/{ChoicesArtifact-Kk-qvrSB.js → ChoicesArtifact-EwCf4Yxu.js} +1 -1
- package/dist/assets/{DiagramView-DZUBo1uP.js → DiagramView-BX6N99cQ.js} +1 -1
- package/dist/assets/{DiffView-CiZy4jFA.js → DiffView-CI0eSnPP.js} +1 -1
- package/dist/assets/{FileSaveConflictDialog-DZ9NDwOO.js → FileSaveConflictDialog-GLj2W7VE.js} +1 -1
- package/dist/assets/{FilesView-DqiZ9kw9.js → FilesView-CI0tfZQL.js} +1 -1
- package/dist/assets/{GitHubDetailScaffold-DM2DH7o8.js → GitHubDetailScaffold-B85tZ9m7.js} +1 -1
- package/dist/assets/{GitHubLinkPicker-ChB8NZ1h.js → GitHubLinkPicker-Y6AuNiGl.js} +1 -1
- package/dist/assets/{GitHubListPrimitives-CibDiJGq.js → GitHubListPrimitives-BJHBud6i.js} +1 -1
- package/dist/assets/{GitView--EaZQrBr.js → GitView-DueE69kW.js} +3 -3
- package/dist/assets/{IssuesSurface-CySTpaD1.js → IssuesSurface-Cg-xkdIu.js} +2 -2
- package/dist/assets/{JsonTreeView-_yMHKKQZ.js → JsonTreeView-Cvg6lc40.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-D_-2fQw0.js → MarkdownRendererImpl-DExPx-QM.js} +1 -1
- package/dist/assets/{PatchDiff-bHObDlhD.js → PatchDiff-_c3HZ34I.js} +1 -1
- package/dist/assets/{PierreDiffViewer-UY7Cse-s.js → PierreDiffViewer-CZnaqO-_.js} +1 -1
- package/dist/assets/{PullRequestsSurface-iXy6chwc.js → PullRequestsSurface-C9AYPiwo.js} +2 -2
- package/dist/assets/{SessionSwitcherContent-DJGCa_wN.js → SessionSwitcherContent-DOpnN-8S.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CDOX-5Y2.js → SessionSwitcherDropdown-CmHMPZ69.js} +2 -2
- package/dist/assets/{SessionUnreadDot-Dwc3MdvA.js → SessionUnreadDot-CZCQ4t1J.js} +1 -1
- package/dist/assets/SettingsView-D5PO5M3z.js +11 -0
- package/dist/assets/{SettingsWindow-CUg49Mfh.js → SettingsWindow-DXV5UOE8.js} +1 -1
- package/dist/assets/{SubagentsArtifact-DUZX9tDe.js → SubagentsArtifact-CO1ZiI1x.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BuZZaRw4.js → ToolOutputDialog-GOwNLj-y.js} +1 -1
- package/dist/assets/{ToolPartDiffPreview-CKncG6i2.js → ToolPartDiffPreview-BoaiZji6.js} +1 -1
- package/dist/assets/{VirtualizedFileDiff-BGZiLPe_.js → VirtualizedFileDiff-Chq1X8nw.js} +1 -1
- package/dist/assets/VisualFrame-u7aRcX7O.js +22 -0
- package/dist/assets/{VisualsArtifact-Bq0vMO-i.js → VisualsArtifact-D9vPjihW.js} +1 -1
- package/dist/assets/{collapsible-Bro9KrfM.js → collapsible-BjpDEohv.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-DJQqK49u.js → computeVirtualFileMetrics-DmPCxbok.js} +1 -1
- package/dist/assets/{contextFileOpenGuard-ByWK3Sru.js → contextFileOpenGuard-CukNcUeY.js} +1 -1
- package/dist/assets/{fileTreeStatus-CyJ3TOYD.js → fileTreeStatus-CDyfNPYO.js} +1 -1
- package/dist/assets/{gitStatusPredicates-BsXrwngT.js → gitStatusPredicates-uI7Y7L5k.js} +1 -1
- package/dist/assets/{githubLink-g2bmC0qi.js → githubLink-B9Mxac4R.js} +1 -1
- package/dist/assets/{index-C9rUUQ_Y.js → index-BWq2ibCw.js} +1 -1
- package/dist/assets/{index-CKKWVoND.js → index-BxKPJ9uG.js} +9 -9
- package/dist/assets/index-C5JgjS20.css +1 -0
- package/dist/assets/{main-DsLMU9CT.js → main-CWfC-9xT.js} +4 -4
- package/dist/assets/{main-DT-4_fhe.js → main-ckQ0ciIN.js} +2 -2
- package/dist/assets/{markdownCore-QmM_aOnZ.js → markdownCore-p2q2Kxwo.js} +1 -1
- package/dist/assets/{miniChat-BqGslD2z.js → miniChat-x2TrwRYA.js} +2 -2
- package/dist/assets/{mobile-C5JOcDIC.js → mobile-B0x2G8h1.js} +2 -2
- package/dist/assets/{nativeFileSave-DSMsJqXM.js → nativeFileSave-D542OJlG.js} +1 -1
- package/dist/assets/{pi-session-focus-preference-Cc_S4zi1.js → pi-session-focus-preference-Q_RZUCnt.js} +1 -1
- package/dist/assets/{renderDiffWithHighlighter-BXhnIAHg.js → renderDiffWithHighlighter-CSFGSknx.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CiSkecEE.js → renderElectronMiniChatApp-CFIdesZT.js} +2 -2
- package/dist/assets/{renderFileWithHighlighter-CK29YZtC.js → renderFileWithHighlighter-C5JE0mRX.js} +1 -1
- package/dist/assets/{renderMobileApp-C4JuoxsZ.js → renderMobileApp-B1ybjcGM.js} +3 -3
- package/dist/assets/{runtimeEndpointReset-Dwj-jCDS.js → runtimeEndpointReset-DyZSKCYM.js} +7 -7
- package/dist/assets/{runtimeSurface-0K7vuUpd.js → runtimeSurface-BR_dhe7_.js} +1 -1
- package/dist/assets/{selection-CnYkEsu_.js → selection-CfOpW4rA.js} +1 -1
- package/dist/assets/{useAppFontEffects-CV5UyTRw.js → useAppFontEffects-COMvkffC.js} +97 -97
- package/dist/assets/{useGitHubRemoteSearch-CgP-zEBj.js → useGitHubRemoteSearch-M1AE2YuX.js} +1 -1
- package/dist/assets/{useSwitcherItems-C8G5F0hs.js → useSwitcherItems-D0i2BYYP.js} +1 -1
- package/dist/assets/{web-components-BpncHjnV.js → web-components-wOQkOurQ.js} +1 -1
- 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/plugins/visuals/extension.js +2 -2
- package/server/index.js +4 -0
- package/server/lib/pi/ui-settings-store.js +2 -1
- package/server/lib/wallpaper/DOCUMENTATION.md +25 -0
- package/server/lib/wallpaper/routes.js +63 -0
- package/server/lib/wallpaper/routes.test.js +109 -0
- package/server/lib/wallpaper/store.js +87 -0
- package/dist/assets/SettingsView-DA-U9lsj.js +0 -11
- package/dist/assets/VisualFrame-DBZkHFnG.js +0 -22
- package/dist/assets/index-B_L9GVYw.css +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{w as v,S as y,B as x,I as m}from"./useAppFontEffects-
|
|
1
|
+
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as f}from"./vendor-react-Bz1tRBxM.js";import{w as v,S as y,B as x,I as m}from"./useAppFontEffects-COMvkffC.js";import{p as w,r as S,u as j,a as A,b as I,c as k}from"./selection-CfOpW4rA.js";import"./vendor-clsx-B-dksMZM.js";import"./index-BxKPJ9uG.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-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";const R=(s,a)=>s.length===a.length&&s.every((i,c)=>i===a[c]),T=s=>s==="running"||s==="pending"?"running":s==="error"?"error":s==="cancelled"?"cancelled":"completed",z=new Intl.DateTimeFormat(void 0,{hour:"numeric",minute:"2-digit"}),D=new Intl.DateTimeFormat(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}),F=s=>{const a=new Date(s);return a.toDateString()===new Date().toDateString()?z.format(a):D.format(a)};function b({title:s,count:a}){return t.jsxs("header",{className:"flex items-baseline gap-2 px-0.5",children:[t.jsx("h3",{className:"typography-meta font-medium text-foreground",children:s}),t.jsx("span",{className:"typography-micro tabular-nums text-subtle-foreground",children:a})]})}function H({sessionId:s}){const a=v(e=>{if(!s)return[];const n=e.reducer.bySession.get(s);if(!n)return[];const r=[];for(const l of n.parts.values())l.type==="tool"&&l.tool?.name===y&&r.push(l);return r},R,s?`session:${s}`:"chrome"),i=f.useMemo(()=>a.flatMap(e=>{const n=T(e.tool?.state),r=w(e.tool?.metadata,n)??(n==="running"?S(e.tool?.input):null);return!r||r.runs.length===0?[]:[{id:e.id,startedAt:e.tool?.startedAt??0,details:r}]}).sort((e,n)=>n.startedAt-e.startedAt),[a]),{active:c,finished:h}=f.useMemo(()=>{const e=[],n=[];for(const r of i)r.details.runs.forEach((l,p)=>{const N={key:`${r.id}:${p}`,callId:r.id,index:p,startedAt:r.startedAt,run:l};(l.status==="running"||l.status==="queued"?e:n).push(N)});return{active:e,finished:n}},[i]),d=j(e=>e.selected),u=j(e=>e.select),o=d?i.find(e=>e.id===d.callId):void 0,g=d&&o?o.details.runs[d.index]:void 0;if(g&&o){const{runs:e}=o.details,n=d?.index??0;return t.jsxs("div",{className:"@container flex h-full min-h-0 flex-col","data-testid":"agents-surface",children:[t.jsxs("nav",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-border/60 px-1.5","aria-label":"Sub-agent",children:[t.jsxs(x,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>u(null),children:[t.jsx(m,{name:"arrow-left-s",className:"size-4"}),"All agents"]}),e.length>1?t.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[t.jsx("span",{className:"mr-1 typography-micro tabular-nums text-subtle-foreground",children:`${n+1} of ${e.length}`}),t.jsx(x,{variant:"ghost",size:"icon",className:"size-7","aria-label":"Previous sub-agent",disabled:n===0,onClick:()=>u({callId:o.id,index:n-1}),children:t.jsx(m,{name:"arrow-up-s",className:"size-4"})}),t.jsx(x,{variant:"ghost",size:"icon",className:"size-7","aria-label":"Next sub-agent",disabled:n===e.length-1,onClick:()=>u({callId:o.id,index:n+1}),children:t.jsx(m,{name:"arrow-down-s",className:"size-4"})})]}):null]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:t.jsx(A,{run:g})})]})}return i.length===0?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[t.jsx(m,{name:"robot-2","aria-hidden":"true",className:"size-6 text-subtle-foreground"}),t.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:"No sub-agents in this session"}),t.jsx("p",{className:"max-w-64 text-balance typography-micro text-muted-foreground",children:"When the agent hands work to sub-agents, each one shows up here with its steps and answer."})]}):t.jsxs("div",{className:"@container flex h-full min-h-0 flex-col gap-5 overflow-y-auto p-3","data-testid":"agents-surface",children:[c.length>0?t.jsxs("section",{className:"space-y-2","aria-label":"Working",children:[t.jsx(b,{title:"Working",count:c.length}),t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(15rem,1fr))] gap-2",children:c.map(e=>t.jsx(I,{run:e.run,onOpen:()=>u({callId:e.callId,index:e.index})},e.key))})]}):null,h.length>0?t.jsxs("section",{className:"space-y-1","aria-label":"Finished",children:[t.jsx(b,{title:"Finished",count:h.length}),t.jsx("ul",{className:"-mx-1.5",children:h.map(e=>t.jsx("li",{children:t.jsx(k,{run:e.run,time:e.startedAt>0?F(e.startedAt):void 0,onOpen:()=>u({callId:e.callId,index:e.index})})},e.key))})]}):null]})}export{H as AgentsSurface};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as d}from"./vendor-react-Bz1tRBxM.js";import{B as y,I as v,f as P,m as R,n as _,p as M}from"./useAppFontEffects-
|
|
1
|
+
import{j as t}from"./vendor-boot-D-KEJjsM.js";import{R as d}from"./vendor-react-Bz1tRBxM.js";import{B as y,I as v,f as P,m as R,n as _,p as M}from"./useAppFontEffects-COMvkffC.js";import{c as T}from"./index-BxKPJ9uG.js";import{u as B,a as L,b as G,c as V,d as X,e as K}from"./VisualFrame-u7aRcX7O.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";const W=6,Y=/^data:image\/(?:png|jpeg|webp|gif|svg\+xml);base64,/,Q=e=>typeof e=="string"&&Y.test(e),b=e=>e.toUpperCase(),U=e=>String.fromCharCode(97+e),J=(e,s)=>{if(!e||typeof e!="object")return null;const n=e,r=typeof n.label=="string"?n.label.trim():"";if(!r)return null;const a=typeof n.id=="string"&&/^[a-z]$/.test(n.id)?n.id:U(s),o=typeof n.description=="string"?n.description.trim():"";return{id:a,label:r,...o?{description:o}:{},...typeof n.html=="string"&&n.html.length>0?{html:n.html}:{},...Q(n.image)?{image:n.image}:{},...typeof n.path=="string"&&n.path.trim()?{path:n.path.trim()}:{}}},S=e=>{if(!Array.isArray(e)||e.length===0)return null;const s=[],n=new Set;for(const[r,a]of e.slice(0,W).entries()){const o=J(a,r);if(!o||n.has(o.id))return null;n.add(o.id),s.push(o)}return s},k=e=>typeof e=="string"&&e.trim()?e.trim():"Choose one",Z=e=>{if(!e||typeof e!="object")return null;const s=e,n=S(s.options);if(!n||n.some(a=>a.html===void 0&&a.image===void 0))return null;const r={title:k(s.title),options:n};if(s.answer===null)return{...r,answer:null};if(s.answer&&typeof s.answer=="object"){const a=s.answer;if(typeof a.id!="string"||!n.some(l=>l.id===a.id))return r;const o=typeof a.note=="string"?a.note.trim():"";return{...r,answer:{id:a.id,...o?{note:o}:{}}}}return r},q=e=>{if(!e||typeof e!="object")return null;const s=e,n=S(s.options);return n?{title:k(s.title),options:n.map(r=>{const a={...r};return delete a.image,a})}:null},ee=e=>e.choices.length===0?null:{title:k(e.title),options:e.choices.map(s=>{const n=`${b(s.id)}: `,r=s.label.startsWith(n)?s.label.slice(n.length):s.label;return{id:s.id,label:r||s.label,...s.description?{description:s.description}:{}}})},te=(e,s)=>{const n=r=>r?e.find(a=>a.id===r):void 0;return n(s.picked)??n(s.chosenId)??e.find(r=>s.offered?.includes(r.id))??e[0]},se=e=>{const s=e?.options;return Array.isArray(s)?s.reduce((n,r)=>{const a=r?.html;return n+(typeof a=="string"?a.length:0)},0):0},D=120,H=560,ne=240,re=2e3,ae=(e,s,n)=>Math.min(n,Math.max(s,e)),O=e=>`${b(e.id)}: ${e.label}`;function ie({option:e,allowNetwork:s,expanded:n,onExpandedChange:r}){const a=G(e.html,s),o=d.useRef(null),l=V(o),[m,u]=d.useState("page"),[p,j]=d.useState(null),w=p??ne,f=O(e),N=d.useCallback(g=>{j(ae(g,D,H))},[]);return t.jsxs("div",{ref:o,style:{height:w},"data-choice-page":p===null?"loading":"fitted",children:[l?t.jsx(X,{title:f,srcDoc:a,style:{height:w},onHeight:N}):null,t.jsx(K,{details:{title:f,html:e.html},srcDoc:a,open:n,onOpenChange:r,view:m,onViewChange:u})]})}function oe({option:e,expanded:s,onExpandedChange:n}){const r=O(e);return t.jsxs(t.Fragment,{children:[t.jsx("img",{src:e.image,alt:e.description?`${r}. ${e.description}`:r,className:"block w-full bg-[var(--surface-muted)] object-contain",style:{maxHeight:H}}),t.jsx(R,{open:s,onOpenChange:n,children:t.jsxs(_,{showCloseButton:!1,className:"h-[calc(100dvh-2rem)] w-[min(1200px,calc(100vw-2rem))] max-w-none gap-0 overflow-hidden bg-background p-0",children:[t.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border/60 pl-4 pr-2",children:[t.jsx(M,{className:"min-w-0 flex-1 truncate typography-ui-header font-medium leading-normal",children:r}),t.jsx(y,{variant:"ghost",size:"xs",className:"text-muted-foreground",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:t.jsx(v,{name:"close",className:"size-3.5"})})]}),t.jsx("div",{className:"flex min-h-0 flex-1 items-center justify-center overflow-auto bg-[var(--surface-muted)] p-4",children:t.jsx("img",{src:e.image,alt:r,className:"max-h-full max-w-full object-contain"})})]})})]})}function le({option:e,allowNetwork:s,expanded:n,onExpandedChange:r}){return e.html!==void 0?t.jsx(ie,{option:e,allowNetwork:s,expanded:n,onExpandedChange:r}):e.image!==void 0?t.jsx(oe,{option:e,expanded:n,onExpandedChange:r}):t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 px-4 py-8 text-center text-muted-foreground",style:{minHeight:D},children:[t.jsx("span",{className:"typography-meta",children:"Preview not loaded"}),e.path?t.jsx("span",{className:"max-w-full truncate font-mono typography-micro text-subtle-foreground",children:e.path}):null]})}const ce=(e,s)=>s?"Waiting for your choice":e.answer===null?"No choice made":e.answer?`You chose ${b(e.answer.id)}`:null;function de({details:e,question:s,allowNetwork:n}){const[r,a]=d.useState(""),[o,l]=d.useState(!1),[m,u]=d.useState(!1),[p,j]=d.useState(!1),[w,f]=d.useState(null),N=d.useId(),g=e.answer?.id,c=te(e.options,{picked:w,chosenId:g,offered:s?.choices.map(i=>i.id)}),C=b(c.id),I=i=>{l(!0),u(!1),i.catch(()=>u(!0)).finally(()=>l(!1))},A=ce(e,!!s),E=!!s?.choices.some(i=>i.id===c.id),z=c.html!==void 0||c.image!==void 0,$=i=>{if(i.key!=="ArrowLeft"&&i.key!=="ArrowRight")return;const h=e.options.findIndex(F=>F.id===c.id),x=e.options[(h+(i.key==="ArrowRight"?1:-1)+e.options.length)%e.options.length];i.preventDefault(),f(x.id),i.currentTarget.querySelector(`[data-choice-tab="${x.id}"]`)?.focus()};return t.jsxs("section",{className:"my-3 space-y-2","data-plugin-artifact":"visuals-choices","aria-label":e.title,children:[t.jsxs("header",{className:"flex min-h-7 flex-wrap items-baseline gap-x-2",children:[t.jsx("h3",{className:"min-w-0 typography-ui-label font-medium text-foreground [text-wrap:balance]",children:e.title}),A?t.jsx("span",{className:"typography-micro text-subtle-foreground",children:A}):null]}),t.jsxs("figure",{className:"overflow-hidden rounded-xl border border-border/60 bg-background","data-choice":c.id,children:[t.jsxs("div",{className:"flex h-11 items-center gap-2 border-b border-border/60 pl-2 pr-1.5",children:[t.jsx("div",{role:"group","aria-label":"Options",className:"scrollbar-none flex min-w-0 flex-1 items-center gap-1.5 overflow-x-auto py-1",onKeyDown:$,children:e.options.map(i=>{const h=b(i.id),x=i.id===c.id;return t.jsxs(y,{variant:"chip",size:"xs",className:"max-w-[14rem] shrink-0 gap-1.5","aria-pressed":x,tabIndex:x?0:-1,"data-choice-tab":i.id,"data-chosen":i.id===g||void 0,title:i.label,onClick:()=>f(i.id),children:[t.jsx("span",{"aria-hidden":"true",className:"typography-micro font-medium text-muted-foreground",children:h}),t.jsx("span",{className:"sr-only",children:`${h}: `}),t.jsx("span",{className:"min-w-0 truncate",children:i.label}),i.id===g?t.jsxs(t.Fragment,{children:[t.jsx(v,{name:"check","aria-hidden":"true",className:"size-3.5 shrink-0"}),t.jsx("span",{className:"sr-only",children:", chosen"})]}):null]},i.id)})}),z?t.jsx(y,{variant:"ghost",size:"xs",className:"shrink-0 text-muted-foreground",onClick:()=>j(!0),"aria-label":`Expand ${C}`,title:"Expand",children:t.jsx(v,{name:"fullscreen",className:"size-3.5"})}):null]}),t.jsx("div",{className:"grid",children:e.options.map(i=>{const h=i.id===c.id;return t.jsx("div",{className:T("min-w-0 [grid-area:1/1]",h?null:"pointer-events-none invisible"),"aria-hidden":h?void 0:!0,"data-choice-panel":i.id,children:t.jsx(le,{option:i,allowNetwork:n,expanded:h&&p,onExpandedChange:j})},i.id)})}),c.description||E?t.jsxs("figcaption",{className:"flex min-h-11 items-center gap-3 border-t border-border/60 px-3 py-2",children:[t.jsx("p",{className:"min-w-0 flex-1 typography-meta text-muted-foreground [text-wrap:pretty]",children:c.description??""}),E&&s?t.jsx(y,{size:"sm",className:"shrink-0",onClick:()=>I(s.answer(c.id,r)),disabled:o,children:`Choose ${C}`}):null]}):null]}),s?t.jsxs("div",{className:"flex items-center gap-2",children:[s.allowNote?t.jsxs(t.Fragment,{children:[t.jsx("label",{htmlFor:N,className:"sr-only",children:"Note to send with your choice"}),t.jsx(P,{id:N,value:r,onChange:i=>a(i.target.value),placeholder:"Add a note for the agent (optional)",maxLength:re,disabled:o,className:"h-8 flex-1"})]}):t.jsx("span",{className:"flex-1"}),t.jsx(y,{variant:"ghost",size:"sm",className:"shrink-0 text-muted-foreground",onClick:()=>I(s.dismiss()),disabled:o,children:"Skip"})]}):e.answer?.note?t.jsxs("p",{className:"typography-meta text-muted-foreground [text-wrap:pretty]",children:[t.jsx("span",{className:"text-foreground",children:"Your note: "}),e.answer.note]}):null,m?t.jsx("p",{role:"alert",className:"typography-meta text-[var(--status-error)]",children:"Could not send your answer. Check your connection and try again."}):null]})}function ve({part:e,directory:s,question:n}){const r=B(s),a=e.state?.status,o=e.state?.metadata,l=e.state?.input,m=a==="pending"||a==="running",u=d.useMemo(()=>Z(o)??(m&&n?q(l)??ee(n):null),[l,o,n,m]);if(m&&!u){const p=l?.title;return t.jsx(L,{title:typeof p=="string"?p:void 0,size:se(l),label:"Drawing options"})}return!u||!m&&a!=="completed"?null:t.jsx(de,{details:u,question:m?n:void 0,allowNetwork:r})}export{ve as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as c}from"./vendor-boot-D-KEJjsM.js";import{R as t}from"./vendor-react-Bz1tRBxM.js";import{j as $,t as d,I as B}from"./useAppFontEffects-
|
|
1
|
+
import{j as c}from"./vendor-boot-D-KEJjsM.js";import{R as t}from"./vendor-react-Bz1tRBxM.js";import{j as $,t as d,I as B}from"./useAppFontEffects-COMvkffC.js";import{u as A,b as G,s as ee,i as W}from"./index-BxKPJ9uG.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-GLj2W7VE.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CXhN0IMY.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-tailwind-merge-BKkUfl9q.js";import"./vendor-fuse.js-t_7AcMTv.js";import"./vendor-react-drawio-IYnLUY5N.js";const se=l=>l.split("/").pop()||l;function xe(){const{files:l}=$(),[x,k]=t.useState(null),[L,R]=t.useState(""),[M,E]=t.useState(!0),[b,h]=t.useState(null),[m,F]=t.useState(!1),[U,p]=t.useState(!1),[j,P]=t.useState(!1),[q,H]=t.useState(0),g=t.useRef(void 0),C=t.useRef(""),v=t.useRef(0),S=t.useRef(0),y=t.useRef(0),D=t.useRef(null),I=t.useRef(!0),w=t.useRef(null),T=A(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const i=t.useCallback((e,n,s)=>I.current&&v.current===e&&G()===n&&w.current===s,[]),K=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=G(),u=l?.readFile;S.current+=1,y.current+=1,E(!0),k(e),w.current=e,h(null),p(!1),P(!1),F(!1);try{const r=await u?.(e);if(!i(n,s,e))return;if(!r){d.error("Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}C.current=r.content,R(r.content),g.current=r.revision}catch(r){if(!i(n,s,e))return;d.error(r instanceof Error?r.message:"Failed to read file"),k(null),w.current=null,C.current="",R(""),g.current=void 0,E(!1);return}finally{i(n,s,e)&&E(!1)}},[l,i]);t.useEffect(()=>ee(()=>{if(v.current+=1,g.current=void 0,S.current+=1,y.current+=1,!I.current)return;h(null),p(!1),P(!1),F(!1);const e=w.current;e&&K(e)}),[K]),t.useEffect(()=>{if(!T)return;const e=A.getState().consumePendingDiagramFile();e&&K(e)},[K,T]);const z=t.useCallback(async(e,n,s,u,r,o)=>{let a=null,f=s,V=u;try{if(V){const N=await l?.readFile?.(e);if(!i(r,o,e))return;N&&(a=N.content??null,typeof N.revision=="string"&&(f=N.revision),V=N.exists!==!1)}}catch{if(!i(r,o,e))return}i(r,o,e)&&(h({path:e,displayPath:se(e),exists:V,currentRevision:f,currentContent:a,dirtyContent:n,runtimeKey:o}),p(!1))},[l,i]),X=t.useCallback(async(e,n,s,u,r)=>{const o=await l?.writeFile?.(e,n,te(g.current,s?!0:void 0));return i(u,r,e)?{stale:!1,success:!!o?.success,revision:o?.revision}:{stale:!0}},[l,i]),O=t.useCallback((e,n)=>{C.current=e,typeof n<"u"&&(g.current=n),D.current?.getXml()===e&&R(e)},[]),J=t.useCallback(async()=>{const e=D.current?.getXml();if(!x||!l?.writeFile||!e||e===C.current||j||m)return;const n=v.current,s=G(),u=x,r=e,o=S.current+1;S.current=o,P(!0);try{const a=await X(u,r,!1,n,s);if(a.stale)return;if(!a.success){d.error("Failed to write file");return}O(r,a.revision)}catch(a){if(!i(n,s,u))return;if(W(a)){await z(u,r,a.currentRevision??null,a.exists,n,s);return}d.error(a instanceof Error?a.message:"Save failed")}finally{S.current===o&&P(!1)}},[O,x,l,i,m,j,z,X]),Q=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!e.exists){k(null),w.current=null,C.current="",R(""),g.current=void 0,h(null),p(!1);return}const u=y.current+1;y.current=u,F(!0);try{const r=await l?.readFile?.(e.path);if(!i(n,s,e.path))return;if(!r){d.error("Failed to read file");return}C.current=r.content??"",R(r.content??""),g.current=r.revision,H(o=>o+1),h(null),p(!1)}catch(r){if(!i(n,s,e.path))return;d.error(r instanceof Error?r.message:"Failed to read file")}finally{y.current===u&&F(!1)}},[l,i,m,b]),Y=t.useCallback(async()=>{const e=b;if(!e||m||!i(v.current,e.runtimeKey,e.path))return;const n=v.current,s=e.runtimeKey;if(!l?.writeFile){d.error("Saving not supported");return}const o=D.current?.getXml()??e.dirtyContent;if(!o){d.error("Failed to write file");return}const a=y.current+1;y.current=a,F(!0);try{const f=await X(e.path,o,!0,n,s);if(f.stale)return;if(!f.success){d.error("Failed to write file");return}O(o,f.revision),h(null),p(!1)}catch(f){if(!i(n,s,e.path))return;if(W(f)){await z(e.path,o,f.currentRevision??e.currentRevision,f.exists,n,s);return}d.error(f instanceof Error?f.message:"Save failed")}finally{y.current===a&&F(!1)}},[O,l,i,m,z,X,b]),Z=t.useCallback(()=>{m||j||(h(null),p(!1))},[m,j]),_=x?x.split("/").pop()||x:"";return x?M?c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx(B,{name:"loader-4",className:"size-4 animate-spin"})}):c.jsxs("div",{className:"flex h-full flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-border/30 px-3 py-1.5",children:[c.jsx(B,{name:"file",className:"size-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"typography-ui text-muted-foreground truncate flex-1",children:_}),c.jsx("button",{type:"button",onClick:()=>{J()},className:"size-6 flex items-center justify-center rounded-md text-foreground hover:bg-interactive-hover/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Save diagram",children:c.jsx(B,{name:"save-3",className:"size-4"})}),c.jsx("button",{type:"button",onClick:()=>A.getState().setActiveMainTab("chat"),className:"size-6 flex items-center justify-center rounded-md text-muted-foreground hover:bg-interactive-hover/50 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary",title:"Close diagram view",children:c.jsx(B,{name:"close",className:"size-4"})})]}),c.jsx("div",{className:"flex-1 min-h-0",children:c.jsx(re,{ref:D,xml:L,className:"h-full"},q)}),c.jsx(ne,{open:!!b,conflict:b,isResolving:m||j,showCompare:U,onToggleCompare:()=>p(e=>!e),onReload:()=>{Q()},onOverwrite:()=>{Y()},onClose:Z})]}):c.jsx("div",{className:"flex h-full items-center justify-center p-3",children:c.jsx("div",{className:"typography-ui text-muted-foreground",children:"Pick a file from the tree."})})}export{xe as DiagramView};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,b1 as Rt}from"./vendor-boot-D-KEJjsM.js";import{R as r}from"./vendor-react-Bz1tRBxM.js";import{c as se,u as Q,b as ot,n as Ye}from"./index-
|
|
1
|
+
import{j as t,b1 as Rt}from"./vendor-boot-D-KEJjsM.js";import{R as r}from"./vendor-react-Bz1tRBxM.js";import{c as se,u as Q,b as ot,n as Ye}from"./index-BxKPJ9uG.js";import{bL as Et,bH as At,aS as Tt,aj as lt,aW as ct,bl as Mt,K as Re,B as Le,I as G,j as ut,ax as ce,t as dt,bm as ft,D as It,h as Pt,i as $t,a0 as Je,b8 as Wt,bM as _t,bN as Bt,aZ as Ot,ai as zt,bO as Gt,bP as Ht,bQ as Ut,x as Vt,bR as qt,bS as Kt,ap as Xt,aq as Qt,ar as Yt}from"./useAppFontEffects-COMvkffC.js";import{d as pt,i as ht,a as Ge,b as He,c as Jt,C as Zt}from"./gitStatusPredicates-uI7Y7L5k.js";import{p as en}from"./VirtualizedFileDiff-Chq1X8nw.js";import{P as tn}from"./PierreDiffViewer-CZnaqO-_.js";import{v as nn,g as sn}from"./contextFileOpenGuard-CukNcUeY.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-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./web-components-wOQkOurQ.js";import"./computeVirtualFileMetrics-DmPCxbok.js";import"./vendor-shiki-BEwTOAFg.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-shikijs-engine-oniguruma-DPWuIF1G.js";import"./themeResolver-DrfmQi8i.js";import"./vendor-pierre-theming-BO6EPniU.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"./renderDiffWithHighlighter-CSFGSknx.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-CMbTn5WQ.js";import"./runtimeEndpointReset-DyZSKCYM.js";import"./SessionUnreadDot-CZCQ4t1J.js";/* empty css */import"./permissionStore-zIpxq9Pq.js";import"./appThemeRegistry-Ca8eGRB9.js";import"./registerCustomTheme-C-h6lsYW.js";function rn(s,n=10){const e=[];let i;for(const l of s.split(`
|
|
2
2
|
`)){const f=l.match(Et);if(f!=null){i!=null&&(i.hunkLines.length>0&&(Pe(i,n,"trailing"),Oe(i,e)),i=void 0);const d=parseInt(f[3]),b=parseInt(f[1]),g=parseInt(f[4]??"1"),c=parseInt(f[2]??"1");isNaN(d)||isNaN(b)||isNaN(g)||isNaN(c)?e.push(l):i={additionStart:d,deletionStart:b,additionCount:0,deletionCount:0,hunkLines:[],contextLines:[]};continue}if(i==null){e.push(l);continue}if(l.startsWith(" "))i.contextLines.push(l);else if(l!==""){if(i.hunkLines.length>0&&i.contextLines.length>n*2){const d=i.contextLines.length-n*2,b=i.contextLines.slice(-n);Pe(i,n,"trailing");const{additionCount:g,deletionCount:c}=i;Oe(i,e),i={additionStart:i.additionStart+g+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Pe(i,n,i.hunkLines.length===0?"leading":"before-change"),i.hunkLines.push(l),l.startsWith("+")?i.additionCount+=1:l.startsWith("-")&&(i.deletionCount+=1)}}i!=null&&i.hunkLines.length>0&&(Pe(i,n,"trailing"),Oe(i,e));const o=e.join(`
|
|
3
3
|
`);return s.endsWith(`
|
|
4
4
|
`)?`${o}
|
package/dist/assets/{FileSaveConflictDialog-DZ9NDwOO.js → FileSaveConflictDialog-GLj2W7VE.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as r}from"./vendor-boot-D-KEJjsM.js";import{R as a}from"./vendor-react-Bz1tRBxM.js";import{D}from"./vendor-react-drawio-IYnLUY5N.js";import{c as C}from"./index-
|
|
1
|
+
import{j as r}from"./vendor-boot-D-KEJjsM.js";import{R as a}from"./vendor-react-Bz1tRBxM.js";import{D}from"./vendor-react-drawio-IYnLUY5N.js";import{c as C}from"./index-BxKPJ9uG.js";import{m as E,n as S,o as N,p as B,q as F,U as H,B as p}from"./useAppFontEffects-COMvkffC.js";const A='<mxfile><diagram id="new" name="Page-1"><mxGraphModel dx="0" dy="0" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0"><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel></diagram></mxfile>';function w(){if(typeof document>"u")return!1;const t=document.documentElement.getAttribute("data-theme");return t==="dark"||!t&&window.matchMedia("(prefers-color-scheme: dark)").matches}const T=a.forwardRef(function({xml:e,readOnly:s,className:d,onChange:u},m){const l=a.useRef(e),c=a.useRef(null),i=a.useRef(!1),[o,y]=a.useState(w),f=a.useRef(e),h=a.useRef(e);h.current!==e&&(h.current=e,f.current=e,l.current=e);const v=a.useRef(o);v.current!==o&&(v.current=o,f.current=l.current);const g=a.useRef(null);a.useEffect(()=>{const n=()=>y(w());n();const x=new MutationObserver(n);return x.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>x.disconnect()},[]),a.useEffect(()=>{const n=setTimeout(()=>{g.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(n)},[]),a.useImperativeHandle(m,()=>({getXml:()=>l.current}));const R=a.useCallback(()=>{!e&&!i.current&&(i.current=!0,setTimeout(()=>{c.current?.template({})},500))},[e]),j=a.useCallback(n=>{l.current=n.xml,u?.(n.xml)},[u]);return r.jsx("div",{ref:g,className:C("h-full w-full",d),children:r.jsx(D,{ref:c,xml:f.current||A,autosave:!0,urlParameters:{ui:s?"simple":o?"dark":"kennedy",spin:!0,libraries:!s,chrome:s,nav:s,layers:s,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:R,onAutoSave:j},o?"dark":"light")})}),X=(t,e)=>!t||t.runtimeKey!==e.runtimeKey||t.root!==e.root||t.path!==e.path||t.generation!==e.generation,b=t=>{if(typeof t=="string")return t;if(t===null)return null},G=(t,e)=>{if(e===!0)return t!==void 0?{expectedRevision:b(t),overwrite:!0}:{overwrite:!0};if(t!==void 0)return{expectedRevision:b(t)}},W=(t,e)=>!!(t&&e&&t.runtimeKey===e.runtimeKey&&t.root===e.root&&t.path===e.path&&t.generation===e.generation),k=(t,e=4e3)=>t.length>e?`${t.slice(0,e)}
|
|
2
2
|
|
|
3
3
|
… truncated …`:t,Y=({open:t,conflict:e,isResolving:s,showCompare:d,onToggleCompare:u,onReload:m,onOverwrite:l,onClose:c})=>{if(!e)return null;const i=!e.exists;return r.jsx(E,{open:t,onOpenChange:o=>{o||c()},children:r.jsxs(S,{showCloseButton:!1,className:"max-w-lg",children:[r.jsxs(N,{children:[r.jsx(B,{children:i?"File deleted on disk":"File changed on disk"}),r.jsx(F,{children:i?`“${e.displayPath}” was deleted since you opened it. Your edits are preserved. Reload to discard them, or overwrite to recreate the file.`:`“${e.displayPath}” changed since you opened it. Your edits are preserved. Reload to discard them and load the current version, or overwrite to keep your edits.`})]}),d&&!i?r.jsxs("div",{className:"grid max-h-64 grid-cols-1 gap-2 overflow-auto py-2",children:[r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Current version on disk"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.currentContent??"")})]}),r.jsxs("div",{children:[r.jsx("div",{className:"typography-meta text-muted-foreground",children:"Your edits"}),r.jsx("pre",{className:"mt-1 max-h-28 overflow-auto rounded-md bg-[var(--surface-subtle)] p-2 text-xs whitespace-pre-wrap break-words",children:k(e.dirtyContent)})]})]}):null,r.jsxs(H,{className:"flex flex-wrap gap-2",children:[i?null:r.jsx(p,{variant:"outline",onClick:u,disabled:s,"aria-label":d?"Hide version comparison":"Compare versions",title:d?"Hide version comparison":"Compare versions",children:d?"Hide compare":"Compare"}),r.jsx(p,{variant:"outline",onClick:m,disabled:s,"aria-label":i?"Discard edits and close":"Reload current version",title:i?"Discard edits and close":"Reload current version",children:i?"Discard edits":"Reload"}),r.jsx(p,{variant:"destructive",onClick:l,disabled:s,"aria-label":i?"Recreate file with my edits":"Overwrite with my edits",title:i?"Recreate file with my edits":"Overwrite with my edits",children:s?"Working…":"Overwrite"})]})]})})};export{T as D,Y as F,G as b,W as i,X as s};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aj as Po,b4 as zt,b5 as $n,E as c,ah as Fs,Q as we,b6 as Io,b7 as $o,O as Es,M as Tt,ap as Kn,S as Bo,aq as an,j as e,ak as Vo,b8 as Wo,af as _o,b9 as qo,ba as ut,bb as Vr,bc as Ko,J as Ho,U as zn,bd as Go,be as Uo,bf as Xo,b1 as Yo,bg as Jo,X as Zo,L as Qo}from"./vendor-boot-D-KEJjsM.js";import{R as a,a as w}from"./vendor-react-Bz1tRBxM.js";import{c as X,f as zs,B as Ms,N as ei,I as ti,O as ni,P as ri,Q as si,u as ye,i as Ds,R as Oe,b as ai,s as oi,T as ii,U as bt,V as ci,W as li,a as Wr,X as ui,Y as _r,r as qr,Z as Mn,_ as di}from"./index-CKKWVoND.js";import{cp as fi,aW as jt,B as U,I as F,f as Dt,cq as mi,m as Ts,n as As,o as Os,p as Ls,q as Ps,U as Is,D as on,h as cn,i as ln,a2 as nn,t as he,a0 as fe,aY as Bn,cr as rn,aj as $s,aE as Kr,ag as pi,bl as Bs,K as Vs,cs as Ws,J as _s,H as Vn,L as hi,ap as it,aq as ct,ar as lt,bE as gi,bF as xi,bG as vi,j as bi,$ as yi,ai as wi,aZ as ji,bP as ki,ct as Hr,cu as Gr,bS as Ci,cv as Ur,a as Ni,g as Si}from"./useAppFontEffects-CV5UyTRw.js";import{javascript as yt}from"./vendor-codemirror-lang-javascript-DF3GDYje.js";import{json as qs}from"./vendor-codemirror-lang-json-DCqvG1nE.js";import{css as Ks}from"./vendor-codemirror-lang-css-DoEEdEpW.js";import{html as Wn}from"./vendor-codemirror-lang-html-h25V-Hp5.js";import{markdown as Hs}from"./vendor-codemirror-lang-markdown-6BNbCEPe.js";import{l as Gs}from"./vendor-codemirror-language-data-BUZIlm3G.js";import{python as Us}from"./vendor-codemirror-lang-python-DQym-8Tx.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 Ys,s as zi,F as Mi}from"./FileSaveConflictDialog-DZ9NDwOO.js";import{U as Yr,ab as Di,ac as Ti,ad as Ai,ae as Oi,af as Li,ag as en}from"./runtimeEndpointReset-Dwj-jCDS.js";import{s as _n,b as Js,c as Zs}from"./SessionUnreadDot-Dwc3MdvA.js";import{F as Qs,a as Pi,g as kt,i as ea,b as ta,c as un,n as Ii,d as $i,M as Mt,e as ce,s as Bi,f as Vi,h as Wi,j as _i,k as qi,l as Ki,m as Hi,t as tn,o as Dn,u as Gi,p as Ui,q as Xi,r as Jr,v as Yi,w as Zr,x as Ji,y as Zi}from"./fileTreeStatus-CyJ3TOYD.js";import{J as Qi,F as ec}from"./JsonTreeView-_yMHKKQZ.js";import{a as Qr,g as sn,b as es,c as ts,o as tc,d as nc}from"./vendor-codemirror-search-BlDCaCMK.js";import{v as rc,g as sc}from"./vendor-replit-codemirror-vim-Cvk64got.js";import{P as ac,S as oc}from"./StickyHorizontalScrollbar-CMbTn5WQ.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-0K7vuUpd.js";import"./nativeFileSave-DSMsJqXM.js";import"./vendor-lezer-javascript-CUdJ0VGA.js";import"./vendor-lezer-lr-DluApmOX.js";import"./vendor-codemirror-autocomplete-BKvJ8PfM.js";import"./vendor-lezer-json-BKYAA8Hu.js";import"./vendor-lezer-css-DRxDmhcy.js";import"./vendor-lezer-html-qr9pUPmM.js";import"./vendor-lezer-markdown-B-uzYzYT.js";import"./vendor-lezer-python-Bj232yb5.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-BpncHjnV.js";import"./computeVirtualFileMetrics-DJQqK49u.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-PxblpQn6.js";import"./renderFileWithHighlighter-CK29YZtC.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";const qn=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 qn;case"json":case"jsonc":case"json5":return qs().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 Ks().language;case"py":case"python":return Us().language;case"md":case"markdown":case"mdown":case"mkd":return Hs().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 qn}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 qs();case"css":case"scss":case"sass":case"less":return Ks();case"html":case"htm":case"xml":case"drawio":case"dio":return Wn();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Hs({codeLanguages:ic}),lc()];case"sh":case"bash":case"zsh":case"fish":case"env":return qn;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=>Kn.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(Yr,{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 q=n===t?"Project files":wt(n),l=wc(n,t)?sa(n):null,$=!!l&&!i.trim(),K=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(Yr,{leading:I,icon:n===t?"file-text":"folder",title:q,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(Zs,"px-2"),"aria-label":`Up one level to ${K}`,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(Js(!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(Js(!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:q,onOpenDialog:l})=>{const $=t.type==="directory",{canRename:K,canCreateFile:I,canCreateFolder:M,canDelete:H,canReveal:_}=C,Y=!$&&!!z,A=zs()&&Ms(),D=_&&!u&&A,x=K||I||M||H||Y||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:[K&&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(J=>{if(J.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 J=kt(n,t.path)||t.path;nn(J).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(J=>{console.error("Download failed:",J),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(),q(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"]})]}),H&&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(Qs,{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=Jo,Lc=tc,Pc=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 Kn.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),q=a.useRef(n),l=a.useRef(d),$=a.useRef(h),K=a.useRef(v),I=a.useRef(C),M=a.useRef(k),H=a.useRef(new Map),[_,Y]=a.useState([]),A=a.useCallback(x=>{const V=(x??[]).map(N=>{const S=H.current.get(N.id);return S?{id:N.id,content:N.content,container:S}:null}).filter(N=>N!==null);Y(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(()=>{q.current=n},[n]),a.useEffect(()=>{l.current=d,$.current=h},[d,h]),a.useEffect(()=>{K.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)]:[],qo({fixed:!0}),ls.of(Vr(u)),Ko(),Ho.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&&K.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,q.current(E),A(I.current)}),us.of(we.editable.of(!o)),ds.of(s??[]),fs.of(vs(f)),ms.of(xs(C,H.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,Y([])}},[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,H.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=>Yo.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:q,onDiagramChange:l,jsonViewMode:$,markdownViewMode:K,htmlViewMode:I,htmlLoading:M,htmlPreviewNonce:H,htmlPreviewSrc:_,fileContent:Y,canUseShikiFileView:A,textViewMode:D,draftContent:x,onDraftChange:V,canEdit:N,vimMode:S,editorExtensions:g,editorWrapperRef:R,shouldMaskEditorForPendingNavigation:E,onEditorViewReady:L,onEditorViewDestroy:J,enableSearch:G=!1,searchOpen:Q,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:q,onChange:l},`${n.path}:${y}`)}):k&&se&&$==="tree"?e.jsx(Kr,{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:Y,maxHeight:"100%",initiallyExpandedDepth:2})})}):me&&K==="preview"?e.jsxs("div",{className:X("h-full overflow-auto",le),children:[Y.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(Y.length/1024)}KB). Preview may be limited.`}):null,e.jsx(Kr,{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:Y,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"},H)}):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:J,...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)}
|
|
1
|
+
import{aj as Po,b4 as zt,b5 as $n,E as c,ah as Fs,Q as we,b6 as Io,b7 as $o,O as Es,M as Tt,ap as Kn,S as Bo,aq as an,j as e,ak as Vo,b8 as Wo,af as _o,b9 as qo,ba as ut,bb as Vr,bc as Ko,J as Ho,U as zn,bd as Go,be as Uo,bf as Xo,b1 as Yo,bg as Jo,X as Zo,L as Qo}from"./vendor-boot-D-KEJjsM.js";import{R as a,a as w}from"./vendor-react-Bz1tRBxM.js";import{c as X,f as zs,B as Ms,N as ei,I as ti,O as ni,P as ri,Q as si,u as ye,i as Ds,R as Oe,b as ai,s as oi,T as ii,U as bt,V as ci,W as li,a as Wr,X as ui,Y as _r,r as qr,Z as Mn,_ as di}from"./index-BxKPJ9uG.js";import{cp as fi,aW as jt,B as U,I as F,f as Dt,cq as mi,m as Ts,n as As,o as Os,p as Ls,q as Ps,U as Is,D as on,h as cn,i as ln,a2 as nn,t as he,a0 as fe,aY as Bn,cr as rn,aj as $s,aE as Kr,ag as pi,bl as Bs,K as Vs,cs as Ws,J as _s,H as Vn,L as hi,ap as it,aq as ct,ar as lt,bE as gi,bF as xi,bG as vi,j as bi,$ as yi,ai as wi,aZ as ji,bP as ki,ct as Hr,cu as Gr,bS as Ci,cv as Ur,a as Ni,g as Si}from"./useAppFontEffects-COMvkffC.js";import{javascript as yt}from"./vendor-codemirror-lang-javascript-DF3GDYje.js";import{json as qs}from"./vendor-codemirror-lang-json-DCqvG1nE.js";import{css as Ks}from"./vendor-codemirror-lang-css-DoEEdEpW.js";import{html as Wn}from"./vendor-codemirror-lang-html-h25V-Hp5.js";import{markdown as Hs}from"./vendor-codemirror-lang-markdown-6BNbCEPe.js";import{l as Gs}from"./vendor-codemirror-language-data-BUZIlm3G.js";import{python as Us}from"./vendor-codemirror-lang-python-DQym-8Tx.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 Ys,s as zi,F as Mi}from"./FileSaveConflictDialog-GLj2W7VE.js";import{U as Yr,ab as Di,ac as Ti,ad as Ai,ae as Oi,af as Li,ag as en}from"./runtimeEndpointReset-DyZSKCYM.js";import{s as _n,b as Js,c as Zs}from"./SessionUnreadDot-CZCQ4t1J.js";import{F as Qs,a as Pi,g as kt,i as ea,b as ta,c as un,n as Ii,d as $i,M as Mt,e as ce,s as Bi,f as Vi,h as Wi,j as _i,k as qi,l as Ki,m as Hi,t as tn,o as Dn,u as Gi,p as Ui,q as Xi,r as Jr,v as Yi,w as Zr,x as Ji,y as Zi}from"./fileTreeStatus-CDyfNPYO.js";import{J as Qi,F as ec}from"./JsonTreeView-Cvg6lc40.js";import{a as Qr,g as sn,b as es,c as ts,o as tc,d as nc}from"./vendor-codemirror-search-BlDCaCMK.js";import{v as rc,g as sc}from"./vendor-replit-codemirror-vim-Cvk64got.js";import{P as ac,S as oc}from"./StickyHorizontalScrollbar-CMbTn5WQ.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-BR_dhe7_.js";import"./nativeFileSave-D542OJlG.js";import"./vendor-lezer-javascript-CUdJ0VGA.js";import"./vendor-lezer-lr-DluApmOX.js";import"./vendor-codemirror-autocomplete-BKvJ8PfM.js";import"./vendor-lezer-json-BKYAA8Hu.js";import"./vendor-lezer-css-DRxDmhcy.js";import"./vendor-lezer-html-qr9pUPmM.js";import"./vendor-lezer-markdown-B-uzYzYT.js";import"./vendor-lezer-python-Bj232yb5.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-wOQkOurQ.js";import"./computeVirtualFileMetrics-DmPCxbok.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-PxblpQn6.js";import"./renderFileWithHighlighter-C5JE0mRX.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";const qn=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 qn;case"json":case"jsonc":case"json5":return qs().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 Ks().language;case"py":case"python":return Us().language;case"md":case"markdown":case"mdown":case"mkd":return Hs().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 qn}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 qs();case"css":case"scss":case"sass":case"less":return Ks();case"html":case"htm":case"xml":case"drawio":case"dio":return Wn();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Hs({codeLanguages:ic}),lc()];case"sh":case"bash":case"zsh":case"fish":case"env":return qn;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=>Kn.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(Yr,{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 q=n===t?"Project files":wt(n),l=wc(n,t)?sa(n):null,$=!!l&&!i.trim(),K=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(Yr,{leading:I,icon:n===t?"file-text":"folder",title:q,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(Zs,"px-2"),"aria-label":`Up one level to ${K}`,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(Js(!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(Js(!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:q,onOpenDialog:l})=>{const $=t.type==="directory",{canRename:K,canCreateFile:I,canCreateFolder:M,canDelete:H,canReveal:_}=C,Y=!$&&!!z,A=zs()&&Ms(),D=_&&!u&&A,x=K||I||M||H||Y||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:[K&&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(J=>{if(J.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 J=kt(n,t.path)||t.path;nn(J).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(J=>{console.error("Download failed:",J),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(),q(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"]})]}),H&&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(Qs,{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=Jo,Lc=tc,Pc=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 Kn.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),q=a.useRef(n),l=a.useRef(d),$=a.useRef(h),K=a.useRef(v),I=a.useRef(C),M=a.useRef(k),H=a.useRef(new Map),[_,Y]=a.useState([]),A=a.useCallback(x=>{const V=(x??[]).map(N=>{const S=H.current.get(N.id);return S?{id:N.id,content:N.content,container:S}:null}).filter(N=>N!==null);Y(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(()=>{q.current=n},[n]),a.useEffect(()=>{l.current=d,$.current=h},[d,h]),a.useEffect(()=>{K.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)]:[],qo({fixed:!0}),ls.of(Vr(u)),Ko(),Ho.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&&K.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,q.current(E),A(I.current)}),us.of(we.editable.of(!o)),ds.of(s??[]),fs.of(vs(f)),ms.of(xs(C,H.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,Y([])}},[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,H.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=>Yo.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:q,onDiagramChange:l,jsonViewMode:$,markdownViewMode:K,htmlViewMode:I,htmlLoading:M,htmlPreviewNonce:H,htmlPreviewSrc:_,fileContent:Y,canUseShikiFileView:A,textViewMode:D,draftContent:x,onDraftChange:V,canEdit:N,vimMode:S,editorExtensions:g,editorWrapperRef:R,shouldMaskEditorForPendingNavigation:E,onEditorViewReady:L,onEditorViewDestroy:J,enableSearch:G=!1,searchOpen:Q,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:q,onChange:l},`${n.path}:${y}`)}):k&&se&&$==="tree"?e.jsx(Kr,{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:Y,maxHeight:"100%",initiallyExpandedDepth:2})})}):me&&K==="preview"?e.jsxs("div",{className:X("h-full overflow-auto",le),children:[Y.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(Y.length/1024)}KB). Preview may be limited.`}):null,e.jsx(Kr,{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:Y,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"},H)}):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:J,...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
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),q=ye(A=>A.setPendingFileFocusPath),l=w.useRef(null),[$,K]=w.useState(0),I=w.useRef(null),M=w.useRef({key:"",attempts:0}),H=w.useCallback(()=>{K(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,H()}))},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 J=l.current;J&&(J.dispatch({selection:{anchor:E},effects:we.scrollIntoView(E,{y:"center"})}),J.focus())}),D()},[h,v,b,$,o,i,u,f,d,s,H,j,t,n,k,y,z,C]),w.useEffect(()=>{if(!P||!t)return;const A=ce(P);if(!A){q(null);return}n!==A||i||s!==A||(!o&&!u&&!f&&!d&&h&&C==="edit"&&l.current?.focus(),q(null))},[h,o,i,u,f,d,s,P,t,n,q,C]);const _=ce(j?.path??"");return{editorViewRef:l,notifyEditorViewChanged:H,shouldMaskEditor:!!(j&&_&&n===_&&!i&&!o&&!u&&!f&&!d)}}function qc(t){return!(!t.autoSaveEnabled||!t.isDirty||!t.canWrite||t.isSaving||t.fileLoading||t.isNonEditableBinary||!t.selectedFilePath||t.loadedFilePath!==t.selectedFilePath)}function Kc(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 Hc=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),[q,l]=w.useState("idle"),[$,K]=w.useState(null),I=w.useRef(null),M=w.useRef(null),H=w.useRef(j);H.current=j;const _=w.useRef(v);_.current=v;const Y=w.useRef(k);Y.current=k;const A=w.useCallback(S=>S?Xs(S,Y.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(!Kc({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=Ys(z,S?.overwrite),L=await C(n,R,E);return L?.success?A(g)?(K(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 K(E),H.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(qc({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()})},Hc),D},[t,D,u,i,o,h,y,s,V,n,x,C]),w.useEffect(()=>{l("idle"),P(!1),K(null)},[n]),w.useEffect(()=>()=>{D(),M.current&&clearTimeout(M.current)},[D]),{autoSaveStatus:q,cancelPendingAutosave:D,isSaving:y,saveConflict:$,clearSaveConflict:()=>K(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 Yc({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",Jc=1500,Zc=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 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"),[P,q]=w.useState("text"),[l,$]=w.useState("edit"),[K,I]=w.useState("edit"),[M,H]=w.useState(0),[_,Y]=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 J=w.useRef(h);J.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},[]),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"),q(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=>{q(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)&&(H(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=J.current?.()??null;if(Z&&Z.path!==B)return!1;try{const pe=await f(B,ue,Ys(L.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(()=>{Y(!0),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>Y(!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||K!=="preview"||!f)&&(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,ne(n,B).then(ue=>{ue&&re()})},Jc))},[u,K,ne,n,re,f]);w.useEffect(()=>W,[W,K,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:K,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),q=a.useRef(0),l=a.useRef(!1),[$,K]=a.useState(()=>ai());a.useEffect(()=>oi(S=>{K(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||""),J=L?_i(L)?L:ce(`${S}/${L}`):ce(`${S}/${E.name}`),G=E.isDirectory?"directory":"file";R.push({name:E.name,path:J,type:G,extension:G==="file"&&E.name.includes(".")?E.name.split(".").pop()?.toLowerCase():void 0,size:E.size})}return qi(R)},[o,u]),M=`${$}|${n}|g${u?"1":"0"}|${o}`,H=a.useRef(M);H.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=H.current,L=q.current+1;q.current=L,P.current=new Map(P.current).set(g,L),j.current=new Set(j.current).add(g);const J=()=>!l.current&&H.current===E&&P.current.get(g)===L,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(!J())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(!J())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{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]),Y=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||(Y(),await _(n))},[d,_,Y,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,Y())},[Y,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 J=ce(L);return y.current.has(J)||j.current.has(J)},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: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=q=>{const l=h.current,$=q.target;!l||!($ instanceof Node)||l.contains($)||v(!1)},P=q=>{q.key==="Escape"&&(q.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:q,isSelectedImage:l,isSelectedPdf:$,isUnsupportedBinary:K,wrapLines:I,onToggleWrapLines:M,textViewMode:H,onToggleSearch:_,isGoToLineOpen:Y,onOpenGoToLineChange:A,editorView:D,canUseShikiFileView:x,isJson:V,isHtml:N,onToggleTextViewMode:S,isMarkdown:g,mdViewMode:R,onToggleMdViewMode:E,isDrawio:L,drawioViewMode:J,onToggleDrawioViewMode:G,diagramSaved:Q,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=(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:q,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:()=>{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&&!$&&!K&&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"})})),H==="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(!Y),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:Y,onOpenChange:A,view:D,variant:"inline"})]})]}),x&&o&&!V&&!N&&e.jsx(In,{currentMode:H==="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:J,onToggle:G}),J==="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"})})),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:q,getFileStatus:l,getFolderBadge:$,fileRowPermissions:K,downloadFile:I,contextMenuPath:M,setContextMenuPath:H,rightClickMenuPath:_,setRightClickMenuPath:Y,toggleDirectory:A,handleRevealPath:D,refreshDirectory:x})=>{const V=!!(t&&k[t]),N=s.trim().length>0,S=t?j[t]:null,g=a.useMemo(()=>Ki(y),[y]);function R(E,L){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:P,alwaysShowActions:q,status:Q?void 0:l(G.path),badge:Q?$(G.path):void 0,permissions:K,downloadFile:I,contextMenuPath:M,setContextMenuPath:H,rightClickMenuPath:_,setRightClickMenuPath:Y,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(Hi,{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:P,isUnsupportedBinary:q,wrapLines:l,onToggleWrapLines:$,textViewMode:K,onToggleSearch:I,onOpenGoToLineChange:M,canUseShikiFileView:H,isJson:_,isHtml:Y,onToggleTextViewMode:A,isDrawio:D,drawioViewMode:x,onToggleDrawioViewMode:V,diagramSaved:N,onSaveDiagram:S,jsonViewMode:g,onToggleJsonViewMode:R,canCopy:E,onCopyContent:L,canCopyPath:J,onCopyPath:G,onDownloadFile:Q,isMobile:ie,mode:W,isFullscreen:te,onToggleFullscreen:Le})=>{if(!t)return null;const xe=bt(),le=!y&&!P&&!q,Fe=s&&i,se=le&&K==="edit",me=D?{label:x==="preview"?"Edit diagram source":"Show diagram",onSelect:V}:un(t.path)?{label:Y?"Show source":"Show page preview",onSelect:A}:H&&s&&!_&&!Y?{label:K==="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")),J&&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: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=Kn.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(),q=ji()??"",l=ce(q.trim()),$=el(n,t),K=t!=="editor-only",I=t==="editor-only"&&!b,M=ki(q),[H,_]=a.useState(""),Y=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,J=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),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:Z,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]),Ke=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&&Ke&&!Dn(Ke,l)),Hn=Lt?Hr(Ke):void 0,ge=a.useMemo(()=>({allowOutsideWorkspace:t==="editor-only"&&Lt,outsideFileGrant:Hn,directory:l||void 0}),[t,Lt,Hn,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,Ye]=a.useState(""),Se=a.useRef(""),[et,ze]=a.useState(null),[ft,Me]=a.useState(void 0),[Yn,De]=a.useState(null),Re=Oe(r=>r.activeRuntimeKey),[be,qe]=a.useState(null),[pn,Jn]=a.useState(!1),[fa,Pe]=a.useState(!1),[mt,Te]=a.useState(""),[ma,pa]=a.useState(`
|
|
4
4
|
`),Zn=a.useRef(null),Ie=a.useRef(0),pt=a.useRef(null),[Qn,hn]=a.useState(!1),Pt=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),Ye(""),ze(null),Me(void 0),De(null),qe(null),Pe(!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),La=en(r=>r.loadInstalledApps);a.useEffect(()=>{gn&&ir()},[gn,ir]);const Pa=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),Ye(""),ze(null),Me(void 0),De(null),qe(null),Pe(!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),Ye(""),ze(null),Me(void 0),De(null),qe(null),Pe(!1),hn(!1))},[Re]);const Ba=f?x:q,{results:dr,searching:fr,failed:mr}=Xi({directory:Ba,query:H,chrome:n,showGitignored:P}),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 qr(`/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&&Jr(T)&&re(l,O)}})),()=>{r=!0}},[o,se,re,l]);const xn=a.useMemo(()=>Ee.length>Mt?`${Ee.slice(0,Mt)}
|