@openchamber/web 1.20.0 → 1.21.0

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 (119) hide show
  1. package/dist/assets/{CodeMirrorCommentWidgets-C36E738Y.js → CodeMirrorCommentWidgets-C2BopIs3.js} +1 -1
  2. package/dist/assets/CommitSection-HJeMUAWb.js +1 -0
  3. package/dist/assets/DiffView-D5cvbEPb.js +4 -0
  4. package/dist/assets/FilesView-DPU8aNPL.js +17 -0
  5. package/dist/assets/GitView-Ct6xWrVH.js +6 -0
  6. package/dist/assets/{JsonTreeView-KnXFN2A-.js → JsonTreeView-osju7J70.js} +1 -1
  7. package/dist/assets/MarkdownImageGallery-EujHSZ2M.js +1 -0
  8. package/dist/assets/MarkdownRendererImpl-CPzu4kIr.js +12 -0
  9. package/dist/assets/OnboardingScreen-w2VG4fWY.js +1 -0
  10. package/dist/assets/{PatchDiff-BzVOVog8.js → PatchDiff-Dan3mADn.js} +1 -1
  11. package/dist/assets/PierreDiffViewer-CGoI2v0q.js +157 -0
  12. package/dist/assets/PlanView-Dgg-WTEc.js +4 -0
  13. package/dist/assets/SessionSwitcherDropdown-CJTrc8K7.js +1 -0
  14. package/dist/assets/SettingsView-D9yRuFZw.js +28 -0
  15. package/dist/assets/SettingsWindow-DXF-MTHG.js +1 -0
  16. package/dist/assets/{ToolOutputDialog-BB1c--Zr.js → ToolOutputDialog-DrCa1JRk.js} +6 -6
  17. package/dist/assets/{ToolPartDiffPreview-DaOIDISD.js → ToolPartDiffPreview-B_tfvlNF.js} +2 -2
  18. package/dist/assets/{VirtualizedFileDiff-lESMT-2b.js → VirtualizedFileDiff-CN_BctrR.js} +4 -4
  19. package/dist/assets/{Virtualizer-X_7XPoTH.js → Virtualizer-CZlLSacm.js} +1 -1
  20. package/dist/assets/Virtualizer-D_a8gKmg.js +1 -0
  21. package/dist/assets/{WalkthroughView-CaSYE0lw.js → WalkthroughView-D9Q4lr5x.js} +2 -2
  22. package/dist/assets/{computeVirtualFileMetrics-DkRR5b75.js → computeVirtualFileMetrics-Gi1d5eU1.js} +2 -2
  23. package/dist/assets/contextPanelEmbeddedChat-CpzVNWAv.js +1 -0
  24. package/dist/assets/de-B_LdJwEM.js +9 -0
  25. package/dist/assets/es-CubfsAYV.js +15 -0
  26. package/dist/assets/fr-5qJM0nFS.js +13 -0
  27. package/dist/assets/index-BW82eK5v.css +1 -0
  28. package/dist/assets/index-Brm3X9rs.js +1 -0
  29. package/dist/assets/index-rlLjZUM5.js +7 -0
  30. package/dist/assets/{isDiffPlainText-BG53Ixxy.js → isDiffPlainText-pH9kAJQH.js} +1 -1
  31. package/dist/assets/{isFilePlainText-BbV-39jl.js → isFilePlainText-CVKy_dgB.js} +1 -1
  32. package/dist/assets/ja-DJYIBUlH.js +15 -0
  33. package/dist/assets/ko-DcUBkB7y.js +15 -0
  34. package/dist/assets/main-DLBxKIoX.js +926 -0
  35. package/dist/assets/main-vUCh0VB0.js +2 -0
  36. package/dist/assets/markdownCore-DG6GHLF4.js +3 -0
  37. package/dist/assets/{miniChat-ldEghBLB.js → miniChat-BlzGEYgE.js} +2 -2
  38. package/dist/assets/mobile-CkX6H-IT.js +2 -0
  39. package/dist/assets/{patchFileDiff-BcFaMtMu.js → patchFileDiff-BCTsE43U.js} +3 -3
  40. package/dist/assets/pl-rB6BLcio.js +15 -0
  41. package/dist/assets/pt-BR-DcwtlO-o.js +15 -0
  42. package/dist/assets/renderElectronMiniChatApp-CJYe_KOL.js +2 -0
  43. package/dist/assets/renderMobileApp-hQJTnr8B.js +25 -0
  44. package/dist/assets/runtimeEndpointReset-BDh7r8BL.js +15 -0
  45. package/dist/assets/scheduledTasksApi-CAGPh_gZ.js +1 -0
  46. package/dist/assets/{shikiHighlight-DCT2Sq_z.js → shikiHighlight-BgTPSITe.js} +1 -1
  47. package/dist/assets/uk-INZlFD9A.js +15 -0
  48. package/dist/assets/{useAppFontEffects-B53Rb6m7.js → useAppFontEffects-Cll4gnsh.js} +170 -180
  49. package/dist/assets/useInlineCommentController-DFFv0hae.js +2 -0
  50. package/dist/assets/{vendor-base-ui-DsHmyMwp.js → vendor-base-ui-_6j2xOWl.js} +1 -1
  51. package/dist/assets/{vendor-codemirror-language-data-vch3tJ4c.js → vendor-codemirror-language-data-DkQX2EBa.js} +2 -2
  52. package/dist/assets/{vendor-framer-motion-CRSgBxjL.js → vendor-framer-motion-livSKyyV.js} +1 -1
  53. package/dist/assets/vendor-legendapp-list-gg7YLRW7.js +1 -0
  54. package/dist/assets/{vendor-motion-dom-DJLgZh4Q.js → vendor-motion-dom-D_o3BTI3.js} +1 -1
  55. package/dist/assets/vendor-zod-BLfBSgBh.js +39 -0
  56. package/dist/assets/{web-components-pcwCTWjC.js → web-components-DLnGY4fs.js} +4 -4
  57. package/dist/assets/zh-CN-Dzda8xa1.js +15 -0
  58. package/dist/assets/zh-TW-Cwn3rNYZ.js +15 -0
  59. package/dist/index.html +6 -6
  60. package/dist/mini-chat.html +5 -5
  61. package/dist/mobile.html +5 -5
  62. package/package.json +4 -4
  63. package/server/index.js +8 -0
  64. package/server/lib/client-auth/pairing.js +8 -7
  65. package/server/lib/client-auth/pairing.test.js +5 -1
  66. package/server/lib/client-auth/remote-clients.js +9 -1
  67. package/server/lib/client-auth/remote-clients.test.js +17 -0
  68. package/server/lib/github/pr-status.js +10 -1
  69. package/server/lib/quota/providers/index.js +4 -18
  70. package/server/lib/relay/DOCUMENTATION.md +1 -1
  71. package/server/lib/relay/service.js +34 -2
  72. package/server/lib/relay/service.test.js +69 -0
  73. package/server/lib/session-goal/runtime.js +2 -1
  74. package/server/lib/session-goal/runtime.test.js +4 -2
  75. package/server/lib/terminal/DOCUMENTATION.md +2 -0
  76. package/server/lib/terminal/runtime.js +29 -1
  77. package/server/lib/terminal/runtime.test.js +26 -0
  78. package/server/lib/ui-auth/ui-auth.js +2 -2
  79. package/server/lib/ui-auth/ui-auth.test.js +2 -2
  80. package/dist/assets/CommitSection-C-F3AX6D.js +0 -1
  81. package/dist/assets/DiagramEditor-BPECg1jS.js +0 -1
  82. package/dist/assets/DiagramView-D0YNMix8.js +0 -1
  83. package/dist/assets/DiffView-BHWaMYCC.js +0 -4
  84. package/dist/assets/FilesView-NMBCW2Tm.js +0 -14
  85. package/dist/assets/GitView-Rp8P1KEI.js +0 -6
  86. package/dist/assets/MarkdownImageGallery-BMn3mtor.js +0 -1
  87. package/dist/assets/MarkdownRendererImpl-kD6N03pH.js +0 -12
  88. package/dist/assets/OnboardingScreen-CenIeD4v.js +0 -1
  89. package/dist/assets/PierreDiffViewer-Dlby4XqT.js +0 -136
  90. package/dist/assets/PlanView-Czu1KMJa.js +0 -4
  91. package/dist/assets/SessionSwitcherDropdown-IETz58DB.js +0 -1
  92. package/dist/assets/SettingsView-B6vmuf-c.js +0 -28
  93. package/dist/assets/SettingsWindow-CauZpdD3.js +0 -1
  94. package/dist/assets/contextPanelEmbeddedChat-BEARQjgn.js +0 -1
  95. package/dist/assets/de-DFdX3ABv.js +0 -9
  96. package/dist/assets/es-iC-FKvV9.js +0 -15
  97. package/dist/assets/fr-BBbi_1AL.js +0 -13
  98. package/dist/assets/index-BiEgzzkg.js +0 -1
  99. package/dist/assets/index-Cwmuwk3V.js +0 -7
  100. package/dist/assets/index-GNm1wgUH.css +0 -1
  101. package/dist/assets/ja-DQLQJL2J.js +0 -15
  102. package/dist/assets/ko-BeElEB4Y.js +0 -15
  103. package/dist/assets/main-Dpzo18z7.js +0 -2
  104. package/dist/assets/main-WMjtYzJs.js +0 -921
  105. package/dist/assets/markdownCore--tDmyI_v.js +0 -2
  106. package/dist/assets/mobile-Dk-VGreF.js +0 -2
  107. package/dist/assets/pl-CLHt2_vV.js +0 -15
  108. package/dist/assets/pt-BR-C_MPUq7e.js +0 -15
  109. package/dist/assets/renderElectronMiniChatApp-DIgCOmXY.js +0 -2
  110. package/dist/assets/renderMobileApp-CDfHS5rr.js +0 -25
  111. package/dist/assets/runtimeEndpointReset-ovNbaZ-x.js +0 -15
  112. package/dist/assets/scheduledTasksApi-BFSlqgnG.js +0 -1
  113. package/dist/assets/uk-PhsC-c4-.js +0 -15
  114. package/dist/assets/useInlineCommentController-DSfrIBKT.js +0 -2
  115. package/dist/assets/vendor-zod-C9ioTTSo.js +0 -39
  116. package/dist/assets/zh-CN-wF-NOFHM.js +0 -15
  117. package/dist/assets/zh-TW-4m4-A7rT.js +0 -15
  118. package/server/lib/quota/providers/command-code.js +0 -90
  119. package/server/lib/quota/providers/command-code.test.js +0 -85
@@ -1 +1 @@
1
- import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-DSfrIBKT.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
1
+ import{j as a}from"./vendor-react-BUCujlKS.js";import{I as l,a as I}from"./useInlineCommentController-DFFv0hae.js";function E(g){const{drafts:x,editingDraftId:d,commentText:o,onTextChange:r,selection:n,isDragging:u,fileLabel:s,newWidgetId:f,mapDraftToRange:p,onSave:m,onCancel:c,onEdit:C,onDelete:h}=g,t=[];for(const e of x){const i=p(e);if(e.id===d){t.push({afterLine:i.end,id:`edit-${e.id}`,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:i,isEditing:!0,onSave:m,onCancel:c},`edit-${e.id}`)});continue}t.push({afterLine:i.end,id:`card-${e.id}`,content:a.jsx(I,{draft:e,onEdit:()=>C(e),onDelete:()=>h(e)},`card-${e.id}`)})}if(n&&!d&&!u){const e={...n,start:Math.min(n.start,n.end),end:Math.max(n.start,n.end)};t.push({afterLine:e.end,id:f,content:a.jsx(l,{initialText:o,onTextChange:r,fileLabel:s,lineRange:e,isEditing:!1,onSave:m,onCancel:c},f)})}return t}export{E as b};
@@ -0,0 +1 @@
1
+ import{R as S,f as oe,j as s}from"./vendor-react-BUCujlKS.js";import{u as Ve}from"./vendor-tanstack-react-virtual-g05Cx3z9.js";import{f as Q,am as ze,a4 as fe,a5 as me,I as $,a6 as ue,h as J,B as Z,$ as Ee,gR as Te,bz as pe,bA as ge,bB as xe,bC as be,bD as ye,bE as ve,bj as Ie}from"./useAppFontEffects-Cll4gnsh.js";import{u as Ce}from"./index-rlLjZUM5.js";const ke={"?":{code:"?",color:"var(--status-info)",description:"Untracked file"},A:{code:"A",color:"var(--status-success)",description:"New file"},D:{code:"D",color:"var(--status-error)",description:"Deleted file"},R:{code:"R",color:"var(--status-info)",description:"Renamed file"},C:{code:"C",color:"var(--status-info)",description:"Copied file"},M:{code:"M",color:"var(--status-warning)",description:"Modified file"}},Me=ke.M;function Re(p){const e=p.index?.trim(),t=p.working_dir?.trim();return e&&e!=="?"?e.charAt(0):t?t.charAt(0):e?.charAt(0)||t?.charAt(0)||"M"}function $e(p){const e=Re(p);return ke[e]??Me}const He=S.memo(function(e){const t=oe.c(58),{file:o,actionLabel:x,actionSymbol:b,onAction:m,onViewDiff:f,onRevert:l,isReverting:d,stats:z,rowPaddingClassName:g,indentPx:y,actionAtStart:V,showRevert:H}=e,j=y===void 0?0:y,r=V===void 0?!1:V,w=H===void 0?!0:H;let N;t[0]!==o?(N=$e(o),t[0]=o,t[1]=N):N=t[1];const h=N,{t:E}=Q(),F=h.description,M=z?.insertions??0,C=z?.deletions??0;let D;t[2]!==m||t[3]!==f?(D=U=>{U.key===" "?(U.preventDefault(),m()):U.key==="Enter"&&(U.preventDefault(),f())},t[2]=m,t[3]=f,t[4]=D):D=t[4];const A=D;let T;t[5]!==m?(T=U=>{U.preventDefault(),U.stopPropagation(),m()},t[5]=m,t[6]=T):T=t[6];const u=T;let P;t[7]!==l?(P=U=>{U.preventDefault(),U.stopPropagation(),l()},t[7]=l,t[8]=P):P=t[8];const W=P;let L;t[9]!==x||t[10]!==b||t[11]!==u?(L=s.jsx("button",{type:"button",onClick:u,className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":x,title:x,children:b}),t[9]=x,t[10]=b,t[11]=u,t[12]=L):L=t[12];const R=L,X=`group flex items-center gap-2 py-1.5 cursor-pointer ${g??"px-3"}`;let I;t[13]!==j?(I=j>0?{paddingLeft:`${j}px`}:void 0,t[13]=j,t[14]=I):I=t[14];const Y=r?R:null;let K;t[15]!==h.color?(K={color:h.color},t[15]=h.color,t[16]=K):K=t[16];let G;t[17]!==h.code||t[18]!==F||t[19]!==K?(G=s.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:K,title:F,"aria-label":F,children:h.code}),t[17]=h.code,t[18]=F,t[19]=K,t[20]=G):G=t[20];let O;t[21]!==o.path?(O=s.jsx(ze,{filePath:o.path,className:"h-3.5 w-3.5 shrink-0"}),t[21]=o.path,t[22]=O):O=t[22];let B;if(t[23]!==o.path){e:{const U=o.path.lastIndexOf("/");if(U===-1){let ne;t[25]===Symbol.for("react.memo_cache_sentinel")?(ne={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[25]=ne):ne=t[25],B=s.jsx("span",{className:"flex-1 min-w-0 truncate typography-ui-label text-foreground",style:ne,title:o.path,children:o.path});break e}const De=o.path.slice(0,U),Ae=o.path.slice(U);let te;t[26]===Symbol.for("react.memo_cache_sentinel")?(te={direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},t[26]=te):te=t[26];let se;t[27]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx("span",{className:"text-muted-foreground",children:"/"}),t[27]=se):se=t[27];const re=s.jsx("span",{className:"text-foreground",children:Ae.slice(1)});let ie;t[28]!==re?(ie=s.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[se,re]}),t[28]=re,t[29]=ie):ie=t[29],B=s.jsxs("span",{className:"flex-1 min-w-0 flex items-baseline overflow-hidden",title:o.path,children:[s.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:te,children:De}),ie]})}t[23]=o.path,t[24]=B}else B=t[24];let q;t[30]===Symbol.for("react.memo_cache_sentinel")?(q={color:"var(--status-success)"},t[30]=q):q=t[30];let i;t[31]!==M?(i=s.jsxs("span",{style:q,children:["+",M]}),t[31]=M,t[32]=i):i=t[32];let n,a;t[33]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("span",{className:"text-muted-foreground mx-0.5",children:"/"}),a={color:"var(--status-error)"},t[33]=n,t[34]=a):(n=t[33],a=t[34]);let c;t[35]!==C?(c=s.jsxs("span",{style:a,children:["-",C]}),t[35]=C,t[36]=c):c=t[36];let k;t[37]!==i||t[38]!==c?(k=s.jsxs("span",{className:"shrink-0 typography-micro",children:[i,n,c]}),t[37]=i,t[38]=c,t[39]=k):k=t[39];let v;t[40]!==o.path||t[41]!==W||t[42]!==d||t[43]!==w||t[44]!==E?(v=w?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx("button",{type:"button",onClick:W,disabled:d,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50","aria-label":E("gitView.changes.revertFileAria",{path:o.path}),children:d?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})})}),s.jsx(ue,{sideOffset:8,children:E("gitView.changes.revertFileTooltip")})]}):null,t[40]=o.path,t[41]=W,t[42]=d,t[43]=w,t[44]=E,t[45]=v):v=t[45];const _=r?null:R;let ee;return t[46]!==A||t[47]!==f||t[48]!==I||t[49]!==Y||t[50]!==G||t[51]!==O||t[52]!==B||t[53]!==k||t[54]!==v||t[55]!==_||t[56]!==X?(ee=s.jsxs("div",{className:X,role:"button",tabIndex:0,onClick:f,onKeyDown:A,style:I,children:[Y,G,O,B,k,v,_]}),t[46]=A,t[47]=f,t[48]=I,t[49]=Y,t[50]=G,t[51]=O,t[52]=B,t[53]=k,t[54]=v,t[55]=_,t[56]=X,t[57]=ee):ee=t[57],ee}),je=14,Se=p=>p.replace(/\\/g,"/").replace(/^\/+/,"").trim(),we=(p,e)=>({id:`dir:${p}`,path:p,name:e,children:new Map,directFiles:[],files:[]}),Fe=p=>{const e=we("","");for(const t of p){const o=Se(t.path);if(!o)continue;const b=o.split("/").filter(Boolean).slice(0,-1);let m=e;if(m.files.push(t),b.length>0){let f="";for(const l of b){f=f?`${f}/${l}`:l;const d=m.children.get(l);if(d){d.files.push(t),m=d;continue}const z=we(f,l);z.files.push(t),m.children.set(l,z),m=z}}m.directFiles.push(t)}return e},Pe=(p,e)=>{const t=[],o=(x,b)=>{const m=Array.from(x.children.values()).sort((l,d)=>l.path.localeCompare(d.path));for(const l of m)t.push({key:l.id,kind:"directory",depth:b,directory:l}),e.has(l.path)&&o(l,b+1);const f=[...x.directFiles].sort((l,d)=>l.path.localeCompare(d.path));for(const l of f)t.push({key:`file:${Se(l.path)}`,kind:"file",depth:b,file:l})};return o(p,0),t},Le=1e3,Ne=34,ce=30,le="pl-0 pr-2",de=(p,e)=>`${p} ${e}`,Ye=({groups:p,diffStats:e,revertingPaths:t,isRevertingAll:o=!1,headerBackgroundClassName:x="bg-sidebar",onVisiblePathsChange:b,onRevertAll:m,onRevertDirectory:f})=>{const{t:l}=Q(),d=S.useRef(null),g=Ce(i=>i.gitChangesViewMode)==="tree",y=S.useMemo(()=>p.filter(i=>i.entries.length>0),[p]),[V,H]=S.useState(new Set),[j,r]=S.useState(new Set),[w,N]=S.useState(!1),[h,E]=S.useState(null),F=S.useMemo(()=>y.map(i=>Fe(i.entries)),[y]),M=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{Array.from(F[a]?.children.values()??[]).forEach(c=>{i.push(de(n.id,c.path))})}),i},[F,y]);S.useEffect(()=>{g&&r(i=>{const n=new Set,a=new Set(M);return i.forEach(c=>{(c.slice(c.indexOf(" ")+1).includes("/")||a.has(c))&&n.add(c)}),M.forEach(c=>n.add(c)),n})},[g,M]);const C=S.useMemo(()=>{const i=[];return y.forEach((n,a)=>{if(i.push({type:"header",key:`header:${n.id}`,groupIndex:a}),!V.has(n.id)){if(g){const c=new Set;j.forEach(v=>{v.startsWith(`${n.id} `)&&c.add(v.slice(n.id.length+1))}),Pe(F[a],c).forEach(v=>{v.kind==="file"?i.push({type:"file",key:`${n.id}:${v.key}`,groupIndex:a,file:v.file,depth:v.depth}):i.push({type:"directory",key:`${n.id}:${v.key}`,groupIndex:a,directory:v.directory,depth:v.depth})});return}n.entries.forEach(c=>{i.push({type:"file",key:`${n.id}:file:${c.path}`,groupIndex:a,file:c,depth:0})})}}),m&&y.length>0&&i.push({type:"revert-all",key:"revert-all"}),i},[V,j,g,m,F,y]),D=C.length,A=D>=Le,T=Ve({count:D,enabled:A,getScrollElement:()=>d.current,estimateSize:()=>Ne,overscan:12,getItemKey:i=>C[i]?.key??i}),u=T.getVirtualItems(),P=S.useMemo(()=>{if(!A)return 0;const i=d.current?.scrollTop??0;return u.find(a=>a.end>i)?.index??0},[A,u,d]);S.useEffect(()=>{if(!b)return;const i=n=>n&&n.type==="file"?n.file.path:null;if(D===0){b([]);return}if(!A){const n=[];for(const a of C)if(a.type==="file"&&(n.push(a.file.path),n.length>=ce))break;b(n);return}b(C.slice(P,P+Math.ceil((d.current?.clientHeight??0)/Ne)+ce).map(n=>i(n)).filter(n=>!!n).slice(0,ce))},[b,D,C,A,P]);const W=S.useCallback(i=>{H(n=>{const a=new Set(n);return a.has(i)?a.delete(i):a.add(i),a})},[]),L=S.useCallback((i,n)=>{r(a=>{const c=new Set(a),k=de(i,n);return c.has(k)?c.delete(k):c.add(k),c})},[]),R=S.useMemo(()=>{const i=new Set;return y.forEach(n=>n.entries.forEach(a=>i.add(a.path))),Array.from(i)},[y]),X=R.length,I=h?o||h.paths.some(i=>t.has(i)):!1,Y=S.useCallback(async()=>{!m||o||R.length===0||(await m(R),N(!1))},[R,o,m]),K=S.useCallback(async()=>{!f||!h||I||(await f(h.paths),E(null))},[I,f,h]),G=S.useCallback((i,n)=>{const a=V.has(i.id),c=i.entries.length;return s.jsxs("div",{className:J("sticky top-0 z-10 flex items-center gap-2 py-2",x,le,!n&&"mt-1 border-t border-border/40"),children:[s.jsx("button",{type:"button",onClick:()=>i.onActionAll(i.entries.map(k=>k.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":i.actionAllLabel,title:i.actionAllLabel,children:i.actionSymbol}),s.jsxs("button",{type:"button",onClick:()=>W(i.id),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-expanded":!a,children:[s.jsx("h3",{className:"truncate typography-ui-header font-semibold text-foreground",children:i.title}),s.jsx("span",{className:"typography-meta text-muted-foreground",children:c}),s.jsx($,{name:"arrow-down-s",className:J("size-3.5 shrink-0 text-muted-foreground transition-transform",a&&"-rotate-90")})]})]})},[V,x,W]),O=S.useCallback((i,n,a)=>{const c=j.has(de(i.id,n.path)),k=n.files.map(_=>_.path),v=o||k.some(_=>t.has(_));return s.jsxs("div",{className:J("group flex items-center gap-2 py-1.5",le),style:{paddingLeft:`${a*je}px`},children:[s.jsxs("button",{type:"button",onClick:()=>L(i.id,n.path),className:"flex min-w-0 flex-1 items-center gap-2 rounded text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary","aria-label":c?l("gitView.changes.collapseDirectoryAria",{path:n.path}):l("gitView.changes.expandDirectoryAria",{path:n.path}),children:[c?s.jsx($,{name:"folder-open-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}):s.jsx($,{name:"folder-3-fill",className:"h-4 w-4 flex-shrink-0 text-primary/60"}),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-ui-label text-foreground",title:n.path,children:n.name}),s.jsx("span",{className:"ml-auto shrink-0 typography-micro text-muted-foreground",children:n.files.length})]}),i.showRevertActions!==!1&&f?s.jsx("button",{type:"button",onClick:()=>E({path:n.path,paths:k,count:k.length}),disabled:v,className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50","aria-label":l("gitView.changes.revertDirectoryAria",{path:n.path}),title:l("gitView.changes.revertDirectoryTooltip"),children:v?s.jsx($,{name:"loader-4",className:"size-3.5 animate-spin"}):s.jsx($,{name:"arrow-go-back",className:"size-3.5"})}):null,s.jsx("button",{type:"button",onClick:()=>i.onActionAll(n.files.map(_=>_.path)),className:"flex size-5 shrink-0 items-center justify-center rounded typography-micro font-semibold text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]","aria-label":l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),title:l(i.actionSymbol==="+"?"gitView.changes.stageDirectoryAria":"gitView.changes.unstageDirectoryAria",{path:n.path}),children:i.actionSymbol})]})},[j,o,f,t,l,L]),B=S.useCallback((i,n)=>{if(i.type==="revert-all")return s.jsx("div",{className:J("flex justify-end py-2",le),children:s.jsxs(Z,{variant:"ghost",size:"sm",onClick:()=>N(!0),disabled:o,className:"gap-1.5 text-[var(--status-error)] hover:bg-[var(--status-error)]/10 hover:text-[var(--status-error)]",children:[s.jsx($,{name:"arrow-go-back",className:"size-3.5"}),l("gitView.changes.revertAll")]})});const a=y[i.groupIndex];if(!a)return null;if(i.type==="header")return G(a,n);if(i.type==="directory")return O(a,i.directory,i.depth);const c=i.file;return s.jsx(He,{file:c,actionLabel:a.getActionLabel(c.path),actionSymbol:a.actionSymbol,onAction:()=>a.onActionFile(c.path),stats:e?.[c.path],onViewDiff:()=>a.onViewDiff(c.path),onRevert:()=>a.onRevertFile(c.path),isReverting:t.has(c.path)||o,rowPaddingClassName:le,indentPx:i.depth*je,actionAtStart:!g,showRevert:a.showRevertActions!==!1})},[e,o,g,O,G,t,l,y]),q=S.useCallback(i=>{const n=C[i],a=C[i-1];return!n||!a||n.type!=="file"&&n.type!=="directory"||a.type!=="file"&&a.type!=="directory"?!1:a.groupIndex===n.groupIndex},[C]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex h-full min-h-0 w-full flex-col overflow-hidden",children:[s.jsx(Ee,{ref:d,className:"overlay-scrollbar-target overlay-scrollbar-container min-h-0 w-full flex-1 overflow-x-hidden overflow-y-auto",children:A?s.jsx("div",{style:{height:T.getTotalSize(),position:"relative"},children:u.map(i=>{const n=C[i.index];return n?s.jsx("div",{"data-index":i.index,ref:T.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${i.start}px)`},className:J(q(i.index)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(n,i.index===0)},n.key):null})}):s.jsx("div",{role:"list","aria-label":l("gitView.changes.changedFilesAria"),children:C.map((i,n)=>s.jsx("div",{className:J("relative",q(n)&&"before:pointer-events-none before:absolute before:left-0 before:right-2 before:top-0 before:border-t before:border-border/60"),children:B(i,n===0)},i.key))})}),s.jsx(Te,{containerRef:d,disableHorizontal:!0})]}),s.jsx(pe,{open:w,onOpenChange:i=>{!o&&!i&&N(!1)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertAllDialogTitle")}),s.jsx(ye,{children:X===1?l("gitView.changes.revertAllDescriptionSingle",{count:X}):l("gitView.changes.revertAllDescriptionPlural",{count:X})})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>N(!1),disabled:o,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{Y()},disabled:o,children:l(o?"gitView.changes.reverting":"gitView.changes.revertAll")})]})]})}),s.jsx(pe,{open:!!h,onOpenChange:i=>{!I&&!i&&E(null)},children:s.jsxs(ge,{className:"max-w-md",children:[s.jsxs(xe,{children:[s.jsx(be,{children:l("gitView.changes.revertDirectoryDialogTitle")}),s.jsx(ye,{children:h?h.count===1?l("gitView.changes.revertDirectoryDescriptionSingle",{count:h.count,path:h.path}):l("gitView.changes.revertDirectoryDescriptionPlural",{count:h.count,path:h.path}):null})]}),s.jsxs(ve,{children:[s.jsx(Z,{variant:"outline",size:"sm",onClick:()=>E(null),disabled:I,children:l("gitView.common.cancel")}),s.jsx(Z,{variant:"destructive",size:"sm",onClick:()=>{K()},disabled:I||!h,children:l(I?"gitView.changes.reverting":"gitView.changes.revertDirectory")})]})]})})]})},he=38,ae=200,Ge=p=>{const e=oe.c(23),{value:t,onChange:o,onSubmit:x,placeholder:b,disabled:m,hasTouchInput:f,isMobile:l}=p,d=m===void 0?!1:m,z=f===void 0?!1:f,g=l===void 0?!1:l,{t:y}=Q(),V=S.useRef(null),H=Ce(Oe);let j;e[0]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{const u=V.current;if(!u)return;const P=document.activeElement===u,W=()=>{u.style.height=`${he}px`;const R=u.scrollHeight,X=Math.min(Math.max(R,he),ae);u.style.height=`${X}px`,u.style.overflowY=R>ae?"auto":"hidden",R>ae&&!P&&(u.scrollTop=u.scrollHeight)};W();const L=window.requestAnimationFrame(W);return()=>{window.cancelAnimationFrame(L)}},e[0]=j):j=e[0];let r;e[1]!==t?(r=[t],e[1]=t,e[2]=r):r=e[2],S.useLayoutEffect(j,r);let w;e[3]!==o?(w=u=>o(u.target.value),e[3]=o,e[4]=w):w=e[4];let N;e[5]!==x?(N=u=>{u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&!u.shiftKey&&!u.altKey&&(u.preventDefault(),x?.())},e[5]=x,e[6]=N):N=e[6];let h;e[7]!==b||e[8]!==y?(h=b??y("gitView.commit.messagePlaceholder"),e[7]=b,e[8]=y,e[9]=h):h=e[9];const E=z?"on":"off",F=z?"sentences":"off",M=g||H,C=d&&"opacity-50";let D;e[10]!==C?(D=J("w-full rounded-lg border border-border/60 bg-surface-elevated px-3 py-2 typography-ui-label text-foreground placeholder:text-muted-foreground","resize-none outline-none transition-[border-color,box-shadow] duration-150","focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",C),e[10]=C,e[11]=D):D=e[11];let A;e[12]===Symbol.for("react.memo_cache_sentinel")?(A={minHeight:he,maxHeight:ae},e[12]=A):A=e[12];let T;return e[13]!==d||e[14]!==F||e[15]!==M||e[16]!==D||e[17]!==w||e[18]!==N||e[19]!==h||e[20]!==E||e[21]!==t?(T=s.jsx("textarea",{ref:V,value:t,onChange:w,onKeyDown:N,placeholder:h,rows:1,disabled:d,autoCorrect:E,autoCapitalize:F,spellCheck:M,className:D,style:A}),e[13]=d,e[14]=F,e[15]=M,e[16]=D,e[17]=w,e[18]=N,e[19]=h,e[20]=E,e[21]=t,e[22]=T):T=e[22],T};function Oe(p){return p.inputSpellcheckEnabled}const Ke=p=>{const e=oe.c(30),{highlights:t,onInsert:o}=p,{t:x}=Q();if(t.length===0)return null;let b;e[0]!==t||e[1]!==o?(b=()=>{o(t)},e[0]=t,e[1]=o,e[2]=b):b=e[2];const m=b;let f;e[3]!==x?(f=x("gitView.commit.aiHighlights.title"),e[3]=x,e[4]=f):f=e[4];let l;e[5]!==f?(l=s.jsx("p",{className:"typography-micro text-muted-foreground",children:f}),e[5]=f,e[6]=l):l=e[6];let d;e[7]!==x?(d=x("gitView.commit.aiHighlights.insertAria"),e[7]=x,e[8]=d):d=e[8];let z;e[9]===Symbol.for("react.memo_cache_sentinel")?(z=s.jsx($,{name:"arrow-down",className:"size-4"}),e[9]=z):z=e[9];let g;e[10]!==m||e[11]!==d?(g=s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"ghost",size:"icon",className:"size-6",onClick:m,"aria-label":d,children:z})}),e[10]=m,e[11]=d,e[12]=g):g=e[12];let y;e[13]!==x?(y=x("gitView.commit.aiHighlights.insertTooltip"),e[13]=x,e[14]=y):y=e[14];let V;e[15]!==y?(V=s.jsx(ue,{sideOffset:8,children:y}),e[15]=y,e[16]=V):V=e[16];let H;e[17]!==g||e[18]!==V?(H=s.jsxs(fe,{children:[g,V]}),e[17]=g,e[18]=V,e[19]=H):H=e[19];let j;e[20]!==l||e[21]!==H?(j=s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l,H]}),e[20]=l,e[21]=H,e[22]=j):j=e[22];let r;e[23]!==t?(r=t.map(Be),e[23]=t,e[24]=r):r=e[24];let w;e[25]!==r?(w=s.jsx("ul",{className:"space-y-1",children:r}),e[25]=r,e[26]=w):w=e[26];let N;return e[27]!==j||e[28]!==w?(N=s.jsxs("div",{className:"space-y-2 rounded-xl border border-border/60 bg-transparent px-3 py-2",children:[j,w]}),e[27]=j,e[28]=w,e[29]=N):N=e[29],N};function Be(p,e){return s.jsx("li",{className:"typography-meta text-foreground",children:p},`${p}-${e}`)}const qe=p=>{const e=oe.c(80),{stagedCount:t,commitMessage:o,onCommitMessageChange:x,generatedHighlights:b,onInsertHighlights:m,onGenerateMessage:f,isGeneratingMessage:l,onCommit:d,onCommitAndPush:z,commitAction:g,hasPendingIndexMutation:y,gitmojiEnabled:V,onOpenGitmojiPicker:H}=p,j=y===void 0?!1:y,{t:r}=Q(),w=t>0;let N;e[0]!==g||e[1]!==o||e[2]!==j||e[3]!==w?(N=o.trim()&&w&&g===null&&!j,e[0]=g,e[1]=o,e[2]=j,e[3]=w,e[4]=N):N=e[4];const h=N,{isMobile:E,hasTouchInput:F}=Ie();let M;e[5]!==r?(M=r("gitView.commit.title"),e[5]=r,e[6]=M):M=e[6];let C;e[7]!==M?(C=s.jsx("h3",{className:"typography-ui-header font-semibold text-foreground",children:M}),e[7]=M,e[8]=C):C=e[8];let D;e[9]!==w||e[10]!==r?(D=w?null:s.jsx("span",{className:"min-w-0 truncate typography-meta text-muted-foreground",children:r("gitView.commit.stageFilesHint")}),e[9]=w,e[10]=r,e[11]=D):D=e[11];let A;e[12]!==C||e[13]!==D?(A=s.jsxs("div",{className:"flex w-full items-baseline gap-2 px-0 pt-2 pb-1",children:[C,D]}),e[12]=C,e[13]=D,e[14]=A):A=e[14];let T;e[15]!==b||e[16]!==m?(T=s.jsx(Ke,{highlights:b,onInsert:m}),e[15]=b,e[16]=m,e[17]=T):T=e[17];let u;e[18]!==h||e[19]!==l||e[20]!==d?(u=()=>{h&&!l&&d()},e[18]=h,e[19]=l,e[20]=d,e[21]=u):u=e[21];let P;e[22]!==r?(P=r("gitView.commit.messagePlaceholder"),e[22]=r,e[23]=P):P=e[23];const W=g!==null;let L;e[24]!==o||e[25]!==F||e[26]!==E||e[27]!==x||e[28]!==W||e[29]!==u||e[30]!==P?(L=s.jsx(Ge,{value:o,onChange:x,onSubmit:u,placeholder:P,disabled:W,hasTouchInput:F,isMobile:E}),e[24]=o,e[25]=F,e[26]=E,e[27]=x,e[28]=W,e[29]=u,e[30]=P,e[31]=L):L=e[31];let R;e[32]!==V||e[33]!==H||e[34]!==r?(R=V&&s.jsxs(Z,{variant:"outline",size:"sm",onClick:H,className:"w-fit",type:"button",children:[s.jsx($,{name:"emotion-happy",className:"size-4"}),r("gitView.commit.addGitmoji")]}),e[32]=V,e[33]=H,e[34]=r,e[35]=R):R=e[35];const X=l||g!==null||j||t===0;let I;e[36]!==r?(I=r("gitView.commit.generateAria"),e[36]=r,e[37]=I):I=e[37];let Y;e[38]!==l?(Y=l?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"ai-generate-2",className:"size-4 text-primary"}),e[38]=l,e[39]=Y):Y=e[39];let K;e[40]!==r?(K=r("gitView.commit.generate"),e[40]=r,e[41]=K):K=e[41];let G;e[42]!==K?(G=s.jsx("span",{className:"commit-actions__label",children:K}),e[42]=K,e[43]=G):G=e[43];let O;e[44]!==f||e[45]!==X||e[46]!==I||e[47]!==Y||e[48]!==G?(O=s.jsxs(Z,{variant:"outline",size:"sm",onClick:f,disabled:X,type:"button","aria-label":I,className:"commit-actions__btn",children:[Y,G]}),e[44]=f,e[45]=X,e[46]=I,e[47]=Y,e[48]=G,e[49]=O):O=e[49];let B;e[50]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsx("div",{className:"flex-1"}),e[50]=B):B=e[50];const q=!h||l;let i;e[51]!==r?(i=r("gitView.commit.commitAria"),e[51]=r,e[52]=i):i=e[52];let n;e[53]!==g||e[54]!==r?(n=g==="commit"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.committing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"git-commit",className:"size-4"}),s.jsx("span",{className:"commit-actions__label",children:r("gitView.commit.commit")})]}),e[53]=g,e[54]=r,e[55]=n):n=e[55];let a;e[56]!==d||e[57]!==q||e[58]!==i||e[59]!==n?(a=s.jsx(Z,{size:"sm",variant:"outline",onClick:d,disabled:q,className:"commit-actions__btn whitespace-nowrap","aria-label":i,children:n}),e[56]=d,e[57]=q,e[58]=i,e[59]=n,e[60]=a):a=e[60];let c;e[61]!==h||e[62]!==g||e[63]!==l||e[64]!==E||e[65]!==z||e[66]!==r?(c=E?s.jsxs(fe,{children:[s.jsx(me,{asChild:!0,children:s.jsx(Z,{variant:"default",size:"sm",onClick:()=>z(),disabled:!h||l,className:"h-7 w-7 p-0","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}):s.jsx($,{name:"arrow-up",className:"size-3.5"})})}),s.jsx(ue,{side:"top",children:s.jsx("p",{children:r("gitView.commit.push")})})]}):s.jsx(Z,{size:"sm",variant:"default",onClick:()=>z(),disabled:!h||l,className:"commit-actions__btn","aria-label":r("gitView.commit.pushAria"),children:g==="commitAndPush"?s.jsxs(s.Fragment,{children:[s.jsx($,{name:"loader-4",className:"size-4 animate-spin"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.pushing")})]}):s.jsxs(s.Fragment,{children:[s.jsx($,{name:"arrow-up",className:"size-3.5"}),s.jsx("span",{className:"commit-actions__label commit-actions__label--push",children:r("gitView.commit.push")})]})}),e[61]=h,e[62]=g,e[63]=l,e[64]=E,e[65]=z,e[66]=r,e[67]=c):c=e[67];let k;e[68]!==O||e[69]!==a||e[70]!==c?(k=s.jsxs("div",{className:"@container/commit-actions flex items-center gap-2 min-w-0",children:[O,B,a,c]}),e[68]=O,e[69]=a,e[70]=c,e[71]=k):k=e[71];let v;e[72]!==L||e[73]!==R||e[74]!==k||e[75]!==T?(v=s.jsxs("div",{className:"flex flex-col gap-3 px-0 pt-1 pb-3",children:[T,L,R,k]}),e[72]=L,e[73]=R,e[74]=k,e[75]=T,e[76]=v):v=e[76];let _;return e[77]!==v||e[78]!==A?(_=s.jsxs("section",{className:"border-0 bg-transparent rounded-none",children:[A,v]}),e[77]=v,e[78]=A,e[79]=_):_=e[79],_};export{Ye as C,qe as a};
@@ -0,0 +1,4 @@
1
+ import{R as o,j as n,f as be}from"./vendor-react-BUCujlKS.js";import{W as pn,a as at,u as te,F as Ge}from"./index-rlLjZUM5.js";import{f as we,V as Et,a9 as hn,bj as gn,ab as xn,aa as bn,ac as wn,ad as ae,y as vt,k as yn,hB as vn,hC as jn,hD as Sn,cw as Nn,t as Ke,hE as Fn,ak as Be,B as me,I as A,h as le,a4 as kn,a5 as Cn,a6 as Dn,ho as Bt,hF as Rn,fp as An,fu as $e,_ as En,bX as it,am as Vt,aj as Bn,aZ as Vn,a$ as Ln,fv as Tn,b0 as Mn}from"./useAppFontEffects-Cll4gnsh.js";import{c as _n,p as In}from"./vendor-zustand-BAGL70zf.js";import{P as On}from"./PierreDiffViewer-CGoI2v0q.js";import{u as zn,v as Pn,g as Gn,W as $n}from"./main-DLBxKIoX.js";import{f as Kn}from"./patchFileDiff-BCTsE43U.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-_6j2xOWl.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-CpzVNWAv.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-codemirror-state-C9awkmn-.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-codemirror-view-CiLROUVV.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DkQX2EBa.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./web-components-DLnGY4fs.js";import"./computeVirtualFileMetrics-Gi1d5eU1.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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"./VirtualizedFileDiff-CN_BctrR.js";import"./isDiffPlainText-pH9kAJQH.js";import"./vendor-diff-C3JhlQdm.js";import"./Virtualizer-D_a8gKmg.js";import"./useInlineCommentController-DFFv0hae.js";import"./runtimeEndpointReset-BDh7r8BL.js";import"./appThemeRegistry-BK0dHKa6.js";import"./registerCustomTheme-BBXUCRnG.js";import"./SessionSwitcherDropdown-CJTrc8K7.js";import"./scheduledTasksApi-CAGPh_gZ.js";import"./vendor-cron-parser-CUcP7OfX.js";import"./vendor-luxon-BZ0puJYg.js";const Wn="openchamber.git-base-branch",Hn=100,We=(s,e)=>JSON.stringify([at(),s,e]),jt=_n()(In((s,e)=>({overrides:{},getOverride:(i,a)=>!i||!a?null:e().overrides[We(i,a)]??null,setOverride:(i,a,d)=>{!i||!a||!d||s(f=>{const p=We(i,a),g=Object.entries({...f.overrides,[p]:d});for(;g.length>Hn;)g.shift();return{overrides:Object.fromEntries(g)}})},clearOverride:(i,a)=>{!i||!a||s(d=>{const f=We(i,a);if(!(f in d.overrides))return d;const p={...d.overrides};return delete p[f],{overrides:p}})}}),{name:Wn,storage:pn(),partialize:s=>({overrides:s.overrides})})),Un=(s,e)=>!!s&&e!==null&&s!==e,qn=(s,e,i,a)=>i?s===null||a&&e===null?!0:e!==null&&s===e:!1,Xn=(s,e)=>s==="branch"&&!e?"working":s,Jn=(s,e,i)=>JSON.stringify([s,e,i]),Yn=(s,e,i,a,d,f)=>{const p=o.useRef({directory:"",attempts:0}),[g,u]=o.useState(()=>({directory:"",exhausted:!1})),m=o.useRef(d);m.current=d;const x=!!s&&g.directory===s&&g.exhausted;return o.useEffect(()=>{if(!s||!e||a||i)return;const c=p.current.directory===s?p.current.attempts:0;if(c>=f){g.directory===s&&g.exhausted||u({directory:s,exhausted:!0});return}p.current={directory:s,attempts:c+1},m.current()},[s,g,a,e,i,f]),x},Qn=(s,e,i,a)=>{const[d,f]=o.useState(()=>new Map),p=o.useRef(d);p.current=d;const g=o.useRef(i);g.current=i;const u=o.useCallback((m,x)=>{const c=new Map(p.current);if(x===null){if(!c.delete(m))return}else c.set(m,x);p.current=c,f(c)},[]);return o.useEffect(()=>{s&&(p.current=new Map,f(p.current))},[s]),o.useEffect(()=>{const m=g.current;if(!s||!m||!e)return;let x=!1;const c=new Set;for(const v of e.split("\0"))p.current.has(v)||(c.add(v),u(v,a),m(v).then(S=>{x||(c.delete(v),u(v,S))}).catch(()=>{x||(c.delete(v),u(v,null))}));return()=>{x=!0;for(const v of c)u(v,null)}},[e,a,s,u]),d},St=(s,e)=>{if(e.length===0)return null;let i=null,a=null;for(const f of e)f.top<=s?(!i||f.top>i.top)&&(i=f):(!a||f.top<a.top)&&(a=f);const d=i??a;return d?{path:d.path,topOffset:d.top-s}:null},Zn=(s,e,i,a)=>Math.min(Math.max(0,a),Math.max(0,s+i-e)),Nt=s=>{if(!s)return null;const e=s.split(`
2
+ `);let i=null;for(const a of e){const d=a.match(/^@@\s*-\d+(?:,\d+)?\s+\+(\d+)(?:,\d+)?\s*@@/);if(d){const f=Number.parseInt(d[1]??"",10);i=Number.isFinite(f)&&f>=1?f:null;continue}if(i!==null){if(a.startsWith(" ")){i+=1;continue}if(a.startsWith("+"))return i;if(a.startsWith("-"))return Math.max(1,i)}}return null},es=1100,ts=15e3,Ft=500,kt=300,ns=1e6,ss=3,rs=s=>s<=6?s:s<=12?6:s<=25?4:2,is={original:"",modified:"",isBinary:!1,contextMode:"patch"},os=3,as=o.memo(()=>{const s=be.c(4),{t:e}=we();let i;s[0]!==e?(i=e("diffView.binary.unavailable"),s[0]=e,s[1]=i):i=s[1];let a;return s[2]!==i?(a=n.jsx("div",{className:"rounded-lg border border-border/60 bg-background px-3 py-2",children:n.jsx("div",{className:"typography-meta text-muted-foreground",children:i})}),s[2]=i,s[3]=a):a=s[3],a}),Lt={"?":{code:"?",color:"var(--status-info)",descriptionKey:"diffView.change.untracked"},A:{code:"A",color:"var(--status-success)",descriptionKey:"diffView.change.new"},D:{code:"D",color:"var(--status-error)",descriptionKey:"diffView.change.deleted"},R:{code:"R",color:"var(--status-info)",descriptionKey:"diffView.change.renamed"},C:{code:"C",color:"var(--status-info)",descriptionKey:"diffView.change.copied"},M:{code:"M",color:"var(--status-warning)",descriptionKey:"diffView.change.modified"}},ls=Lt.M,cs=s=>{const e=s.index?.trim(),i=s.working_dir?.trim();return e&&e!=="?"?e.charAt(0):i?i.charAt(0):e?.charAt(0)||i?.charAt(0)||"M"},Tt=s=>{const e=cs(s);return Lt[e]??ls},us=s=>{const{index:e,working_dir:i}=s;return e==="A"||i==="A"||e==="?"||i==="?"},Ct=s=>{const e=s.index?.trim();return!!(e&&e!=="?")},Dt=s=>!!s.working_dir?.trim()||s.index==="?",fs=(s,e)=>An(s,e),Rt=s=>(s||"").replace(/\\/g,"/").replace(/\/+$/,""),At=(s,e)=>{const i=s.split(`
3
+ `),a=e.split(`
4
+ `),d=Math.min(i.length,a.length);for(let f=0;f<d;f+=1)if(i[f]!==a[f])return f+1;return a.length>i.length?i.length+1:i.length>a.length?Math.max(1,a.length):1},ds=s=>/^Binary files .+ differ$/m.test(s)||/^GIT binary patch$/m.test(s),ms=s=>Array.isArray(s)?s.filter(e=>!e||typeof e!="object"?!1:typeof e.file=="string"):[],ps=s=>s==="added"?"A":s==="deleted"?"D":"M",ot=(s,e,i)=>ds(e)?{original:"",modified:"",isBinary:!0,patch:e,contextMode:i}:{original:"",modified:"",patch:e,fileDiff:Kn(s,e),contextMode:i},Mt=(s,e,i)=>{const a=s??0,d=e??0;return!a&&!d?null:n.jsxs("span",{className:le("typography-meta flex items-center gap-1 text-xs whitespace-nowrap","flex-shrink-0",i?.className),children:[a?n.jsxs("span",{style:{color:"var(--status-success)"},children:["+",a]}):null,d?n.jsxs("span",{style:{color:"var(--status-error)"},children:["-",d]}):null]})},hs=o.memo(s=>{const e=be.c(58),{scope:i,workingCount:a,stagedCount:d,turnCount:f,branchCount:p,showBranchOption:g,onScopeChange:u}=s,{t:m}=we(),[x,c]=o.useState(!1),v=i==="staged"?d:i==="turn"?f:i==="branch"?p??0:a;let S;e[0]!==i||e[1]!==m?(S=m(i==="staged"?"diffView.scope.staged":i==="turn"?"diffView.scope.lastTurn":i==="branch"?"diffView.scope.branch":"diffView.scope.changed"),e[0]=i,e[1]=m,e[2]=S):S=e[2];const O=S;let T;e[3]!==m?(T=m("diffView.scope.selectorAria"),e[3]=m,e[4]=T):T=e[4];let ne;e[5]!==v?(ne=n.jsxs("span",{className:"diff-toolbar__scope-count",children:[": ",v]}),e[5]=v,e[6]=ne):ne=e[6];let y;e[7]!==O||e[8]!==ne?(y=n.jsxs("span",{className:"whitespace-nowrap",children:[O,ne]}),e[7]=O,e[8]=ne,e[9]=y):y=e[9];let V;e[10]===Symbol.for("react.memo_cache_sentinel")?(V=n.jsx(A,{name:"arrow-down-s",className:"size-4 flex-shrink-0 opacity-60"}),e[10]=V):V=e[10];let M;e[11]!==T||e[12]!==y?(M=n.jsx(Vn,{asChild:!0,children:n.jsxs("button",{type:"button",className:"flex h-7 flex-shrink-0 items-center gap-1.5 rounded-md px-2 typography-ui-label font-semibold text-foreground outline-none hover:bg-interactive-hover focus-visible:ring-2 focus-visible:ring-ring","aria-label":T,children:[y,V]})}),e[11]=T,e[12]=y,e[13]=M):M=e[13];let q;e[14]!==u?(q=ie=>{(ie==="working"||ie==="staged"||ie==="turn"||ie==="branch")&&(u?.(ie),c(!1))},e[14]=u,e[15]=q):q=e[15];let X;e[16]!==m?(X=m("diffView.scope.changed"),e[16]=m,e[17]=X):X=e[17];let se;e[18]!==X?(se=n.jsx("span",{children:X}),e[18]=X,e[19]=se):se=e[19];let J;e[20]!==a?(J=n.jsx("span",{className:"typography-meta text-muted-foreground",children:a}),e[20]=a,e[21]=J):J=e[21];let Y;e[22]!==J||e[23]!==se?(Y=n.jsx($e,{value:"working",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[se,J]})}),e[22]=J,e[23]=se,e[24]=Y):Y=e[24];let C;e[25]!==m?(C=m("diffView.scope.staged"),e[25]=m,e[26]=C):C=e[26];let _;e[27]!==C?(_=n.jsx("span",{children:C}),e[27]=C,e[28]=_):_=e[28];let re;e[29]!==d?(re=n.jsx("span",{className:"typography-meta text-muted-foreground",children:d}),e[29]=d,e[30]=re):re=e[30];let L;e[31]!==_||e[32]!==re?(L=n.jsx($e,{value:"staged",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[_,re]})}),e[31]=_,e[32]=re,e[33]=L):L=e[33];let G;e[34]!==m?(G=m("diffView.scope.lastTurn"),e[34]=m,e[35]=G):G=e[35];let $;e[36]!==G?($=n.jsx("span",{children:G}),e[36]=G,e[37]=$):$=e[37];let E;e[38]!==f?(E=n.jsx("span",{className:"typography-meta text-muted-foreground",children:f}),e[38]=f,e[39]=E):E=e[39];let K;e[40]!==$||e[41]!==E?(K=n.jsx($e,{value:"turn",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[$,E]})}),e[40]=$,e[41]=E,e[42]=K):K=e[42];let Q;e[43]!==p||e[44]!==g||e[45]!==m?(Q=g?n.jsx($e,{value:"branch",children:n.jsxs("span",{className:"flex min-w-0 flex-1 items-center justify-between gap-3",children:[n.jsx("span",{children:m("diffView.scope.branch")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:p??"…"})]})}):null,e[43]=p,e[44]=g,e[45]=m,e[46]=Q):Q=e[46];let z;e[47]!==i||e[48]!==Y||e[49]!==L||e[50]!==K||e[51]!==Q||e[52]!==q?(z=n.jsx(Ln,{align:"start",className:"w-40",children:n.jsxs(Tn,{value:i,onValueChange:q,children:[Y,L,K,Q]})}),e[47]=i,e[48]=Y,e[49]=L,e[50]=K,e[51]=Q,e[52]=q,e[53]=z):z=e[53];let W;return e[54]!==x||e[55]!==z||e[56]!==M?(W=n.jsxs(Mn,{open:x,onOpenChange:c,children:[M,z]}),e[54]=x,e[55]=z,e[56]=M,e[57]=W):W=e[57],W}),gs=o.memo(s=>{const e=be.c(11),{changedFiles:i,selectedFile:a,onSelectFile:d}=s,{t:f}=we();if(i.length===0)return null;let p;if(e[0]!==i||e[1]!==d||e[2]!==a||e[3]!==f){let u;e[5]!==d||e[6]!==a||e[7]!==f?(u=m=>{const x=Tt(m),c=a===m.path;return n.jsx("li",{children:n.jsxs("button",{type:"button",onClick:()=>d(m.path),className:le("flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors",c?"bg-interactive-selection text-interactive-selection-foreground":"text-muted-foreground hover:bg-interactive-hover hover:text-foreground"),children:[n.jsx(Vt,{filePath:m.path,className:"h-3.5 w-3.5 flex-shrink-0"}),n.jsx("span",{className:"typography-micro font-semibold w-4 text-center uppercase",style:{color:x.color},title:f(x.descriptionKey),"aria-label":f(x.descriptionKey),children:x.code}),n.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},title:m.path,children:m.path}),Mt(m.insertions,m.deletions)]})},m.path)},e[5]=d,e[6]=a,e[7]=f,e[8]=u):u=e[8],p=i.map(u),e[0]=i,e[1]=d,e[2]=a,e[3]=f,e[4]=p}else p=e[4];let g;return e[9]!==p?(g=n.jsx(it,{outerClassName:"flex-1 min-h-0",className:"px-2 py-2",children:n.jsx("ul",{className:"flex flex-col gap-1",children:p})}),e[9]=p,e[10]=g):g=e[10],g}),xs=o.memo(s=>{const e=be.c(20),{filePath:i,diff:a,renderSideBySide:d}=s,{t:f}=we(),p=a.original.length>0,g=a.modified.length>0,u=d?"flex flex-row gap-6 items-start justify-center":"flex flex-col gap-4 items-center",m=d?"flex flex-col items-center gap-2 flex-1 min-w-0":"flex flex-col items-center gap-2";let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={contain:"layout"},e[0]=x):x=e[0];let c;e[1]!==a.original||e[2]!==i||e[3]!==p||e[4]!==m||e[5]!==d||e[6]!==f?(c=p&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f("diffView.image.original")}),n.jsx("img",{src:a.original,alt:f("diffView.image.originalAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[1]=a.original,e[2]=i,e[3]=p,e[4]=m,e[5]=d,e[6]=f,e[7]=c):c=e[7];let v;e[8]!==a.modified||e[9]!==i||e[10]!==g||e[11]!==p||e[12]!==m||e[13]!==d||e[14]!==f?(v=g&&n.jsxs("div",{className:m,children:[n.jsx("span",{className:"typography-meta text-muted-foreground font-medium",children:f(p?"diffView.image.modified":"diffView.image.new")}),n.jsx("img",{src:a.modified,alt:f("diffView.image.modifiedAlt",{path:i}),className:d?"max-w-full max-h-[70vh] object-contain":"max-w-full object-contain",style:{imageRendering:"auto"}})]}),e[8]=a.modified,e[9]=i,e[10]=g,e[11]=p,e[12]=m,e[13]=d,e[14]=f,e[15]=v):v=e[15];let S;return e[16]!==u||e[17]!==c||e[18]!==v?(S=n.jsx("div",{className:"w-full overflow-auto p-4",style:x,children:n.jsxs("div",{className:u,children:[c,v]})}),e[16]=u,e[17]=c,e[18]=v,e[19]=S):S=e[19],S}),bs=o.memo(s=>{const e=be.c(16),{filePath:i,diff:a,renderSideBySide:d,wrapLines:f}=s;let p;e[0]!==i?(p=Bn(i)||"text",e[0]=i,e[1]=p):p=e[1];const g=p;if(a.isBinary){let x;return e[2]===Symbol.for("react.memo_cache_sentinel")?(x=n.jsx(as,{}),e[2]=x):x=e[2],x}if(Be(i)){let x;return e[3]!==a||e[4]!==i||e[5]!==d?(x=n.jsx(xs,{filePath:i,diff:a,renderSideBySide:d}),e[3]=a,e[4]=i,e[5]=d,e[6]=x):x=e[6],x}let u;e[7]===Symbol.for("react.memo_cache_sentinel")?(u={contain:"layout"},e[7]=u):u=e[7];let m;return e[8]!==a.fileDiff||e[9]!==a.modified||e[10]!==a.original||e[11]!==i||e[12]!==g||e[13]!==d||e[14]!==f?(m=n.jsx("div",{className:"w-full",style:u,children:n.jsx(On,{original:a.original,modified:a.modified,fileDiff:a.fileDiff,language:g,fileName:i,renderSideBySide:d,wrapLines:f,layout:"inline"})}),e[8]=a.fileDiff,e[9]=a.modified,e[10]=a.original,e[11]=i,e[12]=g,e[13]=d,e[14]=f,e[15]=m):m=e[15],m}),ws=o.memo(s=>{const e=be.c(7),{filePath:i,staged:a,busyAction:d,disabled:f,onAction:p}=s,{t:g}=we();let u;return e[0]!==d||e[1]!==f||e[2]!==i||e[3]!==p||e[4]!==a||e[5]!==g?(u=n.jsx("div",{className:"flex items-center gap-0.5 rounded-full border border-[var(--interactive-border)]/45 bg-[var(--surface-background)]/95 px-1 py-0.5 shadow-sm backdrop-blur-md",children:a?n.jsx(rt,{label:g("gitView.changes.unstageFileAria",{path:i}),icon:"arrow-go-back",loading:d==="unstage",disabled:f,onClick:()=>p("unstage")}):n.jsxs(n.Fragment,{children:[n.jsx(rt,{label:g("gitView.changes.revertFileAria",{path:i}),icon:"arrow-go-back",loading:d==="discard",disabled:f,tone:"failure",onClick:()=>p("discard")}),n.jsx(rt,{label:g("gitView.changes.stageFileAria",{path:i}),icon:"add",loading:d==="stage",disabled:f,tone:"success",onClick:()=>p("stage")})]})}),e[0]=d,e[1]=f,e[2]=i,e[3]=p,e[4]=a,e[5]=g,e[6]=u):u=e[6],u}),rt=s=>{const e=be.c(14),{label:i,icon:a,loading:d,disabled:f,tone:p,onClick:g}=s,u=p==="failure"&&"text-[var(--status-error)] hover:text-[var(--status-error)]",m=p==="success"&&"text-[var(--status-success)] hover:text-[var(--status-success)]";let x;e[0]!==u||e[1]!==m?(x=le("h-6 w-6 rounded-none bg-transparent p-0 text-muted-foreground opacity-70 hover:bg-transparent hover:text-foreground hover:opacity-100",u,m),e[0]=u,e[1]=m,e[2]=x):x=e[2];let c;e[3]!==g?(c=O=>{O.stopPropagation(),g()},e[3]=g,e[4]=c):c=e[4];let v;e[5]!==a||e[6]!==d?(v=d?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:a,className:a==="add"?"size-4":"size-3.5"}),e[5]=a,e[6]=d,e[7]=v):v=e[7];let S;return e[8]!==f||e[9]!==i||e[10]!==x||e[11]!==c||e[12]!==v?(S=n.jsx(me,{variant:"ghost",size:"sm",className:x,disabled:f,title:i,"aria-label":i,onClick:c,children:v}),e[8]=f,e[9]=i,e[10]=x,e[11]=c,e[12]=v,e[13]=S):S=e[13],S},ys=o.memo(({directory:s,file:e,layout:i,wrapLines:a,isSelected:d,isExpanded:f,isMounted:p,onSelect:g,onExpandedChange:u,registerSectionRef:m,showOpenInEditorAction:x=!1,isOpeningInEditor:c=!1,onOpenInEditor:v,staged:S=!1,loadFullFiles:O=!1,initialDiffData:T=null,readOnlyActions:ne=!1})=>{const{t:y}=we(),{git:V}=Et(),M=ae(o.useCallback(w=>w.directories.get(s)?.diffCache.get(e.path)??null,[s,e.path])),q=ae(w=>w.setDiff),X=ae(w=>w.fetchStatus),se=te(w=>w.setDiffFileLayout),[J,Y]=o.useState(0),[C,_]=o.useState(null),[re,L]=o.useState(!1),[G,$]=o.useState(null),[E,K]=o.useState(!1),[Q,z]=o.useState(null),[W,ie]=o.useState(null),ce=o.useRef(null),Ce=o.useRef(null),pe=o.useMemo(()=>Tt(e),[e]),Ve=i==="side-by-side",ye=O?"full":"patch",he=`${e.index}:${e.working_dir}:${e.insertions}:${e.deletions}`,Z=o.useMemo(()=>T||(S?W:Q||(M?{original:M.original,modified:M.modified,isBinary:M.isBinary,contextMode:"full"}:null)),[M,T,Q,S,W]),De=Z?.contextMode===ye,b=o.useCallback(w=>{Ce.current=w,m(e.path,w)},[e.path,m]),ge=o.useCallback(w=>{u(e.path,w)},[e.path,u]),ue=o.useCallback(()=>{g(e.path)},[e.path,g]);o.useEffect(()=>{S?ie(null):z(null),_(null),ce.current=null},[he,S]),o.useEffect(()=>{if(!f||!p)return;if(!s||T||Z&&De){ce.current=null,L(!1);return}const w=`${s}::${e.path}::${S?"staged":"unstaged"}::${he}::${ye}::${J}`;if(ce.current===w)return;ce.current=w,_(null),L(!0);let D=!1;const de=at(),Le=O?ns:ss,Te=Be(e.path)?V.getGitFileDiff(s,{path:e.path,staged:S}):V.getGitDiff(s,{path:e.path,staged:S,contextLines:Le}),Me=ts,_e=new Promise((B,H)=>{setTimeout(()=>H(new Error(`Timed out after ${Me}ms`)),Me)});return Promise.race([Te,_e]).then(B=>{if(!D){if("diff"in B){const H=ot(e.path,B.diff,ye);S?ie(H):z(H)}else{const H={original:B.original??"",modified:B.modified??"",isBinary:B.isBinary,contextMode:"full"};S?ie(H):q(s,e.path,H,de)}L(!1)}}).catch(B=>{if(D)return;const H=B instanceof Error?B.message:String(B);_(H),L(!1)}),()=>{D=!0,ce.current===w&&(ce.current=null)}},[ye,Z,De,J,s,e.path,he,V,T,f,p,O,q,S]);const Re=o.useCallback(()=>{ge(!f),ue()},[ge,ue,f]),fe=o.useCallback(async w=>{if(!(!s||G!==null)){$(w);try{w==="stage"?await V.stageGitFile(s,e.path):w==="unstage"?await V.unstageGitFile(s,e.path):await V.revertGitFile(s,e.path,{scope:"working"}),Y(D=>D+1),await X(s,V)}catch(D){const de=w==="unstage"?"gitView.toast.unstageFileFailed":w==="stage"?"gitView.toast.stageFileFailed":"gitView.toast.revertFailed";Ke.error(D instanceof Error?D.message:y(de))}finally{$(D=>D===w?null:D)}}},[s,X,e.path,G,V,y]);return n.jsxs("div",{ref:b,className:"scroll-mt-9 border-b border-[var(--interactive-border)]/40 last:border-b-0",children:[n.jsx("div",{className:"sticky top-0 z-30 border-b border-[var(--interactive-border)]/35 bg-[var(--surface-elevated)]/90 backdrop-blur-md supports-[backdrop-filter]:bg-[var(--surface-elevated)]/80",children:n.jsxs("div",{role:"button",tabIndex:0,onClick:Re,onKeyDown:w=>{w.target===w.currentTarget&&(w.key==="Enter"||w.key===" ")&&(w.preventDefault(),Re())},className:le("cursor-pointer","group/header relative grid min-h-9 w-full min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 overflow-hidden px-3 py-2","bg-transparent","text-muted-foreground hover:text-foreground",d?"bg-[var(--interactive-selection)]/35":null),children:[n.jsx("div",{className:"absolute inset-0 pointer-events-none group-hover/header:bg-[var(--interactive-hover)]/50"}),n.jsxs("div",{className:"relative flex min-w-0 flex-1 items-center gap-2",children:[n.jsx("span",{className:"flex size-5 items-center justify-center opacity-70 group-hover/header:opacity-100",children:f?n.jsx(A,{name:"arrow-down-s",className:"size-4"}):n.jsx(A,{name:"arrow-right-s",className:"size-4"})}),n.jsx("span",{className:"typography-micro font-semibold leading-none w-4 text-center uppercase",style:{color:pe.color},title:y(pe.descriptionKey),"aria-label":y(pe.descriptionKey),children:pe.code}),n.jsx("span",{className:"min-w-0 flex-1 overflow-hidden typography-ui-label",title:e.path,children:n.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[n.jsx(Vt,{filePath:e.path,className:"h-3.5 w-3.5 flex-shrink-0 align-middle"}),(()=>{const w=e.path.lastIndexOf("/");if(w===-1)return n.jsx("span",{className:"block min-w-0 truncate typography-ui-label text-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:e.path});const D=e.path.slice(0,w),de=e.path.slice(w+1);return n.jsxs("span",{className:"flex min-w-0 items-baseline overflow-hidden",children:[n.jsx("span",{className:"min-w-0 truncate typography-ui-label text-muted-foreground",style:{direction:"rtl",textAlign:"left",unicodeBidi:"plaintext"},children:D}),n.jsxs("span",{className:"flex-shrink-0 typography-ui-label",children:[n.jsx("span",{className:"text-muted-foreground",children:"/"}),n.jsx("span",{className:"text-foreground",children:de})]})]})})()]})})]}),n.jsxs("div",{className:"relative flex shrink-0 items-center justify-self-end gap-2",children:[Mt(e.insertions,e.deletions),x&&v?n.jsx(me,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0 opacity-70 hover:opacity-100",title:y("diffView.actions.openFileInEditorAtChange"),onClick:w=>{w.stopPropagation(),v(e.path,Z)},disabled:c,children:c?n.jsx(A,{name:"loader-4",className:"size-3.5 animate-spin"}):n.jsx(A,{name:"edit",className:"size-3.5"})}):null,n.jsx(Bt,{mode:Ve?"side-by-side":"unified",onModeChange:w=>{const D=w==="side-by-side"?"side-by-side":"inline";se(e.path,D)},className:"opacity-70"})]})]})}),f&&n.jsxs("div",{className:"relative bg-background overflow-hidden",children:[!p&&!C?n.jsx("div",{className:"h-40 border border-border/40 bg-background/40"}):null,C?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.failedToLoadDiff")}),n.jsx("div",{className:"typography-meta text-muted-foreground max-w-[32rem] text-center",children:C}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>Y(w=>w+1),children:y("diffView.actions.retry")})]}):null,p&&re&&!Z&&!C?n.jsxs("div",{className:"flex items-center justify-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),y("diffView.state.loadingDiff")]}):null,p&&Z&&!E&&e.insertions+e.deletions>Ft?n.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-8 text-sm text-muted-foreground",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:y("diffView.state.largeDiff",{count:e.insertions+e.deletions})}),n.jsx("div",{className:"typography-meta text-muted-foreground",children:y("diffView.state.largeDiffDescription")}),n.jsx("button",{type:"button",className:"typography-ui-label text-primary hover:underline",onClick:()=>K(!0),children:y("diffView.actions.renderAnyway")})]}):null,p&&Z&&(E||e.insertions+e.deletions<=Ft)?n.jsxs(n.Fragment,{children:[n.jsx(bs,{filePath:e.path,diff:Z,renderSideBySide:Ve,wrapLines:a}),n.jsx("div",{className:"pointer-events-none absolute bottom-3 right-3 z-20",children:n.jsx("div",{className:"pointer-events-auto",children:ne?null:n.jsx(ws,{filePath:e.path,staged:S,busyAction:G,disabled:G!==null,onAction:fe})})})]}):null]})]})}),Mi=({hideStackedFileSidebar:s=!1,stackedDefaultCollapsedAll:e=!1,pinSelectedFileHeaderToTopOnNavigate:i=!1,showOpenInEditorAction:a=!1,diffScope:d="all",onDiffScopeChange:f,targetFilePath:p=null,flushContent:g=!1})=>{const{t:u}=we(),{git:m,files:x}=Et(),c=hn(),v=te(t=>t.openContextSurface),S=zn(t=>t.requestSource),{screenWidth:O,isMobile:T}=gn(),ne=xn(c??null),y=bn(c??null),V=wn(c??null),M=ae(t=>t.setActiveDirectory),q=ae(t=>t.ensureStatus),X=ae(t=>t.fetchStatus),se=ae(t=>t.fetchBranches),J=ae(t=>t.clearDiffCache),Y=ae(t=>t.setDiff),[C,_]=o.useState(null),[re,L]=o.useState(!1),[G,$]=o.useState(null),[E,K]=o.useState(()=>new Set),[Q,z]=o.useState(()=>new Set),[W,ie]=o.useState(!1),[ce,Ce]=o.useState(0),[pe,Ve]=o.useState(()=>new Map),[ye,he]=o.useState(!1),[Z,De]=o.useState(!1),[b,ge]=o.useState(d);o.useEffect(()=>{ge(d)},[d]);const ue=te(t=>t.pendingDiffFile),Re=te(t=>t.pendingDiffStaged),fe=te(t=>t.pendingDiffScope),w=te(t=>t.setPendingDiffFile),D=te(t=>t.diffLayoutPreference),de=te(t=>t.diffFileLayout),Le=te(t=>t.setDiffFileLayout),Te=te(t=>t.diffWrapLines),Me=te(t=>t.setDiffWrapLines),_e=te(t=>t.openContextFileAtLine),B=vt(t=>t.currentSessionId),H=yn(B??"",c??void 0),He=Te,Ue=b==="staged"?!0:b==="working"?!1:null,Ie=Ue??re,qe=T||O<=768,_t=!!B&&b!=="turn"&&!qe&&!Ge(),It=b!=="turn"&&!qe&&!Ge(),Ot=!s&&!qe&&O>=1024,ve=o.useRef(null),Ae=o.useRef(new Map),xe=o.useRef(null),P=o.useRef(null),je=o.useRef(!1),Se=o.useRef(null),lt=o.useRef(null),Xe=o.useRef(null),Je=o.useRef(null),ct=o.useCallback(()=>{const t=ve.current;if(!t)return null;const r=t.getBoundingClientRect().top,l=[];for(const[h,j]of Ae.current)j&&l.push({path:h,top:j.getBoundingClientRect().top});return St(r,l)},[]),Ne=o.useCallback(()=>{xe.current=null,je.current=!1,$(null),P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null)},[]),Fe=o.useCallback(t=>{K(r=>{if(r.has(t))return r;const l=new Set(r);return l.add(t),l})},[]),Ee=o.useMemo(()=>{for(let t=H.length-1;t>=0;t-=1){const r=H[t];if(r.role==="user")return ms(r.summary?.diffs)}return[]},[H]),zt=o.useMemo(()=>{const t=new Map;for(const r of Ee)if(r.file){if(typeof r.patch=="string"){t.set(r.file,ot(r.file,r.patch,"patch"));continue}t.set(r.file,{original:r.before??"",modified:r.after??"",contextMode:"full"})}return t},[Ee]),Pt=o.useMemo(()=>y?.files?y.files.filter(Dt).length:0,[y]),Gt=o.useMemo(()=>y?.files?y.files.filter(Ct).length:0,[y]),$t=Ee.length,k=y?.current??null,ke=ae(t=>c?t.directories.get(c)?.branches??null:null),Kt=ae(t=>c?t.directories.get(c)?.isLoadingBranches??!1:!1),Wt=o.useCallback(()=>{c&&se(c,m)},[c,se,m]),Ht=Yn(c??null,ne!==!1,Kt,!!ke,Wt,os),ut=o.useMemo(()=>{const t=y?.tracking?.trim().split("/")[0];return(t&&ke?.defaultBranches?.[t])??ke?.defaultBranches?.origin??null},[ke,y?.tracking]),Ye=!Ge()&&Un(k,ut),Ut=y!==null,ft=Ge()||Ht||qn(k,ut,Ut,ke!==null),qt=jt(t=>t.setOverride),Xt=jt(o.useCallback(t=>c&&k?t.overrides[We(c,k)]??null:null,[k,c])),[Jt,Qe]=o.useState(null),[Yt,Ze]=o.useState(!1),[dt,Qt]=o.useState("");o.useEffect(()=>{const t=Xn(b,!ft);t!==b&&(ge(t),t==="working"&&f?.("working"))},[b,ft,f]),o.useEffect(()=>{if(!Ye||!c||!k){Qe(null),Ze(!1);return}let t=!1;return Ze(!1),vn(c,k).then(r=>{t||Qe(r.base)}).catch(()=>{t||Qe(null)}).finally(()=>{t||Ze(!0)}),()=>{t=!0}},[k,c,Ye]);const oe=Xt??Jt,[Oe,mt]=o.useState(null),[pt,ht]=o.useState(null),ze=o.useRef(0),et=o.useCallback(()=>{if(!c||!k||!oe)return;const t=ze.current+1;ze.current=t,mt(null),ht(null),jn(c,{base:oe,head:k}).then(r=>{ze.current===t&&mt(r)}).catch(r=>{ze.current===t&&ht(r instanceof Error?r.message:u("diffView.branch.loadError"))})},[oe,k,c,u]);o.useEffect(()=>{b==="branch"&&et()},[b,et]);const gt=b==="branch"&&c&&k&&oe?Jn(c,oe,k):null,Zt=o.useMemo(()=>b==="branch"?Array.from(E).sort().join("\0"):"",[b,E]),en=o.useCallback(t=>!c||!oe||!k?Promise.reject(new Error("branch range is unavailable")):Sn(c,{base:oe,head:k,path:t}).then(r=>ot(t,r.diff,"patch")),[oe,k,c]),tn=Qn(gt,Zt,gt?en:null,is),nn=Oe?.length??null,N=o.useMemo(()=>{if(b==="branch")return(Oe??[]).map(l=>({path:l.path,index:"",working_dir:l.status,insertions:0,deletions:0,isNew:l.status==="A"})).sort((l,h)=>l.path.localeCompare(h.path));if(b==="turn")return Ee.map(l=>({path:l.file??"",index:"",working_dir:ps(l.status),insertions:l.additions??0,deletions:l.deletions??0,isNew:l.status==="added"})).filter(l=>l.path).sort((l,h)=>l.path.localeCompare(h.path));if(!y?.files)return[];const t=y.diffStats??{},r=b==="staged"?Ct:b==="working"?Dt:()=>!0;return y.files.filter(r).map(l=>({...l,insertions:t[l.path]?.insertions??0,deletions:t[l.path]?.deletions??0,isNew:us(l)})).sort((l,h)=>l.path.localeCompare(h.path))},[b,Oe,Ee,y]),tt=o.useMemo(()=>N.map(t=>t.path).join("\0"),[N]);o.useEffect(()=>{const t=tt?tt.split("\0"):[],r=new Set(t),l=`${c??""}:${b}:${e?"collapsed":"default"}`,h=lt.current!==l;lt.current=l,K(j=>{if(h){const R=e?0:rs(t.length);return new Set(t.slice(0,R))}let I=!1;const F=new Set;for(const R of j){if(!r.has(R)){I=!0;continue}F.add(R)}return I?F:j}),z(j=>{if(h)return new Set;let I=!1;const F=new Set;for(const R of j){if(!r.has(R)){I=!0;continue}F.add(R)}return I?F:j})},[b,tt,c,e]);const xt=o.useCallback(()=>{Se.current=null;const t=ve.current;if(!t)return;const r=t.getBoundingClientRect(),l=r.top-kt,h=r.bottom+kt,j={},I=[];for(const[F,R]of Ae.current){if(!R)continue;const U=R.getBoundingClientRect();I.push({path:F,top:U.top}),E.has(F)&&(U.bottom<l||U.top>h||(j[F]=!0))}Xe.current=St(r.top,I),z(F=>{let R=!1;const U=new Set(F);for(const yt of Object.keys(j))U.has(yt)||(U.add(yt),R=!0);return R?U:F})},[E]),ee=o.useCallback(()=>{typeof window>"u"||Se.current===null&&(Se.current=window.requestAnimationFrame(xt))},[xt]);o.useEffect(()=>{const t=ve.current;if(t)return ee(),t.addEventListener("scroll",ee,{passive:!0}),window.addEventListener("resize",ee),()=>{t.removeEventListener("scroll",ee),window.removeEventListener("resize",ee),Se.current!==null&&(window.cancelAnimationFrame(Se.current),Se.current=null)}},[N,E,ee]);const nt=o.useCallback(t=>{const r=de[t.path];if(r)return r;if(D==="inline")return"inline";if(D==="side-by-side")return"side-by-side";const l=O<es;return t.isNew||l?"inline":"side-by-side"},[de,D,O]),bt=o.useMemo(()=>N.length===0?null:N.every(t=>nt(t)==="side-by-side")?"side-by-side":"inline",[N,nt]);o.useEffect(()=>{c&&(M(c),q(c,m))},[c,M,q,m]),o.useEffect(()=>{if(c)return Nn.onGitRefreshHint(t=>{Rt(t.directory)===Rt(c)&&(t.paths?.length&&(Je.current=ct()??Xe.current,J(c,t.paths),Ve(r=>{const l=new Map(r);for(const h of t.paths??[])l.set(h,(l.get(h)??0)+1);return l})),X(c,m,{silent:!0}))})},[ct,J,c,X,m]),o.useLayoutEffect(()=>{const t=Je.current;if(!t)return;Je.current=null;const r=ve.current,l=Ae.current.get(t.path);if(!r||!l)return;const h=r.getBoundingClientRect().top,j=l.getBoundingClientRect().top-h;r.scrollTop=Zn(r.scrollTop,t.topOffset,j,r.scrollHeight-r.clientHeight),Xe.current=t},[pe]),o.useEffect(()=>{b!=="all"&&!fe||ue&&(fe&&ge(fe),_(ue),L(fe==="staged"||!fe&&Re),w(null),je.current=!0,xe.current=ue,Fe(ue),Ce(t=>t+1))},[b,Fe,ue,fe,Re,w]),o.useEffect(()=>{if(b==="all")return;const t=p?.trim();t&&(_(t),L(b==="staged"),je.current=!0,xe.current=t,Fe(t),Ce(r=>r+1))},[b,Fe,p]),o.useEffect(()=>{if(!C)return;N.some(r=>r.path===C)||(_(null),L(!1))},[N,C]);const sn=o.useCallback((t,r)=>{const l=Ae.current;r?l.set(t,r):l.delete(t),ee()},[ee]),rn=o.useCallback((t,r)=>{Ne(),K(l=>{const h=l.has(t);if(r===h)return l;const j=new Set(l);return r?j.add(t):j.delete(t),j}),r||z(l=>{if(!l.has(t))return l;const h=new Set(l);return h.delete(t),h}),ee()},[Ne,ee]),on=o.useCallback(()=>{Ne(),K(t=>t.size>0?new Set:new Set(N.map(r=>r.path))),z(new Set),ee()},[Ne,N,ee]),an=o.useCallback(async t=>{if(!B)return;const r=vt.getState().getDirectoryForSession(B)||c||"";if(!r){Ke.error(u("diffView.reviewDialog.toast.noSessionDirectory"));return}De(!0);try{await Fn({originalSessionID:B,directory:r,providerID:t.providerID,modelID:t.modelID,agent:t.agent||void 0,variant:t.variant||void 0,generateHandoff:t.generateHandoff,returnAfterHandoffRequest:t.generateHandoff,autoReview:t.autoReview}),he(!1)}catch(l){console.error("[review-flow] failed to start review flow",l),Ke.error(l instanceof Error?l.message:u("diffView.reviewDialog.toast.startFailed"))}finally{De(!1)}},[B,c,u]),Pe=o.useCallback(t=>{const r=Ae.current.get(t),l=ve.current;if(!r||!l)return!1;const h=r.getBoundingClientRect().top-l.getBoundingClientRect().top;return l.scrollTo({top:l.scrollTop+h,behavior:"auto"}),!0},[]);o.useEffect(()=>{if(!xe.current)return;let r=0;const l=20;let h=!1;const j=(F=!0)=>{h||(h=!0,xe.current=null,je.current=!1,F&&$(null),P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null))},I=()=>{if(h){P.current=null;return}const F=xe.current;if(!F){j(),P.current=null;return}if(!Pe(F)){r+=1,r<l?P.current=window.requestAnimationFrame(I):(j(),P.current=null);return}if(i&&je.current){$(F),j(!1);return}j()};return P.current=window.requestAnimationFrame(I),()=>{h=!0,P.current!==null&&(window.cancelAnimationFrame(P.current),P.current=null)}},[i,ce,Pe]);const ln=o.useCallback(t=>{},[]),st=o.useCallback(t=>{Ne(),_(t),L(!1),je.current=!0,xe.current=t,Fe(t),Ce(r=>r+1),Pe(t)},[Ne,Fe,Pe]);o.useEffect(()=>{const t=r=>{if(!r.altKey||r.metaKey||r.ctrlKey||r.shiftKey||r.key!=="ArrowDown"&&r.key!=="ArrowUp")return;const l=r.target;if(l instanceof HTMLElement&&(l.isContentEditable||l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.closest('[role="dialog"]'))||N.length===0)return;const h=r.key==="ArrowDown"?1:-1,j=C?N.findIndex(R=>R.path===C):-1,I=j===-1?h>0?0:N.length-1:j+h,F=N[I];F&&(r.preventDefault(),st(F.path))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[N,C,st]);const cn=o.useCallback(t=>{const r=t==="side-by-side"?"side-by-side":"inline";N.forEach(l=>{Le(l.path,r)})},[N,Le]),[un,wt]=o.useState(null),fn=o.useCallback(async(t,r)=>{if(!c||!t)return;wt(t);const l=at();try{let h=null;if(r?.patch&&!r.isBinary&&!Be(t)?h=Nt(r.patch):r&&r.contextMode==="full"&&!r.isBinary&&!Be(t)&&(h=At(r.original,r.modified)),h===null)try{const U=await m.getGitDiff(c,{path:t,staged:Ie,contextLines:3});h=Nt(U.diff)}catch{h=null}let j=r;if(h===null||!j){const U=await m.getGitFileDiff(c,{path:t,staged:Ie});j={original:U.original??"",modified:U.modified??"",isBinary:U.isBinary},Ie||Y(c,t,j,l)}const I=h??(j.isBinary||Be(t)?1:At(j.original,j.modified)),F=fs(c,t),R=await Pn(x,F,{directory:c});if(!R.ok){Ke.error(Gn(R.reason));return}_e(c,F,I,1)}finally{wt(h=>h===t?null:h)}},[Ie,c,x,m,_e,Y]),dn=()=>{if(!c)return null;const t=r=>Ue!==null?Ue:re&&r===C;return n.jsxs("div",{className:le("flex min-w-0 flex-1 min-h-0 h-full",g?"gap-0":"gap-3 px-3 pb-3 pt-2"),children:[Ot&&n.jsxs("section",{className:"hidden lg:flex w-72 flex-col rounded-xl border border-border/60 bg-background/70 overflow-hidden",children:[n.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/40",children:[n.jsx("span",{className:"typography-ui-header font-semibold text-foreground",children:u("diffView.section.files")}),n.jsx("span",{className:"typography-meta text-muted-foreground",children:N.length})]}),n.jsx(gs,{changedFiles:N,selectedFile:null,onSelectFile:st})]}),n.jsx("div",{className:"relative flex-1 min-w-0 min-h-0 h-full",children:n.jsx(it,{ref:ve,outerClassName:"min-h-0 h-full",className:"[overflow-anchor:none] pb-16",disableHorizontal:!0,observeMutations:!1,preventOverscroll:!0,"data-diff-virtual-root":!0,children:n.jsx("div",{className:"flex flex-col [overflow-anchor:none]","data-diff-virtual-content":!0,children:N.map(r=>n.jsx(ys,{directory:c,file:r,layout:nt(r),wrapLines:He,isSelected:!1,isExpanded:E.has(r.path),isMounted:Q.has(r.path)||r.path===G,onSelect:ln,onExpandedChange:rn,registerSectionRef:sn,showOpenInEditorAction:a&&b!=="turn",isOpeningInEditor:un===r.path,onOpenInEditor:(l,h)=>{fn(l,h)},staged:t(r.path),loadFullFiles:W,readOnlyActions:b==="branch",initialDiffData:b==="turn"?zt.get(r.path)??null:b==="branch"?tn.get(r.path)??null:null},`${r.path}:${pe.get(r.path)??0}`))})})})]})},mn=()=>{if(!c)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.selectSessionDirectory")});if(b!=="turn"&&V&&!y)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.state.loadingRepositoryStatus")]});if(b!=="turn"&&ne===!1)return n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:u("diffView.state.notGitRepository")});if(b==="branch"){if(!Yt)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.resolvingBase")]});if(!oe){const t=(ke?.all??[]).map(l=>l.replace(/^remotes\//,"")).filter(l=>l!==k&&!l.endsWith(`/${k}`)).sort(),r=En(t,dt,l=>[l]);return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx(A,{name:"git-branch",className:"size-6 text-muted-foreground"}),n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.noBaseTitle")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:u("diffView.branch.noBaseDescription")}),n.jsx("input",{type:"text",value:dt,onChange:l=>Qt(l.target.value),placeholder:u("gitView.branch.searchPlaceholder"),"aria-label":u("gitView.branch.searchPlaceholder"),className:"w-full max-w-sm rounded-md border border-border/60 bg-[var(--surface-elevated)] px-2.5 py-1.5 typography-meta text-foreground outline-none placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]"}),n.jsx(it,{outerClassName:"max-h-48 w-full max-w-sm min-h-0",className:"px-1 py-1",children:r.length===0?n.jsx("div",{className:"px-2 py-3 typography-meta text-muted-foreground",children:u("gitView.branch.empty")}):n.jsx("div",{className:"flex flex-col gap-0.5",children:r.map(l=>n.jsxs("button",{type:"button",onClick:()=>c&&k&&qt(c,k,l),className:"flex items-center gap-2 rounded-md px-2 py-1.5 text-left hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]",children:[n.jsx(A,{name:"git-branch",className:"size-3.5 text-primary"}),n.jsx("span",{className:"truncate typography-ui-label text-foreground",title:l,children:l})]},l))})})]})}if(pt)return n.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center",children:[n.jsx("div",{className:"typography-ui-label font-semibold text-foreground",children:u("diffView.branch.loadError")}),n.jsx("div",{className:"max-w-sm typography-micro text-muted-foreground",children:pt}),n.jsx(me,{variant:"outline",size:"sm",onClick:()=>et(),children:u("diffView.actions.retry")})]});if(Oe===null)return n.jsxs("div",{className:"flex flex-1 items-center justify-center gap-2 text-sm text-muted-foreground",children:[n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}),u("diffView.branch.loadingFiles")]})}return N.length===0?n.jsx("div",{className:"flex flex-1 items-center justify-center text-sm text-muted-foreground",children:b==="turn"?u("diffView.state.noLastTurnChanges"):b==="branch"&&oe?u("diffView.branch.empty",{base:oe}):u("diffView.state.cleanWorkingTree")}):dn()};return n.jsxs("div",{className:"flex h-full flex-col overflow-hidden bg-background",children:[n.jsxs("div",{className:"@container/diff-toolbar flex min-w-0 items-center gap-2 px-3 py-2 bg-background",children:[!T&&(b==="working"||b==="staged"||b==="turn"||b==="branch"?n.jsx(hs,{scope:b,workingCount:Pt,stagedCount:Gt,turnCount:$t,branchCount:nn,showBranchOption:Ye,onScopeChange:t=>{ge(t),f?.(t)}}):n.jsx("div",{className:"flex items-center gap-1 rounded-md px-2 py-1 text-muted-foreground shrink-0",children:n.jsx("span",{className:"typography-ui-label font-semibold text-foreground",children:V&&!y?u("diffView.state.loadingChanges"):N.length===1?u("diffView.summary.changedFilesSingle",{count:N.length}):u("diffView.summary.changedFilesPlural",{count:N.length})})})),N.length>0&&n.jsxs(me,{variant:"ghost",size:"sm",onClick:on,className:le("diff-toolbar__expand-button h-7 flex-shrink-0 gap-1 px-1.5 text-muted-foreground hover:text-foreground","ml-auto"),title:E.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll"),children:[n.jsx(A,{name:"expand-up-down",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__expand-label typography-ui-label",children:E.size>0?u("diffView.actions.collapseAll"):u("diffView.actions.expandAll")})]}),N.length>0&&_t&&n.jsxs(me,{variant:"default",size:"sm",onClick:()=>he(!0),disabled:Z,className:"diff-toolbar__review-button h-7 flex-shrink-0 gap-1.5 px-2","aria-label":u("diffView.actions.reviewAria"),children:[Z?n.jsx(A,{name:"loader-4",className:"size-4 animate-spin"}):n.jsx(A,{name:"search-eye",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__review-label typography-ui-label",children:u("diffView.actions.review")})]}),N.length>0&&It&&n.jsxs(me,{variant:"outline",size:"sm",onClick:()=>{const t=c??"";S(t,{kind:"working-tree",scope:b==="staged"||b==="working"?b:"all"}),v(t,"walkthrough")},className:le("diff-toolbar__walkthrough-button h-7 flex-shrink-0 gap-1.5 px-2",$n),"aria-label":u("walkthrough.action.open"),children:[n.jsx(A,{name:"route",className:"size-4"}),n.jsx("span",{className:"diff-toolbar__walkthrough-label typography-ui-label",children:u("walkthrough.action.open")})]}),N.length>0&&n.jsxs(kn,{children:[n.jsx(Cn,{asChild:!0,children:n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>ie(t=>!t),"aria-pressed":W,"aria-label":u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles"),className:le("h-7 w-7 flex-shrink-0 p-0 text-muted-foreground hover:text-foreground",W&&"bg-interactive-selection text-interactive-selection-foreground"),children:n.jsx(A,{name:"file-download",className:"size-4"})})}),n.jsx(Dn,{children:n.jsx("p",{children:u(W?"diffView.actions.disableFullFiles":"diffView.actions.loadFullFiles")})})]}),N.length>0&&n.jsx(me,{variant:"ghost",size:"sm",onClick:()=>Me(!Te),className:le("h-5 w-5 p-0 transition-opacity",He?"text-foreground opacity-100":"text-muted-foreground opacity-60 hover:opacity-100"),title:u(He?"diffView.actions.disableLineWrap":"diffView.actions.enableLineWrap"),children:n.jsx(A,{name:"text-wrap",className:"size-4"})}),bt&&n.jsx(Bt,{mode:bt==="side-by-side"?"side-by-side":"unified",onModeChange:cn})]}),n.jsx(Rn,{open:ye,onOpenChange:he,projectDirectory:c??null,submitting:Z,onConfirm:an}),mn()]})};export{Mi as DiffView};
@@ -0,0 +1,17 @@
1
+ import{f as pt,R as r,c as gr,j as s,r as en}from"./vendor-react-BUCujlKS.js";import{Q as Xi,R as Ji,S as Yi,T as Zi,ak as xr,n as Ke,u as ht,cY as Qi,C as vr,w as ea,r as wr,V as br,e as ta,cW as sa,aK as na,cX as ra,a as ia}from"./index-rlLjZUM5.js";import{f as ts,y as yr,a9 as $r,bL as aa,h as U,he as oa,f9 as la,S as Ss,B as z,V as ca,L as ua,bj as da,aa as fa,c1 as ma,hf as jr,hg as ha,gL as pa,t as G,l as Fr,aj as tn,bY as ys,cw as ga,b as xa,hh as sn,by as va,ak as Nr,hi as Cr,bZ as Sr,b_ as wa,f_ as ba,hj as ya,hk as ja,hl as Fa,bz as Wr,bA as _r,bB as Ur,bC as Kr,bD as Gr,bE as Hr,I as w,b0 as ln,aZ as cn,am as Fs,a$ as un,aY as Ns,bX as nn,al as rn,bT as kr,a4 as zt,a5 as Lt,a6 as It,bw as Na,bx as Ca,g as ks,a_ as Sa,b6 as ka}from"./useAppFontEffects-Cll4gnsh.js";import{Q as Ra,v as Va,w as Ta,x as Da,y as Pa,z as Ea}from"./runtimeEndpointReset-BDh7r8BL.js";import{c as Rr,s as Ma,C as Vr,P as an}from"./shikiHighlight-BgTPSITe.js";import{a as za}from"./vendor-codemirror-state-C9awkmn-.js";import{E as jt}from"./vendor-codemirror-view-CiLROUVV.js";import{J as La,F as Ia}from"./JsonTreeView-osju7J70.js";import{ensurePierreThemeRegistered as Tr,getResolvedShikiTheme as Aa}from"./appThemeRegistry-BK0dHKa6.js";import{V as Oa,W as Ba}from"./Virtualizer-CZlLSacm.js";import{V as $a}from"./Virtualizer-D_a8gKmg.js";import{u as js,c as Wa,e as _a}from"./scheduledTasksApi-CAGPh_gZ.js";import{D as Ua}from"./vendor-react-drawio-Ct3Q0DsD.js";import{I as Ka,u as Ga,n as Ha}from"./useInlineCommentController-DFFv0hae.js";import{b as qa}from"./CodeMirrorCommentWidgets-C2BopIs3.js";import"./vendor-scheduler-7OC5HNn7.js";import"./vendor-vite-runtime-DD1OZmLC.js";import"./vendor-zustand-BAGL70zf.js";import"./vendor-zod-BLfBSgBh.js";import"./vendor-opencode-sdk-BJ73u-bH.js";import"./vendor-simplewebauthn-browser-VDA66rT_.js";import"./vendor-base-ui-_6j2xOWl.js";import"./vendor-floating-ui-utils-BzXdqYpP.js";import"./vendor-floating-ui-react-dom-DKpLs02S.js";import"./vendor-floating-ui-dom-WyXykhNi.js";import"./vendor-floating-ui-core-CXmKXOXc.js";import"./vendor-use-sync-external-store-D6wYuSt-.js";import"./contextPanelEmbeddedChat-CpzVNWAv.js";import"./vendor-class-variance-authority-5VPnzWs2.js";import"./vendor-clsx-B-dksMZM.js";import"./vendor-dnd-kit-core-BZknOX2w.js";import"./vendor-dnd-kit-utilities-B_MdXhJC.js";import"./vendor-dnd-kit-accessibility-BHxJPORy.js";import"./vendor-dnd-kit-sortable-CsEagZ81.js";import"./vendor-framer-motion-livSKyyV.js";import"./vendor-motion-dom-D_o3BTI3.js";import"./vendor-motion-utils-BGh8QBgx.js";import"./vendor-tanstack-react-virtual-g05Cx3z9.js";import"./vendor-tanstack-virtual-core-Dubg10g5.js";import"./vendor-sonner-DFyL3AvE.js";import"./vendor-cmdk-DgLInKvT.js";import"./vendor-radix-ui-react-dialog-B94Bt2qq.js";import"./vendor-radix-ui-primitive-Dc_FVRD7.js";import"./vendor-radix-ui-react-compose-refs-DcAh5WdT.js";import"./vendor-radix-ui-react-context-Czxm7Z62.js";import"./vendor-radix-ui-react-id-f5BLKEVw.js";import"./vendor-radix-ui-react-use-layout-effect-D_3IhJdJ.js";import"./vendor-radix-ui-react-use-controllable-state-BFT5YmkA.js";import"./vendor-radix-ui-react-dismissable-layer-D7kXcwgJ.js";import"./vendor-radix-ui-react-primitive-DhVoX9SD.js";import"./vendor-radix-ui-react-slot-BQgQOasS.js";import"./vendor-radix-ui-react-use-callback-ref-BZPnuXAC.js";import"./vendor-radix-ui-react-use-escape-keydown-oph88g-F.js";import"./vendor-radix-ui-react-focus-scope-CiaxW4dD.js";import"./vendor-radix-ui-react-portal-BMJYHWck.js";import"./vendor-radix-ui-react-presence-CNxf-uq4.js";import"./vendor-radix-ui-react-focus-guards-B6qJXYua.js";import"./vendor-react-remove-scroll-DO7dCTnK.js";import"./vendor-tslib-De9GV7Vy.js";import"./vendor-react-remove-scroll-bar-BcFYyj3E.js";import"./vendor-react-style-singleton-q6EMHnwf.js";import"./vendor-get-nonce-C-Z93AgS.js";import"./vendor-use-sidecar-zDC0RhA3.js";import"./vendor-use-callback-ref-D3RC8gqK.js";import"./vendor-aria-hidden-DvXkyWUv.js";import"./vendor-codemirror-language-BgPj_McA.js";import"./vendor-lezer-common-B3-cUCR_.js";import"./vendor-lezer-highlight-CDMHUZ74.js";import"./vendor-style-mod-NZ5MEPvj.js";import"./vendor-codemirror-lang-javascript-Cc2ZYbgX.js";import"./vendor-lezer-javascript-D7Tj24ot.js";import"./vendor-lezer-lr-bhwg1HMg.js";import"./vendor-codemirror-autocomplete-DzPz9Wgq.js";import"./vendor-marijn-find-cluster-break-DXwl3gUT.js";import"./vendor-w3c-keyname-Vcq4gwWv.js";import"./vendor-crelt-C8TCjufn.js";import"./vendor-codemirror-lang-json-CMBS2tG9.js";import"./vendor-lezer-json-Iaex0UN-.js";import"./vendor-codemirror-lang-css-O0cZX78y.js";import"./vendor-lezer-css-C5xB6jxd.js";import"./vendor-codemirror-lang-html-CfgK872x.js";import"./vendor-lezer-html-C0I1p52t.js";import"./vendor-codemirror-lang-markdown-BPGOH9ye.js";import"./vendor-lezer-markdown-C6g-d6P3.js";import"./vendor-codemirror-language-data-DkQX2EBa.js";import"./vendor-codemirror-lang-python-HahnQaAS.js";import"./vendor-lezer-python-CvuFxeZl.js";import"./vendor-codemirror-commands-B7H_j0iU.js";import"./vendor-legendapp-list-gg7YLRW7.js";import"./vendor-tailwind-merge-CPcsbTWB.js";import"./vendor-fuse.js-Dw8P0qyA.js";import"./vendor-codemirror-search-BmS-GmcX.js";import"./vendor-replit-codemirror-vim-B2DJlAhT.js";import"./vendor-replit-codemirror-vim-core-FHzKdNUS.js";import"./web-components-DLnGY4fs.js";import"./computeVirtualFileMetrics-Gi1d5eU1.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-BmJyTmjJ.js";import"./vendor-pierre-theming-C6Z4M5_u.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"./isFilePlainText-CVKy_dgB.js";import"./registerCustomTheme-BBXUCRnG.js";function Dr(a){const e=pt.c(41),{containerRef:n,filePath:d,fileContent:g}=a,{t:x}=ts(),y=yr(so),b=yr(to),h=$r(),F=aa(eo),[p,C]=r.useState(null),[S,V]=r.useState(""),[j,D]=r.useState(!1),o=r.useRef(!1),L=r.useRef(null),$=r.useRef(null),[H,I]=r.useState(null);let T;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=()=>{C(null),V(""),D(!1),o.current=!1,$.current=null,I(null)},e[0]=T):T=e[0];const k=T;let Z,X;e[1]!==n?(Z=()=>{const M=n.current;if(!M)return;const W=()=>{if(o.current)return;const ne=window.getSelection(),Se=ne?.toString().trim()??"";if(!ne||!Se||ne.rangeCount===0){k();return}const ie=ne.getRangeAt(0);if(!M.contains(ie.commonAncestorContainer)){k();return}const ae=ie.getBoundingClientRect();$.current=ie.cloneRange(),V(Se),C({x:ae.left+ae.width/2,y:ae.top-10})},se=ne=>{L.current?.contains(ne.target)||o.current&&k()};return document.addEventListener("selectionchange",W),document.addEventListener("pointerdown",se),()=>{document.removeEventListener("selectionchange",W),document.removeEventListener("pointerdown",se)}},X=[n,k],e[1]=n,e[2]=Z,e[3]=X):(Z=e[2],X=e[3]),r.useEffect(Z,X);let J;e[4]!==g?(J=M=>{const W=de=>g.slice(0,de).split(`
2
+ `).length,se=Za,ne=(de,Te)=>{for(const De of se(de)){const ke=g.indexOf(De,Te);if(ke>=0)return ke}return-1},Se=M.length>=8?g.indexOf(M):-1;if(Se>=0){const de=W(Se);return{start:de,end:de+M.split(`
3
+ `).length-1}}const ie=M.split(`
4
+ `).map(Ya).filter(Boolean);if(ie.length===0)return null;const ae=ne(ie[0],0);if(ae<0)return null;const ye=W(ae);if(ie.length===1)return{start:ye,end:ye};const Ve=ne(ie[ie.length-1],ae);return Ve<0?null:{start:ye,end:Math.max(ye,W(Ve))}},e[4]=g,e[5]=J):J=e[5];const P=J;let Q;e[6]===Symbol.for("react.memo_cache_sentinel")?(Q=()=>{const M=$.current;if(!M){I(null);return}I(oa(M))},e[6]=Q):Q=e[6];const Ne=Q;let K,q;e[7]!==j?(K=()=>{if(!j)return;let M=null;const W=()=>{M===null&&(M=window.requestAnimationFrame(()=>{M=null,Ne()}))};return document.addEventListener("scroll",W,{capture:!0,passive:!0}),window.addEventListener("resize",W),()=>{M!==null&&window.cancelAnimationFrame(M),document.removeEventListener("scroll",W,{capture:!0}),window.removeEventListener("resize",W)}},q=[j,Ne],e[7]=j,e[8]=K,e[9]=q):(K=e[8],q=e[9]),r.useEffect(K,q);let ee;e[10]!==S?(ee=()=>{S&&(D(!0),o.current=!0,Ne(),window.getSelection()?.removeAllRanges())},e[10]=S,e[11]=ee):ee=e[11];const le=ee;let te;e[12]!==F||e[13]!==y||e[14]!==h||e[15]!==d||e[16]!==b||e[17]!==P||e[18]!==S?(te=M=>{const W=y??(b?"draft":null);if(!S||!W||!h){k();return}const se=P(S);F({directory:h,sessionKey:W},{source:"file-quote",fileLabel:d,startLine:se?.start??0,endLine:se?.end??0,code:S,language:"",text:M.trim()}),k(),queueMicrotask(Ja)},e[12]=F,e[13]=y,e[14]=h,e[15]=d,e[16]=b,e[17]=P,e[18]=S,e[19]=te):te=e[19];const Ce=te;if(!p)return null;let E;e[20]!==j||e[21]!==P||e[22]!==S?(E=j?P(S):null,e[20]=j,e[21]=P,e[22]=S,e[23]=E):E=e[23];const ve=E;let we;e[24]!==p.x||e[25]!==p.y?(we={left:p.x,top:p.y,transform:"translate(-50%, -100%)"},e[24]=p.x,e[25]=p.y,e[26]=we):we=e[26];let ce;e[27]!==j||e[28]!==H?(ce=j&&H&&H.length>0?gr.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-40",children:H.map(Xa)}),document.body):null,e[27]=j,e[28]=H,e[29]=ce):ce=e[29];let ue;e[30]!==j||e[31]!==d||e[32]!==ve||e[33]!==le||e[34]!==Ce||e[35]!==x?(ue=j?s.jsx("div",{className:"w-[min(420px,80vw)]",children:s.jsx(Ka,{fileLabel:d,lineRange:ve?{start:ve.start,end:ve.end}:void 0,onSave:Ce,onCancel:k})}):s.jsx("div",{className:U("flex items-center whitespace-nowrap","oc-glass-popover rounded-full border border-[var(--interactive-border)]","shadow-[0_4px_16px_-4px_rgb(0_0_0_/_0.12)]","p-1"),children:s.jsx("button",{type:"button",onClick:le,className:U("px-3.5 py-1.5 rounded-full","text-sm font-medium","text-[var(--surface-foreground)]","hover:bg-[var(--interactive-hover)]","transition-colors duration-150"),title:x("chat.textSelection.title.commentOnSelection"),children:x("chat.textSelection.actions.comment")})}),e[30]=j,e[31]=d,e[32]=ve,e[33]=le,e[34]=Ce,e[35]=x,e[36]=ue):ue=e[36];let be;return e[37]!==we||e[38]!==ce||e[39]!==ue?(be=gr.createPortal(s.jsxs("div",{ref:L,className:"fixed z-50",style:we,children:[ce,ue]}),document.body),e[37]=we,e[38]=ce,e[39]=ue,e[40]=be):be=e[40],be}function Xa(a,e){return s.jsx("div",{className:"oc-chat-comment-rect absolute",style:{left:a.left,top:a.top,width:a.width,height:a.height}},e)}function Ja(){la()}function Ya(a){return a.trim()}function Za(a){const e=a.trim();return[e,e.slice(0,32),e.split(" ").slice(0,4).join(" ")].filter(Qa)}function Qa(a){return a.length>=8}function eo(a){return a.addDraft}function to(a){return a.newSessionDraft?.open}function so(a){return a.currentSessionId}const no=(a,e)=>{if(!e)return null;const n=Number.parseInt(a.trim(),10);return!Number.isFinite(n)||n<1?null:Math.min(n,e.state.doc.lines)},Pr=(a,e)=>{const n=a.state.doc.lineAt(e.main.head);return{lineNumber:n.number,character:e.main.head-n.from+1,selection:e}},Er=(a,e,n)=>{const d=a.state.doc.line(e),g=Math.max(1,Math.min(n,d.length+1)),x=d.from+g-1;a.dispatch({selection:za.cursor(x),effects:jt.scrollIntoView(x,{y:"center"})})};function ro({open:a,onOpenChange:e,view:n,variant:d="overlay"}){const{t:g}=ts(),[x,y]=r.useState(""),b=r.useRef(null),h=r.useRef(!1),F=r.useRef(null),p=r.useRef(null),C=r.useMemo(()=>no(x,n),[x,n]);r.useEffect(()=>{!a||!n||(h.current=!1,b.current=Pr(n,n.state.selection),y(""))},[a,n]),r.useEffect(()=>{a&&window.requestAnimationFrame(()=>{p.current?.focus(),p.current?.select()})},[a]),r.useEffect(()=>{if(!(!a||!n||!b.current)){if(C===null){const{selection:o}=b.current;n.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})});return}Er(n,C,b.current.character)}},[C,a,n]);const S=r.useCallback(()=>{if(!n||h.current||!b.current)return;const{selection:o}=b.current;n.dispatch({selection:o,effects:jt.scrollIntoView(o.main.from,{y:"center"})})},[n]),V=r.useCallback(o=>{o||S(),e(o)},[e,S]),j=r.useCallback(()=>{!n||C===null||!b.current||(h.current=!0,Er(n,C,b.current.character),e(!1),n.focus())},[C,e,n]);r.useEffect(()=>{if(!a)return;const o=$=>{const H=F.current,I=$.target;!H||!(I instanceof Node)||H.contains(I)||V(!1)},L=$=>{$.key==="Escape"&&($.preventDefault(),V(!1))};return document.addEventListener("pointerdown",o,!0),document.addEventListener("keydown",L,!0),()=>{document.removeEventListener("pointerdown",o,!0),document.removeEventListener("keydown",L,!0)}},[V,a,d]);const D=r.useMemo(()=>{if(!n)return g("goToLineDialog.helper.editorUnavailable");if(C===null){const o=b.current??Pr(n,n.state.selection);return g("goToLineDialog.helper.currentLineRange",{current:o.lineNumber,max:n.state.doc.lines})}return g("goToLineDialog.helper.goToLine",{line:C})},[C,g,n]);return d==="inline"?a?s.jsxs("div",{ref:F,className:"ml-1 flex h-6 items-center gap-1",children:[s.jsx(Ss,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:g("goToLineDialog.field.linePlaceholderShort"),className:"h-6 w-20 rounded-md border-border/70 bg-transparent px-2 typography-meta"}),s.jsx(z,{variant:"outline",size:"xs",onClick:j,disabled:!n||C===null,className:"h-6 px-2",children:g("goToLineDialog.actions.go")})]}):null:s.jsx("div",{ref:F,className:U("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",a?"pointer-events-auto translate-y-0 opacity-100":"pointer-events-none -translate-y-1 opacity-0"),children:s.jsxs("div",{className:"min-w-0",children:[s.jsx(Ss,{ref:p,type:"number",min:1,step:1,inputMode:"numeric",value:x,onChange:o=>y(o.target.value),onKeyDown:o=>{o.key==="Enter"&&(o.preventDefault(),j())},placeholder:g("goToLineDialog.field.linePlaceholder"),className:"h-8 w-full rounded-md border-border/70 bg-background/60 typography-ui-label"}),s.jsx("div",{className:"mt-2 rounded-md bg-primary/15 px-3 py-1.5 typography-ui-label text-foreground/95",children:D})]})})}function Mr(){const a=pt.c(8),[e]=en.useState(io),n=en.useRef(!1);let d;a[0]!==e?(d=h=>{if(h==null){e.cleanUp(),n.current=!1;return}n.current||(n.current=!0,e.setup(h,h.firstElementChild??void 0))},a[0]=e,a[1]=d):d=a[1];const g=d;let x,y;a[2]!==e?(x=()=>()=>{n.current=!1,e.cleanUp()},y=[e],a[2]=e,a[3]=x,a[4]=y):(x=a[3],y=a[4]),en.useLayoutEffect(x,y);let b;return a[5]!==g||a[6]!==e?(b={virtualizer:e,setScroller:g},a[5]=g,a[6]=e,a[7]=b):b=a[7],b}function io(){return new $a}function ao(a){return!(!a.autoSaveEnabled||!a.isDirty||!a.canWrite||a.isSaving||a.fileLoading||a.isNonEditableBinary||!a.selectedFilePath||a.loadedFilePath!==a.selectedFilePath)}function oo(a){return a.selectedFilePath?a.isDirty?!(a.fileLoading||a.loadedFilePath!==a.selectedFilePath||a.isNonEditableBinary||a.draftContent===""&&a.fileContent!==""&&a.loadedFilePath!==a.selectedFilePath):!0:!1}const lo='<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 zr(){if(typeof document>"u")return!1;const a=document.documentElement.getAttribute("data-theme");return a==="dark"||!a&&window.matchMedia("(prefers-color-scheme: dark)").matches}const co=r.forwardRef(function({xml:e,readOnly:n,className:d,onChange:g},x){const y=r.useRef(e),b=r.useRef(null),h=r.useRef(!1),[F,p]=r.useState(zr),C=r.useRef(e),S=r.useRef(e);S.current!==e&&(S.current=e,C.current=e,y.current=e);const V=r.useRef(F);V.current!==F&&(V.current=F,C.current=y.current);const j=r.useRef(null);r.useEffect(()=>{const L=()=>p(zr());L();const $=new MutationObserver(L);return $.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>$.disconnect()},[]),r.useEffect(()=>{const L=setTimeout(()=>{j.current?.querySelector(".diagrams-iframe")?.focus()},600);return()=>clearTimeout(L)},[]),r.useImperativeHandle(x,()=>({getXml:()=>y.current}));const D=r.useCallback(()=>{!e&&!h.current&&(h.current=!0,setTimeout(()=>{b.current?.template({})},500))},[e]),o=r.useCallback(L=>{y.current=L.xml,g?.(L.xml)},[g]);return s.jsx("div",{ref:j,className:U("h-full w-full",d),children:s.jsx(Ua,{ref:b,xml:C.current||lo,autosave:!0,urlParameters:{ui:n?"simple":F?"dark":"kennedy",spin:!0,libraries:!n,chrome:n,nav:n,layers:n,noSaveBtn:!0,noExitBtn:!0,saveAndExit:!1},onLoad:D,onAutoSave:o},F?"dark":"light")})}),uo=a=>{const e=B(a);if(!e)return"";if(e==="/"||/^[A-Za-z]:\/$/.test(e))return e;const n=e.lastIndexOf("/");if(n<0)return e;if(n===0)return"/";const d=e.slice(0,n);return/^[A-Za-z]:$/.test(d)?`${d}/`:d},fo=a=>{const e=pt.c(8),{label:n,iconDataUrl:d}=a,[g,x]=r.useState(!1);let y;e[0]!==n?(y=n.trim().slice(0,1).toUpperCase()||"?",e[0]=n,e[1]=y):y=e[1];const b=y;if(d&&!g){let p;e[2]===Symbol.for("react.memo_cache_sentinel")?(p=()=>x(!0),e[2]=p):p=e[2];let C;return e[3]!==d?(C=s.jsx("img",{src:d,alt:"",className:"size-4 rounded-sm",onError:p}),e[3]=d,e[4]=C):C=e[4],C}let h;e[5]===Symbol.for("react.memo_cache_sentinel")?(h=U("size-4 rounded-sm flex items-center justify-center","bg-[var(--surface-muted)] text-[9px] font-medium text-muted-foreground"),e[5]=h):h=e[5];let F;return e[6]!==b?(F=s.jsx("span",{className:h,children:b}),e[6]=b,e[7]=F):F=e[7],F},mo=a=>a.slice().sort((e,n)=>e.type!==n.type?e.type==="directory"?-1:1:e.name.localeCompare(n.name)),B=a=>{if(!a)return"";const e=a.replace(/\\/g,"/"),n=e.startsWith("//");let d=e.replace(/\/+/g,"/");n&&!d.startsWith("//")&&(d=`/${d}`);const g=d==="/",x=/^[A-Za-z]:\/$/.test(d);return!g&&!x&&(d=d.replace(/\/+$/,"")),d},ho=a=>a.startsWith("/")||a.startsWith("//")||/^[A-Za-z]:\//.test(a),Ot=a=>/^[A-Za-z]:\//.test(a)?a.toLowerCase():a,Rs=(a,e)=>{const n=B(e),d=B(a);if(!n||!d)return!1;const g=Ot(n),x=Ot(d);return x===g||x.startsWith(`${g}/`)},Lr=(a,e)=>{const n=B(e),d=B(a);if(!Rs(d,n))return[];const x=d.slice(n.length).replace(/^\//,"").split("/"),y=[];let b=n;for(let h=0;h<x.length-1;h++)b=b?`${b}/${x[h]}`:x[h],y.push(b);return y},Cs=(a,e)=>{if(!e)return"";const n=B(e);if(!a||!Rs(n,a))return n;const d=n.slice(a.length);return d.startsWith("/")?d.slice(1):d},po=new Set(["node_modules"]),go=a=>{const e=pt.c(3),{status:n}=a;let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={open:"var(--status-info)",modified:"var(--status-warning)","git-modified":"var(--status-warning)","git-added":"var(--status-success)","git-deleted":"var(--status-error)"},e[0]=d):d=e[0];const g=d[n];let x;return e[1]!==g?(x=s.jsx("span",{className:"size-2 rounded-full",style:{backgroundColor:g}}),e[1]=g,e[2]=x):x=e[2],x},Ir=a=>{const e=pt.c(11),{name:n}=a,d=r.useRef(null),g=r.useRef(null),[x,y]=r.useState(!1);let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{const S=d.current,V=g.current;if(!S||!V)return;const j=()=>{y(V.scrollWidth>S.clientWidth+1)};j();const D=new ResizeObserver(j);return D.observe(S),D.observe(V),()=>{D.disconnect()}},e[0]=b):b=e[0];let h;e[1]!==n?(h=[n],e[1]=n,e[2]=h):h=e[2],r.useLayoutEffect(b,h);let F;e[3]!==n?(F=s.jsx("span",{ref:g,"aria-hidden":"true",className:"invisible absolute whitespace-nowrap",children:n}),e[3]=n,e[4]=F):F=e[4];let p;e[5]!==n||e[6]!==x?(p=x?s.jsxs("span",{className:"open-file-name-marquee-track",children:[s.jsx("span",{className:"open-file-name-marquee-item",children:n}),s.jsx("span",{className:"open-file-name-marquee-item","aria-hidden":"true",children:n})]}):s.jsx("span",{className:"block min-w-0 truncate",children:n}),e[5]=n,e[6]=x,e[7]=p):p=e[7];let C;return e[8]!==F||e[9]!==p?(C=s.jsxs("span",{ref:d,className:"relative block min-w-0 flex-1 overflow-hidden whitespace-nowrap",children:[F,p]}),e[8]=F,e[9]=p,e[10]=C):C=e[10],C},xo=a=>po.has(a),vo=a=>{const e=B(a);return e==="node_modules"||e.endsWith("/node_modules")||e.includes("/node_modules/")},wo=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("is a directory")||n.includes("eisdir")},Ar=a=>{const n=(a instanceof Error?a.message:String(a??"")).toLowerCase();return n.includes("file not found")||n.includes("enoent")||n.includes("no such file")||n.includes("does not exist")},At=2e5;function bo(a){const e=a.length>400?`${a.slice(0,200)}${a.slice(-200)}`:a;let n=2166136261;for(let d=0;d<e.length;d+=1)n^=e.charCodeAt(d),n=n+((n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24))>>>0;return`${a.length}:${n.toString(16)}`}const yo=a=>{let e=0,n=0;for(let d=0;d<a.length;d+=1)a.charCodeAt(d)===10&&(d>0&&a.charCodeAt(d-1)===13?e+=1:n+=1);return e>n?`\r
5
+ `:`
6
+ `},qr=a=>a.replace(/\r\n/g,`
7
+ `).replace(/\r/g,`
8
+ `),jo=(a,e)=>{const n=qr(a);return e===`\r
9
+ `?n.replace(/\n/g,`\r
10
+ `):n},Xr=(a,e)=>s.jsx(Fs,{filePath:a,extension:e}),Or=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="md"||e==="markdown"},Fo=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="json"||e==="jsonc"||e==="json5"||e==="geojson"},on=a=>{if(!a)return!1;const e=a.toLowerCase().split(".").pop();return e==="html"||e==="htm"},No=a=>{const e=pt.c(76),{node:n,root:d,isExpanded:g,isActive:x,isMobile:y,isBrowserClient:b,alwaysShowActions:h,status:F,badge:p,permissions:C,downloadFile:S,contextMenuPath:V,setContextMenuPath:j,rightClickMenuPath:D,setRightClickMenuPath:o,onSelect:L,onToggle:$,onRevealPath:H,onOpenDialog:I}=a,{t:T}=ts(),k=n.type==="directory",{canRename:Z,canCreateFile:X,canCreateFolder:J,canDelete:P,canReveal:Q}=C,Ne=!k&&!!S,K=Q&&!b,q=Z||X||J||P||Ne||K;let ee;e[0]!==q||e[1]!==n.path||e[2]!==o?(ee=fe=>{q&&(fe?.preventDefault(),o(n.path))},e[0]=q,e[1]=n.path,e[2]=o,e[3]=ee):ee=e[3];const le=ee;let te;e[4]!==k||e[5]!==n||e[6]!==L||e[7]!==$?(te=()=>{k?$(n.path):L(n)},e[4]=k,e[5]=n,e[6]=L,e[7]=$,e[8]=te):te=e[8];const Ce=te;let E;e[9]!==n.path||e[10]!==j||e[11]!==o?(E=fe=>{fe.stopPropagation(),o(null),j(n.path)},e[9]=n.path,e[10]=j,e[11]=o,e[12]=E):E=e[12];const ve=E;let we;e[13]!==X||e[14]!==J||e[15]!==P||e[16]!==Z||e[17]!==K||e[18]!==S||e[19]!==b||e[20]!==k||e[21]!==n||e[22]!==I||e[23]!==H||e[24]!==d||e[25]!==T?(we=fe=>{const{Item:pe,Separator:Ze}=fe;return s.jsxs(s.Fragment,{children:[Z&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("rename",n)},children:[s.jsx(w,{name:"edit",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.rename")]}),s.jsxs(pe,{onClick:_=>{_.stopPropagation(),ks(n.path).then(it=>{if(it.ok){G.success(T("sidebarFilesTree.toast.pathCopied"));return}G.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(w,{name:"file-copy",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.copyPath")]}),s.jsxs(pe,{onClick:_=>{_.stopPropagation();const it=Cs(d,n.path)||n.path;ks(it).then(me=>{if(me.ok){G.success(T("filesView.toast.relativePathCopied"));return}G.error(T("sidebarFilesTree.toast.copyFailed"))})},children:[s.jsx(w,{name:"file-copy-2",className:"mr-2 size-4"})," ",T("filesView.tree.menu.copyRelativePath")]}),!k&&S&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),S(n.path).catch(it=>{console.error("Download failed:",it),G.error(T("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"})," ",T(b?"sidebarFilesTree.menu.download":"sidebarFilesTree.menu.save")]}),K&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),H(n.path)},children:[s.jsx(w,{name:"folder-received",className:"mr-2 size-4"})," ",T(ka())]}),k&&(X||J)&&s.jsxs(s.Fragment,{children:[s.jsx(Ze,{}),X&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("createFile",n)},children:[s.jsx(w,{name:"file-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFile")]}),J&&s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("createFolder",n)},children:[s.jsx(w,{name:"folder-add",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.newFolder")]})]}),P&&s.jsxs(s.Fragment,{children:[s.jsx(Ze,{}),s.jsxs(pe,{onClick:_=>{_.stopPropagation(),I("delete",n)},className:"text-destructive focus:text-destructive",children:[s.jsx(w,{name:"delete-bin",className:"mr-2 size-4"})," ",T("sidebarFilesTree.menu.delete")]})]})]})},e[13]=X,e[14]=J,e[15]=P,e[16]=Z,e[17]=K,e[18]=S,e[19]=b,e[20]=k,e[21]=n,e[22]=I,e[23]=H,e[24]=d,e[25]=T,e[26]=we):we=e[26];const ce=we,ue=D===n.path;let be;e[27]!==n.path||e[28]!==o?(be=fe=>o(fe?n.path:null),e[27]=n.path,e[28]=o,e[29]=be):be=e[29];const M=y?void 0:le;let W;e[30]!==M?(W=s.jsx("div",{className:"group relative flex items-center",onContextMenu:M}),e[30]=M,e[31]=W):W=e[31];const se=y?void 0:le,ne=x?"bg-interactive-selection/70":"hover:bg-interactive-hover/40";let Se;e[32]!==ne?(Se=U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors pr-8 select-none",ne),e[32]=ne,e[33]=Se):Se=e[33];let ie;e[34]!==k||e[35]!==g||e[36]!==n.extension||e[37]!==n.path?(ie=k?g?s.jsx(w,{name:"folder-open",className:"size-4 flex-shrink-0 text-muted-foreground"}):s.jsx(w,{name:"folder-3",className:"size-4 flex-shrink-0 text-muted-foreground"}):Xr(n.path,n.extension),e[34]=k,e[35]=g,e[36]=n.extension,e[37]=n.path,e[38]=ie):ie=e[38];let ae;e[39]!==n.name||e[40]!==n.path?(ae=s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",title:n.path,children:n.name}),e[39]=n.name,e[40]=n.path,e[41]=ae):ae=e[41];let ye;e[42]!==k||e[43]!==F?(ye=!k&&F&&s.jsx(go,{status:F}),e[42]=k,e[43]=F,e[44]=ye):ye=e[44];let Ve;e[45]!==p||e[46]!==k?(Ve=k&&p&&s.jsxs("span",{className:"text-xs flex items-center gap-1 ml-auto mr-1",children:[p.modified>0&&s.jsxs("span",{className:"text-[var(--status-warning)]",children:["M",p.modified]}),p.added>0&&s.jsxs("span",{className:"text-[var(--status-success)]",children:["+",p.added]})]}),e[45]=p,e[46]=k,e[47]=Ve):Ve=e[47];let de;e[48]!==Ce||e[49]!==Se||e[50]!==ie||e[51]!==ae||e[52]!==ye||e[53]!==Ve||e[54]!==se?(de=s.jsxs("button",{type:"button",onClick:Ce,onContextMenu:se,className:Se,children:[ie,ae,ye,Ve]}),e[48]=Ce,e[49]=Se,e[50]=ie,e[51]=ae,e[52]=ye,e[53]=Ve,e[54]=se,e[55]=de):de=e[55];let Te;e[56]!==h||e[57]!==V||e[58]!==ve||e[59]!==q||e[60]!==y||e[61]!==n.path||e[62]!==ce||e[63]!==j?(Te=q&&s.jsx("div",{className:U("absolute right-1 top-1/2 -translate-y-1/2",h?"opacity-100":"opacity-0 focus-within:opacity-100 group-hover:opacity-100"),children:s.jsxs(ln,{open:V===n.path,onOpenChange:fe=>j(fe?n.path:null),children:[s.jsx(cn,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"icon",className:"size-6",onClick:ve,children:s.jsx(w,{name:"more-2-fill",className:"size-4"})})}),s.jsx(un,{align:"end",side:"bottom",onCloseAutoFocus:()=>j(null),children:ce({Item:Ns,Separator:Sa})})]})}),e[56]=h,e[57]=V,e[58]=ve,e[59]=q,e[60]=y,e[61]=n.path,e[62]=ce,e[63]=j,e[64]=Te):Te=e[64];let De;e[65]!==de||e[66]!==Te||e[67]!==W?(De=s.jsxs(Pa,{render:W,children:[de,Te]}),e[65]=de,e[66]=Te,e[67]=W,e[68]=De):De=e[68];let ke;e[69]!==ce?(ke=s.jsx(Va,{className:"min-w-[180px]",children:ce({Item:Da,Separator:Ta})}),e[69]=ce,e[70]=ke):ke=e[70];let Y;return e[71]!==De||e[72]!==ke||e[73]!==ue||e[74]!==be?(Y=s.jsxs(Ea,{open:ue,onOpenChange:be,children:[De,ke]}),e[71]=De,e[72]=ke,e[73]=ue,e[74]=be,e[75]=Y):Y=e[75],Y},Co=a=>{const e=pt.c(83),{activeDialog:n,dialogData:d,dialogInputValue:g,onDialogInputChange:x,isDialogSubmitting:y,onDialogSubmit:b,onClose:h,inputRef:F}=a,{t:p}=ts(),C=!!n;let S;e[0]!==h?(S=E=>!E&&h(),e[0]=h,e[1]=S):S=e[1];let V;e[2]!==n||e[3]!==p?(V=n==="createFile"&&p("filesView.dialog.createFile.title"),e[2]=n,e[3]=p,e[4]=V):V=e[4];let j;e[5]!==n||e[6]!==p?(j=n==="createFolder"&&p("filesView.dialog.createFolder.title"),e[5]=n,e[6]=p,e[7]=j):j=e[7];let D;e[8]!==n||e[9]!==p?(D=n==="rename"&&p("filesView.dialog.rename.title"),e[8]=n,e[9]=p,e[10]=D):D=e[10];let o;e[11]!==n||e[12]!==p?(o=n==="delete"&&p("filesView.dialog.delete.title"),e[11]=n,e[12]=p,e[13]=o):o=e[13];let L;e[14]!==V||e[15]!==j||e[16]!==D||e[17]!==o?(L=s.jsxs(Kr,{children:[V,j,D,o]}),e[14]=V,e[15]=j,e[16]=D,e[17]=o,e[18]=L):L=e[18];let $;e[19]!==n||e[20]!==d?.path||e[21]!==p?($=n==="createFile"&&p("filesView.dialog.createFile.description",{path:d?.path??p("filesView.dialog.rootFallback")}),e[19]=n,e[20]=d?.path,e[21]=p,e[22]=$):$=e[22];let H;e[23]!==n||e[24]!==d?.path||e[25]!==p?(H=n==="createFolder"&&p("filesView.dialog.createFolder.description",{path:d?.path??p("filesView.dialog.rootFallback")}),e[23]=n,e[24]=d?.path,e[25]=p,e[26]=H):H=e[26];let I;e[27]!==n||e[28]!==d?.name||e[29]!==p?(I=n==="rename"&&p("filesView.dialog.rename.description",{name:d?.name??""}),e[27]=n,e[28]=d?.name,e[29]=p,e[30]=I):I=e[30];let T;e[31]!==n||e[32]!==d?.name||e[33]!==p?(T=n==="delete"&&p("filesView.dialog.delete.description",{name:d?.name??""}),e[31]=n,e[32]=d?.name,e[33]=p,e[34]=T):T=e[34];let k;e[35]!==I||e[36]!==T||e[37]!==$||e[38]!==H?(k=s.jsxs(Gr,{children:[$,H,I,T]}),e[35]=I,e[36]=T,e[37]=$,e[38]=H,e[39]=k):k=e[39];let Z;e[40]!==k||e[41]!==L?(Z=s.jsxs(Ur,{children:[L,k]}),e[40]=k,e[41]=L,e[42]=Z):Z=e[42];let X;e[43]!==n||e[44]!==g||e[45]!==F||e[46]!==x||e[47]!==b||e[48]!==p?(X=n!=="delete"&&s.jsx("div",{className:"py-4",children:s.jsx(Ss,{value:g,onChange:E=>x(E.target.value),placeholder:p(n==="rename"?"filesView.dialog.rename.placeholder":"filesView.dialog.namePlaceholder"),onKeyDown:E=>{E.key==="Enter"&&b()},ref:F})}),e[43]=n,e[44]=g,e[45]=F,e[46]=x,e[47]=b,e[48]=p,e[49]=X):X=e[49];let J;e[50]!==p?(J=p("filesView.dialog.cancel"),e[50]=p,e[51]=J):J=e[51];let P;e[52]!==y||e[53]!==h||e[54]!==J?(P=s.jsx(z,{variant:"outline",onClick:h,disabled:y,children:J}),e[52]=y,e[53]=h,e[54]=J,e[55]=P):P=e[55];const Q=n==="delete"?"destructive":"default";let Ne;e[56]!==b?(Ne=()=>{b()},e[56]=b,e[57]=Ne):Ne=e[57];let K;e[58]!==n||e[59]!==g||e[60]!==y?(K=y||n!=="delete"&&!g.trim(),e[58]=n,e[59]=g,e[60]=y,e[61]=K):K=e[61];let q;e[62]!==n||e[63]!==y||e[64]!==p?(q=y?s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}):p(n==="delete"?"filesView.dialog.delete.confirm":"filesView.dialog.confirm"),e[62]=n,e[63]=y,e[64]=p,e[65]=q):q=e[65];let ee;e[66]!==Q||e[67]!==Ne||e[68]!==K||e[69]!==q?(ee=s.jsx(z,{variant:Q,onClick:Ne,disabled:K,children:q}),e[66]=Q,e[67]=Ne,e[68]=K,e[69]=q,e[70]=ee):ee=e[70];let le;e[71]!==P||e[72]!==ee?(le=s.jsxs(Hr,{children:[P,ee]}),e[71]=P,e[72]=ee,e[73]=le):le=e[73];let te;e[74]!==F||e[75]!==Z||e[76]!==X||e[77]!==le?(te=s.jsxs(_r,{initialFocus:F,children:[Z,X,le]}),e[74]=F,e[75]=Z,e[76]=X,e[77]=le,e[78]=te):te=e[78];let Ce;return e[79]!==C||e[80]!==S||e[81]!==te?(Ce=s.jsx(Wr,{open:C,onOpenChange:S,children:te}),e[79]=C,e[80]=S,e[81]=te,e[82]=Ce):Ce=e[82],Ce},Br=(a,e,n)=>{const d=pt.c(8),[g,x]=r.useState(""),[y,b]=r.useState(0);let h,F;d[0]!==a||d[1]!==n||d[2]!==e?(h=()=>{if(!a){x("");return}let C=!1;x("");const S=ta(),V=sa(S);na(S).then(D=>{C||!D||(x(a),e(null))}).catch(D=>{C||(e(D instanceof Error?D.message:n),x(a))});const j=ra(()=>{C||(x(a),b(So),e(null))});return()=>{C=!0,V(),j()}},F=[a,e,n],d[0]=a,d[1]=n,d[2]=e,d[3]=h,d[4]=F):(h=d[3],F=d[4]),r.useEffect(h,F);let p;return d[5]!==y||d[6]!==g?(p={readyKey:g,nonce:y},d[5]=y,d[6]=g,d[7]=p):p=d[7],p},Hc=({mode:a="full"})=>{const{t:e}=ts(),{files:n,runtime:d}=ca(),{currentTheme:g,availableThemes:x,lightThemeId:y,darkThemeId:b}=ua(),{isMobile:h,isTablet:F,screenWidth:p}=da(),C=Xi(d.platform),S=h||F,V=Ji(),j=Yi(),D=$r()??"",o=B(D.trim()),L=a!=="editor-only",$=a==="editor-only"&&!h,H=Zi(t=>t.searchFiles),I=fa(D),[T,k]=r.useState(""),Z=ma(T,200),X=r.useRef(null),[J,P]=r.useState(!1),[Q,Ne]=r.useState(!0),[K,q]=r.useState(!1),[ee,le]=r.useState(!1),te=r.useRef(0),Ce=r.useCallback(t=>{te.current=Math.max(0,te.current+(t?1:-1))},[]),[E,ve]=r.useState("edit"),[we,ce]=r.useState("edit"),[ue,be]=r.useState("tree"),[M,W]=r.useState("edit"),[se,ne]=r.useState("preview"),[Se,ie]=r.useState(0),ae=r.useRef({}),ye=r.useRef({}),Ve=r.useRef({}),de=r.useRef({}),Te=r.useMemo(()=>x.find(t=>t.metadata.id===y)??xr(!1),[x,y]),De=r.useMemo(()=>x.find(t=>t.metadata.id===b)??xr(!0),[x,b]);r.useEffect(()=>{Tr(Te),Tr(De)},[Te,De]);const ke=r.useMemo(()=>[],[]),Y=Ke(t=>o?t.byRoot[o]?.openPaths??ke:ke),fe=Ke(t=>o?t.byRoot[o]?.selectedPath??null:null),pe=Ke(t=>o?t.byRoot[o]?.expandedPaths??ke:ke),Ze=Ke(t=>t.removeOpenPath),_=Ke(t=>t.removeOpenPathsByPrefix),it=Ke(t=>t.removeExpandedPathsByPrefix),me=Ke(t=>t.setSelectedPath),dn=Ke(t=>t.toggleExpandedPath),ss=Ke(t=>t.expandPaths),Ft=r.useCallback(t=>{const i=B(t),l=i.split("/"),u=l[l.length-1]||i,m=u.includes(".")?u.split(".").pop()?.toLowerCase():void 0;return{name:u,path:i,type:"file",extension:m}},[]),Nt=r.useMemo(()=>Y.map(Ft),[Y,Ft]),Vs=r.useMemo(()=>{if(fe){const t=Ot(fe);if(Y.some(i=>Ot(i)===t))return fe}return Y[0]??null},[Y,fe]),c=r.useMemo(()=>Vs?Ft(Vs):null,[Vs,Ft]),Ge=c?.path??"",[,Jr]=r.useState(0);r.useEffect(()=>{if(!o||!fe)return;const t=Ot(fe);Y.some(l=>Ot(l)===t)||me(o,Y[0]??null)},[Y,o,fe,me]);const ns=!!(o&&Ge&&!Rs(Ge,o)),fn=ns?jr(Ge):void 0,gt=r.useMemo(()=>({allowOutsideWorkspace:a==="editor-only"&&ns,outsideFileGrant:fn,directory:o||void 0}),[a,ns,fn,o]),He=r.useCallback(async t=>{const i=jr(t),l=await ha(t,o,a==="editor-only");return l.outsideFileGrant&&l.outsideFileGrant!==i&&Jr(u=>u+1),l},[a,o]),Ts=r.useRef(null),[mn,Yr]=r.useState({left:!1,right:!1}),hn=r.useCallback(()=>{const t=Ts.current;t&&Yr({left:t.scrollLeft>2,right:t.scrollLeft+t.clientWidth<t.scrollWidth-2})},[]),pn=r.useRef(hn);pn.current=hn,r.useEffect(()=>{const t=Ts.current;if(!t)return;const i=()=>pn.current();i(),t.addEventListener("scroll",i,{passive:!0});const l=new ResizeObserver(i);return l.observe(t),()=>{t.removeEventListener("scroll",i),l.disconnect()}},[Nt.length]);const[gn,Ds]=r.useState({}),[rs,Bt]=r.useState({}),ze=r.useRef(new Set),Le=r.useRef(new Set),Qe=r.useRef(new Map),xn=r.useRef(0),[vn,is]=r.useState([]),[Zr,as]=r.useState(!1),[R,he]=r.useState(""),{isPlaying:os,play:Qr,stop:ei}=pa(),[Be,at]=r.useState(!1),[et,ge]=r.useState(null),[ti,Ie]=r.useState(""),[Pe,oe]=r.useState(null),[re,xe]=r.useState(""),[$t,Ps]=r.useState(!1),[wn,si]=r.useState(`
11
+ `),ni=r.useRef(null),qe=r.useRef(null),Ee=r.useRef(null),ot=r.useRef(""),Wt=r.useRef(""),tt=r.useRef(null),bn=r.useRef(null),Xe=r.useRef(null),_t=r.useRef(0),Ct=r.useRef(null),[ls,ri]=r.useState(0),[ii,St]=r.useState("idle"),[ai,cs]=r.useState(!1),[Ut,yn]=r.useState(!1),je=ht(t=>t.autoSaveEnabled),oi=ht(t=>t.setAutoSaveEnabled),[Es,Kt]=r.useState(!1),kt=r.useRef(null),Gt=r.useRef(null),Ht=r.useRef(!1),qt=r.useRef(null),Xt=r.useRef(null),$e=r.useRef(null),us=r.useRef(null),[li,Ms]=r.useState(0),Rt=r.useRef(null),xt=r.useRef({key:"",attempts:0});r.useEffect(()=>()=>{Rt.current!==null&&typeof window<"u"&&(window.cancelAnimationFrame(Rt.current),Rt.current=null)},[]);const[vt,zs]=r.useState(null),[wt,ci]=r.useState(null),[lt,jn]=r.useState(""),[ui,Ls]=r.useState(!1),[di,fi]=r.useState(null),[mi,hi]=r.useState(null),[pi,Fn]=r.useState(!1),[gi,Nn]=r.useState(!1),[xi,Is]=r.useState(!1),Cn=!!n.writeFile,Sn=!!n.createDirectory,kn=!!n.rename,Rn=!!n.delete,Vn=!!n.revealPath,vi=js(t=>t.availableApps),wi=js(t=>t.isCacheStale),Tn=js(t=>t.initialize),bi=js(t=>t.loadInstalledApps);r.useEffect(()=>{Tn()},[Tn]);const yi=r.useCallback(t=>{n.revealPath&&n.revealPath(t).catch(()=>{G.error(e("sidebarFilesTree.toast.revealFailed"))})},[n,e]),ji=r.useCallback(async t=>{if(!c?.path||await Qi(c.path,t.id,t.appName)||await vr(c.path,t.appName))return;const u=uo(c.path)||o;u&&await vr(u,t.appName)||G.error(e("filesView.toast.openInAppFailed",{app:t.appName}))},[o,c?.path,e]),As=r.useCallback((t,i)=>{zs(t),ci(i),jn(t==="rename"&&i.name||""),Ls(!1)},[]),[A,We]=r.useState(null),Vt=r.useRef(!1),ct=r.useRef(null),[Dn,Tt]=r.useState(!1),Je=ht(t=>t.pendingFileNavigation),ds=ht(t=>t.setPendingFileNavigation),Os=ht(t=>t.pendingFileFocusPath),Bs=ht(t=>t.setPendingFileFocusPath),Pn=ht(t=>t.fileEditorKeymap),Jt=Fr(t=>t.settingsDefaultFileViewerPreview),Fi=Fr(t=>t.showMessageTTSButtons);r.useEffect(()=>{const t=()=>{Vt.current=!1,ct.current=null,Tt(!1)};return document.addEventListener("mouseup",t),()=>document.removeEventListener("mouseup",t)},[]),r.useEffect(()=>()=>{qt.current!==null&&window.clearTimeout(qt.current),Xt.current!==null&&window.clearTimeout(Xt.current)},[]);const Ni=r.useCallback((t,i)=>{const l=t.split(`
12
+ `),u=Math.max(1,i.start),m=Math.min(l.length,i.end);return u>m?"":l.slice(u-1,m).join(`
13
+ `)},[]),fs=r.useRef(null),Ci=Ga({source:"file",fileLabel:c?.path??null,language:c?.path&&tn(c.path)||"text",getCodeForRange:t=>Ni(R,Ha(t)),toStoreRange:t=>({startLine:t.start,endLine:t.end}),fromDraftRange:t=>({start:t.startLine,end:t.endLine})}),{drafts:En,commentText:ms,setCommentText:Mn,editingDraftId:hs,setSelection:zn,saveComment:Ln,cancel:Yt,reset:In,startEdit:An,deleteDraft:On}=Ci;r.useEffect(()=>{We(null),In(),xe(""),Ps(!1)},[c?.path,In]),r.useEffect(()=>{zn(A)},[A,zn]),r.useEffect(()=>{if(!A&&!hs)return;const t=l=>{const u=l.target;u.closest('[data-comment-input="true"]')||u.closest('[data-comment-card="true"]')||u.closest(".cm-gutterElement")||u.closest("[data-sonner-toast]")||u.closest("[data-sonner-toaster]")||ms.trim()||(We(null),Yt())},i=setTimeout(()=>{document.addEventListener("click",t)},100);return()=>{clearTimeout(i),document.removeEventListener("click",t)}},[Yt,ms,hs,A]);const Bn=r.useCallback((t,i)=>{const l=i??A??void 0;i&&We(i),Ln(t,l),We(null)},[A,Ln]),$n=r.useCallback((t,i)=>{const l=[];for(const u of i){if(!(u&&typeof u.name=="string"&&u.name.length>0)||!V&&u.name.startsWith(".")||!j&&xo(u.name))continue;const m=u.name,f=B(u.path||""),v=f?ho(f)?f:B(`${t}/${f}`):B(`${t}/${m}`),N=u.isDirectory?"directory":"file",O=N==="file"&&m.includes(".")?m.split(".").pop()?.toLowerCase():void 0;l.push({name:m,path:v,type:N,extension:O})}return mo(l)},[j,V]),Ae=r.useCallback(async t=>{const i=B(t.trim());if(!i||ze.current.has(i)||Le.current.has(i))return;Le.current=new Set(Le.current),Le.current.add(i);const l=xn.current+1;xn.current=l,Qe.current=new Map(Qe.current),Qe.current.set(i,l);const u=()=>Qe.current.get(i)===l;await(n.listDirectory?n.listDirectory(i).then(f=>f.entries.map(v=>({name:v.name,path:v.path,isDirectory:v.isDirectory}))):ea.listLocalDirectory(i).then(f=>f.map(v=>({name:v.name,path:v.path,isDirectory:v.isDirectory})))).then(f=>{if(!u())return;const v=$n(i,f);ze.current=new Set(ze.current),ze.current.add(i),Bt(N=>{if(!N[i])return N;const O={...N};return delete O[i],O}),Ds(N=>({...N,[i]:v}))}).catch(f=>{if(!u())return;const v=f instanceof Error?f.message:String(f??"");if(v==="Directory not found"&&o&&i!==o){it(o,i),Bt(N=>{if(!N[i])return N;const O={...N};return delete O[i],O});return}console.error("Failed to load files directory:",f),Bt(N=>({...N,[i]:v}))}).finally(()=>{u()&&(Qe.current=new Map(Qe.current),Qe.current.delete(i),Le.current=new Set(Le.current),Le.current.delete(i))})},[n,$n,it,o]),ps=r.useCallback(async()=>{o&&(ze.current=new Set,Le.current=new Set,Qe.current=new Map,Bt({}),Ds(t=>Object.keys(t).length===0?t:{}),await Ae(o))},[Ae,o]),Ye=r.useCallback(async t=>{if(!t){await ps();return}const i=B(t);ze.current=new Set(ze.current),ze.current.delete(i),Le.current=new Set(Le.current),Le.current.delete(i),await Ae(i)},[Ae,ps]),Wn=r.useRef(""),_n=r.useRef("");r.useEffect(()=>{if(!o)return;const t=`${o}|h${V?"1":"0"}|g${j?"1":"0"}`,i=Wn.current!==o,l=_n.current!==t;!i&&!l||(i&&(Wn.current=o,he(""),ge(null),Ie(""),oe(null),P(!1)),l&&(_n.current=t,ze.current=new Set,Le.current=new Set,Qe.current=new Map,Bt({}),Ds(u=>Object.keys(u).length===0?u:{}),Ae(o)))},[Ae,o,j,V]),r.useEffect(()=>{if(!n.listDirectory)return;const t=()=>{if(!document.hidden&&pe.length>0)for(const i of pe)Ye(i)};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},[pe,n.listDirectory,Ye]),r.useEffect(()=>{if(!n.listDirectory||pe.length===0)return;const t=setInterval(()=>{if(!document.hidden)for(const i of pe)Ye(i)},8e3);return()=>clearInterval(t)},[pe,n.listDirectory,Ye]);const Si=r.useCallback(async t=>{if(t?.preventDefault(),!wt||!vt)return;Ls(!0);const i=()=>{zs(null)},l=m=>{G.error(m)},u=()=>{Ls(!1)};if(vt==="createFile"){if(!lt.trim()){l(e("sidebarFilesTree.toast.filenameRequired")),u();return}if(!n.writeFile){l(e("sidebarFilesTree.toast.writeNotSupported")),u();return}const m=wt.path,f=m?`${m}/`:"",v=B(`${f}${lt.trim()}`);await n.writeFile(v,"").then(async N=>{N.success&&(G.success(e("sidebarFilesTree.toast.fileCreated")),await Ye(m)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="createFolder"){if(!lt.trim()){l(e("sidebarFilesTree.toast.folderNameRequired")),u();return}const m=wt.path,f=m?`${m}/`:"",v=B(`${f}${lt.trim()}`);await n.createDirectory(v).then(async N=>{N.success&&(G.success(e("sidebarFilesTree.toast.folderCreated")),await Ye(m)),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="rename"){if(!lt.trim()){l(e("sidebarFilesTree.toast.nameRequired")),u();return}if(!n.rename){l(e("sidebarFilesTree.toast.renameNotSupported")),u();return}const m=wt.path,f=m.split("/").slice(0,-1).join("/"),v=f?`${f}/`:"",N=B(`${v}${lt.trim()}`);await n.rename(m,N).then(async O=>{O.success&&(G.success(e("sidebarFilesTree.toast.renamedSuccessfully")),await Ye(f),o&&_(o,m),(c?.path===m||c?.path.startsWith(`${m}/`))&&(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}if(vt==="delete"){if(!n.delete){l(e("sidebarFilesTree.toast.deleteNotSupported")),u();return}const m=wt.path,f=m.split("/").slice(0,-1).join("/");await n.delete(m).then(async v=>{v.success&&(G.success(e("sidebarFilesTree.toast.deletedSuccessfully")),await Ye(f),o&&_(o,m),(c?.path===m||c?.path.startsWith(`${m}/`))&&(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1))),i()}).catch(()=>l(e("sidebarFilesTree.toast.operationFailed"))).finally(u);return}u()},[vt,wt,lt,n,Ye,h,_,o,c?.path,me,e]);r.useEffect(()=>{if(!D){is([]),as(!1);return}const t=Z.trim();if(!t){is([]),as(!1);return}let i=!1;return as(!0),H(D,t,150,{includeHidden:V,respectGitignore:!j,type:"file"}).then(l=>{if(i)return;const m=l.filter(f=>j||!vo(f.path)).map(f=>({name:f.name,path:B(f.path),type:"file",extension:f.extension,relativePath:f.relativePath}));is(m)}).catch(()=>{i||is([])}).finally(()=>{i||as(!1)}),()=>{i=!0}},[D,Z,H,V,j]);const Un=r.useCallback(async t=>{const i=await He(t);if(n.readFile)return(await n.readFile(t,{...i,directory:o||void 0})).content??"";const l=new URLSearchParams({path:t});i.allowOutsideWorkspace&&l.set("allowOutsideWorkspace","true"),i.outsideFileGrant&&l.set("outsideFileGrant",i.outsideFileGrant),o&&l.set("directory",o);const u=await wr(`/api/fs/read?${l.toString()}`);if(!u.ok){const m=await u.json().catch(()=>({error:u.statusText}));throw new Error(m.error||e("filesView.error.readFileFailed"))}return u.text()},[n,He,o,e]),ut=r.useCallback(async t=>{if(n.statFile){const i=await He(t),l=await n.statFile(t,{...i,directory:o||void 0});return{path:l.path,size:l.size,mtimeMs:l.mtimeMs}}return null},[n,He,o]);r.useEffect(()=>{if(!o||!n.statFile||Y.length===0)return;let t=!1;const i=[...Y];return Promise.all(i.map(async l=>{try{const u=await He(l),m=await n.statFile?.(l,{...u,directory:o||void 0});!t&&m&&!m.isFile&&_(o,l)}catch(u){!t&&Ar(u)&&_(o,l)}})),()=>{t=!0}},[n,Y,_,He,o]);const $s=r.useMemo(()=>R.length>At?`${R.slice(0,At)}
14
+
15
+ … truncated …`:R,[R]),Me=re!==$s,Dt=r.useCallback(async()=>{if(!c||!n.writeFile)return G.error(e("filesView.toast.savingNotSupported")),!1;const t=ys(c.path)||Ut;if(!oo({selectedFilePath:c.path,loadedFilePath:Pe,fileLoading:Be,isDirty:Me,draftContent:re,fileContent:R,isNonEditableBinary:t}))return t?console.warn(`[saveDraft] refusing to save binary file "${c.path}".`):re===""&&R!==""&&Pe!==c.path&&console.warn(`[saveDraft] refusing to save empty draft for "${c.path}" (${R.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(!Me)return!0;Ps(!0);try{const i=jo(re,wn);if(!(await n.writeFile(c.path,i))?.success)return G.error(e("filesView.toast.writeFileFailed")),!1;if(he(re),o&&Rs(c.path,o)){const u=Cs(o,c.path);u&&ga.requestGitRefresh({directory:o,paths:[u]})}if(o&&/(?:^|\/)\.agents\/loops\/[^/]+\.md$/i.test(B(c.path))){const u=xa.getState().projects.find(m=>B(m.path)===B(o));if(u)try{await Wa(u.id)}catch{G.error(e("sessions.scheduledTasks.dialog.toast.updateFailed"))}}return c?.path&&sn(c.path)&&(ot.current=re,Wt.current=re),ut(c.path).then(u=>{u&&(Xe.current=u)}).catch(()=>{}),!0}catch(i){return G.error(i instanceof Error?i.message:e("filesView.toast.saveFailed")),!1}finally{Ps(!1)}},[Ut,re,R,Be,n,Me,wn,Pe,ut,o,c,e]);r.useEffect(()=>{je||(St("idle"),qe.current&&(clearTimeout(qe.current),qe.current=null))},[je]);const Kn=1500;r.useEffect(()=>{const t=!!(c&&n.writeFile),i=!!(c?.path&&(ys(c.path)||Ut));if(ao({autoSaveEnabled:je,isDirty:Me,canWrite:t,isSaving:$t,fileLoading:Be,selectedFilePath:c?.path,loadedFilePath:Pe,isNonEditableBinary:i}))return qe.current=setTimeout(()=>{Dt().then(l=>{l&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},Kn),()=>{qe.current&&(clearTimeout(qe.current),qe.current=null)}},[je,Ut,re,Be,Me,Pe,c,n.writeFile,$t,Dt]),r.useEffect(()=>{St("idle")},[c?.path]),va({save_file:t=>{if(!(t.target instanceof Node)||!us.current?.contains(t.target))return!1;qe.current&&(clearTimeout(qe.current),qe.current=null),$t||Dt().then(i=>{i&&(St("saved"),setTimeout(()=>St("idle"),2e3))})},find_in_file:t=>{if(!(t.target instanceof Node)||!us.current?.contains(t.target))return!1;le(!0)}});const Gn=r.useCallback(async t=>{const i=_t.current+1;_t.current=i;const l=()=>{if(!o)return!1;const N=Ke.getState().byRoot[o],O=N?.selectedPath??N?.openPaths[0]??null;return _t.current===i&&O===t.path};if(ge(null),Ie(""),oe(null),yn(!1),at(!0),await He(t.path),!l())return;const u=Nr(t.path),m=Cr(t.path),f=Sr(t.path),v=ys(t.path);if(h&&P(!0),d.isDesktop&&u&&!m){he(""),xe("");return}if(!d.isDesktop&&u&&!m){he(""),xe(""),oe(t.path),at(!1);return}if(f){he(""),xe(""),oe(t.path),at(!1);return}if(v){he(""),xe(""),oe(t.path),at(!1);return}await Un(t.path).then(N=>{if(!l())return;if(wa(N)){yn(!0),he(""),xe(""),oe(t.path);return}const O=qr(N);si(yo(N)),he(O),ot.current=O,Wt.current=O,xe(O.length>At?`${O.slice(0,At)}
16
+
17
+ … truncated …`:O),oe(t.path),ut(t.path).then(ft=>{ft&&l()&&(Xe.current=ft)}).catch(()=>{})}).catch(N=>{if(l()){if(wo(N)){if(at(!1),o&&me(o,null),ge(null),he(""),xe(""),oe(null),Xe.current=null,T.trim().length>0&&k(""),h&&P(!1),o){const ft=[...Lr(t.path,o),t.path];ft.length>0&&ss(o,ft);for(const mt of ft)ze.current.has(mt)||Ae(mt)}return}if(Ar(N)){o&&_(o,t.path),he(""),xe(""),ge(null),Xe.current=null,h&&P(!1);return}he(""),xe(""),ge(N instanceof Error?N.message:e("filesView.error.readFileFailed")),Xe.current=null}}).finally(()=>{l()&&at(!1)})},[ss,h,Ae,Un,ut,_,He,o,d.isDesktop,T,me,e]),gs=r.useCallback(async(t,i)=>{if(!o)return;const l=Lr(t,o),u=i?[...l,t]:l;u.length>0&&ss(o,u);const m=u.map(f=>{if(!ze.current.has(f))return Ae(f)}).filter(Boolean);await Promise.all(m)},[ss,Ae,o]),Hn=r.useCallback((t,i)=>{const l=i.findIndex(u=>u.path===t);return l===-1||i.length<=1?null:i[l+1]??i[l-1]??null},[]),Re=r.useCallback(async t=>{if(Ht.current)Ht.current=!1;else if(Me){Kt(!0),kt.current=t;return}o&&(me(o,t.path),gs(t.path,!1)),ge(null),Ie(""),he(""),ot.current="",Wt.current="",xe(""),oe(null),h&&P(!0)},[gs,Me,h,o,me]);r.useEffect(()=>{c?.path&&gs(c.path,!1)},[gs,c?.path]),r.useEffect(()=>{if(!c){_t.current+=1,Ct.current=null,at(!1);return}if(Pe===c.path||Ct.current===c.path)return;const t=c.path;Ct.current=t,Gn(c).finally(()=>{Ct.current===t&&(Ct.current=null)})},[ls,Gn,Pe,c]);const Ws=r.useRef(Me);Ws.current=Me,r.useEffect(()=>_a(({runtimeKey:t,paths:i})=>{const l=c?.path;t!==ia()||!l||Ws.current||!i.includes(B(l))||(_t.current+=1,Ct.current=null,Xe.current=null,Ie(""),ge(null),oe(null),ri(u=>u+1))}),[c?.path]),r.useEffect(()=>{if(!c?.path||Pe!==c.path)return;let t=!1;const i=window.setInterval(()=>{document.hidden||ut(c.path).then(l=>{if(t||!l)return;const u=Xe.current;if(!u||u.path!==c.path){Xe.current=l;return}const m=l.mtimeMs!==void 0&&u.mtimeMs!==void 0&&l.mtimeMs!==u.mtimeMs,f=l.size!==u.size;!m&&!f||Ws.current||(Xe.current=l,oe(null))}).catch(()=>{})},2e3);return()=>{t=!0,window.clearInterval(i)}},[Pe,ut,c?.path]);const ki=r.useCallback(()=>{const t=kt.current,i=Gt.current;if(kt.current=null,Gt.current=null,Ht.current=!0,Kt(!1),xe($s),i){o&&Ze(o,i),c?.path===i&&(t?Re(t):(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)));return}if(t){Re(t);return}},[$s,Re,h,Ze,o,c?.path,me]),Ri=r.useCallback(async()=>{const t=kt.current,i=Gt.current;if(!await Dt()){Ht.current=!1;return}if(kt.current=null,Gt.current=null,Ht.current=!0,Kt(!1),i){o&&Ze(o,i),c?.path===i&&(t?await Re(t):(o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)));return}if(t){await Re(t);return}},[Re,h,Ze,o,Dt,c?.path,me]),qn=r.useCallback(t=>{const i=c?.path===t,l=Hn(t,Nt);if(i&&Me){Kt(!0),kt.current=l,Gt.current=t;return}if(o&&Ze(o,t),!!i){if(l){Re(l);return}o&&me(o,null),he(""),ge(null),Ie(""),oe(null),h&&P(!1)}},[Hn,Re,Me,h,Nt,Ze,o,c?.path,me]),Vi=r.useCallback(t=>{if(Y.includes(t))return"open";if(I?.files){const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=I.files.find(u=>u.path===i);if(l){if(l.index==="A"||l.working_dir==="?")return"git-added";if(l.index==="D")return"git-deleted";if(l.index==="M"||l.working_dir==="M")return"git-modified"}}return null},[Y,I,o]),Ti=r.useCallback(t=>{if(!I?.files)return null;const i=t.startsWith(o+"/")?t.slice(o.length+1):t,l=i?`${i}/`:"";let u=0,m=0;for(const f of I.files)f.path.startsWith(l)&&((f.index==="M"||f.working_dir==="M")&&u++,(f.index==="A"||f.working_dir==="?")&&m++);return u+m>0?{modified:u,added:m}:null},[I,o]),Di=r.useCallback(async t=>{const i=B(t);o&&(dn(o,i),ze.current.has(i)||await Ae(i))},[Ae,o,dn]),Pi=r.useMemo(()=>({canRename:kn,canCreateFile:Cn,canCreateFolder:Sn,canDelete:Rn,canReveal:Vn}),[kn,Cn,Sn,Rn,Vn]);function Xn(t,i){const l=gn[t]??[];return l.map((u,m)=>{const f=u.type==="directory",v=f&&pe.includes(u.path),N=c?.path===u.path,O=m===l.length-1;return s.jsxs("li",{className:"relative",children:[i>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"absolute top-3.5 left-[-12px] w-3 h-px bg-border/40"}),O&&s.jsx("span",{className:"absolute top-3.5 bottom-0 left-[-13px] w-[2px] bg-background"})]}),s.jsx(No,{node:u,root:o,isExpanded:v,isActive:N,isMobile:h,isBrowserClient:C,alwaysShowActions:S,status:f?void 0:Vi(u.path),badge:f?Ti(u.path):void 0,permissions:Pi,downloadFile:n.downloadFile,contextMenuPath:di,setContextMenuPath:fi,rightClickMenuPath:mi,setRightClickMenuPath:hi,onSelect:Re,onToggle:Di,onRevealPath:yi,onOpenDialog:As}),f&&v&&s.jsxs("ul",{className:"flex flex-col gap-1 ml-3 pl-3 border-l border-border/40 relative",children:[rs[u.path]?s.jsxs("li",{className:"flex items-center gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"min-w-0 flex-1 truncate text-[var(--status-error)]",title:rs[u.path],children:rs[u.path]}),s.jsxs(z,{variant:"ghost",size:"xs",className:"h-6 gap-1",onClick:()=>{Ye(u.path)},children:[s.jsx(w,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):null,Xn(u.path,i+1)]})]},u.path)})}const Fe=!!(c?.path&&Nr(c.path)),xs=!!(c?.path&&Cr(c.path)),Oe=!!(c?.path&&Sr(c.path)),_s=!!(c?.path&&(ys(c.path)||Ut)),st=_s&&!Fe&&!Oe,Jn=r.useMemo(()=>B(Je?.path??""),[Je?.path]),Pt=!!(Je&&Jn&&Ge&&Ge===Jn&&!Be&&!et&&!Fe&&!Oe&&!st),dt=r.useMemo(()=>Cs(o,Ge),[Ge,o]),Ei=!!(c&&(!Fe||xs)&&!Oe&&!st&&R.length>0),Mi=!!(c&&dt.length>0),_e=!!(c&&!ns&&!_s&&!Fe&&n.writeFile&&R.length<=At),bt=!!(c?.path&&Or(c.path)),Zt=!!(c?.path&&Fo(c.path)),Et=!!(c?.path&&on(c.path)),Qt=!!(c?.path&&sn(c.path)),Us=!!(c&&!_s&&!Fe)&&!bt&&!Qt&&!(Et&&M==="preview"),zi=bt&&we==="edit"||Et&&M==="edit"||Zt&&ue==="text"||!bt&&!Et&&!Zt&&E==="edit",vs=r.useMemo(()=>Ge?ba(Ge):null,[Ge]),[Yn,Ks]=r.useState(null);r.useEffect(()=>{let t=!1;const i=c?.path;if(!i||vs){Ks(null);return}return Ks(null),ya(i).then(l=>{t||Ks(l)}),()=>{t=!0}},[c?.path,vs]),r.useEffect(()=>{!_e&&E==="edit"&&ve("view")},[_e,E]);const Gs="openchamber:files:md-viewer-mode",Hs="openchamber:files:html-viewer-mode",qs="openchamber:files:json-viewer-mode";r.useEffect(()=>{const t=c?.path;if(!t)return;ve(ae.current[t]??"edit");let i=Jt?"preview":"edit";try{const m=localStorage.getItem(Gs);(m==="preview"||m==="edit")&&(i=m)}catch{}ce(ye.current[t]??i);let l=Jt?"preview":"edit";try{const m=localStorage.getItem(Hs);(m==="preview"||m==="edit")&&(l=m)}catch{}W(Ve.current[t]??l),ne(de.current[t]??(Jt?"preview":"edit"));let u=Jt?"tree":"text";try{const m=localStorage.getItem(qs);(m==="tree"||m==="text")&&(u=m)}catch{}be(u)},[c?.path,Jt]);const Li=r.useCallback(t=>{const i=c?.path;i&&(ae.current[i]=t),ve(t)},[c?.path]),Ii=r.useCallback(t=>{const i=c?.path;i&&(ye.current[i]=t),ce(t);try{localStorage.setItem(Gs,t)}catch{}},[c?.path]),nt=r.useCallback(()=>we,[we]),Ai=r.useCallback(t=>{be(t);try{localStorage.setItem(qs,t)}catch{}},[]),Oi=r.useCallback(t=>{const i=c?.path;i&&(Ve.current[i]=t),W(t);try{localStorage.setItem(Hs,t)}catch{}},[c?.path]),Bi=r.useCallback(t=>{const i=c?.path;if(i&&(de.current[i]=t),Ee.current&&(clearTimeout(Ee.current),Ee.current=null),tt.current!==null&&(cancelAnimationFrame(tt.current),tt.current=null),t==="edit")xe(ot.current||R),ne(t);else{ot.current=re;const l=i;ne("edit"),tt.current=requestAnimationFrame(()=>{tt.current=requestAnimationFrame(()=>{tt.current=null,!(o&&l&&Ke.getState().byRoot[o]?.selectedPath!==l)&&(ie(u=>u+1),ne("preview"))})});return}},[re,R,o,c?.path]),Xs=r.useCallback(async(t,i)=>{if(!n.writeFile||i===Wt.current)return!1;if(!(await n.writeFile(t,i))?.success)return G.error(e("filesView.toast.writeFileFailed")),!1;ot.current=i,Wt.current=i,xe(i);const u=await ut(t).catch(()=>null);return u&&(Xe.current=u),!0},[n,ut,e]);r.useEffect(()=>()=>{Ee.current&&(clearTimeout(Ee.current),Ee.current=null),tt.current!==null&&(cancelAnimationFrame(tt.current),tt.current=null)},[se,c?.path]);const $i=r.useCallback(t=>{if(ot.current=t,!je||!c?.path||se!=="preview"||!n.writeFile)return;Ee.current&&clearTimeout(Ee.current);const i=c.path;Ee.current=setTimeout(()=>{Ee.current=null,Xs(i,t).then(l=>{l&&(cs(!0),setTimeout(()=>cs(!1),1500))}).catch(l=>{G.error(l instanceof Error?l.message:e("filesView.toast.saveFailed"))})},Kn)},[je,se,n.writeFile,Xs,c?.path,e]),Wi=r.useMemo(()=>Qt&&(ot.current||re)||R,[re,R,Qt]),Zn=r.useCallback(()=>M,[M]);r.useEffect(()=>{const t=l=>{const u=l?"preview":"edit",m=l?"tree":"text";for(const f of Y)ae.current[f]="edit",Or(f)&&(ye.current[f]=u),on(f)&&(Ve.current[f]=u),sn(f)&&(de.current[f]=u);ve("edit"),ce(u),W(u),ne(u),be(m);try{localStorage.setItem(Gs,u),localStorage.setItem(Hs,u),localStorage.setItem(qs,m)}catch{}},i=l=>{const u=!!l.detail?.enabled;t(u)};return window.addEventListener("openchamber:file-viewer-preview-mode-changed",i),()=>{window.removeEventListener("openchamber:file-viewer-preview-mode-changed",i)}},[Y]),r.useEffect(()=>{if(!Je||!o)return;const t=()=>{typeof window>"u"||Rt.current===null&&(Rt.current=window.requestAnimationFrame(()=>{Rt.current=null,Ms(rt=>rt+1)}))},i=(rt,yt)=>{if(rt.state.doc.length!==yt.length)return!1;if(yt.length===0)return!0;const Qs=Math.min(128,yt.length);if(rt.state.sliceDoc(0,Qs)!==yt.slice(0,Qs))return!1;const pr=Math.max(0,yt.length-Qs);return rt.state.sliceDoc(pr,yt.length)===yt.slice(pr)},l=B(Je.path);if(!l){ds(null),xt.current={key:"",attempts:0};return}const u=`${l}:${Je.line}:${Je.column??1}`;if(xt.current.key!==u&&(xt.current={key:u,attempts:0}),c?.path!==l){if(Es)return;Re(Ft(l));return}if(Be||Pe!==l)return;if(et||Fe||Oe||st){ds(null),xt.current={key:"",attempts:0};return}if(!_e)return;if(E!=="edit"){ve("edit");return}const m=$e.current;if(!m){t();return}if(!i(m,re)){t();return}const f=Math.max(1,Math.min(Je.line,m.state.doc.lines)),v=m.state.doc.line(f),N=Math.max(1,Je.column||1),O=Math.max(0,v.to-v.from),ft=Math.min(O,N-1),mt=v.from+ft;if(!(m.state.selection.main.head===mt)||xt.current.attempts===0){xt.current.attempts+=1,m.dispatch({selection:{anchor:mt},effects:jt.scrollIntoView(mt,{y:"center"})}),m.focus(),t();return}typeof window<"u"&&window.requestAnimationFrame(()=>{const rt=$e.current;rt&&(rt.dispatch({selection:{anchor:mt},effects:jt.scrollIntoView(mt,{y:"center"})}),rt.focus())}),ds(null),xt.current={key:"",attempts:0}},[_e,Es,re,li,et,Be,Fe,Oe,st,Pe,Re,Je,o,c?.path,ds,E,Ft]),r.useEffect(()=>{if(!Os||!o)return;const t=B(Os);if(!t){Bs(null);return}c?.path===t&&(Be||Pe!==t||(!et&&!Fe&&!Oe&&!st&&_e&&E==="edit"&&$e.current?.focus(),Bs(null)))},[_e,et,Be,Fe,Oe,st,Pe,Os,o,c?.path,Bs,E]);const Mt=r.useCallback(t=>{if(!h||!t||!t.hasFocus||typeof window>"u")return;const i=window.visualViewport;if(!i)return;const l=document.documentElement.clientHeight||window.innerHeight;if(Math.max(0,l-(i.offsetTop+i.height))<=0)return;const m=t.state.selection.main.head,f=t.coordsAtPos(m);if(!f)return;const v=Math.round(i.offsetTop+i.height),O=f.bottom+20-v;O<=0||(t.scrollDOM.scrollTop+=O)},[h]);r.useEffect(()=>{if(!h||typeof window>"u")return;const t=()=>{window.requestAnimationFrame(()=>{Mt($e.current)})},i=window.visualViewport;return i?.addEventListener("resize",t),i?.addEventListener("scroll",t,{passive:!0}),document.addEventListener("selectionchange",t),()=>{i?.removeEventListener("resize",t),i?.removeEventListener("scroll",t),document.removeEventListener("selectionchange",t)}},[h,Mt]),ja("open_go_to_line",t=>{if(!_e||E!=="edit"||h)return!1;const i=t.target;if(i?.closest('[role="dialog"]')||!(i instanceof Node)||!us.current?.contains(i))return!1;const l=!!i?.closest(".cm-editor");if(!!i?.closest('input, textarea, [contenteditable="true"], [role="textbox"]')&&!l)return!1;Is(!0)});const ws=ht(t=>t.editorFontSize),Qn=r.useMemo(()=>{if(!c?.path)return[Rr(g,{fontSize:ws})];const t=tn(c.path),i=[Rr(g,t?{syntaxColors:!1,fontSize:ws}:{fontSize:ws})],l=vs??Yn;return l&&i.push(l),t&&i.push(Ma({language:t,themeName:g.metadata.id,theme:Aa(g)})),Q&&i.push(jt.lineWrapping),h&&i.push(jt.updateListener.of(u=>{u.view.hasFocus&&(u.selectionSet||u.focusChanged||u.viewportChanged||u.geometryChanged)&&window.requestAnimationFrame(()=>{Mt(u.view)})})),i},[g,c?.path,vs,Yn,Q,h,Mt,ws]),er=r.useMemo(()=>({light:Te.metadata.id,dark:De.metadata.id}),[Te.metadata.id,De.metadata.id]),es=c?.path&&Oe&&(!gt.allowOutsideWorkspace||gt.outsideFileGrant)?`${c.path}|${gt.allowOutsideWorkspace?"outside":"workspace"}|${gt.outsideFileGrant??""}|${ls}`:"",bs=c?.path&&Et&&M==="preview"&&!d.isVSCode?`${c.path}|${ls}`:"",tr=e("filesView.error.readFileFailed"),{readyKey:sr,nonce:_i}=Br(bs,ge,tr),{readyKey:nr,nonce:rr}=Br(es,ge,tr),Ui=!!(bs&&sr!==bs),ir=!!(es&&nr!==es),ar=c?.path&&Fe?xs?`data:${Fa(c.path)};utf8,${encodeURIComponent(R)}`:ti:"",or=c?.path&&Oe&&es&&nr===es?br().authenticatedAsset("/api/fs/raw",{path:c.path,allowOutsideWorkspace:gt.allowOutsideWorkspace?"true":void 0,outsideFileGrant:gt.outsideFileGrant,directory:o||void 0}):"",lr=r.useCallback(t=>s.jsx("div",{className:"h-full overflow-hidden bg-[var(--surface-background)]",children:s.jsx("iframe",{src:or,className:"h-full w-full border-0",title:t.name},rr)}),[or,rr]);r.useEffect(()=>{let t=!1,i="";return(async()=>{if(!c?.path||!Fe||xs){Ie("");return}ge(null);const u=await He(c.path);if(t)return;await(n.readFileBinary?n.readFileBinary(c.path,u).then(f=>f.dataUrl):(async()=>{const f=await wr("/api/fs/raw",{query:{path:c.path,allowOutsideWorkspace:u.allowOutsideWorkspace?"true":void 0,outsideFileGrant:u.outsideFileGrant,directory:o||void 0}});if(!f.ok)throw new Error(e("filesView.error.readFileFailed"));const v=await f.blob();return i=URL.createObjectURL(v),t?(URL.revokeObjectURL(i),i="",""):i})()).then(f=>{t||(Ie(f),oe(c.path))}).catch(f=>{t||(Ie(""),ge(f instanceof Error?f.message:e("filesView.error.readFileFailed")),oe(null))}).finally(()=>{t||at(!1)})})(),()=>{t=!0,i&&URL.revokeObjectURL(i)}},[ls,n,Fe,xs,He,o,c?.path,gt,e]);const Ki=r.useCallback(()=>zs(null),[]),Gi=r.useMemo(()=>qa({drafts:En,editingDraftId:hs,commentText:ms,onTextChange:Mn,selection:A,isDragging:Dn,fileLabel:c?.path??"",newWidgetId:"files-new-comment-input",mapDraftToRange:t=>({start:t.startLine,end:t.endLine}),onSave:Bn,onCancel:()=>{We(null),Yt()},onEdit:t=>{An(t),We({start:t.startLine,end:t.endLine})},onDelete:On}),[Yt,ms,On,hs,En,Bn,Dn,A,c?.path,Mn,An]),cr=Mr(),ur=Mr(),Js=Ra("unified"),Ue=R.length>At,Ys=r.useMemo(()=>Ue?bo(R):void 0,[R,Ue]),dr=r.useCallback((t,i,l)=>{const u={name:t.name,contents:i,lang:tn(t.path)||void 0},m=f=>s.jsx(Ia,{file:Ue&&Ys?{...u,cacheKey:`${t.path}:${Ys}`}:u,options:{disableFileHeader:!0,overflow:Q?"wrap":"scroll",theme:er,themeType:g.metadata.variant==="dark"?"dark":"light"},className:Ue?"block w-full":"block h-full w-full",style:Ue?void 0:{height:"100%"}},f);return Ue?s.jsx("div",{className:"h-full",children:s.jsx(Oa.Provider,{value:l.virtualizer,children:s.jsx(Ba.Provider,{value:Js,children:m(`${t.path}:${Js?"pool":"pending"}`)})})}):s.jsx("div",{className:"h-full",children:m(t.path)})},[g.metadata.variant,Ue,Ys,er,Js,Q]),fr=({exitFullscreenOnly:t=!1,layout:i="floating"}={})=>{if(!c)return null;const l=i==="docked",u=Na(Ca("save_file")),m=l?"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",f=(v,N)=>s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:N})}),s.jsx(It,{side:"bottom",sideOffset:6,children:v})]});return s.jsxs("div",{className:m,children:[_e&&zi&&s.jsxs(s.Fragment,{children:[$t?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-muted-foreground typography-meta",children:[s.jsx(w,{name:"loader-4",className:"size-3.5 animate-spin"}),e("filesView.editor.saving")]}):je&&ii==="saved"&&!Me?s.jsxs("span",{className:"flex items-center gap-1 px-1 text-[color:var(--status-success)] typography-meta",children:[s.jsx(w,{name:"check",className:"size-3.5"}),e("filesView.editor.saved")]}):Me?f(e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{Dt()},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:e(je?"filesView.editor.saveNowTitle":"filesView.editor.saveNowManualTitle",{shortcut:u}),"aria-label":e("filesView.editor.saveAria",{shortcut:u}),children:s.jsx(w,{name:"save-3",className:"size-4"})})):null,f(e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>oi(!je),className:U("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",je?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),"aria-label":e(je?"filesView.editor.autoSaveOn":"filesView.editor.manualSave"),children:je?s.jsx(w,{name:"file-check-fill",className:"size-4"}):s.jsx(w,{name:"file-check",className:"size-4"})}))]}),s.jsxs(ln,{onOpenChange:Ce,children:[s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex",children:s.jsx(cn,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-foreground opacity-100 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.openInDesktopApp"),"aria-label":e("filesView.editor.openInDesktopApp"),children:s.jsx(w,{name:"file-transfer",className:"size-4"})})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.editor.openInDesktopApp")})]}),s.jsxs(un,{align:"end",className:"w-56 max-h-[70vh] overflow-y-auto",children:[vi.map(v=>s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{ji(v)},children:[s.jsx(fo,{label:v.label,iconDataUrl:v.iconDataUrl}),s.jsx("span",{className:"typography-ui-label text-foreground",children:v.label})]},v.id)),wi?s.jsxs(Ns,{className:"flex items-center gap-2",onClick:()=>{bi(!0)},children:[s.jsx(w,{name:"refresh",className:"size-4"}),s.jsx("span",{className:"typography-ui-label text-foreground",children:e("filesView.editor.refreshApps")})]}):null]})]}),!Fe&&!Oe&&!st&&s.jsxs(s.Fragment,{children:[f(e(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ne(!Q),className:U("size-6 p-0 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",Q?"text-foreground opacity-100":"text-muted-foreground opacity-65 hover:opacity-100"),title:e(Q?"filesView.editor.disableLineWrap":"filesView.editor.enableLineWrap"),children:s.jsx(w,{name:"text-wrap",className:"size-4"})})),E==="edit"&&s.jsxs(s.Fragment,{children:[f(e("filesView.editor.findInFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:v=>{le(!ee),v.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.findInFile"),children:s.jsx(w,{name:"search",className:"size-4"})})),f(e("filesView.editor.goToLine"),s.jsx(z,{variant:"ghost",size:"sm",onClick:v=>{Is(N=>!N),v.currentTarget.blur()},className:"size-6 p-0 text-foreground opacity-100 transition-opacity hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.goToLine"),children:s.jsx(w,{name:"menu-fold-2",className:"size-4"})})),s.jsx(ro,{open:xi,onOpenChange:Is,view:$e.current,variant:"inline"})]})]}),Us&&_e&&!Zt&&!Et&&s.jsx(an,{currentMode:E==="view"?"preview":"edit",onToggle:()=>{Li(E==="view"?"edit":"view")}}),bt&&f(e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ii(nt()==="preview"?"edit":"preview"),className:U("size-6 p-0 transition-colors hover:bg-[var(--interactive-hover)] focus-visible:bg-[var(--interactive-hover)] active:bg-[var(--interactive-hover)]",nt()==="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:e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),"aria-label":e(nt()==="preview"?"filesView.editor.switchToEditMode":"filesView.editor.switchToPreviewMode"),children:s.jsx(w,{name:nt()==="preview"?"eye":"eye-off",className:"size-4"})})),on(c?.path??"")&&s.jsx(an,{currentMode:Zn(),onToggle:()=>{Oi(Zn()==="preview"?"edit":"preview")}}),bt&&nt()==="preview"&&Fi&&s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx(z,{variant:"ghost",size:"sm",className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent","aria-label":e(os?"filesView.tts.stopSpeaking":"filesView.tts.readAloud"),onClick:()=>{os?ei():R.trim()&&Qr(R)},children:os?s.jsx(w,{name:"stop",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"volume-up",className:"size-4"})})}),s.jsx(It,{sideOffset:8,children:e(os?"filesView.tts.stopSpeaking":"filesView.tts.readAloud")})]}),Qt&&s.jsxs(s.Fragment,{children:[s.jsx(an,{currentMode:se,onToggle:()=>Bi(se==="preview"?"edit":"preview")}),se==="preview"&&s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{const v=bn.current?.getXml();if(Ee.current&&(clearTimeout(Ee.current),Ee.current=null),c?.path&&v){if(!await Xs(c.path,v))return;cs(!0),setTimeout(()=>cs(!1),1500)}},className:"size-6 p-0 text-foreground hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.diagram.saveDiagram"),children:ai?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"save-3",className:"size-4"})})]}),Zt&&f(e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>Ai(ue==="tree"?"text":"tree"),className:"size-6 p-0 text-muted-foreground opacity-65 hover:bg-transparent hover:opacity-100 focus-visible:bg-transparent active:bg-transparent",title:e(ue==="tree"?"filesView.editor.switchToTextView":"filesView.editor.switchToTreeView"),children:ue==="tree"?s.jsx(w,{name:"code-sslash",className:"size-4"}):s.jsx(w,{name:"node-tree",className:"size-4"})})),Ei&&f(e("filesView.editor.copyFileContents"),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await ks(R)).ok?(Fn(!0),qt.current!==null&&window.clearTimeout(qt.current),qt.current=window.setTimeout(()=>{Fn(!1)},1200)):G.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFileContents"),"aria-label":e("filesView.editor.copyFileContents"),children:pi?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"clipboard",className:"size-4"})})),Mi&&f(e("filesView.editor.copyFilePathTitle",{path:dt}),s.jsx(z,{variant:"ghost",size:"sm",onClick:async()=>{(await ks(dt)).ok?(Nn(!0),Xt.current!==null&&window.clearTimeout(Xt.current),Xt.current=window.setTimeout(()=>{Nn(!1)},1200)):G.error(e("filesView.toast.copyFailed"))},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.copyFilePathTitle",{path:dt}),"aria-label":e("filesView.editor.copyFilePathTitle",{path:dt}),children:gi?s.jsx(w,{name:"check",className:"size-4 text-[color:var(--status-success)]"}):s.jsx(w,{name:"file-copy-2",className:"size-4"})})),n.downloadFile&&f(e("filesView.editor.saveFile"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{const v=n.downloadFile;v&&v(c.path).catch(N=>{console.error("Download failed:",N),G.error(e("sidebarFilesTree.toast.operationFailed"))})},className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.saveFile"),"aria-label":e("filesView.editor.saveFile"),children:s.jsx(w,{name:"download",className:"size-4"})})),t?f(e("filesView.editor.exitFullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>q(!1),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e("filesView.editor.exitFullscreen"),"aria-label":e("filesView.editor.exitFullscreen"),children:s.jsx(w,{name:"fullscreen-exit",className:"size-4"})})):!h&&a==="full"&&f(e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>q(!K),className:"size-6 p-0 hover:bg-transparent focus-visible:bg-transparent active:bg-transparent",title:e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),"aria-label":e(K?"filesView.editor.exitFullscreen":"filesView.editor.fullscreen"),children:K?s.jsx(w,{name:"fullscreen-exit",className:"size-4"}):s.jsx(w,{name:"fullscreen",className:"size-4"})}))]})},Zs=s.jsxs("div",{className:"relative flex h-full min-h-0 min-w-0 w-full flex-col overflow-hidden",children:[s.jsx(Wr,{open:Es,onOpenChange:t=>{t||Kt(!0)},children:s.jsxs(_r,{showCloseButton:!1,className:"max-w-md",children:[s.jsxs(Ur,{children:[s.jsx(Kr,{children:e("filesView.unsaved.title")}),s.jsx(Gr,{children:e("filesView.unsaved.description")})]}),s.jsxs(Hr,{children:[s.jsx(z,{variant:"outline",onClick:()=>{Ri()},disabled:$t,className:"border-[var(--status-success-border)] bg-[var(--status-success-background)] text-[var(--status-success)] hover:bg-[rgb(var(--status-success)/0.2)]",children:e("filesView.unsaved.saveChanges")}),s.jsx(z,{variant:"destructive",onClick:ki,children:e("filesView.unsaved.discard")})]})]})}),s.jsxs("div",{className:U("flex flex-col flex-shrink-0",L&&"border-b border-border/40"),children:[L?s.jsxs("div",{className:"flex min-w-0 items-center px-3 py-1.5",children:[h&&J&&s.jsx("button",{type:"button",onClick:()=>P(!1),"aria-label":e("filesView.editor.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:s.jsx(w,{name:"arrow-left-s",className:"size-5"})}),h?c?s.jsxs(ln,{children:[s.jsx(cn,{asChild:!0,children:s.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":e("filesView.editor.openFilesAria"),children:[s.jsx(Fs,{filePath:c.path,extension:c.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Ir,{name:c.name}),s.jsx(w,{name:"arrow-down-s",className:"size-4 flex-shrink-0 text-muted-foreground"})]})}),s.jsx(un,{align:"start",className:"w-[min(24rem,calc(100vw-2rem))] max-w-[calc(100vw-2rem)]",children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs(Ns,{onSelect:l=>{if(l.target.closest("[data-close-open-file]")){l.preventDefault();return}i||Re(t)},className:U("flex min-w-0 items-center justify-between gap-2 overflow-hidden",i&&"bg-[var(--interactive-selection)] text-[var(--interactive-selection-foreground)]"),children:[s.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2 overflow-hidden",children:[s.jsx(Fs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx(Ir,{name:t.name})]}),s.jsx("button",{type:"button","data-close-open-file":!0,onPointerDown:l=>{l.preventDefault(),l.stopPropagation()},onClick:l=>{l.preventDefault(),l.stopPropagation(),qn(t.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":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(w,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")}):Nt.length>0?s.jsxs("div",{className:"relative min-w-0 flex-1",children:[mn.left&&s.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"}),mn.right&&s.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"}),s.jsx("div",{ref:Ts,className:"flex min-w-0 items-center gap-1 overflow-x-auto scrollbar-none",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:Nt.map(t=>{const i=c?.path===t.path;return s.jsxs("div",{title:Cs(o,t.path),className:U("group inline-flex items-center gap-1 rounded-md border px-2 py-1 typography-ui-label transition-colors whitespace-nowrap",i?"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:[s.jsx(Fs,{filePath:t.path,extension:t.extension,className:"size-3.5 flex-shrink-0"}),s.jsx("button",{type:"button",onClick:()=>{i||Re(t)},className:"max-w-[12rem] truncate text-left",children:t.name}),s.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),qn(t.path)},className:U("rounded-sm p-0.5 text-[var(--surface-muted-foreground)] hover:text-[var(--surface-foreground)]",!i&&!S&&"opacity-0 group-hover:opacity-100"),"aria-label":e("filesView.editor.closeFileAria",{name:t.name}),children:s.jsx(w,{name:"close",className:"size-3.5"})})]},t.path)})})]}):s.jsx("div",{className:"typography-ui-label font-medium truncate",children:e("filesView.editor.selectFile")})]}):null,c?s.jsxs("div",{className:"flex min-w-0 items-center gap-3 border-t border-border/40 bg-[var(--surface-subtle)] px-3 py-1",children:[dt&&!h?s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta text-muted-foreground",title:dt,children:dt}):null,s.jsx("div",{className:"ml-auto min-w-0 shrink-0 overflow-x-auto",children:fr({layout:"docked"})})]}):null]}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 relative",children:s.jsx(nn,{ref:cr.setScroller,outerClassName:"h-full min-w-0",className:U("h-full min-w-0",Ue&&"[overflow-anchor:none]"),children:c?Be||ir?$?s.jsx("div",{className:"p-3"}):s.jsxs("div",{className:"p-3 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.loading")]}):et?s.jsx("div",{className:"p-3 typography-ui text-[color:var(--status-error)]",children:et}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-3",children:s.jsx("img",{src:ar,alt:c?.name??e("filesView.editor.imageAltFallback"),className:"max-w-full max-h-[70vh] object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Oe?lr(c):st?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),G.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):c&&Qt&&se==="preview"?s.jsx("div",{className:"h-full overflow-hidden",style:{minHeight:"400px"},children:s.jsx(co,{ref:bn,xml:Wi,onChange:$i},`${c.path}:${Se}`)}):c&&Zt&&ue==="tree"?s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.jsonViewerUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToTextMode")})]}),children:s.jsx("div",{className:"h-full overflow-auto",children:s.jsx(La,{jsonString:R,maxHeight:"100%",initiallyExpandedDepth:2})})}):c&&bt&&nt()==="preview"?s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-3",ref:fs,children:[s.jsx(Dr,{containerRef:fs,filePath:c.path,fileContent:R}),R.length>500*1024&&s.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:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(R.length/1024)})}),s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(kr,{content:R,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):c&&Et&&M==="preview"?Ui?s.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground typography-ui-label",children:e("common.loading")}):s.jsx("div",{className:"h-full overflow-hidden",children:s.jsx("iframe",{src:!d.isVSCode&&sr===bs?(()=>{const t=c.path.split("/").map(i=>encodeURIComponent(i)).join("/");return br().authenticatedAsset(`/api/fs/serve${t.startsWith("/")?t:`/${t}`}`)})():void 0,srcDoc:d.isVSCode?(()=>{const t=c.path.substring(0,c.path.lastIndexOf("/")+1);return t?R.replace(/<head([^>]*)>/i,`<head$1><base href="${t}">`):R})():void 0,className:"w-full h-full border-none",sandbox:"allow-scripts allow-same-origin allow-forms",title:e("filesView.editor.htmlPreviewTitle")},_i)}):c&&Us&&E==="view"?dr(c,Ue?R:re,cr):s.jsxs("div",{className:U("relative h-full",Pt&&"overflow-hidden"),ref:us,children:[s.jsx("div",{className:U("h-full",Pt&&"invisible"),children:s.jsx(Vr,{value:re,onChange:xe,readOnly:!_e,vimMode:Pn==="vim",extensions:Qn,className:"h-full",blockWidgets:Gi,onViewReady:t=>{$e.current=t,Ms(i=>i+1),window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{$e.current&&($e.current=null),Ms(t=>t+1)},enableSearch:!0,searchOpen:ee,onSearchOpenChange:le,highlightLines:A?{start:Math.min(A.start,A.end),end:Math.max(A.start,A.end)}:void 0,lineNumbersConfig:{domEventHandlers:{mousedown:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.button!==0)return!1;l.preventDefault();const u=t.state.doc.lineAt(i.from).number;if(A&&!l.shiftKey&&Math.min(A.start,A.end)===u&&Math.max(A.start,A.end)===u)return We(null),Yt(),Vt.current=!1,ct.current=null,Tt(!1),!0;if(h&&A&&!l.shiftKey){const m=Math.min(A.start,A.end,u),f=Math.max(A.start,A.end,u);return We({start:m,end:f}),Vt.current=!1,ct.current=null,Tt(!1),!0}if(Vt.current=!0,ct.current=u,Tt(!0),A&&l.shiftKey){const m=Math.min(A.start,u),f=Math.max(A.end,u);We({start:m,end:f})}else We({start:u,end:u});return!0},mouseover:(t,i,l)=>{if(!(l instanceof MouseEvent)||l.buttons!==1||!Vt.current||ct.current===null)return!1;const u=t.state.doc.lineAt(i.from).number,m=Math.min(ct.current,u),f=Math.max(ct.current,u);return We({start:m,end:f}),Tt(!0),!1},mouseup:()=>(Vt.current=!1,ct.current=null,Tt(!1),!1)}}})}),Pt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]}):s.jsx("div",{className:"p-3 typography-ui text-muted-foreground",children:e("filesView.editor.pickFileFromTree")})})})]}),Hi=!!(o&&gn[o]),mr=o?rs[o]:null,hr=s.jsxs("section",{className:U("flex min-h-0 flex-col overflow-hidden",h?"h-full w-full bg-background":"h-full rounded-xl border border-border/60 bg-background/70"),children:[s.jsx("div",{className:U("flex flex-col gap-2 py-2",h?"px-3":"px-2"),children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx(w,{name:"search",className:"pointer-events-none absolute left-2 top-2 size-4 text-muted-foreground"}),s.jsx(Ss,{ref:X,value:T,onChange:t=>k(t.target.value),placeholder:e("filesView.tree.search.placeholder"),className:"h-8 pl-8 pr-8 typography-meta"}),T.trim().length>0&&s.jsx("button",{type:"button","aria-label":e("filesView.tree.search.clearAria"),className:"absolute right-2 top-2 inline-flex size-4 items-center justify-center text-muted-foreground hover:text-foreground",onClick:()=>{k(""),X.current?.focus()},children:s.jsx(w,{name:"close",className:"size-4"})})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>As("createFile",{path:D,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFileTitle"),"aria-label":e("filesView.tree.actions.newFileTitle"),children:s.jsx(w,{name:"file-add",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFileTitle")})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>As("createFolder",{path:D,type:"directory"}),className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.newFolderTitle"),"aria-label":e("filesView.tree.actions.newFolderTitle"),children:s.jsx(w,{name:"folder-add",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.newFolderTitle")})]}),s.jsxs(zt,{children:[s.jsx(Lt,{asChild:!0,children:s.jsx("span",{className:"inline-flex flex-shrink-0",children:s.jsx(z,{variant:"ghost",size:"sm",onClick:()=>{ps()},className:"size-8 p-0 flex-shrink-0",title:e("filesView.tree.actions.refreshTitle"),"aria-label":e("filesView.tree.actions.refreshTitle"),children:s.jsx(w,{name:"refresh",className:"size-4"})})})}),s.jsx(It,{side:"bottom",sideOffset:6,children:e("filesView.tree.actions.refreshTitle")})]})]})}),s.jsx(nn,{outerClassName:"flex-1 min-h-0",className:U("py-2",h?"px-3":"px-2"),children:s.jsx("ul",{className:"flex flex-col",children:Zr?s.jsxs("li",{className:"flex items-center gap-1.5 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.tree.search.searching")]}):vn.length>0?vn.map(t=>{const i=c?.path===t.path;return s.jsx("li",{children:s.jsxs("button",{type:"button",onClick:()=>{Re(t)},className:U("flex w-full items-center gap-1.5 rounded-md px-2 py-1 text-left text-foreground transition-colors",i?"bg-interactive-selection/70":"hover:bg-interactive-hover/40"),children:[Xr(t.path,t.extension),s.jsx("span",{className:"min-w-0 flex-1 truncate typography-meta",style:{direction:"rtl",textAlign:"left"},title:t.path,children:t.relativePath??t.path})]})},t.path)}):mr?s.jsxs("li",{className:"flex flex-col gap-2 px-2 py-1 typography-meta text-muted-foreground",children:[s.jsx("span",{className:"text-[var(--status-error)]",children:mr}),s.jsxs(z,{variant:"outline",size:"xs",className:"w-fit gap-1.5",onClick:()=>{ps()},children:[s.jsx(w,{name:"refresh",className:"size-3.5"}),e("filesView.tree.actions.refreshTitle")]})]}):Hi?Xn(o,0):s.jsx("li",{className:"px-2 py-1 typography-meta text-muted-foreground",children:e("filesView.state.loading")})})})]}),qi=a==="full"&&K&&c&&s.jsx("div",{className:"absolute inset-0 z-50 flex flex-col bg-background",children:s.jsxs("div",{className:"flex-1 min-h-0 min-w-0 relative",children:[s.jsx("div",{className:"absolute right-4 top-4 z-30",children:fr({exitFullscreenOnly:!0})}),s.jsx(nn,{ref:ur.setScroller,outerClassName:"h-full min-w-0",className:U("h-full min-w-0",Ue&&"[overflow-anchor:none]"),children:Be||ir?$?s.jsx("div",{className:"p-4"}):s.jsxs("div",{className:"p-4 flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),"Loading…"]}):et?s.jsx("div",{className:"p-4 typography-ui text-[color:var(--status-error)]",children:et}):Fe?s.jsx("div",{className:"flex h-full items-center justify-center p-4",children:s.jsx("img",{src:ar,alt:c.name,className:"max-w-full max-h-full object-contain rounded-md border border-border/30 bg-primary/10"},c.path)}):Oe?lr(c):st?s.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-3 p-6 text-center",children:[s.jsx("div",{className:"typography-ui-header text-foreground",children:e("filesView.editor.cannotPreviewBinary")}),s.jsx("div",{className:"max-w-md typography-ui text-muted-foreground",children:e("filesView.editor.binaryFileDescription")}),n.downloadFile?s.jsxs(z,{type:"button",variant:"outline",size:"sm",onClick:()=>{const t=n.downloadFile;!t||!c||t(c.path).catch(i=>{console.error("Download failed:",i),G.error(e("sidebarFilesTree.toast.operationFailed"))})},children:[s.jsx(w,{name:"download",className:"mr-2 size-4"}),e("filesView.editor.saveFile")]}):null]}):bt&&nt()==="preview"?s.jsxs("div",{className:"oc-file-preview h-full overflow-auto p-4",ref:fs,children:[c?s.jsx(Dr,{containerRef:fs,filePath:c.path,fileContent:R}):null,R.length>500*1024&&s.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:e("filesView.warning.largeFilePreviewLimited",{sizeKb:Math.round(R.length/1024)})}),s.jsx(rn,{fallback:s.jsxs("div",{className:"rounded-md border border-destructive/20 bg-destructive/10 px-3 py-2",children:[s.jsx("div",{className:"mb-1 font-medium text-destructive",children:e("filesView.error.previewUnavailable")}),s.jsx("div",{className:"text-sm text-muted-foreground",children:e("filesView.error.switchToEditMode")})]}),children:s.jsx(kr,{content:R,className:"typography-markdown-body",stripFrontmatter:!0,enableFileReferences:!1})})]}):Us&&E==="view"?dr(c,Ue?R:re,ur):s.jsxs("div",{className:U("relative h-full",Pt&&"overflow-hidden"),children:[s.jsx("div",{className:U("h-full",Pt&&"invisible"),children:s.jsx(Vr,{value:re,onChange:xe,readOnly:!_e,vimMode:Pn==="vim",extensions:Qn,className:"h-full",onViewReady:t=>{$e.current=t,window.requestAnimationFrame(()=>{Mt(t)})},onViewDestroy:()=>{$e.current&&($e.current=null)}})}),Pt&&s.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center bg-background",children:s.jsxs("div",{className:"flex items-center gap-2 typography-ui text-muted-foreground",children:[s.jsx(w,{name:"loader-4",className:"size-4 animate-spin"}),e("filesView.state.openingFileAtChange")]})})]})})]})});return s.jsxs("div",{className:"flex h-full min-h-0 overflow-hidden bg-background relative",children:[s.jsx(Co,{activeDialog:vt,dialogData:wt,dialogInputValue:lt,onDialogInputChange:jn,isDialogSubmitting:ui,onDialogSubmit:Si,onClose:Ki,inputRef:ni}),qi,h?J?Zs:hr:a==="editor-only"?s.jsx("div",{className:"flex flex-1 min-h-0 min-w-0 overflow-hidden",children:s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden bg-background",children:Zs})}):s.jsxs("div",{className:"flex flex-1 min-h-0 min-w-0 gap-3 px-3 pb-3 pt-2",children:[p>=700&&s.jsx("div",{className:"w-72 flex-shrink-0 min-h-0 overflow-hidden",children:hr}),s.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden rounded-xl border border-border/60 bg-background",children:Zs})]})]})};function So(a){return a+1}export{Hc as FilesView};