@pi-chamber/web 1.0.5-rc.3 → 1.0.5

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.
Files changed (52) hide show
  1. package/dist/assets/{DiagramView-DxLAcmg-.js → DiagramView-CrKjR8CR.js} +1 -1
  2. package/dist/assets/{DiffView-BzVBoNCp.js → DiffView-CSonR3pr.js} +1 -1
  3. package/dist/assets/{FileSaveConflictDialog-2KqGdUdB.js → FileSaveConflictDialog-Cun0LIbj.js} +1 -1
  4. package/dist/assets/{FilesView-3spQTRpf.js → FilesView-BRR3N7UA.js} +1 -1
  5. package/dist/assets/{GitHubDetailScaffold-C2d4WqKe.js → GitHubDetailScaffold-C1UHuETI.js} +1 -1
  6. package/dist/assets/{GitHubLinkPicker-BDwZtk0x.js → GitHubLinkPicker-B0O3Vapu.js} +1 -1
  7. package/dist/assets/{GitHubListPrimitives-Dor_K85Y.js → GitHubListPrimitives-DvQDU--z.js} +1 -1
  8. package/dist/assets/{GitView-CSAJagWK.js → GitView-wAscrRhO.js} +3 -3
  9. package/dist/assets/{IssuesSurface-euZzv2L9.js → IssuesSurface-mh50UUQ8.js} +2 -2
  10. package/dist/assets/{JsonTreeView-Drmn7tIN.js → JsonTreeView-BfErTllU.js} +1 -1
  11. package/dist/assets/{MarkdownRendererImpl-Bq0p5v9N.js → MarkdownRendererImpl-SXAK4uOu.js} +1 -1
  12. package/dist/assets/{PatchDiff-BegAimf3.js → PatchDiff-CHr79sJ6.js} +1 -1
  13. package/dist/assets/{PierreDiffViewer-DgU2Zcmr.js → PierreDiffViewer-CGpKcLro.js} +1 -1
  14. package/dist/assets/{PullRequestsSurface-CnGgmkuf.js → PullRequestsSurface-CfaOpeZn.js} +2 -2
  15. package/dist/assets/{SessionSwitcherContent-Cq5LIBuG.js → SessionSwitcherContent-DEAw6v12.js} +1 -1
  16. package/dist/assets/{SessionSwitcherDropdown-Dpob2_y5.js → SessionSwitcherDropdown-BSutduo7.js} +2 -2
  17. package/dist/assets/{SessionUnreadDot-BPKnpGAh.js → SessionUnreadDot-Dav_rix1.js} +1 -1
  18. package/dist/assets/{SettingsView-DcOJRyym.js → SettingsView-CQJkOPJh.js} +4 -4
  19. package/dist/assets/{SettingsWindow-C2RB0AjV.js → SettingsWindow-BiY5FmhZ.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-DmzNX2QX.js → ToolOutputDialog-B3RRLhR3.js} +1 -1
  21. package/dist/assets/{ToolPartDiffPreview-CO5Gg17_.js → ToolPartDiffPreview-D9m_vrht.js} +1 -1
  22. package/dist/assets/{VirtualizedFileDiff-CJ1m8JE-.js → VirtualizedFileDiff-B8lhZGLu.js} +1 -1
  23. package/dist/assets/{collapsible-BOcd0lzY.js → collapsible-9MJx4VhA.js} +1 -1
  24. package/dist/assets/{computeVirtualFileMetrics-8mC_o5zA.js → computeVirtualFileMetrics-Bjhk2CQS.js} +1 -1
  25. package/dist/assets/{contextFileOpenGuard-CRboGmXF.js → contextFileOpenGuard-CsF5Boky.js} +1 -1
  26. package/dist/assets/{gitStatusPredicates-BqV-kOGY.js → gitStatusPredicates-B3Zxud6E.js} +1 -1
  27. package/dist/assets/{githubLink-DSgdECMr.js → githubLink-CbGYxsIq.js} +1 -1
  28. package/dist/assets/{index-B3qmI8VW.js → index-B0h6_x5N.js} +1 -1
  29. package/dist/assets/{index-DsQIBAWK.css → index-BwoW_-vk.css} +1 -1
  30. package/dist/assets/{index-DWSrsQWl.js → index-D4n3TVp2.js} +2 -2
  31. package/dist/assets/{main-Bn93XwxQ.js → main-C6i4ph9N.js} +2 -2
  32. package/dist/assets/{main-HPNu-7DG.js → main-r5elIPBi.js} +4 -4
  33. package/dist/assets/{markdownCore-Csm6UEBe.js → markdownCore-C2YQ3Z0q.js} +1 -1
  34. package/dist/assets/{miniChat-C3W5IvM4.js → miniChat-d_GCHoIf.js} +2 -2
  35. package/dist/assets/{mobile-COEEitAQ.js → mobile-BJ3tgyKd.js} +2 -2
  36. package/dist/assets/{nativeFileSave-CFuugNKV.js → nativeFileSave-BJsGPh58.js} +1 -1
  37. package/dist/assets/{pi-session-focus-preference-DQjF7Nh1.js → pi-session-focus-preference-BFnGFuvP.js} +1 -1
  38. package/dist/assets/{renderDiffWithHighlighter-BBwvKSDe.js → renderDiffWithHighlighter-BhMEWmHn.js} +1 -1
  39. package/dist/assets/{renderElectronMiniChatApp-7vIiCPiK.js → renderElectronMiniChatApp-Bap5OwgB.js} +2 -2
  40. package/dist/assets/{renderFileWithHighlighter-VOwWxIE1.js → renderFileWithHighlighter-DUGluXlw.js} +1 -1
  41. package/dist/assets/{renderMobileApp-BQDG02OP.js → renderMobileApp-DJbslvby.js} +3 -3
  42. package/dist/assets/{runtimeEndpointReset-CzwDZ_EP.js → runtimeEndpointReset-D22U_Vjs.js} +6 -6
  43. package/dist/assets/{runtimeSurface-Der4qUnI.js → runtimeSurface-k1Eit61v.js} +1 -1
  44. package/dist/assets/{useAppFontEffects-BQ1JUauS.js → useAppFontEffects-CqHhRKmN.js} +77 -77
  45. package/dist/assets/{useFilesViewSearch-BYG2TZWz.js → useFilesViewSearch-CqoYEK0U.js} +1 -1
  46. package/dist/assets/{useGitHubRemoteSearch-Bo1LF-x_.js → useGitHubRemoteSearch-DYoLQ4ro.js} +1 -1
  47. package/dist/assets/{useSwitcherItems-q0ZavMJb.js → useSwitcherItems-BS6E199F.js} +1 -1
  48. package/dist/assets/{web-components-CJ0xIy7r.js → web-components-DzQ9ybbb.js} +1 -1
  49. package/dist/index.html +4 -4
  50. package/dist/mini-chat.html +3 -3
  51. package/dist/mobile.html +3 -3
  52. package/package.json +1 -1
@@ -1 +1 @@
1
- import{k as c}from"./vendor-boot-EC6IyLt1.js";import{R as t}from"./vendor-react-DASdDPIk.js";import{z as $,t as d,I as B}from"./useAppFontEffects-BQ1JUauS.js";import{f as W,a as A,m as ee,bW as T}from"./index-DWSrsQWl.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-2KqGdUdB.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Duu5LgQA.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),G=W(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const i=t.useCallback((e,n,s)=>I.current&&v.current===e&&A()===n&&w.current===s,[]),z=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=A(),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&&z(e)}),[z]),t.useEffect(()=>{if(!G)return;const e=W.getState().consumePendingDiagramFile();e&&z(e)},[z,G]);const K=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=A(),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(T(a)){await K(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,K,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(T(f)){await K(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,K,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:()=>W.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
+ import{k as c}from"./vendor-boot-EC6IyLt1.js";import{R as t}from"./vendor-react-DASdDPIk.js";import{z as $,t as d,I as B}from"./useAppFontEffects-CqHhRKmN.js";import{f as W,a as A,m as ee,bW as T}from"./index-D4n3TVp2.js";import{b as te,D as re,F as ne}from"./FileSaveConflictDialog-Cun0LIbj.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./runtimeSurface-k1Eit61v.js";import"./nativeFileSave-BJsGPh58.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-react-drawio-Duu5LgQA.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),G=W(e=>e.pendingDiagramFile);t.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const i=t.useCallback((e,n,s)=>I.current&&v.current===e&&A()===n&&w.current===s,[]),z=t.useCallback(async e=>{const n=v.current+1;v.current=n;const s=A(),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&&z(e)}),[z]),t.useEffect(()=>{if(!G)return;const e=W.getState().consumePendingDiagramFile();e&&z(e)},[z,G]);const K=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=A(),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(T(a)){await K(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,K,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(T(f)){await K(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,K,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:()=>W.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{k as t,aL as St}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{e as re,f as Y,a as et,p as Oe}from"./index-DWSrsQWl.js";import{e6 as Nt,dQ as Ct,e4 as Lt,at as tt,ah as nt,cx as Dt,cy as ke,B as Se,I as z,z as st,aN as ce,t as it,dY as rt,ai as kt,al as Rt,an as Et,ap as Ge,cr as At,e7 as Tt,e8 as Mt,y as It,ae as Pt,aI as $t,ar as Wt,cS as _t,h as Bt,aD as zt,aW as Ot,aj as Gt,ak as Ht,am as Ut}from"./useAppFontEffects-BQ1JUauS.js";import{d as ot,i as He,a as Ue,b as Vt,C as Kt}from"./gitStatusPredicates-BqV-kOGY.js";import{p as qt}from"./VirtualizedFileDiff-CJ1m8JE-.js";import{P as Xt}from"./PierreDiffViewer-DgU2Zcmr.js";import{v as Yt,g as Qt}from"./contextFileOpenGuard-CRboGmXF.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./web-components-CJ0xIy7r.js";import"./computeVirtualFileMetrics-8mC_o5zA.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.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-BBwvKSDe.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-BMITjK4e.js";import"./runtimeEndpointReset-CzwDZ_EP.js";import"./SessionUnreadDot-BPKnpGAh.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";function Jt(n,s=10){const e=[];let i;for(const l of n.split(`
1
+ import{k as t,aL as St}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{e as re,f as Y,a as et,p as Oe}from"./index-D4n3TVp2.js";import{e6 as Nt,dQ as Ct,e4 as Lt,at as tt,ah as nt,cx as Dt,cy as ke,B as Se,I as z,z as st,aN as ce,t as it,dY as rt,ai as kt,al as Rt,an as Et,ap as Ge,cr as At,e7 as Tt,e8 as Mt,y as It,ae as Pt,aI as $t,ar as Wt,cS as _t,h as Bt,aD as zt,aW as Ot,aj as Gt,ak as Ht,am as Ut}from"./useAppFontEffects-CqHhRKmN.js";import{d as ot,i as He,a as Ue,b as Vt,C as Kt}from"./gitStatusPredicates-B3Zxud6E.js";import{p as qt}from"./VirtualizedFileDiff-B8lhZGLu.js";import{P as Xt}from"./PierreDiffViewer-CGpKcLro.js";import{v as Yt,g as Qt}from"./contextFileOpenGuard-CsF5Boky.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-k1Eit61v.js";import"./nativeFileSave-BJsGPh58.js";import"./web-components-DzQ9ybbb.js";import"./computeVirtualFileMetrics-Bjhk2CQS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.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-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.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-BhMEWmHn.js";import"./vendor-diff-C3JhlQdm.js";import"./StickyHorizontalScrollbar-BMITjK4e.js";import"./runtimeEndpointReset-D22U_Vjs.js";import"./SessionUnreadDot-Dav_rix1.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./appThemeRegistry-gegrE2dq.js";import"./registerCustomTheme-DmolaWWZ.js";function Jt(n,s=10){const e=[];let i;for(const l of n.split(`
2
2
  `)){const p=l.match(Nt);if(p!=null){i!=null&&(i.hunkLines.length>0&&(Ee(i,s,"trailing"),Ie(i,e)),i=void 0);const d=parseInt(p[3]),b=parseInt(p[1]),g=parseInt(p[4]??"1"),c=parseInt(p[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>s*2){const d=i.contextLines.length-s*2,b=i.contextLines.slice(-s);Ee(i,s,"trailing");const{additionCount:g,deletionCount:c}=i;Ie(i,e),i={additionStart:i.additionStart+g+d,deletionStart:i.deletionStart+c+d,deletionCount:0,additionCount:0,contextLines:b,hunkLines:[]}}Ee(i,s,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&&(Ee(i,s,"trailing"),Ie(i,e));const a=e.join(`
3
3
  `);return n.endsWith(`
4
4
  `)?`${a}
@@ -1,3 +1,3 @@
1
- import{k as r}from"./vendor-boot-EC6IyLt1.js";import{R as a}from"./vendor-react-DASdDPIk.js";import{D as j}from"./vendor-react-drawio-Duu5LgQA.js";import{e as C}from"./index-DWSrsQWl.js";import{au as E,av as S,aw as N,ax as B,ay as F,az as H,B as p}from"./useAppFontEffects-BQ1JUauS.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]),D=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(j,{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:D},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)}
1
+ import{k as r}from"./vendor-boot-EC6IyLt1.js";import{R as a}from"./vendor-react-DASdDPIk.js";import{D as j}from"./vendor-react-drawio-Duu5LgQA.js";import{e as C}from"./index-D4n3TVp2.js";import{au as E,av as S,aw as N,ax as B,ay as F,az as H,B as p}from"./useAppFontEffects-CqHhRKmN.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]),D=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(j,{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:D},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{ah as No,ca as St,cb as Tn,z as c,af as va,M as pe,cc as So,cd as Ro,L as ba,K as rn,am as wa,S as Fo,an as In,k as t,ai as Eo,c4 as zo,ad as Mo,ce as Do,c7 as st,cf as Tr,c3 as To,G as Ao,Q as Cn,cg as Oo,ch as Lo,c6 as Po,aL as Io,ci as Bo,U as $o,J as Vo}from"./vendor-boot-EC6IyLt1.js";import{R as s,a as y}from"./vendor-react-DASdDPIk.js";import{e as J,z as ya,A as ka,B as Wo,h as _o,bU as Ko,x as qo,bV as Ho,f as ke,bW as ja,E as Ee,a as Go,m as Uo,F as Jo,bX as Nt,C as Xo,D as Yo,T as Ar,bY as Qo,a8 as Or,v as Lr,y as Nn,at as Zo}from"./index-DWSrsQWl.js";import{cu as ei,ah as bt,B as q,I as F,as as zt,cv as ti,au as Ca,av as Na,aw as Sa,ax as Ra,ay as Fa,az as Ea,ai as Bn,al as $n,an as Vn,ao as Zt,t as he,ap as en,aq as ni,cw as tn,at as za,E as Pr,bc as ri,cx as Ma,cy as Da,cz as Ta,cA as Aa,cB as An,cC as ai,aj as Xe,ak as Ye,am as Qe,z as si,aA as oi,ae as ii,y as ci,ar as li,cD as Ir,aB as Br,aW as ui,cE as $r}from"./useAppFontEffects-BQ1JUauS.js";import{javascript as xt}from"./vendor-codemirror-lang-javascript-Dw4kFO4e.js";import{json as Oa}from"./vendor-codemirror-lang-json-B-b1vAv-.js";import{css as La}from"./vendor-codemirror-lang-css-RM2HqXZ0.js";import{html as On}from"./vendor-codemirror-lang-html-CHSHUpwq.js";import{markdown as Pa}from"./vendor-codemirror-lang-markdown-BTht2ATe.js";import{l as Ia}from"./vendor-codemirror-language-data-CqU7kHmg.js";import{python as Ba}from"./vendor-codemirror-lang-python-CH6_em9L.js";import{shell as di}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Vr,getResolvedShikiTheme as fi}from"./appThemeRegistry-gegrE2dq.js";import{D as mi,i as $a,b as Va,s as pi,F as hi}from"./FileSaveConflictDialog-2KqGdUdB.js";import{h as Wr,y as gi,z as xi,B as vi,E as bi,G as wi,P as Yt}from"./runtimeEndpointReset-CzwDZ_EP.js";import{e as Ln,h as Wa,i as _a}from"./SessionUnreadDot-BPKnpGAh.js";import{g as Rt,c as Ka,d as qa,e as Wn,n as yi,f as ki,M as Ft,h as se,j as ji,s as Ci,i as Ni,a as Si,t as Qt,k as Sn,b as Ri,l as Fi,u as Ei,m as _r,o as zi,p as Kr}from"./useFilesViewSearch-BYG2TZWz.js";import{J as Mi,F as Di}from"./JsonTreeView-Drmn7tIN.js";import{a as qr,g as nn,b as Hr,c as Gr,o as Ti,d as Ai}from"./vendor-codemirror-search-DUfSCF9S.js";import{v as Oi,g as Li}from"./vendor-replit-codemirror-vim-AnOuN8yJ.js";import{P as Pi,S as Ii}from"./StickyHorizontalScrollbar-BMITjK4e.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-lezer-javascript-ctwLWf4v.js";import"./vendor-lezer-lr-B8TQctNw.js";import"./vendor-codemirror-autocomplete-CGpAsPWp.js";import"./vendor-lezer-json-BP_UAzLL.js";import"./vendor-lezer-css-DUkkbMp7.js";import"./vendor-lezer-html-B3h0MOrG.js";import"./vendor-lezer-markdown-aGLZf_3h.js";import"./vendor-lezer-python-EJ4Im4y2.js";import"./registerCustomTheme-DmolaWWZ.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.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-Duu5LgQA.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./web-components-CJ0xIy7r.js";import"./computeVirtualFileMetrics-8mC_o5zA.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.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-DP6HbEeC.js";import"./renderFileWithHighlighter-VOwWxIE1.js";const Pn=No.define(di);function Bi(e){const n=e.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return Pn;case"json":case"jsonc":case"json5":return Oa().language;case"js":case"javascript":return xt().language;case"jsx":return xt({jsx:!0}).language;case"ts":case"typescript":return xt({typescript:!0}).language;case"tsx":return xt({typescript:!0,jsx:!0}).language;case"html":return On().language;case"css":return La().language;case"py":case"python":return Ba().language;case"md":case"markdown":case"mdown":case"mkd":return Pa().language;case"heex":case"eex":case"leex":return On().language;default:return va.matchLanguageName(Ia,n,!0)}}const Ha=e=>e.split("/").pop()?.toLowerCase()??"",$i=e=>{const n=Ha(e);return n?va.matchFilename(Ia,n):null},Vi=()=>St(Tn.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 Wi(e){const n=e.toLowerCase();switch(Ha(n)){case"makefile":case"gnumakefile":return Pn}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return xt({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return xt({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Oa();case"css":case"scss":case"sass":case"less":return La();case"html":case"htm":case"xml":case"drawio":case"dio":return On();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Pa({codeLanguages:Bi}),Vi()];case"sh":case"bash":case"zsh":case"fish":case"env":return Pn;case"py":case"pyw":case"pyi":return Ba();default:return null}}async function _i(e){const n=$i(e);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function Ur(e,n){const a=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},d=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",f=pe.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:d,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",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:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.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, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.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:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.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:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.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:e.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:e.colors.interactive.hover,color:e.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:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:a}),g=Tn.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"}]),w=Tn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.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:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.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:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[f]:[f,St(So,{fallback:!0}),St(Ro),St(g),St(w)]}const Ki=180,Ga=Fo.define(),qi=1,Hi=2,Gi=4,Jr=new Map,Ui=(e,n)=>{const a=`${e}|${n}`,i=Jr.get(a);if(i)return i;let o="";e&&(o+=`color:${e};`),n&qi&&(o+="font-style:italic;"),n&Hi&&(o+="font-weight:bold;"),n&Gi&&(o+="text-decoration:underline;");const u=rn.mark({attributes:{style:o}});return Jr.set(a,u),u},Ji=(e,n)=>{const a=new In,i=e.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const d=n[u];if(!d||d.length===0)continue;const f=i.line(u+1);let g=f.from;for(const[w,N,x]of d){if(w<=0)continue;const b=g,j=Math.min(g+w,f.to);g+=w,!(j<=b)&&(!N&&!x||a.add(b,j,Ui(N,x)))}}return a.finish()},Xi=ba.define({create(){return rn.none},update(e,n){let a=e.map(n.changes);for(const i of n.effects)i.is(Ga)&&(a=i.value);return a},provide:e=>pe.decorations.from(e)}),Yi=e=>wa.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)},Ki)}async tokenize(n){const a=++this.generation,i=n.state.doc.toString(),o=await ei(i,e.language,e.themeName,e.theme);o&&a===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:Ga.of(Ji(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Qi=e=>[Xi,Yi(e)],We=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),vt=e=>{const n=We(e);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},Ua=e=>{const n=We(e);if(!n||n==="/")return null;const a=n.lastIndexOf("/");if(a<0)return null;if(a===0)return"/";const i=n.slice(0,a);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Xr=(e,n)=>{const a=We(e),i=We(n);return!a||!i?!1:a===i||a.startsWith(`${i}/`)},Yr=(e,n)=>{const a=We(e);if(!a)return We(n);if(a.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(a))return a;const i=We(n);return i?`${i}/${a}`:a},Zi=(e,n)=>{const a=We(e),i=We(n);if(!a||a===i)return!1;const o=Ua(a);return o?i&&Xr(a,i)?Xr(o,i):!0:!1},ec=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KB","MB","GB"];let a=e/1024;for(const i of n){if(a<1024||i===n[n.length-1])return`${a.toFixed(a>=10?0:1)} ${i}`;a/=1024}return""},tc=(e,n)=>!n||e===n?vt(e):e.startsWith(`${n}/`)?e.slice(n.length+1):e,nc=({root:e,directory:n,entries:a,query:i,searchResults:o,isSearching:u,directoryError:d,refreshing:f,editorPath:g,editor:w,onClose:N,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(Et,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:C,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:t.jsx(bt,{filePath:g,className:"size-4 shrink-0"}),title:vt(g)}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]});const P=n===e?"Project files":vt(n),I=Zi(n,e)?Ua(n):null,l=!!I&&!i.trim(),V=I===e?"Project files":vt(I??""),G=N||l&&I?t.jsxs(t.Fragment,{children:[N?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:N,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-4"})}):null,l&&I?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${vt(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:G,icon:n===e?"file-text":"folder",title:P,actions:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:J("size-4",f&&"animate-spin")})})}),t.jsx("div",{className:"shrink-0 px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(zt,{value:i,onChange:T=>x(T.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),t.jsx(ti,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?t.jsx(Et,{message:d}):i.trim()?t.jsx(rc,{root:e,results:o,isSearching:u,onOpenFile:j}):a===void 0?t.jsx(Et,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[l&&I?t.jsxs("button",{type:"button",className:J(_a,"px-2"),"aria-label":`Up one level to ${V}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:J(Ln(!0),"text-muted-foreground")}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,a.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,a.map(T=>t.jsx(Ja,{name:T.name,path:T.path,directory:T.type==="directory",meta:T.type==="directory"?void 0:ec(T.size),onClick:()=>T.type==="directory"?b(Yr(T.path,n||e)):j(Yr(T.path,n||e))},T.path))]})})]})},Ja=({name:e,path:n,directory:a,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:J(_a,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[a?t.jsx(F,{name:"folder-3-fill",className:J(Ln(!0),"text-primary/80")}):t.jsx(bt,{filePath:n,className:Ln(!0)}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,a?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),rc=({root:e,results:n,isSearching:a,onOpenFile:i})=>a?t.jsx(Et,{loading:!0,message:"Loading..."}):n.length===0?t.jsx(Et,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(o=>t.jsx(Ja,{name:vt(o.path),path:o.path,directory:!1,meta:o.relativePath??tc(o.path,e),onClick:()=>i(o.path)},o.path))}),Et=({message:e,loading:n=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),ac=({activeDialog:e,dialogData:n,dialogInputValue:a,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:d,inputRef:f})=>t.jsx(Ca,{open:!!e,onOpenChange:g=>!g&&d(),children:t.jsxs(Na,{initialFocus:f,children:[t.jsxs(Sa,{children:[t.jsxs(Ra,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(Fa,{children:[e==="createFile"&&`Create a new file in ${n?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,e==="rename"&&`Rename ${n?.name??""}`,e==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(zt,{value:a,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:f})}),t.jsxs(Ea,{children:[t.jsx(q,{variant:"outline",onClick:d,disabled:o,children:"Cancel"}),t.jsx(q,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!a.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),sc=({label:e,iconDataUrl:n})=>{const[a,i]=s.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return n&&!a?t.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:J("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Xa=({filePath:e,extension:n})=>t.jsx(bt,{filePath:e,extension:n}),oc=({status:e})=>{const n={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:n}})},Qr=({name:e})=>{const n=s.useRef(null),a=s.useRef(null),[i,o]=s.useState(!1);return s.useLayoutEffect(()=>{const u=n.current,d=a.current;if(!u||!d)return;const f=()=>{o(d.scrollWidth>u.clientWidth+1)};f();const g=new ResizeObserver(f);return g.observe(u),g.observe(d),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:a,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},ic=({node:e,root:n,isExpanded:a,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:d,status:f,badge:g,permissions:w,downloadFile:N,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:P,onRevealPath:I,onOpenDialog:l})=>{const V=e.type==="directory",{canRename:G,canCreateFile:T,canCreateFolder:_,canDelete:H,canReveal:K}=w,X=!V&&!!N,L=ya()&&ka(),O=K&&!u&&L,k=G||T||_||H||X||O,$=s.useCallback(S=>{k&&(S?.preventDefault(),C(e.path))},[k,e.path,C]),E=s.useCallback(()=>{V?P(e.path):v(e)},[V,e,v,P]),R=s.useCallback(S=>{S.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),m=({Item:S,Separator:A})=>t.jsxs(t.Fragment,{children:[G&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),Zt(e.path).then(U=>{if(U.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation();const U=Rt(n,e.path)||e.path;Zt(U).then(Q=>{if(Q.ok){he.success("Relative path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!V&&N&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),N(e.path).catch(U=>{console.error("Download failed:",U),he.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),O&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",Wo()]}),V&&(T||_)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),T&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),_&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),H&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(gi,{open:j===e.path,onOpenChange:S=>C(S?e.path:null),children:[t.jsxs(xi,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:$}),children:[t.jsxs("button",{type:"button",onClick:E,onContextMenu:o?void 0:$,className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[V?a?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Xa,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!V&&f&&t.jsx(oc,{status:f}),V&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),k&&t.jsx("div",{className:J("absolute right-1 top-1/2 -translate-y-1/2",d?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Bn,{open:x===e.path,onOpenChange:S=>b(S?e.path:null),children:[t.jsx($n,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"icon",className:"size-6",onClick:R,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Vn,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:m({Item:en,Separator:ni})})]})})]}),t.jsx(vi,{className:"min-w-[180px]",children:m({Item:bi,Separator:wi})})]})},Rn=(e,n,a)=>{const[i,o]=s.useState(""),[u,d]=s.useState(0);return s.useEffect(()=>{if(!e){o("");return}let f=!1;o("");const g=_o(),w=Ko(g);qo(g).then(x=>{f||!x||(o(e),n(null))}).catch(x=>{f||(n(x instanceof Error?x.message:a),o(e))});const N=Ho(()=>{f||(o(e),d(x=>x+1),n(null))});return()=>{f=!0,w(),N()}},[e,n,a]),{readyKey:i,nonce:u}},cc=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",lc=e=>{const n=document.createElement("div");n.className="cm-vim-panel";const a=Li(e);if(!a)return{top:!1,dom:n};a.state.statusbar=n;const i=a.state.vimPlugin;return cc(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){a.state.statusbar===n&&(a.state.statusbar=null)}}};function Zr(e){return e?[Oi(),Eo.of(lc),zo()]:[]}const uc={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 fc(e){const n=e.querySelector(".cm-search");if(n){for(const[a,i]of Object.entries(uc)){const o=n.querySelector(`button[name="${a}"]`);o&&!o.title&&(o.title=i)}for(const[a,i]of Object.entries(dc)){const u=n.querySelector(`input[name="${a}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Fn=new WeakMap;function mc(e,n){const a=nn(e.state);if(!a.valid)return Fn.delete(e),0;const i=Fn.get(e);if(!n&&i?.doc===e.state.doc&&i.query.eq(a))return i.total;const o=a.getCursor(e.state);let u=0;for(let d=o.next();!d.done;d=o.next())u+=1;return Fn.set(e,{query:a,doc:e.state.doc,total:u}),u}function pc(e){const n=nn(e.state);if(!n.valid)return 0;const a=e.state.selection.main,i=n.getCursor(e.state);let o=0,u=0;for(let d=i.next();!d.done;d=i.next()){const f=d.value;if(o+=1,u===0&&(u=o),a.from===f.from&&a.to===f.to||a.from<f.to&&a.to>f.from||f.from>=a.head)return o}return u}function ea(e,n,a=!1){const i=e.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 f=i.querySelector('button[name="next"]'),g=f?.parentNode===i?f:i.firstChild;i.insertBefore(o,g)}const u=mc(n,a),d=u===0?0:pc(n);o.textContent=u===0?"":`${d}/${u}`}const ta=new st,na=new st,ra=new st,aa=new st,sa=new st,oa=new st,ia=new st,ca=e=>e,En=Bo,hc=Ti,gc=Ai;class xc extends $o{constructor(n,a){super(),this.id=n,this.containerMap=a}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 la=(e,n)=>!e||e.length===0?[]:ba.define({create(a){const i=new In,o=[...e].sort((u,d)=>u.afterLine-d.afterLine);for(const u of o){const d=a.doc.lines;if(u.afterLine>d)continue;const f=a.doc.line(u.afterLine);i.add(f.to,f.to,rn.widget({widget:new xc(u.id,n),block:!0,side:1}))}return i.finish()},update(a,i){return a.map(i.changes)},provide:a=>pe.decorations.from(a)}),ua=e=>{if(!e)return[];const n=Math.max(1,e.start),a=Math.max(n,e.end);return wa.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 In;for(let u=n;u<=a&&u<=i.state.doc.lines;u+=1){const d=i.state.doc.line(u);o.add(d.from,d.from,rn.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function vc({value:e,onChange:n,extensions:a,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:d,onViewReady:f,onViewDestroy:g,blockWidgets:w,enableSearch:N,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=s.useRef(null),v=s.useRef(null),P=s.useRef(e),I=s.useRef(n),l=s.useRef(f),V=s.useRef(g),G=s.useRef(b),T=s.useRef(w),_=s.useRef(j),H=s.useRef(new Map),[K,X]=s.useState([]),L=s.useCallback(k=>{const $=(k??[]).map(E=>{const R=H.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);X(E=>E.length===$.length&&E.every((R,m)=>{const S=$[m];return R.id===S.id&&R.content===S.content&&R.container===S.container})?E:$)},[]),O=s.useCallback(k=>{const $=C.current,E=k??v.current;if(!$||!E)return;const R=E.dom.querySelector(".cm-gutters"),m=R instanceof HTMLElement?R.getBoundingClientRect().width:0;$.style.setProperty("--oc-editor-gutter-width",`${m}px`)},[]);return s.useEffect(()=>{P.current=e},[e]),s.useEffect(()=>{I.current=n},[n]),s.useEffect(()=>{l.current=f,V.current=g},[f,g]),s.useEffect(()=>{G.current=b},[b]),s.useEffect(()=>{T.current=w,L(w)},[w,L]),s.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),$=Mo.create({doc:P.current,extensions:[...k?[pe.cspNonce.of(k)]:[],Do({fixed:!0}),ta.of(Tr(u)),To(),Ao.of(" "),ia.of(Zr(j)),Cn.of([Oo,...Lo,...Po]),pe.updateListener.of(E=>{O(E.view),(E.viewportChanged||E.geometryChanged)&&L(T.current);const R=qr(E.startState),m=qr(E.state);R!==m&&G.current?.(m);const S=!nn(E.startState).eq(nn(E.state));if(m&&(R!==m||S||E.docChanged||E.selectionSet)&&ea(E.view.dom,E.view,R!==m||S||E.docChanged),!E.docChanged)return;const A=E.state.doc.toString();P.current=A,I.current(A),L(T.current)}),na.of(pe.editable.of(!o)),ra.of(a??[]),aa.of(ua(d)),sa.of(la(w,H.current)),oa.of(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]});return v.current=new pe({state:$,parent:C.current}),En(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{O(v.current),L(T.current)}),v.current&&l.current?.(v.current),()=>{V.current?.(),v.current?.destroy(),v.current=null,X([])}},[T,O,L]),s.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[ta.reconfigure(Tr(u)),na.reconfigure(pe.editable.of(!o)),ra.reconfigure(a??[]),aa.reconfigure(ua(d)),sa.reconfigure(la(w,H.current)),oa.reconfigure(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]}),En(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{O(k),L(T.current)}))},[a,d,u,o,w,N,O,L]),s.useEffect(()=>{const k=v.current;if(!k){_.current=j;return}_.current!==j&&(_.current=j,k.dispatch({effects:ia.reconfigure(Zr(j))}))},[j]),s.useEffect(()=>{const k=v.current;!k||N===!1||(x?(hc(k),requestAnimationFrame(()=>{fc(k.dom),ea(k.dom,k,!0)})):gc(k))},[x,N]),s.useEffect(()=>{const k=v.current;if(!k)return;const $=k.state.doc.toString();$!==e&&(k.dispatch({changes:{from:0,to:$.length,insert:e}}),En(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>O(k)))},[e,O]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:J("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)}),K.map(k=>Io.createPortal(k.content,k.container,k.id))]})}const da=({variant:e,selectedFile:n,loading:a,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:d,imagePreviewNonce:f,isSelectedPdf:g,pdfSrc:w,pdfPreviewNonce:N,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:P,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:V,markdownViewMode:G,htmlViewMode:T,htmlLoading:_,htmlPreviewNonce:H,htmlPreviewSrc:K,fileContent:X,canUseShikiFileView:L,textViewMode:O,draftContent:k,onDraftChange:$,canEdit:E,vimMode:R,editorExtensions:m,editorWrapperRef:S,shouldMaskEditorForPendingNavigation:A,onEditorViewReady:z,onEditorViewDestroy:U,enableSearch:Q=!1,searchOpen:ae,onSearchOpenChange:oe,pierreTheme:W,shikiThemeType:te,wrapLines:je})=>{const ze=e==="fullscreen",ue=ze?"p-4":"p-3",Ze=!!(n?.path&&tn(n.path)),_e=!!(n?.path&&Ka(n.path)),Le=!!(n?.path&&qa(n.path)),xe=!!(n?.path&&Wn(n.path)),de=s.useRef(null),ne=()=>n?t.jsxs("div",{className:"relative h-full",ref:de,children:[t.jsx(Di,{file:{name:n.name,contents:k,lang:Ma(n.path)||void 0},options:{disableFileHeader:!0,overflow:je?"wrap":"scroll",theme:W,themeType:te,...je?{}:{unsafeCSS:Pi}},className:"block h-full w-full",style:{height:"100%"}}),t.jsx(Ii,{hostRef:de,enabled:!je})]}):null;return t.jsx(za,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?a?i?t.jsx("div",{className:ue}):t.jsxs("div",{className:`${ue} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),ze?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${ue} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:J("flex h-full items-center justify-center",ue),children:t.jsx("img",{src:d,alt:n.name||"Image",className:J("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",ze?"max-h-full":"max-h-[70vh]")},f)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:w,className:"h-full w-full border-0",title:n.name},N)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.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."}),b?t.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Ze&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(mi,{ref:P,xml:I,onChange:l},`${n.path}:${v}`)}):j&&_e&&V==="tree"?t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(Mi,{jsonString:X,maxHeight:"100%",initiallyExpandedDepth:2})})}):Le&&G==="preview"?t.jsxs("div",{className:J("h-full overflow-auto",ue),children:[X.length>500*1024?t.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(X.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(ri,{content:X,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&xe&&T==="preview"?_?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:K,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},H)}):L&&O==="view"?ne():t.jsxs("div",{className:J("relative h-full",A&&"overflow-hidden"),ref:S,children:[t.jsx("div",{className:J("h-full",A&&"invisible"),children:t.jsx(vc,{value:k,onChange:$,readOnly:!E,vimMode:R,extensions:m,className:"h-full",onViewReady:z,onViewDestroy:U,...Q?{enableSearch:!0,searchOpen:ae,onSearchOpenChange:oe}:{}})}),A?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${ue} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function bc(e,n,a){if(Da(e)&&!Ta(e))return{kind:n?"desktop-image":"asset-image"};if(Aa(e))return{kind:"pdf"};if(An(e))return{kind:"binary",detectedFromContent:!1};const o=await a(e);if(ai(o))return{kind:"binary",detectedFromContent:!0};const u=yi(o);return{kind:"text",content:u,draft:u.length>Ft?`${u.slice(0,Ft)}
1
+ import{ah as No,ca as St,cb as Tn,z as c,af as va,M as pe,cc as So,cd as Ro,L as ba,K as rn,am as wa,S as Fo,an as In,k as t,ai as Eo,c4 as zo,ad as Mo,ce as Do,c7 as st,cf as Tr,c3 as To,G as Ao,Q as Cn,cg as Oo,ch as Lo,c6 as Po,aL as Io,ci as Bo,U as $o,J as Vo}from"./vendor-boot-EC6IyLt1.js";import{R as s,a as y}from"./vendor-react-DASdDPIk.js";import{e as J,z as ya,A as ka,B as Wo,h as _o,bU as Ko,x as qo,bV as Ho,f as ke,bW as ja,E as Ee,a as Go,m as Uo,F as Jo,bX as Nt,C as Xo,D as Yo,T as Ar,bY as Qo,a8 as Or,v as Lr,y as Nn,at as Zo}from"./index-D4n3TVp2.js";import{cu as ei,ah as bt,B as q,I as F,as as zt,cv as ti,au as Ca,av as Na,aw as Sa,ax as Ra,ay as Fa,az as Ea,ai as Bn,al as $n,an as Vn,ao as Zt,t as he,ap as en,aq as ni,cw as tn,at as za,E as Pr,bc as ri,cx as Ma,cy as Da,cz as Ta,cA as Aa,cB as An,cC as ai,aj as Xe,ak as Ye,am as Qe,z as si,aA as oi,ae as ii,y as ci,ar as li,cD as Ir,aB as Br,aW as ui,cE as $r}from"./useAppFontEffects-CqHhRKmN.js";import{javascript as xt}from"./vendor-codemirror-lang-javascript-Dw4kFO4e.js";import{json as Oa}from"./vendor-codemirror-lang-json-B-b1vAv-.js";import{css as La}from"./vendor-codemirror-lang-css-RM2HqXZ0.js";import{html as On}from"./vendor-codemirror-lang-html-CHSHUpwq.js";import{markdown as Pa}from"./vendor-codemirror-lang-markdown-BTht2ATe.js";import{l as Ia}from"./vendor-codemirror-language-data-CqU7kHmg.js";import{python as Ba}from"./vendor-codemirror-lang-python-CH6_em9L.js";import{shell as di}from"./shell-CjFT_Tl9.js";import{ensurePierreThemeRegistered as Vr,getResolvedShikiTheme as fi}from"./appThemeRegistry-gegrE2dq.js";import{D as mi,i as $a,b as Va,s as pi,F as hi}from"./FileSaveConflictDialog-Cun0LIbj.js";import{h as Wr,y as gi,z as xi,B as vi,E as bi,G as wi,P as Yt}from"./runtimeEndpointReset-D22U_Vjs.js";import{e as Ln,h as Wa,i as _a}from"./SessionUnreadDot-Dav_rix1.js";import{g as Rt,c as Ka,d as qa,e as Wn,n as yi,f as ki,M as Ft,h as se,j as ji,s as Ci,i as Ni,a as Si,t as Qt,k as Sn,b as Ri,l as Fi,u as Ei,m as _r,o as zi,p as Kr}from"./useFilesViewSearch-CqoYEK0U.js";import{J as Mi,F as Di}from"./JsonTreeView-BfErTllU.js";import{a as qr,g as nn,b as Hr,c as Gr,o as Ti,d as Ai}from"./vendor-codemirror-search-DUfSCF9S.js";import{v as Oi,g as Li}from"./vendor-replit-codemirror-vim-AnOuN8yJ.js";import{P as Pi,S as Ii}from"./StickyHorizontalScrollbar-BMITjK4e.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-k1Eit61v.js";import"./nativeFileSave-BJsGPh58.js";import"./vendor-lezer-javascript-ctwLWf4v.js";import"./vendor-lezer-lr-B8TQctNw.js";import"./vendor-codemirror-autocomplete-CGpAsPWp.js";import"./vendor-lezer-json-BP_UAzLL.js";import"./vendor-lezer-css-DUkkbMp7.js";import"./vendor-lezer-html-B3h0MOrG.js";import"./vendor-lezer-markdown-aGLZf_3h.js";import"./vendor-lezer-python-EJ4Im4y2.js";import"./registerCustomTheme-DmolaWWZ.js";import"./themeResolver-yJ9XpNMI.js";import"./vendor-pierre-theming-Dgp7B_O4.js";import"./vendor-shikijs-core-CGM_jqPK.js";import"./vendor-shikijs-types-CPSbSeK6.js";import"./vendor-shikijs-vscode-textmate-BgLrS_2D.js";import"./vendor-hast-util-to-html-BKBhbTDb.js";import"./vendor-html-void-elements-CkdplsNl.js";import"./vendor-property-information-rJCbAzvX.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-Duu5LgQA.js";/* empty css */import"./permissionStore-B9Hkrqny.js";import"./web-components-DzQ9ybbb.js";import"./computeVirtualFileMetrics-Bjhk2CQS.js";import"./vendor-shiki-Bbf2GEcE.js";import"./vendor-shikijs-engine-oniguruma-DPWuIF1G.js";import"./vendor-shikijs-engine-javascript-Cme4830A.js";import"./vendor-oniguruma-to-es-DLBnFDCE.js";import"./vendor-oniguruma-parser-C0D4_9rT.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-DP6HbEeC.js";import"./renderFileWithHighlighter-DUGluXlw.js";const Pn=No.define(di);function Bi(e){const n=e.trim().toLowerCase();switch(n){case"bash":case"sh":case"zsh":case"shell":case"shellsession":case"console":return Pn;case"json":case"jsonc":case"json5":return Oa().language;case"js":case"javascript":return xt().language;case"jsx":return xt({jsx:!0}).language;case"ts":case"typescript":return xt({typescript:!0}).language;case"tsx":return xt({typescript:!0,jsx:!0}).language;case"html":return On().language;case"css":return La().language;case"py":case"python":return Ba().language;case"md":case"markdown":case"mdown":case"mkd":return Pa().language;case"heex":case"eex":case"leex":return On().language;default:return va.matchLanguageName(Ia,n,!0)}}const Ha=e=>e.split("/").pop()?.toLowerCase()??"",$i=e=>{const n=Ha(e);return n?va.matchFilename(Ia,n):null},Vi=()=>St(Tn.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 Wi(e){const n=e.toLowerCase();switch(Ha(n)){case"makefile":case"gnumakefile":return Pn}const i=n.lastIndexOf("."),o=i>=0?n.slice(i+1):"";switch(o){case"ts":case"tsx":case"mts":case"cts":return xt({typescript:!0,jsx:o==="tsx"});case"js":case"jsx":case"mjs":case"cjs":return xt({typescript:!1,jsx:o==="jsx"});case"json":case"jsonc":case"json5":case"jsonl":case"ndjson":case"geojson":return Oa();case"css":case"scss":case"sass":case"less":return La();case"html":case"htm":case"xml":case"drawio":case"dio":return On();case"md":case"mdx":case"markdown":case"mdown":case"mkd":return[Pa({codeLanguages:Bi}),Vi()];case"sh":case"bash":case"zsh":case"fish":case"env":return Pn;case"py":case"pyw":case"pyi":return Ba();default:return null}}async function _i(e){const n=$i(e);if(!n)return null;if(n.support)return n.support;try{return await n.load()}catch{return null}}function Ur(e,n){const a=e.metadata.variant==="dark",i=e.config?.fonts?.mono||"monospace",o=e.colors.syntax.highlights||{},u=e.colors.syntax.tokens||{},d=n?.fontSize?`${n.fontSize}px`:"var(--text-code)",f=pe.theme({"&":{backgroundColor:"var(--background)",color:e.colors.syntax.base.foreground,fontSize:d,lineHeight:"1.5",position:"relative"},".cm-scroller":{fontFamily:i,backgroundColor:"var(--background)"},".cm-comment":{color:e.colors.syntax.base.comment},".cm-keyword":{color:e.colors.syntax.base.keyword},".cm-string":{color:e.colors.syntax.base.string},".cm-string-2":{color:u.stringEscape||e.colors.syntax.base.string},".cm-number":{color:e.colors.syntax.base.number},".cm-operator":{color:e.colors.syntax.base.operator},".cm-punctuation":{color:u.punctuation||e.colors.syntax.base.comment},".cm-atom":{color:u.boolean||e.colors.syntax.base.number},".cm-builtin":{color:u.functionCall||e.colors.syntax.base.function},".cm-def":{color:u.variableGlobal||e.colors.syntax.base.variable},".cm-attribute":{color:u.variableOther||u.variableProperty||e.colors.syntax.base.operator},".cm-meta":{color:e.colors.syntax.base.comment},".cm-property":{color:u.variableProperty||e.colors.syntax.base.keyword},".cm-variable":{color:e.colors.syntax.base.variable},".cm-variable-2":{color:u.variableOther||e.colors.syntax.base.function},".cm-variable-3":{color:u.variableGlobal||e.colors.syntax.base.type},".cm-tag":{color:u.tag||e.colors.syntax.base.keyword},".cm-link":{color:u.url||e.colors.syntax.base.keyword,textDecoration:"underline"},".cm-content":{caretColor:e.colors.interactive.cursor},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.colors.interactive.cursor},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e.colors.interactive.selection},".cm-gutters":{backgroundColor:"var(--background)",color:o.lineNumber||e.colors.syntax.base.comment,borderRight:`1px solid ${e.colors.interactive.border}`,position:"sticky",paddingRight:"8px",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:"8px",minWidth:"42px"},".cm-activeLineGutter":{color:o.lineNumberActive||e.colors.syntax.base.foreground},".cm-activeLine":{backgroundColor:e.colors.surface.overlay},".cm-panels":{backgroundColor:"transparent",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.elevated,color:e.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, ${e.colors.surface.elevated} 85%, transparent)`,border:`1px solid ${e.colors.interactive.border}`,borderRadius:"10px",boxShadow:`0 2px 8px color-mix(in srgb, ${e.colors.surface.background} 60%, transparent)`,width:"auto",minWidth:"360px",maxWidth:"480px"},".cm-search":{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0",width:"100%",color:e.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 ${e.colors.interactive.border}`,backgroundColor:e.colors.surface.background,color:e.colors.surface.foreground,fontFamily:"inherit",fontSize:"12px",lineHeight:"1",outline:"none",transition:"border-color 150ms ease"},".cm-search .cm-textfield::placeholder":{color:e.colors.surface.mutedForeground,opacity:1},".cm-search .cm-textfield:focus":{borderColor:e.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:e.colors.interactive.hover},'.cm-search label:has(input[type="checkbox"]:checked)':{backgroundColor:e.colors.interactive.hover,borderColor:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search label:hover::after":{color:e.colors.surface.foreground},'.cm-search label:has(input[type="checkbox"]:checked)::after':{color:e.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:e.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:e.colors.surface.mutedForeground,pointerEvents:"none"},".cm-search .cm-button:hover":{backgroundColor:e.colors.interactive.hover},".cm-search .cm-button:hover::after":{color:e.colors.surface.foreground},".cm-search .cm-button:active":{backgroundColor:e.colors.interactive.active},".cm-search .cm-button:focus-visible":{outline:"none",boxShadow:`0 0 0 1px ${e.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:e.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:e.colors.interactive.hover,color:e.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:e.colors.status.infoBackground,boxShadow:`inset 0 0 0 1px ${e.colors.status.infoBorder}`,borderRadius:"2px"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:e.colors.interactive.selection,color:e.colors.interactive.selectionForeground,boxShadow:`inset 0 0 0 1px ${e.colors.interactive.borderFocus}`},"&.cm-focused":{outline:"none"}},{dark:a}),g=Tn.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"}]),w=Tn.define([{tag:[c.comment,c.docComment,c.meta,c.documentMeta],color:e.colors.syntax.base.comment},{tag:[c.keyword,c.controlKeyword,c.moduleKeyword,c.definitionKeyword,c.modifier],color:e.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:e.colors.syntax.base.operator},{tag:[c.string,c.regexp,c.attributeValue,c.special(c.string),c.monospace],color:e.colors.syntax.base.string},{tag:c.escape,color:u.stringEscape||e.colors.syntax.base.string},{tag:[c.number,c.bool,c.atom,c.null,c.self],color:e.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:e.colors.syntax.base.function},{tag:c.definition(c.variableName),color:u.variableGlobal||e.colors.syntax.base.variable},{tag:[c.variableName,c.local(c.variableName),c.constant(c.variableName),c.literal],color:e.colors.syntax.base.variable},{tag:c.propertyName,color:u.variableProperty||e.colors.syntax.base.variable},{tag:c.attributeName,color:u.variableOther||e.colors.syntax.base.variable},{tag:[c.className,c.typeName,c.namespace],color:e.colors.syntax.base.type},{tag:[c.tagName,c.labelName,c.annotation,c.macroName],color:u.tag||e.colors.syntax.base.keyword},{tag:c.link,color:u.url||e.colors.syntax.base.function,textDecoration:"underline"},{tag:[c.punctuation,c.separator,c.bracket,c.paren,c.brace,c.squareBracket,c.angleBracket],color:u.punctuation||e.colors.syntax.base.comment}]);return n?.syntaxColors===!1?[f]:[f,St(So,{fallback:!0}),St(Ro),St(g),St(w)]}const Ki=180,Ga=Fo.define(),qi=1,Hi=2,Gi=4,Jr=new Map,Ui=(e,n)=>{const a=`${e}|${n}`,i=Jr.get(a);if(i)return i;let o="";e&&(o+=`color:${e};`),n&qi&&(o+="font-style:italic;"),n&Hi&&(o+="font-weight:bold;"),n&Gi&&(o+="text-decoration:underline;");const u=rn.mark({attributes:{style:o}});return Jr.set(a,u),u},Ji=(e,n)=>{const a=new In,i=e.state.doc,o=Math.min(n.length,i.lines);for(let u=0;u<o;u+=1){const d=n[u];if(!d||d.length===0)continue;const f=i.line(u+1);let g=f.from;for(const[w,N,x]of d){if(w<=0)continue;const b=g,j=Math.min(g+w,f.to);g+=w,!(j<=b)&&(!N&&!x||a.add(b,j,Ui(N,x)))}}return a.finish()},Xi=ba.define({create(){return rn.none},update(e,n){let a=e.map(n.changes);for(const i of n.effects)i.is(Ga)&&(a=i.value);return a},provide:e=>pe.decorations.from(e)}),Yi=e=>wa.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)},Ki)}async tokenize(n){const a=++this.generation,i=n.state.doc.toString(),o=await ei(i,e.language,e.themeName,e.theme);o&&a===this.generation&&n.state.doc.length===i.length&&n.dispatch({effects:Ga.of(Ji(n,o))})}destroy(){this.timer&&clearTimeout(this.timer)}}),Qi=e=>[Xi,Yi(e)],We=e=>(e||"").replace(/\\/g,"/").replace(/\/+$/g,""),vt=e=>{const n=We(e);return!n||n==="/"?n||"/":n.split("/").filter(Boolean).at(-1)??n},Ua=e=>{const n=We(e);if(!n||n==="/")return null;const a=n.lastIndexOf("/");if(a<0)return null;if(a===0)return"/";const i=n.slice(0,a);return/^[A-Za-z]:$/.test(i)?`${i}/`:i},Xr=(e,n)=>{const a=We(e),i=We(n);return!a||!i?!1:a===i||a.startsWith(`${i}/`)},Yr=(e,n)=>{const a=We(e);if(!a)return We(n);if(a.startsWith("/")||/^[A-Za-z]:(\/|$)/.test(a))return a;const i=We(n);return i?`${i}/${a}`:a},Zi=(e,n)=>{const a=We(e),i=We(n);if(!a||a===i)return!1;const o=Ua(a);return o?i&&Xr(a,i)?Xr(o,i):!0:!1},ec=e=>{if(typeof e!="number"||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const n=["KB","MB","GB"];let a=e/1024;for(const i of n){if(a<1024||i===n[n.length-1])return`${a.toFixed(a>=10?0:1)} ${i}`;a/=1024}return""},tc=(e,n)=>!n||e===n?vt(e):e.startsWith(`${n}/`)?e.slice(n.length+1):e,nc=({root:e,directory:n,entries:a,query:i,searchResults:o,isSearching:u,directoryError:d,refreshing:f,editorPath:g,editor:w,onClose:N,onQueryChange:x,onOpenDirectory:b,onOpenFile:j,onBackFromEditor:C,onRefresh:v})=>{if(!e)return t.jsx(Et,{message:"Select a project to browse files."});if(g)return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Back",onClick:C,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}),icon:t.jsx(bt,{filePath:g,className:"size-4 shrink-0"}),title:vt(g)}),t.jsx("div",{className:"min-h-0 flex-1 overflow-hidden",children:w})]});const P=n===e?"Project files":vt(n),I=Zi(n,e)?Ua(n):null,l=!!I&&!i.trim(),V=I===e?"Project files":vt(I??""),G=N||l&&I?t.jsxs(t.Fragment,{children:[N?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Close",onClick:N,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"close",className:"size-4"})}):null,l&&I?t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":`Back to ${vt(I)}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:t.jsx(F,{name:"arrow-left",className:"size-4"})}):null]}):void 0;return t.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background text-foreground",children:[t.jsx(Wr,{leading:G,icon:n===e?"file-text":"folder",title:P,actions:t.jsx(q,{type:"button",variant:"ghost",size:"icon","aria-label":"Refresh files",onClick:v,style:{touchAction:"manipulation"},children:t.jsx(F,{name:"refresh",className:J("size-4",f&&"animate-spin")})})}),t.jsx("div",{className:"shrink-0 px-3 py-2",children:t.jsxs("div",{className:"relative",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),t.jsx(zt,{value:i,onChange:T=>x(T.target.value),placeholder:"Search files",className:"h-8 pl-7"})]})}),t.jsx(ti,{className:"min-h-0 w-full flex-1 overflow-y-auto pb-3",children:d?t.jsx(Et,{message:d}):i.trim()?t.jsx(rc,{root:e,results:o,isSearching:u,onOpenFile:j}):a===void 0?t.jsx(Et,{loading:!0,message:"Loading..."}):t.jsxs("div",{className:"flex w-full min-w-0 flex-col px-1",children:[l&&I?t.jsxs("button",{type:"button",className:J(_a,"px-2"),"aria-label":`Up one level to ${V}`,onClick:()=>b(I),style:{touchAction:"manipulation"},children:[t.jsx(F,{name:"arrow-left",className:J(Ln(!0),"text-muted-foreground")}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-muted-foreground"),children:"Up one level"})]}):null,a.length===0?t.jsx("div",{className:"px-3 py-8 text-center typography-ui-label text-muted-foreground",children:"This directory is empty."}):null,a.map(T=>t.jsx(Ja,{name:T.name,path:T.path,directory:T.type==="directory",meta:T.type==="directory"?void 0:ec(T.size),onClick:()=>T.type==="directory"?b(Yr(T.path,n||e)):j(Yr(T.path,n||e))},T.path))]})})]})},Ja=({name:e,path:n,directory:a,meta:i,onClick:o})=>t.jsxs("button",{type:"button",className:J(_a,"px-2"),onClick:o,style:{touchAction:"manipulation"},children:[a?t.jsx(F,{name:"folder-3-fill",className:J(Ln(!0),"text-primary/80")}):t.jsx(bt,{filePath:n,className:Ln(!0)}),t.jsx("span",{className:J(Wa(!0),"flex-1 text-foreground"),children:e}),i?t.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:i}):null,a?t.jsx(F,{name:"arrow-right-s",className:"size-4 shrink-0 text-muted-foreground/60"}):null]}),rc=({root:e,results:n,isSearching:a,onOpenFile:i})=>a?t.jsx(Et,{loading:!0,message:"Loading..."}):n.length===0?t.jsx(Et,{message:"No files found."}):t.jsx("div",{className:"flex w-full min-w-0 flex-col px-1",children:n.map(o=>t.jsx(Ja,{name:vt(o.path),path:o.path,directory:!1,meta:o.relativePath??tc(o.path,e),onClick:()=>i(o.path)},o.path))}),Et=({message:e,loading:n=!1})=>t.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center",children:t.jsxs("div",{className:"flex max-w-sm flex-col items-center gap-2",children:[n?t.jsx(F,{name:"loader-4",className:"size-5 animate-spin text-muted-foreground"}):t.jsx(F,{name:"folder-open-fill",className:"size-6 text-muted-foreground"}),t.jsx("p",{className:"typography-ui-label font-semibold text-foreground",children:e})]})}),ac=({activeDialog:e,dialogData:n,dialogInputValue:a,onDialogInputChange:i,isDialogSubmitting:o,onDialogSubmit:u,onClose:d,inputRef:f})=>t.jsx(Ca,{open:!!e,onOpenChange:g=>!g&&d(),children:t.jsxs(Na,{initialFocus:f,children:[t.jsxs(Sa,{children:[t.jsxs(Ra,{children:[e==="createFile"&&"Create File",e==="createFolder"&&"Create Folder",e==="rename"&&"Rename",e==="delete"&&"Delete"]}),t.jsxs(Fa,{children:[e==="createFile"&&`Create a new file in ${n?.path??"root"}`,e==="createFolder"&&`Create a new folder in ${n?.path??"root"}`,e==="rename"&&`Rename ${n?.name??""}`,e==="delete"&&`Are you sure you want to delete ${n?.name??""}? This action cannot be undone.`]})]}),e!=="delete"&&t.jsx("div",{className:"py-4",children:t.jsx(zt,{value:a,onChange:g=>i(g.target.value),placeholder:e==="rename"?"New name":"Name",onKeyDown:g=>{g.key==="Enter"&&u()},ref:f})}),t.jsxs(Ea,{children:[t.jsx(q,{variant:"outline",onClick:d,disabled:o,children:"Cancel"}),t.jsx(q,{variant:e==="delete"?"destructive":"default",onClick:()=>{u()},disabled:o||e!=="delete"&&!a.trim(),children:o?t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}):e==="delete"?"Delete":"Confirm"})]})]})}),sc=({label:e,iconDataUrl:n})=>{const[a,i]=s.useState(!1),o=e.trim().slice(0,1).toUpperCase()||"?";return n&&!a?t.jsx("img",{src:n,alt:"",className:"size-4 rounded-sm",onError:()=>i(!0)}):t.jsx("span",{className:J("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),children:o})},Xa=({filePath:e,extension:n})=>t.jsx(bt,{filePath:e,extension:n}),oc=({status:e})=>{const n={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"}[e];return t.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:n}})},Qr=({name:e})=>{const n=s.useRef(null),a=s.useRef(null),[i,o]=s.useState(!1);return s.useLayoutEffect(()=>{const u=n.current,d=a.current;if(!u||!d)return;const f=()=>{o(d.scrollWidth>u.clientWidth+1)};f();const g=new ResizeObserver(f);return g.observe(u),g.observe(d),()=>{g.disconnect()}},[e]),t.jsxs("span",{ref:n,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[t.jsx("span",{ref:a,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:e}),i?t.jsxs("span",{className:"open-file-name-marquee-track",children:[t.jsx("span",{className:"open-file-name-marquee-item",children:e}),t.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:e})]}):t.jsx("span",{className:"block min-w-0 truncate",children:e})]})},ic=({node:e,root:n,isExpanded:a,isActive:i,isMobile:o,isBrowserClient:u,alwaysShowActions:d,status:f,badge:g,permissions:w,downloadFile:N,contextMenuPath:x,setContextMenuPath:b,rightClickMenuPath:j,setRightClickMenuPath:C,onSelect:v,onToggle:P,onRevealPath:I,onOpenDialog:l})=>{const V=e.type==="directory",{canRename:G,canCreateFile:T,canCreateFolder:_,canDelete:H,canReveal:K}=w,X=!V&&!!N,L=ya()&&ka(),O=K&&!u&&L,k=G||T||_||H||X||O,$=s.useCallback(S=>{k&&(S?.preventDefault(),C(e.path))},[k,e.path,C]),E=s.useCallback(()=>{V?P(e.path):v(e)},[V,e,v,P]),R=s.useCallback(S=>{S.stopPropagation(),C(null),b(e.path)},[e.path,b,C]),m=({Item:S,Separator:A})=>t.jsxs(t.Fragment,{children:[G&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("rename",e)},children:[t.jsx(F,{name:"edit",className:"mr-2 size-4"})," ","Rename"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),Zt(e.path).then(U=>{if(U.ok){he.success("Path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy",className:"mr-2 size-4"})," ","Copy Path"]}),t.jsxs(S,{onClick:z=>{z.stopPropagation();const U=Rt(n,e.path)||e.path;Zt(U).then(Q=>{if(Q.ok){he.success("Relative path copied");return}he.error("Copy failed")})},children:[t.jsx(F,{name:"file-copy-2",className:"mr-2 size-4"})," ","Copy Relative Path"]}),!V&&N&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),N(e.path).catch(U=>{console.error("Download failed:",U),he.error("Operation failed")})},children:[t.jsx(F,{name:"download",className:"mr-2 size-4"})," ",u?"Download":"Save"]}),O&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),I(e.path)},children:[t.jsx(F,{name:"folder-received",className:"mr-2 size-4"})," ",Wo()]}),V&&(T||_)&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),T&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFile",e)},children:[t.jsx(F,{name:"file-add",className:"mr-2 size-4"})," ","New File"]}),_&&t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("createFolder",e)},children:[t.jsx(F,{name:"folder-add",className:"mr-2 size-4"})," ","New Folder"]})]}),H&&t.jsxs(t.Fragment,{children:[t.jsx(A,{}),t.jsxs(S,{onClick:z=>{z.stopPropagation(),l("delete",e)},className:"text-destructive focus:text-destructive",children:[t.jsx(F,{name:"delete-bin",className:"mr-2 size-4"})," ","Delete"]})]})]});return t.jsxs(gi,{open:j===e.path,onOpenChange:S=>C(S?e.path:null),children:[t.jsxs(xi,{render:t.jsx("div",{className:"group relative flex items-center",onContextMenu:o?void 0:$}),children:[t.jsxs("button",{type:"button",onClick:E,onContextMenu:o?void 0:$,className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[V?a?t.jsx(F,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(F,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):t.jsx(Xa,{filePath:e.path,extension:e.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:e.path,children:e.name}),!V&&f&&t.jsx(oc,{status:f}),V&&g&&t.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[g.modified>0&&t.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",g.modified]}),g.added>0&&t.jsxs("span",{className:"text-[var(--status-success)]",children:["+",g.added]})]})]}),k&&t.jsx("div",{className:J("absolute right-1 top-1/2 -translate-y-1/2",d?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:t.jsxs(Bn,{open:x===e.path,onOpenChange:S=>b(S?e.path:null),children:[t.jsx($n,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"icon",className:"size-6",onClick:R,children:t.jsx(F,{name:"more-2-fill",className:"size-4"})})}),t.jsx(Vn,{align:"end",side:"bottom",onCloseAutoFocus:()=>b(null),children:m({Item:en,Separator:ni})})]})})]}),t.jsx(vi,{className:"min-w-[180px]",children:m({Item:bi,Separator:wi})})]})},Rn=(e,n,a)=>{const[i,o]=s.useState(""),[u,d]=s.useState(0);return s.useEffect(()=>{if(!e){o("");return}let f=!1;o("");const g=_o(),w=Ko(g);qo(g).then(x=>{f||!x||(o(e),n(null))}).catch(x=>{f||(n(x instanceof Error?x.message:a),o(e))});const N=Ho(()=>{f||(o(e),d(x=>x+1),n(null))});return()=>{f=!0,w(),N()}},[e,n,a]),{readyKey:i,nonce:u}},cc=e=>e!==null&&typeof e=="object"&&"updateStatus"in e&&typeof e.updateStatus=="function",lc=e=>{const n=document.createElement("div");n.className="cm-vim-panel";const a=Li(e);if(!a)return{top:!1,dom:n};a.state.statusbar=n;const i=a.state.vimPlugin;return cc(i)&&i.updateStatus(),{top:!1,dom:n,destroy(){a.state.statusbar===n&&(a.state.statusbar=null)}}};function Zr(e){return e?[Oi(),Eo.of(lc),zo()]:[]}const uc={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 fc(e){const n=e.querySelector(".cm-search");if(n){for(const[a,i]of Object.entries(uc)){const o=n.querySelector(`button[name="${a}"]`);o&&!o.title&&(o.title=i)}for(const[a,i]of Object.entries(dc)){const u=n.querySelector(`input[name="${a}"]`)?.parentElement;u&&!u.title&&(u.title=i)}}}const Fn=new WeakMap;function mc(e,n){const a=nn(e.state);if(!a.valid)return Fn.delete(e),0;const i=Fn.get(e);if(!n&&i?.doc===e.state.doc&&i.query.eq(a))return i.total;const o=a.getCursor(e.state);let u=0;for(let d=o.next();!d.done;d=o.next())u+=1;return Fn.set(e,{query:a,doc:e.state.doc,total:u}),u}function pc(e){const n=nn(e.state);if(!n.valid)return 0;const a=e.state.selection.main,i=n.getCursor(e.state);let o=0,u=0;for(let d=i.next();!d.done;d=i.next()){const f=d.value;if(o+=1,u===0&&(u=o),a.from===f.from&&a.to===f.to||a.from<f.to&&a.to>f.from||f.from>=a.head)return o}return u}function ea(e,n,a=!1){const i=e.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 f=i.querySelector('button[name="next"]'),g=f?.parentNode===i?f:i.firstChild;i.insertBefore(o,g)}const u=mc(n,a),d=u===0?0:pc(n);o.textContent=u===0?"":`${d}/${u}`}const ta=new st,na=new st,ra=new st,aa=new st,sa=new st,oa=new st,ia=new st,ca=e=>e,En=Bo,hc=Ti,gc=Ai;class xc extends $o{constructor(n,a){super(),this.id=n,this.containerMap=a}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 la=(e,n)=>!e||e.length===0?[]:ba.define({create(a){const i=new In,o=[...e].sort((u,d)=>u.afterLine-d.afterLine);for(const u of o){const d=a.doc.lines;if(u.afterLine>d)continue;const f=a.doc.line(u.afterLine);i.add(f.to,f.to,rn.widget({widget:new xc(u.id,n),block:!0,side:1}))}return i.finish()},update(a,i){return a.map(i.changes)},provide:a=>pe.decorations.from(a)}),ua=e=>{if(!e)return[];const n=Math.max(1,e.start),a=Math.max(n,e.end);return wa.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 In;for(let u=n;u<=a&&u<=i.state.doc.lines;u+=1){const d=i.state.doc.line(u);o.add(d.from,d.from,rn.line({class:"oc-cm-selected-line"}))}return o.finish()}},{decorations:i=>i.decorations})};function vc({value:e,onChange:n,extensions:a,className:i,readOnly:o,lineNumbersConfig:u,highlightLines:d,onViewReady:f,onViewDestroy:g,blockWidgets:w,enableSearch:N,searchOpen:x,onSearchOpenChange:b,vimMode:j}){const C=s.useRef(null),v=s.useRef(null),P=s.useRef(e),I=s.useRef(n),l=s.useRef(f),V=s.useRef(g),G=s.useRef(b),T=s.useRef(w),_=s.useRef(j),H=s.useRef(new Map),[K,X]=s.useState([]),L=s.useCallback(k=>{const $=(k??[]).map(E=>{const R=H.current.get(E.id);return R?{id:E.id,content:E.content,container:R}:null}).filter(E=>E!==null);X(E=>E.length===$.length&&E.every((R,m)=>{const S=$[m];return R.id===S.id&&R.content===S.content&&R.container===S.container})?E:$)},[]),O=s.useCallback(k=>{const $=C.current,E=k??v.current;if(!$||!E)return;const R=E.dom.querySelector(".cm-gutters"),m=R instanceof HTMLElement?R.getBoundingClientRect().width:0;$.style.setProperty("--oc-editor-gutter-width",`${m}px`)},[]);return s.useEffect(()=>{P.current=e},[e]),s.useEffect(()=>{I.current=n},[n]),s.useEffect(()=>{l.current=f,V.current=g},[f,g]),s.useEffect(()=>{G.current=b},[b]),s.useEffect(()=>{T.current=w,L(w)},[w,L]),s.useEffect(()=>{if(!C.current)return;const k=(()=>{if(typeof document>"u")return null;const E=document.querySelector('meta[name="csp-nonce"]')?.getAttribute("content");if(E)return E;const R=window.__PICHAMBER_CSP_NONCE__;return typeof R=="string"&&R.length>0?R:null})(),$=Mo.create({doc:P.current,extensions:[...k?[pe.cspNonce.of(k)]:[],Do({fixed:!0}),ta.of(Tr(u)),To(),Ao.of(" "),ia.of(Zr(j)),Cn.of([Oo,...Lo,...Po]),pe.updateListener.of(E=>{O(E.view),(E.viewportChanged||E.geometryChanged)&&L(T.current);const R=qr(E.startState),m=qr(E.state);R!==m&&G.current?.(m);const S=!nn(E.startState).eq(nn(E.state));if(m&&(R!==m||S||E.docChanged||E.selectionSet)&&ea(E.view.dom,E.view,R!==m||S||E.docChanged),!E.docChanged)return;const A=E.state.doc.toString();P.current=A,I.current(A),L(T.current)}),na.of(pe.editable.of(!o)),ra.of(a??[]),aa.of(ua(d)),sa.of(la(w,H.current)),oa.of(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]});return v.current=new pe({state:$,parent:C.current}),En(v.current,v.current.state.doc.length,200),v.current.requestMeasure(),requestAnimationFrame(()=>{O(v.current),L(T.current)}),v.current&&l.current?.(v.current),()=>{V.current?.(),v.current?.destroy(),v.current=null,X([])}},[T,O,L]),s.useEffect(()=>{const k=v.current;k&&(k.dispatch({effects:[ta.reconfigure(Tr(u)),na.reconfigure(pe.editable.of(!o)),ra.reconfigure(a??[]),aa.reconfigure(ua(d)),sa.reconfigure(la(w,H.current)),oa.reconfigure(N?[Hr({top:!0}),Cn.of(ca(Gr))]:[])]}),En(k,k.state.doc.length,200),k.requestMeasure(),requestAnimationFrame(()=>{O(k),L(T.current)}))},[a,d,u,o,w,N,O,L]),s.useEffect(()=>{const k=v.current;if(!k){_.current=j;return}_.current!==j&&(_.current=j,k.dispatch({effects:ia.reconfigure(Zr(j))}))},[j]),s.useEffect(()=>{const k=v.current;!k||N===!1||(x?(hc(k),requestAnimationFrame(()=>{fc(k.dom),ea(k.dom,k,!0)})):gc(k))},[x,N]),s.useEffect(()=>{const k=v.current;if(!k)return;const $=k.state.doc.toString();$!==e&&(k.dispatch({changes:{from:0,to:$.length,insert:e}}),En(k,k.state.doc.length,300),k.requestMeasure(),requestAnimationFrame(()=>O(k)))},[e,O]),t.jsxs(t.Fragment,{children:[t.jsx("div",{ref:C,className:J("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)}),K.map(k=>Io.createPortal(k.content,k.container,k.id))]})}const da=({variant:e,selectedFile:n,loading:a,suppressLoadingIndicator:i,fileError:o,isSelectedImage:u,imageSrc:d,imagePreviewNonce:f,isSelectedPdf:g,pdfSrc:w,pdfPreviewNonce:N,isUnsupportedBinary:x,onDownload:b,enableRichPreviews:j,drawioViewMode:C,drawioRemountNonce:v,diagramEditorRef:P,diagramEditorXml:I,onDiagramChange:l,jsonViewMode:V,markdownViewMode:G,htmlViewMode:T,htmlLoading:_,htmlPreviewNonce:H,htmlPreviewSrc:K,fileContent:X,canUseShikiFileView:L,textViewMode:O,draftContent:k,onDraftChange:$,canEdit:E,vimMode:R,editorExtensions:m,editorWrapperRef:S,shouldMaskEditorForPendingNavigation:A,onEditorViewReady:z,onEditorViewDestroy:U,enableSearch:Q=!1,searchOpen:ae,onSearchOpenChange:oe,pierreTheme:W,shikiThemeType:te,wrapLines:je})=>{const ze=e==="fullscreen",ue=ze?"p-4":"p-3",Ze=!!(n?.path&&tn(n.path)),_e=!!(n?.path&&Ka(n.path)),Le=!!(n?.path&&qa(n.path)),xe=!!(n?.path&&Wn(n.path)),de=s.useRef(null),ne=()=>n?t.jsxs("div",{className:"relative h-full",ref:de,children:[t.jsx(Di,{file:{name:n.name,contents:k,lang:Ma(n.path)||void 0},options:{disableFileHeader:!0,overflow:je?"wrap":"scroll",theme:W,themeType:te,...je?{}:{unsafeCSS:Pi}},className:"block h-full w-full",style:{height:"100%"}}),t.jsx(Ii,{hostRef:de,enabled:!je})]}):null;return t.jsx(za,{outerClassName:"h-full min-w-0",className:"h-full min-w-0",children:n?a?i?t.jsx("div",{className:ue}):t.jsxs("div",{className:`${ue} flex items-center gap-2 typography-ui text-muted-foreground`,children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),ze?"Loading…":"Loading..."]}):o?t.jsx("div",{className:`${ue} typography-ui text-[color:var(--status-error)]`,children:o}):u?t.jsx("div",{className:J("flex h-full items-center justify-center",ue),children:t.jsx("img",{src:d,alt:n.name||"Image",className:J("max-w-full object-contain rounded-md border border-border/30 bg-primary/10",ze?"max-h-full":"max-h-[70vh]")},f)}):g?t.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:t.jsx("iframe",{src:w,className:"h-full w-full border-0",title:n.name},N)}):x?t.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[t.jsx("div",{className:"typography-ui-header text-foreground",children:"Cannot preview binary file"}),t.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."}),b?t.jsxs(q,{type:"button",variant:"outline",size:"sm",onClick:b,children:[t.jsx(F,{name:"download",className:"mr-2 size-4"}),"Save file"]}):null]}):j&&Ze&&C==="preview"?t.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:t.jsx(mi,{ref:P,xml:I,onChange:l},`${n.path}:${v}`)}):j&&_e&&V==="tree"?t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"JSON viewer unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to text mode to view raw content."})]}),children:t.jsx("div",{className:"h-full overflow-auto",children:t.jsx(Mi,{jsonString:X,maxHeight:"100%",initiallyExpandedDepth:2})})}):Le&&G==="preview"?t.jsxs("div",{className:J("h-full overflow-auto",ue),children:[X.length>500*1024?t.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(X.length/1024)}KB). Preview may be limited.`}):null,t.jsx(Pr,{fallback:t.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[t.jsx("div",{className:"mb-1 font-medium text-destructive",children:"Preview unavailable"}),t.jsx("div",{className:"text-sm text-muted-foreground",children:"Switch to edit mode to fix the issue."})]}),children:t.jsx(ri,{content:X,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):j&&xe&&T==="preview"?_?t.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:"Loading..."}):t.jsx("div",{className:"h-full overflow-hidden",children:t.jsx("iframe",{src:K,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:"HTML Preview"},H)}):L&&O==="view"?ne():t.jsxs("div",{className:J("relative h-full",A&&"overflow-hidden"),ref:S,children:[t.jsx("div",{className:J("h-full",A&&"invisible"),children:t.jsx(vc,{value:k,onChange:$,readOnly:!E,vimMode:R,extensions:m,className:"h-full",onViewReady:z,onViewDestroy:U,...Q?{enableSearch:!0,searchOpen:ae,onSearchOpenChange:oe}:{}})}),A?t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:t.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Opening file at change..."]})}):null]}):t.jsx("div",{className:`${ue} typography-ui text-muted-foreground`,children:"Pick a file from the tree."})})};async function bc(e,n,a){if(Da(e)&&!Ta(e))return{kind:n?"desktop-image":"asset-image"};if(Aa(e))return{kind:"pdf"};if(An(e))return{kind:"binary",detectedFromContent:!1};const o=await a(e);if(ai(o))return{kind:"binary",detectedFromContent:!0};const u=yi(o);return{kind:"text",content:u,draft:u.length>Ft?`${u.slice(0,Ft)}
2
2
 
3
3
  … truncated …`:u,lineEnding:ki(o)}}function wc({isDirty:e,saveDraft:n}){const a=ke(b=>b.setMainTabGuard),[i,o]=y.useState(!1),u=y.useRef(null),d=y.useRef(!1),f=y.useCallback(b=>d.current?(d.current=!1,!1):e?(u.current=b,o(!0),!0):!1,[e]);y.useEffect(()=>{if(!e){a(null);return}const b=j=>!f({kind:"tab",tab:j});return a(b),()=>{ke.getState().mainTabGuard===b&&a(null)}},[e,f,a]);const g=y.useCallback(()=>{const b=u.current;return u.current=null,d.current=!0,o(!1),b?.kind==="tab"&&a(null),b},[a]),w=y.useCallback(()=>g(),[g]),N=y.useCallback(async()=>await n()?g():(d.current=!1,null),[n,g]),x=y.useCallback(b=>{b||o(!0)},[]);return{confirmOpen:i,discardAndTakeIntent:w,keepModalOpen:x,requestNavigation:f,saveAndTakeIntent:N}}function yc(e,n){if(e.state.doc.length!==n.length)return!1;if(n.length===0)return!0;const a=Math.min(128,n.length);if(e.state.sliceDoc(0,a)!==n.slice(0,a))return!1;const i=Math.max(0,n.length-a);return e.state.sliceDoc(i,n.length)===n.slice(i)}function kc({root:e,selectedPath:n,loadedPath:a,fileLoading:i,fileError:o,isImage:u,isPdf:d,isUnsupportedBinary:f,canEdit:g,textViewMode:w,setTextViewMode:N,draftContent:x,confirmDiscardOpen:b,selectFilePath:j}){const C=ke(L=>L.pendingFileNavigation),v=ke(L=>L.setPendingFileNavigation),P=ke(L=>L.pendingFileFocusPath),I=ke(L=>L.setPendingFileFocusPath),l=y.useRef(null),[V,G]=y.useState(0),T=y.useRef(null),_=y.useRef({key:"",attempts:0}),H=y.useCallback(()=>{G(L=>L+1)},[]);y.useEffect(()=>()=>{T.current!==null&&window.cancelAnimationFrame(T.current)},[]),y.useEffect(()=>{if(!C||!e)return;const L=()=>{T.current===null&&(T.current=window.requestAnimationFrame(()=>{T.current=null,H()}))},O=()=>{v(null),_.current={key:"",attempts:0}},k=se(C.path);if(!k){O();return}const $=`${k}:${C.line}:${C.column??1}`;if(_.current.key!==$&&(_.current={key:$,attempts:0}),n!==k){b||j(k);return}if(i||a!==k)return;if(o||u||d||f){O();return}if(!g)return;if(w!=="edit"){N("edit");return}const E=l.current;if(!E||!yc(E,x)){L();return}const R=Math.max(1,Math.min(C.line,E.state.doc.lines)),m=E.state.doc.line(R),S=Math.max(1,C.column||1),A=m.from+Math.min(Math.max(0,m.to-m.from),S-1);if(!(E.state.selection.main.head===A)||_.current.attempts===0){_.current.attempts+=1,E.dispatch({selection:{anchor:A},effects:pe.scrollIntoView(A,{y:"center"})}),E.focus(),L();return}window.requestAnimationFrame(()=>{const U=l.current;U&&(U.dispatch({selection:{anchor:A},effects:pe.scrollIntoView(A,{y:"center"})}),U.focus())}),O()},[g,b,x,V,o,i,u,d,f,a,H,C,e,n,j,v,N,w]),y.useEffect(()=>{if(!P||!e)return;const L=se(P);if(!L){I(null);return}n!==L||i||a!==L||(!o&&!u&&!d&&!f&&g&&w==="edit"&&l.current?.focus(),I(null))},[g,o,i,u,d,f,a,P,e,n,I,w]);const K=se(C?.path??"");return{editorViewRef:l,notifyEditorViewChanged:H,shouldMaskEditor:!!(C&&K&&n===K&&!i&&!o&&!u&&!d&&!f)}}function jc(e){return!(!e.autoSaveEnabled||!e.isDirty||!e.canWrite||e.isSaving||e.fileLoading||e.isNonEditableBinary||!e.selectedFilePath||e.loadedFilePath!==e.selectedFilePath)}function Cc(e){return e.selectedFilePath?e.isDirty?!(e.fileLoading||e.loadedFilePath!==e.selectedFilePath||e.isNonEditableBinary||e.draftContent===""&&e.fileContent!==""&&e.loadedFilePath!==e.selectedFilePath):!0:!1}const Nc=1500,Sc=2e3;function Rc({autoSaveEnabled:e,selectedPath:n,loadedPath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:d,lineEnding:f,isNonEditableBinary:g,writeFile:w,expectedRevision:N,onSaved:x,captureSaveScope:b,currentSaveScope:j,onConflict:C}){const[v,P]=y.useState(!1),[I,l]=y.useState("idle"),[V,G]=y.useState(null),T=y.useRef(null),_=y.useRef(null),H=y.useRef(C);H.current=C;const K=y.useRef(b);K.current=b;const X=y.useRef(j);X.current=j;const L=y.useCallback(R=>R?$a(R,X.current?.()??null):!0,[]),O=y.useCallback(()=>{T.current&&(clearTimeout(T.current),T.current=null)},[]),k=y.useCallback(()=>{l("saved"),_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{_.current=null,l("idle")},Sc)},[]),$=y.useCallback(async R=>{if(!n||!w)return he.error("Saving not supported"),!1;if(!Cc({selectedFilePath:n,loadedFilePath:a,fileLoading:i,isDirty:o,draftContent:u,fileContent:d,isNonEditableBinary:g}))return g?console.warn(`[saveDraft] refusing to save binary file "${n}".`):u===""&&d!==""&&a!==n&&console.warn(`[saveDraft] refusing to save empty draft for "${n}" (${d.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 m=K.current?.()??null;try{const S=ji(u,f),A=Va(N,R?.overwrite),z=await w(n,S,A);return z?.success?L(m)?(G(null),x(n,u,z?.revision,m),!0):!1:(he.error("Failed to write file"),!1)}catch(S){if(ja(S)){if(!L(m))return!1;const A={path:n,currentRevision:S.currentRevision??null,exists:S.exists};return G(A),H.current?.(A),!1}return he.error(S instanceof Error?S.message:"Save failed"),!1}finally{P(!1)}},[u,N,d,i,o,g,L,f,a,x,n,w]),E=y.useCallback(async R=>{if(O(),v)return!1;const m=await $(R);return m&&k(),m},[O,v,$,k]);return y.useEffect(()=>{e||(l("idle"),O())},[e,O]),y.useEffect(()=>{if(jc({autoSaveEnabled:e,isDirty:o,canWrite:!!(n&&w),isSaving:v,fileLoading:i,selectedFilePath:n,loadedFilePath:a,isNonEditableBinary:g}))return T.current=setTimeout(()=>{T.current=null,$().then(R=>{R&&k()})},Nc),O},[e,O,u,i,o,g,v,a,$,n,k,w]),y.useEffect(()=>{l("idle"),P(!1),G(null)},[n]),y.useEffect(()=>()=>{O(),_.current&&clearTimeout(_.current)},[O]),{autoSaveStatus:I,cancelPendingAutosave:O,isSaving:v,saveConflict:V,clearSaveConflict:()=>G(null),saveDraft:$,saveNow:E}}function Fc(e,n){return typeof e.revision=="string"&&typeof n.revision=="string"&&e.revision!==n.revision?!0:n.mtimeMs!==void 0&&e.mtimeMs!==void 0&&n.mtimeMs!==e.mtimeMs||n.size!==e.size}function Ec({selectedPath:e,loadedPath:n,isDirty:a,readStat:i,onExternalChange:o,pollIntervalMs:u=2e3}){const d=y.useRef(null),f=y.useRef(a);f.current=a;const g=y.useCallback(w=>{d.current=w},[]);return y.useEffect(()=>{if(!e||n!==e)return;let w=!1;const N=window.setInterval(()=>{if(document.hidden)return;const x=d.current,b=x&&x.path===e&&typeof x.revision=="string"?x.revision:null;i(e,{knownRevision:b}).then(j=>{if(w||!j)return;const C=d.current;if(!C||C.path!==e){d.current=j;return}!Fc(C,j)||f.current||(d.current=j,o())}).catch(()=>{})},u);return()=>{w=!0,window.clearInterval(N)}},[n,o,u,i,e]),{recordStat:g}}const fa="pichamber:files:md-viewer-mode",ma="pichamber:files:html-viewer-mode",pa="pichamber:files:json-viewer-mode",zc=1500,Mc=1500;function zn(e,n,a){try{const i=localStorage.getItem(e);if(i&&n.includes(i))return i}catch{}return a}function Mn(e,n){try{localStorage.setItem(e,n)}catch{}}function Dc({root:e,selectedPath:n,fileContent:a,draftContent:i,setDraftContent:o,autoSaveEnabled:u,writeFile:d,expectedRevision:f,captureSaveScope:g,currentSaveScope:w,onSaved:N,onConflict:x}){const[b,j]=y.useState("edit"),[C,v]=y.useState("edit"),[P,I]=y.useState("text"),[l,V]=y.useState("edit"),[G,T]=y.useState("edit"),[_,H]=y.useState(0),[K,X]=y.useState(!1),L=y.useRef({}),O=y.useRef({}),k=y.useRef({}),$=y.useRef({}),E=y.useRef(""),R=y.useRef(""),m=y.useRef(null),S=y.useRef(null),A=y.useRef(null),z=y.useRef(f);z.current=f;const U=y.useRef(g);U.current=g;const Q=y.useRef(w);Q.current=w;const ae=y.useRef(N);ae.current=N;const oe=y.useRef(x);oe.current=x;const W=y.useCallback(()=>{m.current&&(clearTimeout(m.current),m.current=null),A.current!==null&&(cancelAnimationFrame(A.current),A.current=null)},[]),te=y.useCallback(B=>{E.current=B,R.current=B},[]),je=y.useCallback(()=>te(""),[te]);y.useEffect(()=>{n&&(j(L.current[n]??"edit"),v(O.current[n]??zn(fa,["preview","edit"],"edit")),V(k.current[n]??zn(ma,["preview","edit"],"edit")),T($.current[n]??"edit"),I(zn(pa,["tree","text"],"text")))},[n]);const ze=y.useCallback(B=>{n&&(L.current[n]=B),j(B)},[n]),ue=y.useCallback(B=>{n&&(O.current[n]=B),v(B),Mn(fa,B)},[n]),Ze=y.useCallback(B=>{n&&(k.current[n]=B),V(B),Mn(ma,B)},[n]),_e=y.useCallback(B=>{I(B),Mn(pa,B)},[]),Le=y.useCallback(B=>{if(n&&($.current[n]=B),W(),B==="edit"){o(E.current||a),T(B);return}E.current=i;const ce=n;T("edit"),A.current=requestAnimationFrame(()=>{A.current=requestAnimationFrame(()=>{A.current=null,!(e&&ce&&Ee.getState().byRoot[e]?.selectedPath!==ce)&&(H(Y=>Y+1),T("preview"))})})},[W,i,a,e,n,o]),xe=y.useCallback(B=>B?$a(B,Q.current?.()??null):!0,[]),de=y.useCallback(async(B,ce,Y)=>{if(!d||ce===R.current)return!1;const ee=U.current?.()??null;if(ee&&ee.path!==B)return!1;try{const fe=await d(B,ce,Va(z.current,Y?.overwrite));return fe?.success?xe(ee)?(te(ce),o(ce),ae.current?.(B,ce,fe?.revision,ee),!0):!1:(he.error("Failed to write file"),!1)}catch(fe){return ja(fe)?(xe(ee)&&oe.current?.({path:B,currentRevision:fe.currentRevision??null,exists:fe.exists,xml:ce}),!1):(he.error(fe instanceof Error?fe.message:"Save failed"),!1)}},[xe,te,o,d]),ne=y.useCallback(()=>{X(!0),S.current&&clearTimeout(S.current),S.current=setTimeout(()=>X(!1),Mc)},[]),ge=y.useCallback(async(B,ce,Y)=>{m.current&&(clearTimeout(m.current),m.current=null);const ee=await de(B,ce,Y);return ee&&ne(),ee},[de,ne]),ot=y.useCallback(B=>{E.current=B,!(!u||!n||G!=="preview"||!d)&&(m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{m.current=null,de(n,B).then(ce=>{ce&&ne()})},zc))},[u,G,de,n,ne,d]);y.useEffect(()=>W,[W,G,n]),y.useEffect(()=>()=>{S.current&&clearTimeout(S.current)},[]);const Ke=tn(n??"")&&(E.current||i)||a;return{clearDiagramContent:je,diagramEditorXml:Ke,diagramSaved:K,drawioRemountNonce:_,drawioViewMode:G,handleDiagramChange:ot,htmlViewMode:l,jsonViewMode:P,mdViewMode:C,recordDiagramContent:te,saveDiagramNow:ge,saveDiagramXml:de,saveDrawioViewMode:Le,saveHtmlViewMode:Ze,saveJsonViewMode:_e,saveMdViewMode:ue,saveTextViewMode:ze,setTextViewMode:j,textViewMode:b}}function Tc(e,n){return e==="mobile"?!0:n==="full"}function Ac(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(let a=0;a<e.length;a+=1){const i=e[a],o=n[a];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 Oc({files:e,root:n,activeDirectory:a,expandedPaths:i,chrome:o,showGitignored:u,removeExpandedPathsByPrefix:d,enabled:f=!0,visible:g=!0}){const[w,N]=s.useState({}),[x,b]=s.useState({}),j=s.useRef(new Set),C=s.useRef(new Set),v=s.useRef(new Map),P=s.useRef(new Map),I=s.useRef(0),l=s.useRef(!1),[V,G]=s.useState(()=>Go());s.useEffect(()=>Uo(R=>{G(R.runtimeKey)}),[]),s.useEffect(()=>(l.current=!1,()=>{l.current=!0,P.current=new Map,C.current=new Set,v.current=new Map}),[]);const T=s.useCallback((R,m)=>{const S=[];for(const A of m){if(!A?.name||o==="desktop"&&!u&&Ci(A.name))continue;const z=se(A.path||""),U=z?Ni(z)?z:se(`${R}/${z}`):se(`${R}/${A.name}`),Q=A.isDirectory?"directory":"file";S.push({name:A.name,path:U,type:Q,extension:Q==="file"&&A.name.includes(".")?A.name.split(".").pop()?.toLowerCase():void 0,size:A.size})}return Si(S)},[o,u]),_=`${V}|${n}|g${u?"1":"0"}|${o}`,H=s.useRef(_);H.current=_;const K=s.useCallback(async R=>{if(!f)return;const m=se(R.trim());if(!m||j.current.has(m))return;const S=v.current.get(m);if(S){await S;return}const A=H.current,z=I.current+1;I.current=z,P.current=new Map(P.current).set(m,z),C.current=new Set(C.current).add(m);const U=()=>!l.current&&H.current===A&&P.current.get(m)===z,Q=(async()=>{try{const ae=e.listDirectory?(await e.listDirectory(m)).entries.map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory,size:W.size})):(await Jo(m)).map(W=>({name:W.name,path:W.path,isDirectory:W.isDirectory}));if(!U())return;j.current=new Set(j.current).add(m),b(W=>{if(!W[m])return W;const te={...W};return delete te[m],te});const oe=T(m,ae);N(W=>{const te=W[m];return te&&Ac(te,oe)?W:{...W,[m]:oe}})}catch(ae){if(!U())return;const oe=ae instanceof Error?ae.message:String(ae??"");oe==="Directory not found"&&n&&m!==n?(d(n,m),b(W=>{if(!W[m])return W;const te={...W};return delete te[m],te})):(console.error("Failed to load files directory:",ae),b(W=>({...W,[m]:oe})))}finally{P.current.get(m)===z&&(P.current=new Map(P.current),P.current.delete(m))}})();v.current.set(m,Q);try{await Q}finally{v.current.get(m)===Q&&(v.current.delete(m),C.current=new Set(C.current),C.current.delete(m))}},[f,e,T,d,n]),X=s.useCallback(()=>{j.current=new Set,C.current=new Set,v.current=new Map,P.current=new Map,b({}),N(R=>Object.keys(R).length===0?R:{})},[]),L=s.useCallback(async()=>{!f||!n||(X(),await K(n))},[f,K,X,n]),O=s.useCallback(async R=>{if(!f)return;if(!R){await L();return}const m=se(R);j.current=new Set(j.current),j.current.delete(m),C.current=new Set(C.current),C.current.delete(m),v.current.delete(m),P.current=new Map(P.current),P.current.delete(m),await K(m)},[f,K,L]),k=s.useRef("");s.useEffect(()=>{k.current!==_&&(k.current=_,X())},[X,_]),s.useEffect(()=>{!f||!g||!n||j.current.has(se(n))||K(n)},[f,K,n,_,g]),s.useEffect(()=>{!f||!g||!a||K(a)},[a,f,K,g]),s.useEffect(()=>{if(!f||!g||!e.listDirectory)return;const R=z=>{const U=se(z);return v.current.has(U)||C.current.has(U)},m=()=>{if(!(typeof document<"u"&&document.hidden))for(const z of i)R(z)||O(z)},S=()=>{typeof document<"u"&&document.hidden||m()};typeof document<"u"&&document.addEventListener("visibilitychange",S);const A=i.length>0?window.setInterval(m,8e3):null;return()=>{typeof document<"u"&&document.removeEventListener("visibilitychange",S),A!==null&&window.clearInterval(A)}},[f,i,e.listDirectory,O,g]);const $=s.useRef(f&&g);s.useEffect(()=>{const R=f&&g,m=$.current;if($.current=R,!(!R||m)){if(!e.listDirectory){n&&!j.current.has(se(n))&&K(n);return}if(i.length===0){n&&!j.current.has(se(n))&&K(n);return}for(const S of i){const A=se(S);v.current.has(A)||C.current.has(A)||O(S)}}},[f,i,e.listDirectory,K,O,n,g]);const E=s.useCallback(R=>j.current.has(se(R)),[]);return{childrenByDir:w,loadErrorsByDir:x,isLoaded:E,loadDirectory:K,refreshDirectory:O,refreshRoot:L}}const Lc=({showEditorTabsRow:e,isMobile:n,showMobilePageContent:a,onBackMobile:i,selectedFile:o,openFiles:u,root:d,alwaysShowActions:f,editorTabsOverflow:g,editorTabsScrollRef:w,onSelectFile:N,onCloseFile:x})=>e?t.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[n&&a&&t.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:t.jsx(F,{name:"arrow-left-s",className:"size-5"})}),n?o?t.jsxs(Bn,{children:[t.jsx($n,{asChild:!0,children:t.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:[t.jsx(bt,{filePath:o.path,extension:o.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Qr,{name:o.name}),t.jsx(F,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),t.jsx(Vn,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:u.map(b=>{const j=o?.path===b.path;return t.jsxs(en,{onSelect:C=>{if(C.target.closest("[data-close-open-file]")){C.preventDefault();return}j||N(b)},className:J("flex min-w-0 items-center justify-between gap-2 overflow-hidden",j&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[t.jsx(bt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx(Qr,{name:b.name})]}),t.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:C=>{C.preventDefault(),C.stopPropagation()},onClick:C=>{C.preventDefault(),C.stopPropagation(),x(b.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 ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"}):u.length>0?t.jsxs("div",{className:"relative min-w-0 flex-1",children:[g.left&&t.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"}),g.right&&t.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"}),t.jsx("div",{ref:w,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(b=>{const j=o?.path===b.path;return t.jsxs("div",{title:Rt(d,b.path),className:J("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",j?"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:[t.jsx(bt,{filePath:b.path,extension:b.extension,className:"size-3.5 flex-shrink-0"}),t.jsx("button",{type:"button",onClick:()=>{j||N(b)},className:"max-w-[12rem] truncate text-left",children:b.name}),t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),x(b.path)},className:J("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!j&&!f&&"opacity-0 group-hover:opacity-100"),"aria-label":`Close ${b.name}`,children:t.jsx(F,{name:"close",className:"size-3.5"})})]},b.path)})})]}):t.jsx("div",{className:"typography-ui-label font-medium truncate",children:"Select a file"})]}):null,Pc=(e,n)=>{if(!n)return null;const a=Number.parseInt(e.trim(),10);return!Number.isFinite(a)||a<1?null:Math.min(a,n.state.doc.lines)},ha=(e,n)=>{const a=e.state.doc.lineAt(n.main.head);return{lineNumber:a.number,character:n.main.head-a.from+1,selection:n}},ga=(e,n,a)=>{const i=e.state.doc.line(n),o=Math.max(1,Math.min(a,i.length+1)),u=i.from+o-1;e.dispatch({selection:Vo.cursor(u),effects:pe.scrollIntoView(u,{y:"center"})})};function Ic({open:e,onOpenChange:n,view:a,variant:i="overlay"}){const[o,u]=s.useState(""),d=s.useRef(null),f=s.useRef(!1),g=s.useRef(null),w=s.useRef(null),N=s.useMemo(()=>Pc(o,a),[o,a]);s.useEffect(()=>{!e||!a||(f.current=!1,d.current=ha(a,a.state.selection),u(""))},[e,a]),s.useEffect(()=>{e&&window.requestAnimationFrame(()=>{w.current?.focus(),w.current?.select()})},[e]),s.useEffect(()=>{if(!(!e||!a||!d.current)){if(N===null){const{selection:v}=d.current;a.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})});return}ga(a,N,d.current.character)}},[N,e,a]);const x=s.useCallback(()=>{if(!a||f.current||!d.current)return;const{selection:v}=d.current;a.dispatch({selection:v,effects:pe.scrollIntoView(v.main.from,{y:"center"})})},[a]),b=s.useCallback(v=>{v||x(),n(v)},[n,x]),j=s.useCallback(()=>{!a||N===null||!d.current||(f.current=!0,ga(a,N,d.current.character),n(!1),a.focus())},[N,n,a]);s.useEffect(()=>{if(!e)return;const v=I=>{const l=g.current,V=I.target;!l||!(V instanceof Node)||l.contains(V)||b(!1)},P=I=>{I.key==="Escape"&&(I.preventDefault(),b(!1))};return document.addEventListener("pointerdown",v,!0),document.addEventListener("keydown",P,!0),()=>{document.removeEventListener("pointerdown",v,!0),document.removeEventListener("keydown",P,!0)}},[b,e,i]);const C=s.useMemo(()=>a?N===null?`Current Line: ${(d.current??ha(a,a.state.selection)).lineNumber}. Type a line number between 1 and ${a.state.doc.lines} to navigate to.`:`Go to line ${N}`:"Editor unavailable.",[N,a]);return i==="inline"?e?t.jsxs("div",{ref:g,className:"ml-1 flex h-6 items-center gap-1",children:[t.jsx(zt,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line",className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),t.jsx(q,{variant:"outline",size:"xs",onClick:j,disabled:!a||N===null,className:"h-6 px-2",children:"Go"})]}):null:t.jsx("div",{ref:g,className:J("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",e?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:t.jsxs("div",{className:"min-w-0",children:[t.jsx(zt,{ref:w,type:"number",min:1,step:1,inputMode:"numeric",value:o,onChange:v=>u(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),j())},placeholder:"Line number",className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),t.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:C})]})})}const Dn=({currentMode:e,onToggle:n})=>{const a=e==="preview",i=a?"Switch to edit mode":"Switch to preview mode",o=a?"Edit":"Preview";return t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx(q,{variant:"ghost",size:"sm",onClick:n,"aria-label":i,className:"h-5 w-5 p-0",children:a?t.jsx(F,{name:"eye",className:"size-4","aria-hidden":"true"}):t.jsx(F,{name:"eye-off",className:"size-4","aria-hidden":"true"})})}),t.jsx(Qe,{sideOffset:8,children:o})]})},Bc=({selectedFile:e,displaySelectedPath:n,layout:a="floating",exitFullscreenOnly:i=!1,canEdit:o,isEditingFile:u,isSaving:d,autoSaveEnabled:f,autoSaveStatus:g,isDirty:w,onSaveDraft:N,onToggleAutoSave:x,canOpenInDesktopApp:b=!0,openInApps:j,openInCacheStale:C,onOpenInApp:v,onRefreshOpenInApps:P,onToolbarDropdownOpenChange:I,isSelectedImage:l,isSelectedPdf:V,isUnsupportedBinary:G,wrapLines:T,onToggleWrapLines:_,textViewMode:H,onToggleSearch:K,isGoToLineOpen:X,onOpenGoToLineChange:L,editorView:O,canUseShikiFileView:k,isJson:$,isHtml:E,onToggleTextViewMode:R,isMarkdown:m,mdViewMode:S,onToggleMdViewMode:A,isDrawio:z,drawioViewMode:U,onToggleDrawioViewMode:Q,diagramSaved:ae,onSaveDiagram:oe,jsonViewMode:W,onToggleJsonViewMode:te,canCopy:je,copiedContent:ze,onCopyContent:ue,canCopyPath:Ze,copiedPath:_e,onCopyPath:Le,onDownloadFile:xe,isMobile:de,mode:ne,isFullscreen:ge,onToggleFullscreen:ot,onExitFullscreen:Ke})=>{if(!e)return null;const ce=a==="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",Y=(ee,fe)=>t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:fe})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:ee})]});return t.jsxs("div",{className:ce,children:[o&&u&&t.jsxs(t.Fragment,{children:[d?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[t.jsx(F,{name:"loader-4",className:"size-3.5 animate-spin"}),"Saving..."]}):f&&g==="saved"&&!w?t.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[t.jsx(F,{name:"check",className:"size-3.5"}),"Saved"]}):w?Y(f?`Save now (${Nt()}+S) - auto-saves after 1.5s`:`Save now (${Nt()}+S)`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{N()},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:f?`Save now (${Nt()}+S) - auto-saves after 1.5s`:`Save now (${Nt()}+S)`,"aria-label":`Save (${Nt()}+S)`,children:t.jsx(F,{name:"save-3",className:"size-4"})})):null,Y(f?"Auto-save on":"Manual save",t.jsx(q,{variant:"ghost",size:"sm",onClick:x,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",f?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:f?"Auto-save on":"Manual save","aria-label":f?"Auto-save on":"Manual save",children:f?t.jsx(F,{name:"file-check-fill",className:"size-4"}):t.jsx(F,{name:"file-check",className:"size-4"})}))]}),b?t.jsxs(Bn,{onOpenChange:I,children:[t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex",children:t.jsx($n,{asChild:!0,children:t.jsx(q,{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:t.jsx(F,{name:"file-transfer",className:"size-4"})})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Open in desktop app"})]}),t.jsxs(Vn,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[j.map(ee=>t.jsxs(en,{className:"flex items-center gap-2",onClick:()=>{v(ee)},children:[t.jsx(sc,{label:ee.label,iconDataUrl:ee.iconDataUrl}),t.jsx("span",{className:"typography-ui-label text-foreground",children:ee.label})]},ee.id)),C?t.jsxs(en,{className:"flex items-center gap-2",onClick:()=>{P()},children:[t.jsx(F,{name:"refresh",className:"size-4"}),t.jsx("span",{className:"typography-ui-label text-foreground",children:"Refresh Apps"})]}):null]})]}):null,!l&&!V&&!G&&t.jsxs(t.Fragment,{children:[Y(T?"Disable line wrap":"Enable line wrap",t.jsx(q,{variant:"ghost",size:"sm",onClick:_,className:J("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",T?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:T?"Disable line wrap":"Enable line wrap",children:t.jsx(F,{name:"text-wrap",className:"size-4"})})),H==="edit"&&t.jsxs(t.Fragment,{children:[Y("Find in file",t.jsx(q,{variant:"ghost",size:"sm",onClick:ee=>{K(),ee.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:t.jsx(F,{name:"search",className:"size-4"})})),Y("Go to line",t.jsx(q,{variant:"ghost",size:"sm",onClick:ee=>{L(!X),ee.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:t.jsx(F,{name:"menu-fold-2",className:"size-4"})})),t.jsx(Ic,{open:X,onOpenChange:L,view:O,variant:"inline"})]})]}),k&&o&&!$&&!E&&t.jsx(Dn,{currentMode:H==="view"?"preview":"edit",onToggle:R}),m&&Y(S==="preview"?"Switch to edit mode":"Switch to preview mode",t.jsx(q,{variant:"ghost",size:"sm",onClick:A,className:J("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",S==="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:S==="preview"?"Switch to edit mode":"Switch to preview mode","aria-label":S==="preview"?"Switch to edit mode":"Switch to preview mode",children:t.jsx(F,{name:S==="preview"?"eye":"eye-off",className:"size-4"})})),Wn(e?.path??"")&&t.jsx(Dn,{currentMode:E?"preview":"edit",onToggle:R}),z&&t.jsxs(t.Fragment,{children:[t.jsx(Dn,{currentMode:U,onToggle:Q}),U==="preview"&&t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{oe()},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save diagram",children:ae?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"save-3",className:"size-4"})})]}),$&&Y(W==="tree"?"Switch to Text View":"Switch to Tree View",t.jsx(q,{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"?t.jsx(F,{name:"code-sslash",className:"size-4"}):t.jsx(F,{name:"node-tree",className:"size-4"})})),je&&Y("Copy file contents",t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{ue()},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:ze?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"clipboard",className:"size-4"})})),Ze&&Y(`Copy file path (${n})`,t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{Le()},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:_e?t.jsx(F,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):t.jsx(F,{name:"file-copy-2",className:"size-4"})})),xe&&Y("Save file",t.jsx(q,{variant:"ghost",size:"sm",onClick:xe,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Save file","aria-label":"Save file",children:t.jsx(F,{name:"download",className:"size-4"})})),i?Y("Exit fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:Ke,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:"Exit fullscreen","aria-label":"Exit fullscreen",children:t.jsx(F,{name:"fullscreen-exit",className:"size-4"})})):!de&&ne==="full"&&Y(ge?"Exit fullscreen":"Fullscreen",t.jsx(q,{variant:"ghost",size:"sm",onClick:ot,className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:ge?"Exit fullscreen":"Fullscreen","aria-label":ge?"Exit fullscreen":"Fullscreen",children:ge?t.jsx(F,{name:"fullscreen-exit",className:"size-4"}):t.jsx(F,{name:"fullscreen",className:"size-4"})}))]})},$c=({open:e,onOpenChange:n,isSaving:a,onSaveAndContinue:i,onDiscardAndContinue:o})=>t.jsx(Ca,{open:e,onOpenChange:n,children:t.jsxs(Na,{showCloseButton:!1,className:"max-w-md",children:[t.jsxs(Sa,{children:[t.jsx(Ra,{children:"Unsaved changes"}),t.jsx(Fa,{children:"Save your edits before continuing?"})]}),t.jsxs(Ea,{children:[t.jsx(q,{variant:"outline",onClick:i,disabled:a,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"}),t.jsx(q,{variant:"destructive",onClick:o,children:"Discard"})]})]})}),xa=(e,n)=>e.startsWith(`${n}/`)?e.slice(n.length+1):e,Vc=e=>e.index==="A"||e.working_dir==="?"?"git-added":e.index==="D"?"git-deleted":e.index==="M"||e.working_dir==="M"?"git-modified":null,Wc=({root:e,openPaths:n,gitFiles:a})=>{const i=new Set(n),o=new Map,u=new Map,d={modified:0,added:0};for(const w of a??[]){o.has(w.path)||o.set(w.path,w);const N=+(w.index==="M"||w.working_dir==="M"),x=+(w.index==="A"||w.working_dir==="?");if(N===0&&x===0)continue;d.modified+=N,d.added+=x;const b=w.path.split("/");for(let j=1;j<b.length;j+=1){const C=b.slice(0,j).join("/");if(!C)continue;let v=u.get(C);v||(v={modified:0,added:0},u.set(C,v)),v.modified+=N,v.added+=x}}return{getFileStatus:w=>{if(i.has(w))return"open";if(o.size===0)return null;const N=xa(w,e),x=o.get(N);return x?Vc(x):null},getFolderBadge:w=>{if(!a)return null;const N=xa(w,e);if(!N)return d.modified+d.added>0?{...d}:null;const x=u.get(N);return x?{...x}:null}}},_c=e=>new Set(e),Kc=({root:e,isMobile:n,searchQuery:a,onSearchQueryChange:i,searchInputRef:o,searching:u,searchResults:d,selectedFile:f,onSelectFile:g,onOpenDialog:w,currentDirectory:N,refreshRoot:x,childrenByDir:b,loadErrorsByDir:j,expandedPaths:C,isBrowserClient:v,alwaysShowActions:P,getFileStatus:I,getFolderBadge:l,fileRowPermissions:V,downloadFile:G,contextMenuPath:T,setContextMenuPath:_,rightClickMenuPath:H,setRightClickMenuPath:K,toggleDirectory:X,handleRevealPath:L,refreshDirectory:O})=>{const k=!!(e&&b[e]),$=e?j[e]:null,E=s.useMemo(()=>_c(C),[C]);function R(m,S){const A=b[m]??[];return A.map((z,U)=>{const Q=z.type==="directory",ae=Q&&E.has(z.path),oe=f?.path===z.path,W=U===A.length-1;return t.jsxs("li",{className:"relative",children:[S>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),W&&t.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),t.jsx(ic,{node:z,root:e,isExpanded:ae,isActive:oe,isMobile:n,isBrowserClient:v,alwaysShowActions:P,status:Q?void 0:I(z.path),badge:Q?l(z.path):void 0,permissions:V,downloadFile:G,contextMenuPath:T,setContextMenuPath:_,rightClickMenuPath:H,setRightClickMenuPath:K,onSelect:g,onToggle:X,onRevealPath:L,onOpenDialog:w}),Q&&ae&&t.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[j[z.path]?t.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:j[z.path],children:j[z.path]}),t.jsxs(q,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{O(z.path)},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):null,R(z.path,S+1)]})]},z.path)})}return t.jsxs("section",{className:J("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:[t.jsx("div",{className:J("flex flex-col gap-2 py-2",n?"px-3":"px-2"),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs("div",{className:"relative flex-1 min-w-0",children:[t.jsx(F,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),t.jsx(zt,{ref:o,value:a,onChange:m=>i(m.target.value),placeholder:"Search files...",className:"h-8 pl-8 pr-8 typography-meta"}),a.trim().length>0&&t.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:t.jsx(F,{name:"close",className:"size-4"})})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFile",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New File","aria-label":"New File",children:t.jsx(F,{name:"file-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New File"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>w("createFolder",{path:N,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:"New Folder","aria-label":"New Folder",children:t.jsx(F,{name:"folder-add",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"New Folder"})]}),t.jsxs(Xe,{children:[t.jsx(Ye,{asChild:!0,children:t.jsx("span",{className:"inline-flex flex-shrink-0",children:t.jsx(q,{variant:"ghost",size:"sm",onClick:()=>{x()},className:"size-8 p-0 flex-shrink-0",title:"Refresh","aria-label":"Refresh",children:t.jsx(F,{name:"refresh",className:"size-4"})})})}),t.jsx(Qe,{side:"bottom",sideOffset:6,children:"Refresh"})]})]})}),t.jsx(za,{outerClassName:"flex-1 min-h-0",className:J("py-2",n?"px-3":"px-2"),children:t.jsx("ul",{className:"flex flex-col",children:u?t.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx(F,{name:"loader-4",className:"size-4 animate-spin"}),"Searching..."]}):d.length>0?d.map(m=>{const S=f?.path===m.path;return t.jsx("li",{children:t.jsxs("button",{type:"button",onClick:()=>{g(m)},className:J("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",S?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[t.jsx(Xa,{filePath:m.path,extension:m.extension}),t.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:m.path,children:m.relativePath??m.path})]})},m.path)}):$?t.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[t.jsx("span",{className:"text-[var(--status-error)]",children:$}),t.jsxs(q,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{x()},children:[t.jsx(F,{name:"refresh",className:"size-3.5"}),"Refresh"]})]}):k?R(e,0):t.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:"Loading..."})})})]})},ou=({mode:e="full",chrome:n="desktop",onClose:a,isVisible:i=!0})=>{const{files:o,runtime:u}=si(),d=n==="mobile",{currentTheme:f,availableThemes:g,lightThemeId:w,darkThemeId:N}=oi(),{isMobile:x,isTablet:b,screenWidth:j}=ii(),C=Xo(u.platform),v=x||b,P=Yo(),I=ci()??"",l=se(I.trim()),V=Tc(n,e),G=e!=="editor-only",T=e==="editor-only"&&!x,_=li(I),[H,K]=s.useState(""),X=s.useRef(null),[L,O]=s.useState(!1),[k,$]=s.useState(l),[E,R]=s.useState(!1),[m,S]=s.useState(null),A=ke(r=>r.wrapLinesByDefault),z=m??A,U=s.useCallback(r=>{S(r)},[]),[Q,ae]=s.useState(!1),[oe,W]=s.useState(!1),[te,je]=s.useState(!1),ze=s.useRef(null);s.useEffect(()=>{d&&($(l),K(""),O(!1))},[d,l]);const ue=s.useRef(0),Ze=s.useCallback(r=>{ue.current=Math.max(0,ue.current+(r?1:-1))},[]),_e=s.useCallback(r=>r instanceof Element?r.closest('[data-slot="dropdown-menu-content"], [data-slot="dropdown-menu-item"]')!==null:!1,[]);s.useEffect(()=>{if(!te)return;const r=h=>{ue.current>0||_e(h.target)||ze.current&&!ze.current.contains(h.target)&&je(!1)};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[_e,te]);const Le=s.useMemo(()=>g.find(r=>r.metadata.id===w)??Ar(!1),[g,w]),xe=s.useMemo(()=>g.find(r=>r.metadata.id===N)??Ar(!0),[g,N]);s.useEffect(()=>{Vr(Le),Vr(xe)},[Le,xe]);const de=s.useMemo(()=>[],[]),ne=Ee(r=>l?r.byRoot[l]?.openPaths??de:de),ge=Ee(r=>l?r.byRoot[l]?.selectedPath??null:null),ot=Ee(r=>l?r.byRoot[l]?.expandedPaths??de:de),Ke=Ee(r=>r.removeOpenPath),B=Ee(r=>r.removeOpenPathsByPrefix),ce=Ee(r=>r.removeExpandedPathsByPrefix),Y=Ee(r=>r.setSelectedPath),ee=Ee(r=>r.toggleExpandedPath),fe=Ee(r=>r.expandPaths),{childrenByDir:_n,loadErrorsByDir:Kn,isLoaded:it,loadDirectory:ct,refreshDirectory:Mt,refreshRoot:Ya}=Oc({files:o,root:l,activeDirectory:d?k:void 0,expandedPaths:ot,chrome:n,showGitignored:P,removeExpandedPathsByPrefix:ce,enabled:V,visible:i}),qe=s.useCallback(r=>{const h=se(r),M=h.split("/"),D=M[M.length-1]||h,re=D.includes(".")?D.split(".").pop()?.toLowerCase():void 0;return{name:D,path:h,type:"file",extension:re}},[]),Dt=s.useMemo(()=>ne.map(qe),[ne,qe]),an=s.useMemo(()=>{if(ge){const r=Qt(ge);if(ne.some(h=>Qt(h)===r))return ge}return ne[0]??null},[ne,ge]),p=s.useMemo(()=>an?qe(an):null,[an,qe]),Be=p?.path??"";s.useEffect(()=>{if(!l||!ge)return;const r=Qt(ge);ne.some(M=>Qt(M)===r)||Y(l,ne[0]??null)},[ne,l,ge,Y]);const Tt=!!(l&&Be&&!Sn(Be,l)),qn=Tt?Ir(Be):void 0,le=s.useMemo(()=>({allowOutsideWorkspace:e==="editor-only"&&Tt,outsideFileGrant:qn,directory:l||void 0}),[e,Tt,qn,l]),sn=s.useRef(null),[Qa,Za]=s.useState({left:!1,right:!1}),Hn=s.useCallback(()=>{const r=sn.current;r&&Za({left:r.scrollLeft>2,right:r.scrollLeft+r.clientWidth<r.scrollWidth-2})},[]),Gn=s.useRef(Hn);Gn.current=Hn,s.useEffect(()=>{const r=sn.current;if(!r)return;const h=()=>Gn.current();h(),r.addEventListener("scroll",h,{passive:!0});const M=new ResizeObserver(h);return M.observe(r),()=>{r.removeEventListener("scroll",h),M.disconnect()}},[Dt.length]);const[Ce,Pe]=s.useState(""),[on,lt]=s.useState(!1),[Un,ve]=s.useState(null),[es,He]=s.useState(""),be=s.useRef(""),[et,Ne]=s.useState(null),[ut,Se]=s.useState(void 0),[Jn,Re]=s.useState(null),we=Ee(r=>r.activeRuntimeKey),[me,Ie]=s.useState(null),[cn,Xn]=s.useState(!1),[ts,Me]=s.useState(!1),[dt,Fe]=s.useState(""),[ns,rs]=s.useState(`
4
4
  `),Yn=s.useRef(null),De=s.useRef(0),ft=s.useRef(null),[Qn,ln]=s.useState(!1),At=ke(r=>r.autoSaveEnabled),as=ke(r=>r.setAutoSaveEnabled),ss=s.useRef(null),[os,is]=s.useState(null),[cs,ls]=s.useState(null),{value:us,show:ds}=Br(!1,1200),{value:fs,show:ms}=Br(!1,1200),[ps,hs]=s.useState(!1),wt=s.useCallback(()=>{l&&Y(l,null),Pe(""),ve(null),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),x&&O(!1)},[x,l,Y]),{operation:gs,target:xs,inputValue:vs,setInputValue:bs,submitting:ws,inputRef:ys,open:ks,close:js,submit:Cs,capabilities:{canCreateFile:Zn,canCreateFolder:er,canRename:tr,canDelete:nr}}=Ri({files:o,root:l,selectedPath:p?.path??"",refreshDirectory:Mt,removeOpenPathsByPrefix:B,clearSelectedPath:wt}),rr=!!o.revealPath,un=ya()&&ka(),Ns=Yt(r=>r.availableApps),Ss=Yt(r=>r.isCacheStale),ar=Yt(r=>r.initialize),Rs=Yt(r=>r.loadInstalledApps);s.useEffect(()=>{un&&ar()},[un,ar]);const Fs=s.useCallback(r=>{o.revealPath&&o.revealPath(r).catch(()=>{he.error("Failed to reveal path")})},[o]),Es=s.useCallback(async r=>{if(!p?.path||await Qo(p.path,r.id,r.appName)||await Or(p.path,r.appName))return;const D=Fi(p.path)||l;D&&await Or(D,r.appName)||he.error(`Failed to open in ${r.appName}`)},[l,p?.path]),zs=ke(r=>r.fileEditorKeymap),sr=ke(r=>r.expandedEditorToolbar);s.useEffect(()=>{Fe("")},[p?.path]);const or=s.useRef("");s.useEffect(()=>{!l||or.current===l||(or.current=l,Pe(""),ve(null),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),O(!1))},[l]);const ir=s.useRef(we);s.useEffect(()=>{ir.current!==we&&(ir.current=we,De.current+=1,ft.current=null,Pe(""),Fe(""),ve(null),lt(!1),He(""),Ne(null),Se(void 0),Re(null),Ie(null),Me(!1),ln(!1))},[we]);const Ms=d?k:I,{results:cr,searching:lr}=Ei({directory:Ms,query:H,chrome:n,showGitignored:P}),Ot=s.useCallback(async(r,h)=>{if(o.readFile){const Oe=await o.readFile(r,{...h??{},directory:l||void 0});return{content:Oe.content??"",revision:Oe.revision,exists:Oe.exists}}const M=new URLSearchParams({path:r});h?.allowOutsideWorkspace&&M.set("allowOutsideWorkspace","true"),h?.outsideFileGrant&&M.set("outsideFileGrant",h.outsideFileGrant),h?.optional&&M.set("optional","true"),l&&M.set("directory",l);const D=await Lr(`/api/fs/read?${M.toString()}`,{cache:h?.optional?"no-store":"default"});if(!D.ok){const Oe=await D.json().catch(()=>({error:D.statusText}));throw new Error(Oe.error||"Failed to read file")}const re=await D.text(),Z=D.headers?.get?.("x-pichamber-file-revision"),Ae=D.headers?.get?.("x-pichamber-file-exists")!=="false";return{content:re,revision:typeof Z=="string"&&Z.length>0?Z:Ae?void 0:null,exists:Ae}},[o,l]),mt=s.useCallback(async(r,h)=>{if(o.statFile){const M=await o.statFile(r,{...h??{},directory:l||void 0});return{path:M.path,size:M.size,mtimeMs:M.mtimeMs,revision:M.revision}}return null},[o,l]);s.useEffect(()=>{if(!l||!o.statFile||ne.length===0)return;let r=!1;const h=[...ne];return Promise.all(h.map(async M=>{try{const D=await o.statFile?.(M,{directory:l||void 0});!r&&D&&!D.isFile&&B(l,M)}catch(D){!r&&_r(D)&&B(l,M)}})),()=>{r=!0}},[o,ne,B,l]);const dn=s.useMemo(()=>Ce.length>Ft?`${Ce.slice(0,Ft)}
@@ -1,4 +1,4 @@
1
- import{k as n}from"./vendor-boot-EC6IyLt1.js";import{R as h}from"./vendor-react-DASdDPIk.js";import{o as z,I as f,bc as q,cU as O,ao as I,t as S,ae as B,B as x}from"./useAppFontEffects-BQ1JUauS.js";import{p as T}from"./vendor-dompurify-r8glNMJW.js";import{e as m}from"./index-DWSrsQWl.js";const ve=(e,t)=>!e||!t?!1:e.toLowerCase()===t.toLowerCase(),v=e=>!e||e.permissionFallback?!1:e.capabilities?.canPush!==!0,j=e=>!e||e.permissionFallback||e.isAuthor?!1:e.capabilities?.canPush!==!0,D=e=>!e||e.permissionFallback?{allowed:!0,reason:null}:e.capabilities?.canComment!==!0?{allowed:!1,reason:"You need read access to comment"}:{allowed:!0,reason:null},F=(e,t)=>e.trim()?e.trim().length>t?`Title is too long (max ${t} characters)`:null:"Enter a title",Ne=[{id:"open",label:"Open"},{id:"closed",label:"Closed"},{id:"merged",label:"Merged"},{id:"all",label:"All"}],ke=[{id:"all",label:"All"},{id:"mine",label:"Created by me"},{id:"review",label:"Review requested"},{id:"assigned",label:"Assigned"}],je=[{id:"updated",label:"Recently updated"},{id:"newest",label:"Newest"},{id:"oldest",label:"Oldest"}],U=e=>{const t=(e.conclusion??e.state??e.status??"").toLowerCase();return t.includes("fail")||t.includes("error")||t.includes("cancel")||t==="timed_out"||t==="action_required"},W=e=>{const t={failed:{runs:0,statuses:0},pending:{runs:0,statuses:0},passed:{runs:0,statuses:0},other:{runs:0,statuses:0}};if(!e)return t;for(const r of e.runs??[]){const s=(r.conclusion??r.state??r.status??"").toLowerCase();U(r)?t.failed.runs+=1:s.includes("success")||s==="neutral"||s==="skipped"?t.passed.runs+=1:t.pending.runs+=1}for(const r of e.statuses??[]){const s=(r.state??"").toLowerCase();s==="failure"||s==="error"?t.failed.statuses+=1:s==="success"?t.passed.statuses+=1:s==="pending"?t.pending.statuses+=1:t.other.statuses+=1}return t},Ce=[{id:"merge",label:"Merge commit",description:"Add all commits with a merge commit"},{id:"squash",label:"Squash and merge",description:"Combine commits into one commit"},{id:"rebase",label:"Rebase and merge",description:"Replay commits onto the base branch"}],$e=e=>!e||e.state!=="open"?null:e.mergeableState==="behind"?{tone:"warning",icon:"error-warning",title:"This branch is out of date with",detail:"Merge the latest changes from the base branch into this branch.",canUpdate:!0}:e.mergeableState==="dirty"?{tone:"error",icon:"alert",title:"This branch has conflicts with",detail:"Resolve conflicts locally or on GitHub before merging.",canUpdate:!1}:null,Ae=(e,t,r)=>{const s=r?`“${r}”`:"this branch",a=t?`“${t}”`:"the base branch";switch(e){case"merge":return{title:"Merge this pull request?",detail:`Every commit from ${s} will be added to ${a} with a merge commit.`,confirm:"Merge pull request",progress:"Merging…"};case"squash":return{title:"Squash and merge?",detail:`The commits from ${s} will be combined into one commit on ${a}.`,confirm:"Squash and merge",progress:"Merging…"};case"rebase":return{title:"Rebase and merge?",detail:`The commits from ${s} will be replayed onto ${a} without a merge commit.`,confirm:"Rebase and merge",progress:"Merging…"};case"draft":return{title:"Convert to draft?",detail:"Reviewers will see that this pull request is not ready to merge.",confirm:"Convert to draft",progress:"Converting…"};case"ready":return{title:"Mark as ready for review?",detail:"Reviewers will be asked to review this pull request.",confirm:"Ready for review",progress:"Updating…"};case"close":return{title:"Close this pull request?",detail:"The pull request will close without merging. You can reopen it later.",confirm:"Close pull request",progress:"Closing…"};case"reopen":return{title:"Reopen this pull request?",detail:"The pull request will return to its previous open state.",confirm:"Reopen pull request",progress:"Reopening…"};case"update-branch":return{title:"Update this branch?",detail:`This brings ${s} up to date with ${a}. History may be rewritten.`,confirm:"Update branch",progress:"Updating…"};default:return{title:"Continue?",detail:"This action cannot be undone from here.",confirm:"Confirm",progress:"Working…"}}},Se=e=>{if(!e)return null;const t=W(e),r=t.failed.runs+t.failed.statuses,s=t.pending.runs+t.pending.statuses,a=t.passed.runs+t.passed.statuses,i=e.runs.length+e.statuses.length;return{text:`${r} failing · ${s} pending · ${a} passed`,failed:r,pending:s,passed:a,total:i}},Te=(e,t,r)=>{if(!t)return{allowed:!1,reason:"Pull request is still loading"};const s=t.state==="merged",a=t.state==="open";switch(e){case"merge":case"squash":case"rebase":return a?t.draft?{allowed:!1,reason:"Marked as draft"}:t.mergeable===!1||t.mergeableState==="dirty"?{allowed:!1,reason:"Has merge conflicts"}:t.mergeableState==="blocked"?{allowed:!1,reason:"Blocked by required checks"}:v(r)?{allowed:!1,reason:"You need write access to merge"}:{allowed:!0,reason:null}:{allowed:!1,reason:s?"Already merged":"Pull request is closed"};case"ready":return a?t.draft?v(r)?{allowed:!1,reason:"You need write access to mark ready"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Already ready for review"}:{allowed:!1,reason:"Pull request is not open"};case"draft":return a?t.draft?{allowed:!1,reason:"Already a draft"}:v(r)?{allowed:!1,reason:"You need write access to convert to draft"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Pull request is not open"};case"close":return a?j(r)?{allowed:!1,reason:"You need write access or be the author to close"}:{allowed:!0,reason:null}:{allowed:!1,reason:s?"Already merged":"Already closed"};case"reopen":return a?{allowed:!1,reason:"Already open"}:s?{allowed:!1,reason:"Already merged"}:j(r)?{allowed:!1,reason:"You need write access or be the author to reopen"}:{allowed:!0,reason:null};case"update-branch":return a?v(r)?{allowed:!1,reason:"You need write access to update the branch"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Pull request is not open"};default:return{allowed:!0,reason:null}}},Re=e=>H(e).allowed!==!0?[]:e&&!e.permissionFallback&&e.isAuthor===!0?["comment"]:["comment","approve","request-changes"],He=e=>e.verdict==="approve"?!0:e.summary.trim().length>0||e.pendingCount>0,_e=e=>H(e),Me=e=>!e||e.permissionFallback?{allowed:!0,reason:null}:e.capabilities?.canPush!==!0?{allowed:!1,reason:"You need write access to resolve threads"}:{allowed:!0,reason:null},Y=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Ge=e=>{if(!e)return{original:"",modified:""};const t=[],r=[];let s=!1;for(const a of e.split(`
1
+ import{k as n}from"./vendor-boot-EC6IyLt1.js";import{R as h}from"./vendor-react-DASdDPIk.js";import{o as z,I as f,bc as q,cU as O,ao as I,t as S,ae as B,B as x}from"./useAppFontEffects-CqHhRKmN.js";import{p as T}from"./vendor-dompurify-r8glNMJW.js";import{e as m}from"./index-D4n3TVp2.js";const ve=(e,t)=>!e||!t?!1:e.toLowerCase()===t.toLowerCase(),v=e=>!e||e.permissionFallback?!1:e.capabilities?.canPush!==!0,j=e=>!e||e.permissionFallback||e.isAuthor?!1:e.capabilities?.canPush!==!0,D=e=>!e||e.permissionFallback?{allowed:!0,reason:null}:e.capabilities?.canComment!==!0?{allowed:!1,reason:"You need read access to comment"}:{allowed:!0,reason:null},F=(e,t)=>e.trim()?e.trim().length>t?`Title is too long (max ${t} characters)`:null:"Enter a title",Ne=[{id:"open",label:"Open"},{id:"closed",label:"Closed"},{id:"merged",label:"Merged"},{id:"all",label:"All"}],ke=[{id:"all",label:"All"},{id:"mine",label:"Created by me"},{id:"review",label:"Review requested"},{id:"assigned",label:"Assigned"}],je=[{id:"updated",label:"Recently updated"},{id:"newest",label:"Newest"},{id:"oldest",label:"Oldest"}],U=e=>{const t=(e.conclusion??e.state??e.status??"").toLowerCase();return t.includes("fail")||t.includes("error")||t.includes("cancel")||t==="timed_out"||t==="action_required"},W=e=>{const t={failed:{runs:0,statuses:0},pending:{runs:0,statuses:0},passed:{runs:0,statuses:0},other:{runs:0,statuses:0}};if(!e)return t;for(const r of e.runs??[]){const s=(r.conclusion??r.state??r.status??"").toLowerCase();U(r)?t.failed.runs+=1:s.includes("success")||s==="neutral"||s==="skipped"?t.passed.runs+=1:t.pending.runs+=1}for(const r of e.statuses??[]){const s=(r.state??"").toLowerCase();s==="failure"||s==="error"?t.failed.statuses+=1:s==="success"?t.passed.statuses+=1:s==="pending"?t.pending.statuses+=1:t.other.statuses+=1}return t},Ce=[{id:"merge",label:"Merge commit",description:"Add all commits with a merge commit"},{id:"squash",label:"Squash and merge",description:"Combine commits into one commit"},{id:"rebase",label:"Rebase and merge",description:"Replay commits onto the base branch"}],$e=e=>!e||e.state!=="open"?null:e.mergeableState==="behind"?{tone:"warning",icon:"error-warning",title:"This branch is out of date with",detail:"Merge the latest changes from the base branch into this branch.",canUpdate:!0}:e.mergeableState==="dirty"?{tone:"error",icon:"alert",title:"This branch has conflicts with",detail:"Resolve conflicts locally or on GitHub before merging.",canUpdate:!1}:null,Ae=(e,t,r)=>{const s=r?`“${r}”`:"this branch",a=t?`“${t}”`:"the base branch";switch(e){case"merge":return{title:"Merge this pull request?",detail:`Every commit from ${s} will be added to ${a} with a merge commit.`,confirm:"Merge pull request",progress:"Merging…"};case"squash":return{title:"Squash and merge?",detail:`The commits from ${s} will be combined into one commit on ${a}.`,confirm:"Squash and merge",progress:"Merging…"};case"rebase":return{title:"Rebase and merge?",detail:`The commits from ${s} will be replayed onto ${a} without a merge commit.`,confirm:"Rebase and merge",progress:"Merging…"};case"draft":return{title:"Convert to draft?",detail:"Reviewers will see that this pull request is not ready to merge.",confirm:"Convert to draft",progress:"Converting…"};case"ready":return{title:"Mark as ready for review?",detail:"Reviewers will be asked to review this pull request.",confirm:"Ready for review",progress:"Updating…"};case"close":return{title:"Close this pull request?",detail:"The pull request will close without merging. You can reopen it later.",confirm:"Close pull request",progress:"Closing…"};case"reopen":return{title:"Reopen this pull request?",detail:"The pull request will return to its previous open state.",confirm:"Reopen pull request",progress:"Reopening…"};case"update-branch":return{title:"Update this branch?",detail:`This brings ${s} up to date with ${a}. History may be rewritten.`,confirm:"Update branch",progress:"Updating…"};default:return{title:"Continue?",detail:"This action cannot be undone from here.",confirm:"Confirm",progress:"Working…"}}},Se=e=>{if(!e)return null;const t=W(e),r=t.failed.runs+t.failed.statuses,s=t.pending.runs+t.pending.statuses,a=t.passed.runs+t.passed.statuses,i=e.runs.length+e.statuses.length;return{text:`${r} failing · ${s} pending · ${a} passed`,failed:r,pending:s,passed:a,total:i}},Te=(e,t,r)=>{if(!t)return{allowed:!1,reason:"Pull request is still loading"};const s=t.state==="merged",a=t.state==="open";switch(e){case"merge":case"squash":case"rebase":return a?t.draft?{allowed:!1,reason:"Marked as draft"}:t.mergeable===!1||t.mergeableState==="dirty"?{allowed:!1,reason:"Has merge conflicts"}:t.mergeableState==="blocked"?{allowed:!1,reason:"Blocked by required checks"}:v(r)?{allowed:!1,reason:"You need write access to merge"}:{allowed:!0,reason:null}:{allowed:!1,reason:s?"Already merged":"Pull request is closed"};case"ready":return a?t.draft?v(r)?{allowed:!1,reason:"You need write access to mark ready"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Already ready for review"}:{allowed:!1,reason:"Pull request is not open"};case"draft":return a?t.draft?{allowed:!1,reason:"Already a draft"}:v(r)?{allowed:!1,reason:"You need write access to convert to draft"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Pull request is not open"};case"close":return a?j(r)?{allowed:!1,reason:"You need write access or be the author to close"}:{allowed:!0,reason:null}:{allowed:!1,reason:s?"Already merged":"Already closed"};case"reopen":return a?{allowed:!1,reason:"Already open"}:s?{allowed:!1,reason:"Already merged"}:j(r)?{allowed:!1,reason:"You need write access or be the author to reopen"}:{allowed:!0,reason:null};case"update-branch":return a?v(r)?{allowed:!1,reason:"You need write access to update the branch"}:{allowed:!0,reason:null}:{allowed:!1,reason:"Pull request is not open"};default:return{allowed:!0,reason:null}}},Re=e=>H(e).allowed!==!0?[]:e&&!e.permissionFallback&&e.isAuthor===!0?["comment"]:["comment","approve","request-changes"],He=e=>e.verdict==="approve"?!0:e.summary.trim().length>0||e.pendingCount>0,_e=e=>H(e),Me=e=>!e||e.permissionFallback?{allowed:!0,reason:null}:e.capabilities?.canPush!==!0?{allowed:!1,reason:"You need write access to resolve threads"}:{allowed:!0,reason:null},Y=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/,Ge=e=>{if(!e)return{original:"",modified:""};const t=[],r=[];let s=!1;for(const a of e.split(`
2
2
  `)){if(a.startsWith("@@")){s&&(t.push("…"),r.push("…")),s=!0;continue}if(!s||a.startsWith("\\"))continue;const i=a[0],l=a.slice(1);i===" "?(t.push(l),r.push(l)):i==="-"?t.push(l):i==="+"?r.push(l):(t.push(a),r.push(a))}return{original:t.join(`
3
3
  `),modified:r.join(`
4
4
  `)}},Le=e=>{switch(e.split(".").pop()?.toLowerCase()??""){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"py":return"python";case"rb":return"ruby";case"go":return"go";case"rs":return"rust";case"css":case"scss":return"css";case"html":return"html";case"yaml":case"yml":return"yaml";case"sh":return"shell";default:return"text"}},Pe=e=>{const t={newToSynthetic:new Map,oldToSynthetic:new Map,syntheticToNew:new Map,syntheticToOld:new Map};if(!e)return t;let r=!1,s=0,a=0,i=0,l=0;for(const o of e.split(`
@@ -1 +1 @@
1
- import{k as s}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{z as O,A as K,by as F,t as L,au as Q,av as W,aw as J,ax as V,ay as X,B as Y,I as Z}from"./useAppFontEffects-BQ1JUauS.js";import{j as _,d as ee}from"./GitHubListPrimitives-Dor_K85Y.js";import{a as se}from"./GitHubDetailScaffold-C2d4WqKe.js";import{p as P,e as te,f as re}from"./githubLink-DSgdECMr.js";import"./vendor-clsx-B-dksMZM.js";import"./index-DWSrsQWl.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-Der4qUnI.js";import"./nativeFileSave-CFuugNKV.js";import"./vendor-dompurify-r8glNMJW.js";const je=({directory:n,open:p,onClose:j})=>{const i=O().github??null,R=K(e=>e.entriesByDirectory[n]??null),C=K(e=>e.ensureScope),G=F(n||null),[m,A]=r.useState("issue"),[h,H]=r.useState(null),[d,B]=r.useState(""),[$,k]=r.useState([]),[z,y]=r.useState(!1),[q,w]=r.useState(null),[D,E]=r.useState(!1),[g,I]=r.useState(null);r.useEffect(()=>{!p||!i||C(n,i)},[p,n,i,C]);const a=r.useMemo(()=>(R?.scope?.repositories??[]).filter(t=>t.host&&t.owner&&t.repo&&!t.disabledReason).map(t=>({owner:t.owner,repo:t.repo,ref:`${t.host}/${t.owner}/${t.repo}`})),[R]);r.useEffect(()=>{p&&H(G??a[0]?.ref??null)},[p,G,a]);const o=r.useMemo(()=>P(d,a),[d,a]),b=r.useRef(0),T=r.useCallback(async(e,t,c)=>{if(!i)return;const x=b.current+=1,u=e.trim(),v=P(u,a);if(!u||v.link||v.outOfScope){k([]),w(null),y(!1);return}y(!0),w(null);try{if(c==="issue"){const f=await i.issuesList(n,t,{state:"all",q:u});if(b.current!==x)return;k(f.items.slice(0,60).map(l=>({kind:"issue",number:l.number,title:l.title,url:l.url,repo:t})))}else{const f=await i.pullsList(n,t,{state:"all",q:u});if(b.current!==x)return;k(f.items.slice(0,60).map(l=>({kind:"pr",number:l.number,title:l.title,url:l.url,repo:t})))}}catch(f){if(b.current!==x)return;k([]),w(f instanceof Error?f.message:"Search failed")}finally{b.current===x&&y(!1)}},[i,n,a]);r.useEffect(()=>{if(!p||!h)return;const e=setTimeout(()=>{T(d,h,m)},250);return()=>clearTimeout(e)},[p,d,h,m,T]);const U=r.useCallback(async()=>{if(!i||!o.link)return null;const{kind:e,number:t,owner:c,repo:x}=o.link,u=c&&x?a.find(l=>l.owner?.toLowerCase()===c.toLowerCase()&&l.repo?.toLowerCase()===x.toLowerCase())?.ref??null:h;if(!u)return null;const f=/^https?:\/\//i.test(d.trim())?e:m;E(!0);try{if(f==="pr"){const N=await i.pullGet(n,u,t);return N.pr?{kind:"pr",number:t,title:N.pr.title,url:N.pr.url,repo:u}:null}const l=await i.issueGet(n,u,t);return l.issue?{kind:"issue",number:t,title:l.issue.title,url:l.issue.url,repo:u}:null}finally{E(!1)}},[i,o.link,n,m,d,h,a]),S=r.useCallback(async e=>{if(!i)return;const t=`${e.repo}#${e.number}`;I(t);try{const c=await i.agentContext(n,e.repo,e.kind==="pr"?"pr":"issue",e.number);te({kind:e.kind,number:e.number,title:e.title,url:e.url,contextText:c.text},re()),L.success(e.kind==="pr"?"Pull request linked":"Issue linked"),j()}catch(c){L.error(c instanceof Error?c.message:"Failed to link")}finally{I(null)}},[i,n,j]),M=r.useCallback(async()=>{const e=await U();if(!e){L.error("Not found in this repository");return}await S(e)},[U,S]);return p?s.jsx(Q,{open:p,onOpenChange:e=>{e||j()},children:s.jsxs(W,{className:"max-w-md w-[calc(100vw-2rem)]",children:[s.jsxs(J,{children:[s.jsx(V,{children:"Link issue or pull request"}),s.jsx(X,{children:"Search, type #123, or paste a GitHub URL for a repository in scope."})]}),i?s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(_,{ariaLabel:"Link kind",value:m,onChange:e=>A(e),options:[{id:"issue",label:"Issues"},{id:"pr",label:"Pull requests"}]}),a.length>1?s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"sr-only",children:"Repository"}),s.jsx("select",{"aria-label":"Repository",value:h??"",onChange:e=>H(e.target.value||null),className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-[var(--surface-elevated)] px-2 typography-micro text-foreground",children:a.map(e=>s.jsxs("option",{value:e.ref,children:[e.owner,"/",e.repo]},e.ref))})]}):null,s.jsx(ee,{value:d,onChange:B,placeholder:m==="issue"?"Search issues, #123, or paste a URL":"Search pull requests, #123, or paste a URL",ariaLabel:m==="issue"?"Search issues":"Search pull requests"}),o.outOfScope?s.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"That repository is outside this session's scope. Pick a repository listed above."}):null,o.link?s.jsx(Y,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:D||g!==null||!h&&!(o.link.owner&&o.link.repo),"aria-label":`Link ${m==="pr"?"pull request":"issue"} number ${o.link.number}`,children:D||g?"Working…":`Link #${o.link.number}`}):null,q?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:q}):null,s.jsx("div",{className:"max-h-64 min-h-0 overflow-y-auto",role:"list","aria-label":"Matches",children:z?s.jsxs("p",{className:"flex items-center gap-2 p-2 typography-ui text-muted-foreground",children:[s.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"})," Searching…"]}):$.length===0&&d.trim()&&!o.link?s.jsx("p",{className:"p-2 typography-ui text-muted-foreground",children:"No matches. Try #123 or a GitHub URL."}):s.jsx("ul",{className:"flex flex-col gap-0.5",children:$.map(e=>{const t=`${e.repo}#${e.number}`;return s.jsx("li",{role:"listitem",children:s.jsxs("button",{type:"button",onClick:()=>{S(e)},disabled:g!==null,"aria-label":`Link ${e.kind==="pr"?"pull request":"issue"} #${e.number} ${e.title}`,className:"flex w-full items-start gap-2 rounded-md px-2 py-2 text-left hover:bg-interactive-hover disabled:opacity-60",children:[s.jsx("span",{className:"mt-0.5 shrink-0",children:s.jsx(se,{kind:e.kind,state:"open"})}),s.jsx("span",{className:"min-w-0 flex-1",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"shrink-0 font-mono typography-micro text-muted-foreground",children:["#",e.number]}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:e.title,children:g===t?"Linking…":e.title})]})})]})},t)})})})]}):s.jsx("p",{className:"typography-ui text-muted-foreground",children:"GitHub is not available in this runtime."})]})}):null};export{je as GitHubLinkPicker};
1
+ import{k as s}from"./vendor-boot-EC6IyLt1.js";import{R as r}from"./vendor-react-DASdDPIk.js";import{z as O,A as K,by as F,t as L,au as Q,av as W,aw as J,ax as V,ay as X,B as Y,I as Z}from"./useAppFontEffects-CqHhRKmN.js";import{j as _,d as ee}from"./GitHubListPrimitives-DvQDU--z.js";import{a as se}from"./GitHubDetailScaffold-C1UHuETI.js";import{p as P,e as te,f as re}from"./githubLink-CbGYxsIq.js";import"./vendor-clsx-B-dksMZM.js";import"./index-D4n3TVp2.js";import"./vendor-zustand-CUi8eEds.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./runtimeSurface-k1Eit61v.js";import"./nativeFileSave-BJsGPh58.js";import"./vendor-dompurify-r8glNMJW.js";const je=({directory:n,open:p,onClose:j})=>{const i=O().github??null,R=K(e=>e.entriesByDirectory[n]??null),C=K(e=>e.ensureScope),G=F(n||null),[m,A]=r.useState("issue"),[h,H]=r.useState(null),[d,B]=r.useState(""),[$,k]=r.useState([]),[z,y]=r.useState(!1),[q,w]=r.useState(null),[D,E]=r.useState(!1),[g,I]=r.useState(null);r.useEffect(()=>{!p||!i||C(n,i)},[p,n,i,C]);const a=r.useMemo(()=>(R?.scope?.repositories??[]).filter(t=>t.host&&t.owner&&t.repo&&!t.disabledReason).map(t=>({owner:t.owner,repo:t.repo,ref:`${t.host}/${t.owner}/${t.repo}`})),[R]);r.useEffect(()=>{p&&H(G??a[0]?.ref??null)},[p,G,a]);const o=r.useMemo(()=>P(d,a),[d,a]),b=r.useRef(0),T=r.useCallback(async(e,t,c)=>{if(!i)return;const x=b.current+=1,u=e.trim(),v=P(u,a);if(!u||v.link||v.outOfScope){k([]),w(null),y(!1);return}y(!0),w(null);try{if(c==="issue"){const f=await i.issuesList(n,t,{state:"all",q:u});if(b.current!==x)return;k(f.items.slice(0,60).map(l=>({kind:"issue",number:l.number,title:l.title,url:l.url,repo:t})))}else{const f=await i.pullsList(n,t,{state:"all",q:u});if(b.current!==x)return;k(f.items.slice(0,60).map(l=>({kind:"pr",number:l.number,title:l.title,url:l.url,repo:t})))}}catch(f){if(b.current!==x)return;k([]),w(f instanceof Error?f.message:"Search failed")}finally{b.current===x&&y(!1)}},[i,n,a]);r.useEffect(()=>{if(!p||!h)return;const e=setTimeout(()=>{T(d,h,m)},250);return()=>clearTimeout(e)},[p,d,h,m,T]);const U=r.useCallback(async()=>{if(!i||!o.link)return null;const{kind:e,number:t,owner:c,repo:x}=o.link,u=c&&x?a.find(l=>l.owner?.toLowerCase()===c.toLowerCase()&&l.repo?.toLowerCase()===x.toLowerCase())?.ref??null:h;if(!u)return null;const f=/^https?:\/\//i.test(d.trim())?e:m;E(!0);try{if(f==="pr"){const N=await i.pullGet(n,u,t);return N.pr?{kind:"pr",number:t,title:N.pr.title,url:N.pr.url,repo:u}:null}const l=await i.issueGet(n,u,t);return l.issue?{kind:"issue",number:t,title:l.issue.title,url:l.issue.url,repo:u}:null}finally{E(!1)}},[i,o.link,n,m,d,h,a]),S=r.useCallback(async e=>{if(!i)return;const t=`${e.repo}#${e.number}`;I(t);try{const c=await i.agentContext(n,e.repo,e.kind==="pr"?"pr":"issue",e.number);te({kind:e.kind,number:e.number,title:e.title,url:e.url,contextText:c.text},re()),L.success(e.kind==="pr"?"Pull request linked":"Issue linked"),j()}catch(c){L.error(c instanceof Error?c.message:"Failed to link")}finally{I(null)}},[i,n,j]),M=r.useCallback(async()=>{const e=await U();if(!e){L.error("Not found in this repository");return}await S(e)},[U,S]);return p?s.jsx(Q,{open:p,onOpenChange:e=>{e||j()},children:s.jsxs(W,{className:"max-w-md w-[calc(100vw-2rem)]",children:[s.jsxs(J,{children:[s.jsx(V,{children:"Link issue or pull request"}),s.jsx(X,{children:"Search, type #123, or paste a GitHub URL for a repository in scope."})]}),i?s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx(_,{ariaLabel:"Link kind",value:m,onChange:e=>A(e),options:[{id:"issue",label:"Issues"},{id:"pr",label:"Pull requests"}]}),a.length>1?s.jsxs("label",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"sr-only",children:"Repository"}),s.jsx("select",{"aria-label":"Repository",value:h??"",onChange:e=>H(e.target.value||null),className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-[var(--surface-elevated)] px-2 typography-micro text-foreground",children:a.map(e=>s.jsxs("option",{value:e.ref,children:[e.owner,"/",e.repo]},e.ref))})]}):null,s.jsx(ee,{value:d,onChange:B,placeholder:m==="issue"?"Search issues, #123, or paste a URL":"Search pull requests, #123, or paste a URL",ariaLabel:m==="issue"?"Search issues":"Search pull requests"}),o.outOfScope?s.jsx("p",{className:"typography-micro text-muted-foreground",role:"note",children:"That repository is outside this session's scope. Pick a repository listed above."}):null,o.link?s.jsx(Y,{type:"button",variant:"outline",size:"sm",onClick:M,disabled:D||g!==null||!h&&!(o.link.owner&&o.link.repo),"aria-label":`Link ${m==="pr"?"pull request":"issue"} number ${o.link.number}`,children:D||g?"Working…":`Link #${o.link.number}`}):null,q?s.jsx("p",{className:"typography-micro text-[var(--status-error)]",role:"alert",children:q}):null,s.jsx("div",{className:"max-h-64 min-h-0 overflow-y-auto",role:"list","aria-label":"Matches",children:z?s.jsxs("p",{className:"flex items-center gap-2 p-2 typography-ui text-muted-foreground",children:[s.jsx(Z,{name:"loader-4",className:"size-4 animate-spin"})," Searching…"]}):$.length===0&&d.trim()&&!o.link?s.jsx("p",{className:"p-2 typography-ui text-muted-foreground",children:"No matches. Try #123 or a GitHub URL."}):s.jsx("ul",{className:"flex flex-col gap-0.5",children:$.map(e=>{const t=`${e.repo}#${e.number}`;return s.jsx("li",{role:"listitem",children:s.jsxs("button",{type:"button",onClick:()=>{S(e)},disabled:g!==null,"aria-label":`Link ${e.kind==="pr"?"pull request":"issue"} #${e.number} ${e.title}`,className:"flex w-full items-start gap-2 rounded-md px-2 py-2 text-left hover:bg-interactive-hover disabled:opacity-60",children:[s.jsx("span",{className:"mt-0.5 shrink-0",children:s.jsx(se,{kind:e.kind,state:"open"})}),s.jsx("span",{className:"min-w-0 flex-1",children:s.jsxs("span",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsxs("span",{className:"shrink-0 font-mono typography-micro text-muted-foreground",children:["#",e.number]}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:e.title,children:g===t?"Linking…":e.title})]})})]})},t)})})})]}):s.jsx("p",{className:"typography-ui text-muted-foreground",children:"GitHub is not available in this runtime."})]})}):null};export{je as GitHubLinkPicker};
@@ -1 +1 @@
1
- import{k as e}from"./vendor-boot-EC6IyLt1.js";import{R as u}from"./vendor-react-DASdDPIk.js";import{I as o,B as l,as as f}from"./useAppFontEffects-BQ1JUauS.js";import{e as m}from"./index-DWSrsQWl.js";import{W as b,X as g}from"./GitHubDetailScaffold-C2d4WqKe.js";const G=({options:r,value:s,onChange:t,ariaLabel:a})=>e.jsx("div",{role:"tablist","aria-label":a,className:"flex flex-wrap gap-1",children:r.map(i=>{const n=i.id===s;return e.jsx(l,{type:"button",variant:"chip",size:"xs",role:"tab","aria-selected":n,"aria-pressed":n,onClick:()=>t(i.id),className:m(n&&"bg-interactive-selection text-interactive-selection-foreground"),children:i.label},i.id)})}),H=({value:r,onChange:s,placeholder:t,ariaLabel:a})=>{const[i,n]=u.useState(r);u.useEffect(()=>n(r),[r]);const c=u.useRef(s);return c.current=s,u.useEffect(()=>{if(i===r)return;const d=setTimeout(()=>c.current(i),80);return()=>clearTimeout(d)},[i,r]),e.jsxs("span",{className:"relative block min-w-0 flex-1",children:[e.jsx(o,{name:"search","aria-hidden":"true",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(f,{value:i,onChange:d=>n(d.target.value),placeholder:t??"Search","aria-label":a??"Search",className:"h-8 pl-7"})]})},S=({rows:r=7,label:s})=>{const t=["w-3/5","w-2/5","w-1/2","w-2/3","w-2/5","w-3/5","w-1/2"],a=["w-2/5","w-1/3","w-2/5","w-1/4","w-1/3","w-2/5","w-1/3"];return e.jsx("div",{role:"status","aria-label":s,className:"flex animate-pulse flex-col p-1",children:Array.from({length:r},(i,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-2",children:[e.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0 rounded-full bg-muted-foreground/15"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:m("block h-3.5 rounded bg-muted-foreground/15",t[n%t.length])}),e.jsx("span",{"aria-hidden":"true",className:m("block h-3 rounded bg-muted-foreground/15",a[n%a.length])})]}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-12 rounded bg-muted-foreground/15"}),e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-10 rounded bg-muted-foreground/15"})]})]},n))})},p=({icon:r,title:s,description:t,action:a})=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[e.jsx(o,{name:r,"aria-hidden":"true",className:"size-6 text-muted-foreground/60"}),e.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:s}),t?e.jsx("p",{className:"max-w-60 typography-micro text-muted-foreground",children:t}):null,a]}),j=({hasMore:r,isLoading:s,onLoadMore:t,label:a})=>r?e.jsx("div",{className:"flex justify-center px-2 py-2",children:e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:s,children:s?"Loading…":a??"Load more"})}):null,z=({summary:r,summaryTitle:s})=>e.jsx("footer",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:e.jsx("span",{className:"min-w-0 truncate",title:s??r,children:r})}),C=({matchSummary:r,searching:s,onSearchAll:t})=>e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:r,children:r}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:t,disabled:s,children:s?"Searching…":"Search all on GitHub"})]}),R=({title:r,isSearching:s,error:t,hasResults:a,hasMore:i,isLoadingMore:n,onRetry:c,onLoadMore:d,children:h})=>{const x=t?.kind==="rate-limited"?"GitHub rate limit reached — try again in a little while.":"Couldn't search GitHub.";return e.jsxs("section",{"aria-label":r,className:"border-t border-border/60",children:[e.jsx("p",{className:"px-3 pb-0.5 pt-1.5 typography-micro font-medium text-muted-foreground",children:r}),t&&!a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 typography-micro text-muted-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:c,children:"Retry"})]}):null,t&&a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:c,children:"Retry"})]}):null,!t&&s&&!a?e.jsx("p",{className:"px-3 py-2 typography-micro text-muted-foreground",role:"status",children:"Searching GitHub…"}):null,a?e.jsx("div",{className:"flex flex-col p-1 pt-0.5",children:h}):null,!t&&a?e.jsx(j,{hasMore:i,isLoading:n,onLoadMore:d,label:"Load more results"}):null]})},E=({error:r,onRetry:s,label:t})=>{if(!b(r))return null;const a=g(r);return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert","aria-label":`${t} failed to load`,children:[e.jsx(o,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[t," failed to load",r?` — ${a}`:""]}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:s,children:"Retry"})]})},L=({number:r,kindLabel:s,onOpen:t})=>e.jsx("div",{className:"flex flex-col p-1",children:e.jsxs("button",{type:"button",onClick:t,"aria-label":`Open ${s} #${r}`,className:"group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-interactive-hover",children:[e.jsx("span",{className:"inline-flex w-4 shrink-0 items-center justify-center",children:e.jsx(o,{name:"external-link",className:"size-3.5 text-muted-foreground","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:["Open #",r]}),e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"Not in the loaded list"})]})}),I=({onRetry:r})=>e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-3 py-1.5 typography-micro text-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Showing saved results — last refresh failed"}),e.jsx("button",{type:"button",onClick:r,className:"shrink-0 underline","aria-label":"Retry GitHub refresh",children:"Retry"})]}),T=({kind:r,noItemsTitle:s,noItemsBody:t,noItemsIcon:a,noItemsAction:i,onClearFilters:n})=>r==="no-match"?e.jsx(p,{icon:"search",title:"Nothing matches these filters",description:"Try fewer words, or search by number, author, or label.",action:n?e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Clear filters"}):void 0}):e.jsx(p,{icon:a??"git-pull-request",title:s,description:t,action:i});export{S as G,E as S,p as a,j as b,I as c,H as d,T as e,L as f,R as g,C as h,z as i,G as j};
1
+ import{k as e}from"./vendor-boot-EC6IyLt1.js";import{R as u}from"./vendor-react-DASdDPIk.js";import{I as o,B as l,as as f}from"./useAppFontEffects-CqHhRKmN.js";import{e as m}from"./index-D4n3TVp2.js";import{W as b,X as g}from"./GitHubDetailScaffold-C1UHuETI.js";const G=({options:r,value:s,onChange:t,ariaLabel:a})=>e.jsx("div",{role:"tablist","aria-label":a,className:"flex flex-wrap gap-1",children:r.map(i=>{const n=i.id===s;return e.jsx(l,{type:"button",variant:"chip",size:"xs",role:"tab","aria-selected":n,"aria-pressed":n,onClick:()=>t(i.id),className:m(n&&"bg-interactive-selection text-interactive-selection-foreground"),children:i.label},i.id)})}),H=({value:r,onChange:s,placeholder:t,ariaLabel:a})=>{const[i,n]=u.useState(r);u.useEffect(()=>n(r),[r]);const c=u.useRef(s);return c.current=s,u.useEffect(()=>{if(i===r)return;const d=setTimeout(()=>c.current(i),80);return()=>clearTimeout(d)},[i,r]),e.jsxs("span",{className:"relative block min-w-0 flex-1",children:[e.jsx(o,{name:"search","aria-hidden":"true",className:"pointer-events-none absolute left-2 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(f,{value:i,onChange:d=>n(d.target.value),placeholder:t??"Search","aria-label":a??"Search",className:"h-8 pl-7"})]})},S=({rows:r=7,label:s})=>{const t=["w-3/5","w-2/5","w-1/2","w-2/3","w-2/5","w-3/5","w-1/2"],a=["w-2/5","w-1/3","w-2/5","w-1/4","w-1/3","w-2/5","w-1/3"];return e.jsx("div",{role:"status","aria-label":s,className:"flex animate-pulse flex-col p-1",children:Array.from({length:r},(i,n)=>e.jsxs("div",{className:"flex items-center gap-2 rounded-md px-2 py-2",children:[e.jsx("span",{"aria-hidden":"true",className:"size-4 shrink-0 rounded-full bg-muted-foreground/15"}),e.jsxs("span",{className:"min-w-0 flex-1 space-y-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:m("block h-3.5 rounded bg-muted-foreground/15",t[n%t.length])}),e.jsx("span",{"aria-hidden":"true",className:m("block h-3 rounded bg-muted-foreground/15",a[n%a.length])})]}),e.jsxs("span",{className:"flex shrink-0 flex-col items-end gap-1.5",children:[e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-12 rounded bg-muted-foreground/15"}),e.jsx("span",{"aria-hidden":"true",className:"block h-3 w-10 rounded bg-muted-foreground/15"})]})]},n))})},p=({icon:r,title:s,description:t,action:a})=>e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1.5 p-6 text-center",children:[e.jsx(o,{name:r,"aria-hidden":"true",className:"size-6 text-muted-foreground/60"}),e.jsx("p",{className:"typography-ui-label font-medium text-foreground",children:s}),t?e.jsx("p",{className:"max-w-60 typography-micro text-muted-foreground",children:t}):null,a]}),j=({hasMore:r,isLoading:s,onLoadMore:t,label:a})=>r?e.jsx("div",{className:"flex justify-center px-2 py-2",children:e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:t,disabled:s,children:s?"Loading…":a??"Load more"})}):null,z=({summary:r,summaryTitle:s})=>e.jsx("footer",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:e.jsx("span",{className:"min-w-0 truncate",title:s??r,children:r})}),C=({matchSummary:r,searching:s,onSearchAll:t})=>e.jsxs("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-1 border-t border-border/60 px-2 py-1.5 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",title:r,children:r}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:t,disabled:s,children:s?"Searching…":"Search all on GitHub"})]}),R=({title:r,isSearching:s,error:t,hasResults:a,hasMore:i,isLoadingMore:n,onRetry:c,onLoadMore:d,children:h})=>{const x=t?.kind==="rate-limited"?"GitHub rate limit reached — try again in a little while.":"Couldn't search GitHub.";return e.jsxs("section",{"aria-label":r,className:"border-t border-border/60",children:[e.jsx("p",{className:"px-3 pb-0.5 pt-1.5 typography-micro font-medium text-muted-foreground",children:r}),t&&!a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-2 typography-micro text-muted-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:c,children:"Retry"})]}):null,t&&a?e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-3 py-1 typography-micro text-muted-foreground",children:[e.jsx("span",{className:"min-w-0 flex-1",children:x}),e.jsx(l,{type:"button",variant:"ghost",size:"xs",onClick:c,children:"Retry"})]}):null,!t&&s&&!a?e.jsx("p",{className:"px-3 py-2 typography-micro text-muted-foreground",role:"status",children:"Searching GitHub…"}):null,a?e.jsx("div",{className:"flex flex-col p-1 pt-0.5",children:h}):null,!t&&a?e.jsx(j,{hasMore:i,isLoading:n,onLoadMore:d,label:"Load more results"}):null]})},E=({error:r,onRetry:s,label:t})=>{if(!b(r))return null;const a=g(r);return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-[var(--status-error-border)] bg-[var(--status-error-background)] px-3 py-2 typography-micro text-foreground",role:"alert","aria-label":`${t} failed to load`,children:[e.jsx(o,{name:"error-warning",className:"size-4 shrink-0 text-[var(--status-error)]"}),e.jsxs("span",{className:"min-w-0 flex-1 truncate",children:[t," failed to load",r?` — ${a}`:""]}),e.jsx(l,{type:"button",variant:"outline",size:"xs",onClick:s,children:"Retry"})]})},L=({number:r,kindLabel:s,onOpen:t})=>e.jsx("div",{className:"flex flex-col p-1",children:e.jsxs("button",{type:"button",onClick:t,"aria-label":`Open ${s} #${r}`,className:"group/github-row flex w-full items-center gap-2 rounded-md px-2 py-1 text-left hover:bg-interactive-hover",children:[e.jsx("span",{className:"inline-flex w-4 shrink-0 items-center justify-center",children:e.jsx(o,{name:"external-link",className:"size-3.5 text-muted-foreground","aria-hidden":"true"})}),e.jsxs("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",children:["Open #",r]}),e.jsx("span",{className:"shrink-0 typography-micro text-muted-foreground",children:"Not in the loaded list"})]})}),I=({onRetry:r})=>e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-[var(--status-warning-border)] bg-[var(--status-warning-background)] px-3 py-1.5 typography-micro text-foreground",children:[e.jsx(o,{name:"error-warning",className:"size-3.5 shrink-0 text-[var(--status-warning)]"}),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:"Showing saved results — last refresh failed"}),e.jsx("button",{type:"button",onClick:r,className:"shrink-0 underline","aria-label":"Retry GitHub refresh",children:"Retry"})]}),T=({kind:r,noItemsTitle:s,noItemsBody:t,noItemsIcon:a,noItemsAction:i,onClearFilters:n})=>r==="no-match"?e.jsx(p,{icon:"search",title:"Nothing matches these filters",description:"Try fewer words, or search by number, author, or label.",action:n?e.jsx(l,{type:"button",variant:"outline",size:"sm",onClick:n,children:"Clear filters"}):void 0}):e.jsx(p,{icon:a??"git-pull-request",title:s,description:t,action:i});export{S as G,E as S,p as a,j as b,I as c,H as d,T as e,L as f,R as g,C as h,z as i,G as j};