@kabmo-labs/kabmo 0.53.2 → 0.55.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 (146) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +538 -527
  3. package/dist/client/static/js/{Body-vaa10tcd.js → Body-a4dwe3hh.js} +1 -1
  4. package/dist/client/static/js/{CsvGrid-wabx4e6w.js → CsvGrid-ppj80brw.js} +1 -1
  5. package/dist/client/static/js/{DocxView-22b3mhh5.js → DocxView-ef0bd2pg.js} +1 -1
  6. package/dist/client/static/js/{DrawioView-e02qhkp2.js → DrawioView-44tpkzbd.js} +1 -1
  7. package/dist/client/static/js/{HtmlPreview-q7hwcf4s.js → HtmlPreview-w654aykz.js} +1 -1
  8. package/dist/client/static/js/{ImageView-fxb60ge7.js → ImageView-kg0skt5s.js} +1 -1
  9. package/dist/client/static/js/{LayoutWrapper-cey5agsf.js → LayoutWrapper-qepkrtd8.js} +2 -2
  10. package/dist/client/static/js/MergeDiffView-n2h8vv0j.js +1 -0
  11. package/dist/client/static/js/{Modal-e4yq7p5f.js → Modal-8d299emm.js} +17 -17
  12. package/dist/client/static/js/{PdfView-pf3angsq.js → PdfView-eq7fnqa2.js} +1 -1
  13. package/dist/client/static/js/{SessionsView-mcvhpx0b.js → SessionsView-tedh2es3.js} +1 -1
  14. package/dist/client/static/js/{SheetView-5ha5vvsr.js → SheetView-5xm33kgk.js} +1 -1
  15. package/dist/client/static/js/{SvgPreview-45wqjw0b.js → SvgPreview-tp1m8r4t.js} +1 -1
  16. package/dist/client/static/js/{abnfDiagram-O67JEVCF-gnf6krbs.js → abnfDiagram-O67JEVCF-xppr9jf1.js} +1 -1
  17. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-00fd0wsg.js → architectureDiagram-NJMV4G6O-s23e6vtk.js} +1 -1
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-9c2sm96a.js → blockDiagram-BEXU5L5S-7ws8yq9e.js} +1 -1
  19. package/dist/client/static/js/{c4Diagram-YGBWAQC7-pemygn0s.js → c4Diagram-YGBWAQC7-517yhfzj.js} +1 -1
  20. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-h7r3sx3s.js → classDiagram-v2-NBCMYWYE-tcad3rst.js} +1 -1
  21. package/dist/client/static/js/{cose-bilkent-JH36ORCC-krx9crwv.js → cose-bilkent-JH36ORCC-a76vf82p.js} +1 -1
  22. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-5rp2btew.js → cynefinDiagram-VND7K2PF-9kety453.js} +1 -1
  23. package/dist/client/static/js/{dagre-6A5THRUB-q57cnz52.js → dagre-6A5THRUB-6g6gsp6b.js} +1 -1
  24. package/dist/client/static/js/{diagram-22UHCM2B-0bptn06k.js → diagram-22UHCM2B-ngj4fyg3.js} +1 -1
  25. package/dist/client/static/js/{diagram-3UASUU5V-60snxawz.js → diagram-3UASUU5V-xw2m99qa.js} +1 -1
  26. package/dist/client/static/js/{diagram-ATOU4E4O-bb0kewfp.js → diagram-ATOU4E4O-hz3bd083.js} +2 -2
  27. package/dist/client/static/js/{diagram-CDSNMT55-3cdkns0z.js → diagram-CDSNMT55-vfhtemve.js} +3 -3
  28. package/dist/client/static/js/{diagram-MLGK6HIB-03mbhzeq.js → diagram-MLGK6HIB-22cjvj5g.js} +1 -1
  29. package/dist/client/static/js/{diagram-MPIPVDR6-bcvzqqf4.js → diagram-MPIPVDR6-xv8fsecp.js} +2 -2
  30. package/dist/client/static/js/{dockerfile-7kqkk4tz.js → dockerfile-491tyqmj.js} +1 -1
  31. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-sg6kwnbx.js → ebnfDiagram-ZINNZB2B-m6mkn986.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-5b8v0sdv.js → elk-276RUBZZ-jccw706n.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-xbs156j5.js → erDiagram-OPXOYQCR-rxk86jsf.js} +1 -1
  34. package/dist/client/static/js/flowDiagram-KWPJA3E3-aegwx04w.js +1 -0
  35. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-4p7pfk6c.js → ganttDiagram-FUAMR5RP-veweech7.js} +1 -1
  36. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-3xqwr9pf.js → gitGraphDiagram-X574FWY7-7dyqcj8r.js} +2 -2
  37. package/dist/client/static/js/{index-p75b7phb.js → index-088gwjbz.js} +1 -1
  38. package/dist/client/static/js/{index-5qtnmn76.js → index-0ak5wdz1.js} +1 -1
  39. package/dist/client/static/js/{index-pak6t03c.js → index-0qmpqtp2.js} +1 -1
  40. package/dist/client/static/js/{index-26a4afcr.js → index-0xh8402w.js} +1 -1
  41. package/dist/client/static/js/{index-yf5a6t3p.js → index-2asa0faw.js} +1 -1
  42. package/dist/client/static/js/{index-gzz6snng.js → index-2cfw7wem.js} +1 -1
  43. package/dist/client/static/js/{index-e2esj214.js → index-39mr4tym.js} +1 -1
  44. package/dist/client/static/js/{index-hp3s5r3g.js → index-3x88fxzj.js} +1 -1
  45. package/dist/client/static/js/{index-trrmbq0h.js → index-4m94cbms.js} +1 -1
  46. package/dist/client/static/js/{index-rtpg4t84.js → index-5701gj1f.js} +1 -1
  47. package/dist/client/static/js/{index-pdkt3r4r.js → index-60fjqzdw.js} +1 -1
  48. package/dist/client/static/js/{index-mtjbp5ga.js → index-637my5h0.js} +1 -1
  49. package/dist/client/static/js/{index-c8ta3k4g.js → index-7ckzdf4r.js} +158 -156
  50. package/dist/client/static/js/{index-1d8ff4t7.js → index-7ehep28z.js} +2 -2
  51. package/dist/client/static/js/{index-hwq7zgqd.js → index-bfy437re.js} +1 -1
  52. package/dist/client/static/js/{index-zc3snsr9.js → index-bhst1c2x.js} +1 -1
  53. package/dist/client/static/js/{index-nnhs52db.js → index-cz80n8yc.js} +1 -1
  54. package/dist/client/static/js/{index-ayx3q8t9.js → index-d9dz0wt0.js} +1 -1
  55. package/dist/client/static/js/{index-3bmn5cc5.js → index-dg714jam.js} +1 -1
  56. package/dist/client/static/js/{index-z7gd7nvb.js → index-e6tjaccf.js} +1 -1
  57. package/dist/client/static/js/{index-vwxt5ss9.js → index-gsw1zh30.js} +1 -1
  58. package/dist/client/static/js/{index-x0y2c61e.js → index-j0qt8gaj.js} +1 -1
  59. package/dist/client/static/js/{index-45vcpqp9.js → index-kfcpkx7h.js} +1 -1
  60. package/dist/client/static/js/{index-cy6ceab8.js → index-na95tr1k.js} +1 -1
  61. package/dist/client/static/js/{index-ng3e6k6x.js → index-nzjc24v9.js} +1 -1
  62. package/dist/client/static/js/{index-3amzzsdk.js → index-pqmvhqmj.js} +11 -11
  63. package/dist/client/static/js/{index-0btbxkxf.js → index-r51fqzb5.js} +1 -1
  64. package/dist/client/static/js/{index-cj8v7b50.js → index-sx5x2q80.js} +1 -1
  65. package/dist/client/static/js/{index-qj9tcz44.js → index-tk1vr8q2.js} +1 -1
  66. package/dist/client/static/js/{index-j9t5xc3y.js → index-trpn9gxs.js} +1 -1
  67. package/dist/client/static/js/{index-1regq9wd.js → index-twjq786a.js} +1 -1
  68. package/dist/client/static/js/{index-xqkcx4az.js → index-wa234c7k.js} +1 -1
  69. package/dist/client/static/js/{index-mgs5nscx.js → index-wp7tsava.js} +1 -1
  70. package/dist/client/static/js/{index-nmhwjwmt.js → index-wvqwzgpx.js} +1 -1
  71. package/dist/client/static/js/{index-jg6ecfc7.js → index-xbvjpa60.js} +2 -2
  72. package/dist/client/static/js/{index-jf8zcg99.js → index-xm3691yp.js} +4 -4
  73. package/dist/client/static/js/{index-cysdvwqw.js → index-xq78fj64.js} +1 -1
  74. package/dist/client/static/js/{index-ryww3xxj.js → index-zjc8yfbe.js} +1 -1
  75. package/dist/client/static/js/{infoDiagram-VRGFBTTK-c362sv3t.js → infoDiagram-VRGFBTTK-ksz9cvq3.js} +1 -1
  76. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-yc8ts8wj.js → ishikawaDiagram-OU5B5YK6-g8symmrp.js} +1 -1
  77. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-178c75fy.js → journeyDiagram-ZHPQQLJL-qs2e3hdf.js} +1 -1
  78. package/dist/client/static/js/{kanban-definition-PNTS6WVX-w6g3n001.js → kanban-definition-PNTS6WVX-pzef80sz.js} +1 -1
  79. package/dist/client/static/js/{mermaid.core-vcdgn378.js → mermaid.core-chfcvkkc.js} +3 -3
  80. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-t9e8arca.js → mindmap-definition-NLK3R4M7-sds2e243.js} +1 -1
  81. package/dist/client/static/js/one-dark-pro-5fvhpb1t.js +1 -0
  82. package/dist/client/static/js/one-light-pwj40vbr.js +1 -0
  83. package/dist/client/static/js/{pegDiagram-GJSIUBJH-nehn0x9n.js → pegDiagram-GJSIUBJH-m8199cy0.js} +1 -1
  84. package/dist/client/static/js/{pieDiagram-5QR66LMP-p1t3ctd4.js → pieDiagram-5QR66LMP-wqz5k5w6.js} +2 -2
  85. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-614rtbfe.js → quadrantDiagram-O4NWA36T-rjszd8an.js} +1 -1
  86. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-2vpr6pw8.js → railroadDiagram-XR7U4H2S-qv0be7dh.js} +1 -1
  87. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-b91s5q3p.js → requirementDiagram-PLB6GJNP-b87kqbr7.js} +1 -1
  88. package/dist/client/static/js/{rust-jj206pb7.js → rust-m7ma3tq9.js} +1 -1
  89. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-4101kt9r.js → sankeyDiagram-IPEJSGJF-dh5we479.js} +1 -1
  90. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-yq0cxg8c.js → sequenceDiagram-PO4LG4MO-e6fg0x45.js} +1 -1
  91. package/dist/client/static/js/{sizeCapture-INFHLROL-jkvq39vz.js → sizeCapture-INFHLROL-mam6cagq.js} +1 -1
  92. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-y0h7w5rw.js → stateDiagram-v2-GCMORJYK-htwar22v.js} +1 -1
  93. package/dist/client/static/js/{swimlanes-2SLR337P-1y073wzx.js → swimlanes-2SLR337P-5g26cnkr.js} +1 -1
  94. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-8ahz3c68.js → swimlanesDiagram-TC7HE7FX-rseba3zs.js} +1 -1
  95. package/dist/client/static/js/{timeline-definition-EJHVYXUP-yjb0g0ys.js → timeline-definition-EJHVYXUP-5km8n8mj.js} +1 -1
  96. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-8xjkxrkv.js → usecaseDiagram-POWQR4AR-0vt6ms5g.js} +1 -1
  97. package/dist/client/static/js/{vennDiagram-UO4OBE2U-18wjbwtg.js → vennDiagram-UO4OBE2U-k425105a.js} +2 -2
  98. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-xqrfsrwp.js → wardleyDiagram-VNRHLVJA-s0gd4jg1.js} +2 -2
  99. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-azygghkz.js → xychartDiagram-PMCCYNJV-2nrdzp7p.js} +2 -2
  100. package/package.json +5 -5
  101. package/src/client/App.tsx +4 -0
  102. package/src/client/bootstrap.d.ts +11 -0
  103. package/src/client/components/workspace/chat-timeline/tool-renderers/index.tsx +2 -0
  104. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.test.tsx +67 -0
  105. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AgentAdmin.tsx +89 -0
  106. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.test.tsx +91 -0
  107. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +8 -2
  108. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +9 -0
  109. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +16 -1
  110. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.test.tsx +59 -0
  111. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +11 -1
  112. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.test.ts +119 -0
  113. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/agent-admin-rows.ts +174 -0
  114. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/task-rows.ts +14 -2
  115. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.test.ts +22 -0
  116. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/card-header.ts +14 -0
  117. package/src/client/data/settings/omp-schema.json +455 -165
  118. package/src/client/hooks/shell/last-opened-session.test.ts +166 -0
  119. package/src/client/hooks/shell/last-opened-session.ts +74 -0
  120. package/src/client/lib/router/open-session.test.ts +8 -0
  121. package/src/client/lib/router/open-session.ts +9 -4
  122. package/src/client/main.tsx +7 -0
  123. package/src/server/lib/db/schema.ts +10 -0
  124. package/src/server/lib/sessions/last-opened-client.server.ts +86 -0
  125. package/src/server/lib/sessions/last-opened-client.test.ts +91 -0
  126. package/src/server/lib/sessions/last-opened.server.test.ts +127 -0
  127. package/src/server/lib/sessions/last-opened.server.ts +129 -0
  128. package/src/server/plugins/ssr.ts +40 -17
  129. package/src/server/routes/fs/raw.test.ts +33 -0
  130. package/src/server/routes/fs/raw.ts +31 -11
  131. package/src/server/routes/sessions/index.ts +14 -0
  132. package/src/server/routes/sessions/last-opened.test.ts +139 -0
  133. package/src/server/routes/sessions/last-opened.ts +66 -0
  134. package/src/shared/lib/chat/timeline/tool-phrases.test.ts +4 -0
  135. package/src/shared/lib/chat/timeline/tool-phrases.ts +2 -0
  136. package/src/shared/lib/models/provider/glyph.test.ts +13 -11
  137. package/src/shared/lib/models/provider/glyph.ts +1 -0
  138. package/src/shared/lib/models/provider/label.ts +3 -0
  139. package/src/shared/lib/omp/config/schema-releases-19-3.test.ts +64 -0
  140. package/src/shared/lib/omp/config/schema-releases.test.ts +21 -4
  141. package/src/shared/lib/omp/session/wait-idle.test.ts +12 -2
  142. package/src/shared/lib/omp/session/wait-idle.ts +11 -6
  143. package/dist/client/static/js/MergeDiffView-1z9mwf73.js +0 -1
  144. package/dist/client/static/js/flowDiagram-KWPJA3E3-sasgvf55.js +0 -1
  145. package/dist/client/static/js/one-dark-pro-17hh3q12.js +0 -1
  146. package/dist/client/static/js/one-light-cntgvscy.js +0 -1
@@ -1 +1 @@
1
- import{n,o,K,i,a,ze,Me,Se,ie,e,s,p,I,E,Xe,bi,ir,h,sr,He,we,T,tt,wi,he,X,mt,Oo,Uo,N0,H0,Of,Jo,Ni,eg,hA}from"./index-c8ta3k4g.js";import"./index-mtjbp5ga.js";import{Li}from"./index-zc3snsr9.js";import"./index-4kchzh9y.js";import{wA,xu,Fs,wu,Cu,Eu,Bu,Iu,_u,Su,Tu,Du}from"./index-yf5a6t3p.js";var vt={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},be=s(vt);var z=new Set,ae=new Set,ge=new Set;function ve(){ge=new Set(z);for(let t of[...ae])t()}function xe(t){let r=new Set(t);if(r.size===z.size){let l=!0;for(let d of r)if(!z.has(d)){l=!1;break}if(l)return}z.clear();for(let l of r)z.add(l);ve()}function ye(t){let r=new Set(t),l=!1;for(let d of[...z])if(!r.has(d))z.delete(d),l=!0;if(l)ve()}function Ce(t){return z.has(t)}function ke(){return z.size>0}function ht(t){return ae.add(t),()=>{ae.delete(t)}}var xt=ht;function Ee(){return ze(xt,()=>ge)}function Te({x:t,y:r,rows:l,onAction:d,onClose:u}){let x=i(null),[m,c]=n({left:t,top:r});return K(()=>{let b=x.current;if(!b)return;let{width:k,height:g}=b.getBoundingClientRect();c({left:Math.min(t,Math.max(0,window.innerWidth-k-8)),top:Math.min(r,Math.max(0,window.innerHeight-g-8))})},[t,r,l.length]),ie(e("div",{className:"fixed inset-0 z-[70]",onClick:u,onContextMenu:(b)=>{b.preventDefault(),u()},children:e("div",{ref:x,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${m.left}px`,top:`${m.top}px`},onClick:(b)=>b.stopPropagation(),children:l.map((b)=>e("button",{type:"button",role:"menuitem",onClick:()=>{d(b.action),u()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:b.label},b.action))})}),document.body)}var ee={rightFileId:null,fraction:0.5};function ne(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ne(t,r){for(let l=r.length-1;l>=0;l-=1){let d=r[l];if(d!==t)return d}return null}function Pe(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function Y(t){if(!Number.isFinite(t))return ee.fraction;return Math.max(0.2,Math.min(0.8,t))}function De(t,r){if(typeof t!=="object"||t===null)return ee;let l=t,d=typeof l.fraction==="number"?Y(l.fraction):ee.fraction,u=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(u===null||!r.includes(u))return{rightFileId:null,fraction:d};return{rightFileId:u,fraction:d}}function Re({tab:t,openedFiles:r,dirtyIds:l,reopenable:d,activeFileId:u,splitRightFileId:x}){let m=r.filter((g)=>g.id!==t.id),c=r.filter((g)=>!l.has(g.id)),b=r.map((g)=>g.id);return[{action:"split-right",label:"Split right",enabled:ne(t.id,u,b)},{action:"unsplit",label:"Unsplit",enabled:x!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:m.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:c.some((g)=>g.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:d>0}].filter((g)=>g.enabled)}function Z({onHide:t}){let r=Jo("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(be,{size:14})})}function Ie({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,missingIds:u,onCopyPath:x,onRevealInFiles:m,onReopenClosed:c,reopenableCount:b,onSplitTo:k,onUnsplit:g,splitRightFileId:y=null,onHide:R}){let M=Ee(),P=i(null),L=i(null),[D,O]=n(5),[A,F]=n(!1),[f,Q]=n(null);he(L,()=>F(!1)),o(()=>{let v=new ResizeObserver((w)=>{for(let S of w){let q=S.contentRect.width,H=Math.max(1,Math.floor((q-60)/150));O(H)}});if(P.current)v.observe(P.current);return()=>v.disconnect()},[]);let U=Ne(r,t.map((v)=>v.id)),j=[],G=[];if(t.length<=D)j=t;else{let v=t.findIndex((S)=>S.id===r),w=new Set;if(v!==-1&&r!==null)w.add(r);for(let S=t.length-1;S>=0;S--){if(w.size>=D)break;w.add(t[S].id)}j=t.filter((S)=>w.has(S.id)),G=t.filter((S)=>!w.has(S.id))}return e("div",{className:`${wi.desktop} flex bg-ink/10 w-full relative border-b border-ink/10`,ref:P,children:[e("div",{className:"flex overflow-hidden",children:j.map((v)=>{let w=v.id===r,S=Boolean(v.isDiff),q=S?sr(v.diffStatus||"M",v.diffStaged):null,H=Boolean(u?.has(v.id));return e("div",{onClick:()=>l(v.id),onContextMenu:(_)=>{_.preventDefault(),Q({tab:v,x:_.clientX,y:_.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${w?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:H?`${v.path} — file no longer exists`:v.path,children:[S?e(bi,{size:14,className:w?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(mt,{name:v.name,size:14,className:`flex-shrink-0${w||H?"":" opacity-60"}${H?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${H?" text-error line-through":""}`,children:v.name}),q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${q.badgeBgClass}`,children:q.charStatus}),e(Oe,{dirty:M.has(v.id),active:w,label:`Close ${v.name}`,onClose:()=>d(v.id)})]},v.id)})}),f?e(Te,{x:f.x,y:f.y,rows:Re({tab:f.tab,openedFiles:t,dirtyIds:M,reopenable:b?.()??0,activeFileId:r,splitRightFileId:y}),onAction:(v)=>{let w=f.tab;switch(v){case"close":d(w.id);return;case"close-others":for(let S of[...t].reverse())if(S.id!==w.id)d(S.id);l(w.id);return;case"close-all":for(let S of[...t].reverse())d(S.id);return;case"close-saved":for(let S of[...t].reverse())if(!M.has(S.id))d(S.id);return;case"copy-path":x?.(w);return;case"reveal-in-files":m?.(w);return;case"reopen-closed":c?.();return;case"split-right":k?.(w.id);return;case"unsplit":g?.();return}},onClose:()=>Q(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>y!==null?g?.():k?.(U),disabled:y===null&&U===null,"aria-pressed":y!==null,"aria-label":"Split editor",title:y!==null?"Close the split pane (the tab stays open)":U===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${y!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(ir,{size:14})}),R&&e(Z,{onHide:R})]}),G.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:L,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${A?"bg-ink/10 text-ink":""}`,onClick:()=>F(!A),title:"More open files",children:e(E,{size:14})}),A&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),G.map((v)=>{let w=Boolean(u?.has(v.id));return e("div",{onClick:()=>{l(v.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[v.isDiff?e(bi,{size:14,className:"text-info/80"}):e(mt,{name:v.name,size:14,className:w?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${w?"text-error line-through":"text-ink/80"}`,children:v.name}),e(Oe,{dirty:M.has(v.id),active:!1,label:`Close ${v.name}`,onClose:()=>{if(d(v.id),G.length===1)F(!1)}})]},v.id)})]})]})]})}function Oe({dirty:t,active:r,label:l,onClose:d}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(u)=>{u.stopPropagation(),d()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(h,{size:12})})}function Ae({pluginId:t,Component:r,sessionId:l,className:d="",onHide:u}){return e("div",{className:`flex flex-col h-full bg-canvas ${d}`,children:[u&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(Z,{onHide:u})}),e(tt,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Fe({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(Z,{onHide:r})}),e(mt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Le({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let d=i(null);o(()=>{if(!t||d.current===t.request)return;d.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Be({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:d,setPreviewMode:u,sessionId:x}){o(()=>{let m=new Set(t.filter((c)=>!c.isDiff&&c.content===void 0).map((c)=>c.id));xe([...r].filter((c)=>m.has(c)))},[r,t]),o(()=>{if(!d)return;let m=l?.id;if(!l||m===void 0||m===null)return;if(!xu(Fs(l.name)))return;let c=we(x,"editor.previewMode");if(c&&c[m]!==void 0)return;u((b)=>b[m]===void 0?{...b,[m]:!0}:b)},[d,l])}function Ke({activeFile:t,externalChange:r,conflict:l,onReload:d,onKeepMine:u}){if(!t)return null;if(l)return e(Su,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:d,onKeepMine:u});if(r)return e(_u,{fileName:t.name,onReload:d,onKeepMine:u});return null}async function $e(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let d=await fetch("/api/fs/action",{method:"POST",body:l}),u=await d.json().catch(()=>null),x=typeof u?.error==="string"?u.error:null;if(d.status===409)return{status:"exists",reason:x??`${r} already exists.`};if(d.ok&&u?.success&&typeof u.path==="string")return{status:"written",path:u.path};return{status:"failed",reason:x??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Ue(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ge(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function yt(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function qe({fileName:t,filePath:r,content:l,eol:d,root:u,repo:x,onSaved:m,onClose:c}){let[b,k]=n(()=>yt(r)),[g,y]=n(()=>Ue(t)),[R,M]=n(!1),[P,L]=n(null),D=i(null);o(()=>{D.current?.focus(),D.current?.select()},[]);let O=Ge(g),A=async()=>{if(!O||R)return;M(!0),L(null);let f=await $e({parent:b,name:g,content:l,eol:d,root:u,repo:x});if(M(!1),f.status==="written"){m({path:f.path});return}L(f.reason)},F=(f)=>{if(f.key==="Enter"){f.preventDefault(),A();return}if(f.key==="Escape")f.preventDefault(),c()};return e(X,{onClose:c,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void A(),disabled:!O||R,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[R?e(p,{size:12,className:"animate-spin"}):e(Xe,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:b,onInput:(f)=>k(f.target.value),onKeyDown:F,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:D,value:g,onInput:(f)=>y(f.target.value),onKeyDown:F,"aria-label":"File name","aria-invalid":!O,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${O?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!O?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,P?e("div",{className:"text-[10px] text-error font-mono",children:P}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _e(){o(()=>{let t=(r)=>{if(!ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function We({fileName:t,onAnswer:r}){return e(X,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(I,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Ve({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:d,onConfirmSaveMissing:u}){if(t.pending)return e(We,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Tu,{fileName:r.name,filePath:r.path,onClose:d,onConfirm:u});return null}function Je({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:d,asSplitPane:u,tabs:x,activeFile:m,editor:c,externalChange:b,conflict:k,onReload:g,onKeepMine:y,body:R,saveAsOpen:M,onSaveAsClose:P,onSavedAs:L,closeGuard:D}){let O=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:O,onKeyDownCapture:l,onFocusCapture:d,children:[u?null:x,e(Ke,{activeFile:m,externalChange:b,conflict:k,onReload:g,onKeepMine:y}),R,M&&m?e(qe,{fileName:m.name,filePath:m.path,content:c.content,eol:c.eol,root:m.root,repo:m.repo,onSaved:({path:A})=>L(A),onClose:P}):null,e(Ve,{closeGuard:D,activeFile:m,saveMissingConfirm:c.saveMissingConfirm,onCancelSaveMissing:c.cancelSaveMissing,onConfirmSaveMissing:c.confirmSaveMissing})]})}function Ye({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(h,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Ze({fraction:t,onFraction:r,rightPaneName:l,onClosePane:d,rightPane:u,children:x}){let m=i(null),c=i(null),b=Of(c),k=(g)=>{let y=g.currentTarget,R=m.current;if(!y||!R)return;y.setPointerCapture(g.pointerId);let M=(L)=>{let D=R.getBoundingClientRect();if(D.width===0)return;r(Y((L.clientX-D.left)/D.width))},P=()=>{y.releasePointerCapture(g.pointerId),y.removeEventListener("pointermove",M),y.removeEventListener("pointerup",P)};y.addEventListener("pointermove",M),y.addEventListener("pointerup",P)};return e("div",{ref:m,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(Y(t)*100)}%`},children:x}),e("div",{ref:c,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${b?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:k}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Ye,{fileName:l,onClose:d,children:u})})]})}function Qe({openedFiles:t,activeFileId:r,enabled:l}){let[d,u]=T("editor.split",ee),x=t.map((y)=>y.id),m=Pe(De(d,x),r),c=l&&m.rightFileId!==null?t.find((y)=>y.id===m.rightFileId)??null:null,b=a((y)=>{if(y!==null&&!ne(y,r,x))return;u({...m,rightFileId:y})},[m,u,r,x]),k=a(()=>u({...m,rightFileId:null}),[m,u]),g=a((y)=>u({...m,fraction:Y(y)}),[m,u]);return{rightFile:c,fraction:m.fraction,splitTo:b,close:k,setFraction:g}}function je({find:t,runCommand:r,reopenClosed:l}){let d=i(t);d.current=t;let u=i(r);u.current=r;let x=i(l);return x.current=l,{onKeyDownCapture:a((c)=>{let b=d.current;if(c.key==="Escape"){if(!b.open)return;c.preventDefault(),c.stopPropagation(),b.close();return}if((c.metaKey||c.ctrlKey)&&c.shiftKey&&c.code==="KeyT"){if(x.current?.())c.preventDefault(),c.stopPropagation();return}let k=N0(Ni,c);if(!k||!eg(k))return;c.preventDefault(),c.stopPropagation(),u.current(k)},[])}}function et(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(u)=>r.current.runCommand(u)};return o(()=>{let u=l.current;if(!u)return;return hA(u)},[]),{onFocusCapture:a(()=>{if(l.current)hA(l.current)},[])}}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,saveNow:u}){let[x,m]=n(null);_e();let c=a((k)=>{let g=t.find((y)=>y.id===k);if(g&&Ce(k)){m(g);return}d(k)},[t,d]),b=a((k)=>{let g=x;if(!g)return;if(k==="cancel"){m(null);return}if(k==="save"){if(g.id!==r)l(g.id);u()}m(null),d(g.id)},[x,r,l,u,d]);return{requestClose:c,pending:x,answer:b}}function ot(){let[t,r]=n(0),[l,d]=n(!1),u=a(()=>r((x)=>x+1),[]);return{goToLineRequest:t,openGoToLine:u,saveAsOpen:l,setSaveAsOpen:d}}var Ct=Se(()=>import("./Body-vaa10tcd.js").then((t)=>({default:t.EditorBody})));function rt(t){return e(Me,{fallback:e("div",{className:"h-full w-full"}),children:e(Ct,{...t})})}function kt({className:t="",openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m=0,onFileSaved:c,onOpenPath:b,onReopenClosed:k,reopenableCount:g,onCopyPath:y,onRevealInFiles:R,rootPath:M=null,repoPath:P=null,activeEditorPanelKey:L=null,forcedActiveFileId:D=null,asSplitPane:O=!1,onHidePanel:A}){let F=O?D:l,f=r.find((C)=>C.id===F),[Q,U,j]=T("editor.previewMode",{}),G=Du(String(F??"")),[v,w]=T("editor.zoomLevel",Oo),[S,q]=n(!1),[H,_]=T("editor.wordWrap",!0),J=ot(),{sessionId:le}=He(),B=Qe({openedFiles:r,activeFileId:F,enabled:!O}),W=i(null),it=Uo(),st=Li(),de=wu(r,m),ue=Boolean(f&&de.has(f.id)),N=Cu(f??null,{reportSaveError:!0,onFileSaved:c,missing:ue}),at=wA({path:f?.path??"",content:N.content,language:N.language}),lt=N.diskChange,pe=nt({openedFiles:r,activeFileId:F,onSelectFile:d,onCloseFile:u,saveNow:N.saveNow}),te=Eu({text:N.content,documentKey:`${f?.id??""}\x00${N.language}`,readSelection:()=>W.current?.getSelection()??null,select:(C,V,se=!0)=>W.current?.select(C,V,se),reveal:(C)=>W.current?.revealOffset(C),applyDocument:(C,V,se)=>W.current?.applyDocument(C,V,se),toggleWordWrap:()=>_((C)=>!C)}),ce=Bu(f?.path??null,N.content,N.loaded&&!N.loadError);Le({searchReveal:ce,revealMatch:te.revealMatch}),Iu({file:f,editor:N,surfaceRef:W,isPreview:f?Q[f.id]===!0:!1,exitPreview:()=>{let C=f?.id;if(C===void 0||C===null)return;U((V)=>({...V,[C]:!1}))}}),o(()=>{if(m>0)N.reset()},[m]),o(()=>{N.retain(r.map((C)=>C.id)),ye(r.map((C)=>C.id))},[r]),Be({openedFiles:r,dirtyKeys:N.dirtyKeys,activeFile:f,previewReady:j,setPreviewMode:U,sessionId:le});let dt=()=>{if(!f)return;U((C)=>({...C,[f.id]:!C[f.id]}))},oe=(C)=>{if(eg(C)){te.runCommand(C);return}if(C==="toggleWordWrap"){_((V)=>!V);return}if(C==="goToLine"){J.openGoToLine();return}W.current?.runCommand(C)},ut=je({find:te,runCommand:oe,reopenClosed:k}),pt=et({saveNow:N.saveNow,runCommand:oe}),re=H0(L);if(re)return e(Ae,{pluginId:re.pluginId,Component:re.Component,sessionId:le,className:t,onHide:A});if(r.length===0)return e(Fe,{className:t,onHide:A});let ct=N.viewerKind,me=f?Q[f.id]:!1,ft={activeFile:f,editor:N,find:te,surfaceRef:W,pluginFileView:at,wordWrap:H,setWordWrap:_,viewerKind:ct,isPreview:Boolean(me),isReviewing:Boolean(me)&&G.active,onToggleReview:G.toggle,isMaximized:S,setIsMaximized:q,zoomLevel:v,setZoomLevel:w,goToLineRequest:J.goToLineRequest,onSaveAs:()=>J.setSaveAsOpen(!0),onOpenPath:b,rootPath:M,repoPath:P,runCommand:oe,editorFontFamily:it,editorTheme:st,togglePreview:dt,revealActive:Boolean(ce),missing:ue,onConvertDiffToEditor:x,onFileSaved:c},bt=(C)=>({openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m,onFileSaved:c,onOpenPath:b,rootPath:M,repoPath:P,forcedActiveFileId:C,asSplitPane:!0}),gt=e(Ie,{openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:pe.requestClose,missingIds:de,onCopyPath:y,onRevealInFiles:R,onReopenClosed:k,reopenableCount:g,onSplitTo:B.splitTo,onUnsplit:B.close,splitRightFileId:B.rightFile?.id??null,onHide:A}),fe=e(Je,{className:t,isMaximized:S,onKeyDownCapture:ut.onKeyDownCapture,onFocusCapture:pt.onFocusCapture,asSplitPane:O,tabs:gt,activeFile:f,editor:N,externalChange:lt,conflict:N.conflict,onReload:N.resolveConflictByReload,onKeepMine:N.keepMineAgainstDisk,body:e(rt,{...ft}),saveAsOpen:J.saveAsOpen,onSaveAsClose:()=>J.setSaveAsOpen(!1),onSavedAs:(C)=>{J.setSaveAsOpen(!1),b?.(C)},closeGuard:pe});if(!B.rightFile)return fe;return e(Ze,{fraction:B.fraction,onFraction:B.setFraction,rightPaneName:B.rightFile.name,onClosePane:B.close,rightPane:e(kt,{...bt(B.rightFile.id)}),children:fe})}export{kt as Editor};
1
+ import{n,o,K,i,a,ze,Me,Se,ie,e,s,p,I,E,Xe,bi,ir,h,sr,He,we,T,tt,wi,he,X,mt,Oo,Uo,N0,H0,Of,Jo,Ni,eg,hA}from"./index-7ckzdf4r.js";import"./index-637my5h0.js";import{Li}from"./index-bhst1c2x.js";import"./index-4kchzh9y.js";import{wA,xu,Fs,wu,Cu,Eu,Bu,Iu,_u,Su,Tu,Du}from"./index-2asa0faw.js";var vt={name:"panel-right-close",size:24,node:[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]]},be=s(vt);var z=new Set,ae=new Set,ge=new Set;function ve(){ge=new Set(z);for(let t of[...ae])t()}function xe(t){let r=new Set(t);if(r.size===z.size){let l=!0;for(let d of r)if(!z.has(d)){l=!1;break}if(l)return}z.clear();for(let l of r)z.add(l);ve()}function ye(t){let r=new Set(t),l=!1;for(let d of[...z])if(!r.has(d))z.delete(d),l=!0;if(l)ve()}function Ce(t){return z.has(t)}function ke(){return z.size>0}function ht(t){return ae.add(t),()=>{ae.delete(t)}}var xt=ht;function Ee(){return ze(xt,()=>ge)}function Te({x:t,y:r,rows:l,onAction:d,onClose:u}){let x=i(null),[m,c]=n({left:t,top:r});return K(()=>{let b=x.current;if(!b)return;let{width:k,height:g}=b.getBoundingClientRect();c({left:Math.min(t,Math.max(0,window.innerWidth-k-8)),top:Math.min(r,Math.max(0,window.innerHeight-g-8))})},[t,r,l.length]),ie(e("div",{className:"fixed inset-0 z-[70]",onClick:u,onContextMenu:(b)=>{b.preventDefault(),u()},children:e("div",{ref:x,role:"menu","aria-label":"Tab actions",className:"glass-popover absolute w-52 bg-paper border border-ink/15 rounded-md shadow-xl py-1 text-xs text-ink",style:{left:`${m.left}px`,top:`${m.top}px`},onClick:(b)=>b.stopPropagation(),children:l.map((b)=>e("button",{type:"button",role:"menuitem",onClick:()=>{d(b.action),u()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:b.label},b.action))})}),document.body)}var ee={rightFileId:null,fraction:0.5};function ne(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ne(t,r){for(let l=r.length-1;l>=0;l-=1){let d=r[l];if(d!==t)return d}return null}function Pe(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function Y(t){if(!Number.isFinite(t))return ee.fraction;return Math.max(0.2,Math.min(0.8,t))}function De(t,r){if(typeof t!=="object"||t===null)return ee;let l=t,d=typeof l.fraction==="number"?Y(l.fraction):ee.fraction,u=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(u===null||!r.includes(u))return{rightFileId:null,fraction:d};return{rightFileId:u,fraction:d}}function Re({tab:t,openedFiles:r,dirtyIds:l,reopenable:d,activeFileId:u,splitRightFileId:x}){let m=r.filter((g)=>g.id!==t.id),c=r.filter((g)=>!l.has(g.id)),b=r.map((g)=>g.id);return[{action:"split-right",label:"Split right",enabled:ne(t.id,u,b)},{action:"unsplit",label:"Unsplit",enabled:x!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:m.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:c.some((g)=>g.id!==t.id)},{action:"copy-path",label:"Copy path",enabled:Boolean(t.path)},{action:"reveal-in-files",label:"Reveal in Files",enabled:Boolean(t.path)&&!t.isDiff},{action:"reopen-closed",label:"Reopen closed tab",enabled:d>0}].filter((g)=>g.enabled)}function Z({onHide:t}){let r=Jo("toggleEditorPanel","Hide Editor Panel");return e("button",{type:"button",onClick:t,className:"p-1.5 mx-1 rounded transition-colors cursor-pointer text-ink/60 hover:bg-ink/10 hover:text-ink flex-shrink-0",title:r,"aria-label":r,children:e(be,{size:14})})}function Ie({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,missingIds:u,onCopyPath:x,onRevealInFiles:m,onReopenClosed:c,reopenableCount:b,onSplitTo:k,onUnsplit:g,splitRightFileId:y=null,onHide:R}){let M=Ee(),P=i(null),L=i(null),[D,O]=n(5),[A,F]=n(!1),[f,Q]=n(null);he(L,()=>F(!1)),o(()=>{let v=new ResizeObserver((w)=>{for(let S of w){let q=S.contentRect.width,H=Math.max(1,Math.floor((q-60)/150));O(H)}});if(P.current)v.observe(P.current);return()=>v.disconnect()},[]);let U=Ne(r,t.map((v)=>v.id)),j=[],G=[];if(t.length<=D)j=t;else{let v=t.findIndex((S)=>S.id===r),w=new Set;if(v!==-1&&r!==null)w.add(r);for(let S=t.length-1;S>=0;S--){if(w.size>=D)break;w.add(t[S].id)}j=t.filter((S)=>w.has(S.id)),G=t.filter((S)=>!w.has(S.id))}return e("div",{className:`${wi.desktop} flex bg-ink/10 w-full relative border-b border-ink/10`,ref:P,children:[e("div",{className:"flex overflow-hidden",children:j.map((v)=>{let w=v.id===r,S=Boolean(v.isDiff),q=S?sr(v.diffStatus||"M",v.diffStaged):null,H=Boolean(u?.has(v.id));return e("div",{onClick:()=>l(v.id),onContextMenu:(_)=>{_.preventDefault(),Q({tab:v,x:_.clientX,y:_.clientY})},className:`flex items-center space-x-1.5 px-3 py-1.5 cursor-pointer border-r border-ink/10 min-w-[120px] max-w-[210px] group ${w?"bg-paper border-t-2 border-t-ink text-ink":"bg-transparent border-t-2 border-t-transparent text-ink/60 hover:bg-paper/50"}`,title:H?`${v.path} — file no longer exists`:v.path,children:[S?e(bi,{size:14,className:w?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(mt,{name:v.name,size:14,className:`flex-shrink-0${w||H?"":" opacity-60"}${H?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${H?" text-error line-through":""}`,children:v.name}),q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${q.badgeBgClass}`,children:q.charStatus}),e(Oe,{dirty:M.has(v.id),active:w,label:`Close ${v.name}`,onClose:()=>d(v.id)})]},v.id)})}),f?e(Te,{x:f.x,y:f.y,rows:Re({tab:f.tab,openedFiles:t,dirtyIds:M,reopenable:b?.()??0,activeFileId:r,splitRightFileId:y}),onAction:(v)=>{let w=f.tab;switch(v){case"close":d(w.id);return;case"close-others":for(let S of[...t].reverse())if(S.id!==w.id)d(S.id);l(w.id);return;case"close-all":for(let S of[...t].reverse())d(S.id);return;case"close-saved":for(let S of[...t].reverse())if(!M.has(S.id))d(S.id);return;case"copy-path":x?.(w);return;case"reveal-in-files":m?.(w);return;case"reopen-closed":c?.();return;case"split-right":k?.(w.id);return;case"unsplit":g?.();return}},onClose:()=>Q(null)}):null,e("div",{className:"ml-auto flex items-center",children:[e("button",{type:"button",onClick:()=>y!==null?g?.():k?.(U),disabled:y===null&&U===null,"aria-pressed":y!==null,"aria-label":"Split editor",title:y!==null?"Close the split pane (the tab stays open)":U===null?"Open another file to split the editor":"Split the editor and show the newest other file",className:`p-1.5 mx-1 rounded transition-colors cursor-pointer disabled:opacity-30 disabled:cursor-default ${y!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(ir,{size:14})}),R&&e(Z,{onHide:R})]}),G.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:L,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${A?"bg-ink/10 text-ink":""}`,onClick:()=>F(!A),title:"More open files",children:e(E,{size:14})}),A&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-52 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",children:[e("div",{className:"px-3 py-1 text-[10px] uppercase font-mono text-ink/40 border-b border-ink/10 mb-1",children:"Older Tabs"}),G.map((v)=>{let w=Boolean(u?.has(v.id));return e("div",{onClick:()=>{l(v.id),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[v.isDiff?e(bi,{size:14,className:"text-info/80"}):e(mt,{name:v.name,size:14,className:w?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${w?"text-error line-through":"text-ink/80"}`,children:v.name}),e(Oe,{dirty:M.has(v.id),active:!1,label:`Close ${v.name}`,onClose:()=>{if(d(v.id),G.length===1)F(!1)}})]},v.id)})]})]})]})}function Oe({dirty:t,active:r,label:l,onClose:d}){return e("div",{role:"button",tabIndex:-1,"aria-label":l,title:t?`${l} — unsaved changes`:l,className:`p-0.5 rounded hover:bg-ink/10 touch-visible ${r||t?"opacity-100":"opacity-0 group-hover:opacity-100"}`,onClick:(u)=>{u.stopPropagation(),d()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(h,{size:12})})}function Ae({pluginId:t,Component:r,sessionId:l,className:d="",onHide:u}){return e("div",{className:`flex flex-col h-full bg-canvas ${d}`,children:[u&&e("div",{className:"flex justify-end flex-shrink-0 border-b border-ink/10",children:e(Z,{onHide:u})}),e(tt,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})]})}function Fe({className:t="",onHide:r}){return e("div",{className:`relative flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[r&&e("div",{className:"absolute top-0 right-0 flex items-center",children:e(Z,{onHide:r})}),e(mt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Le({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let d=i(null);o(()=>{if(!t||d.current===t.request)return;d.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function Be({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:d,setPreviewMode:u,sessionId:x}){o(()=>{let m=new Set(t.filter((c)=>!c.isDiff&&c.content===void 0).map((c)=>c.id));xe([...r].filter((c)=>m.has(c)))},[r,t]),o(()=>{if(!d)return;let m=l?.id;if(!l||m===void 0||m===null)return;if(!xu(Fs(l.name)))return;let c=we(x,"editor.previewMode");if(c&&c[m]!==void 0)return;u((b)=>b[m]===void 0?{...b,[m]:!0}:b)},[d,l])}function Ke({activeFile:t,externalChange:r,conflict:l,onReload:d,onKeepMine:u}){if(!t)return null;if(l)return e(Su,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:d,onKeepMine:u});if(r)return e(_u,{fileName:t.name,onReload:d,onKeepMine:u});return null}async function $e(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let d=await fetch("/api/fs/action",{method:"POST",body:l}),u=await d.json().catch(()=>null),x=typeof u?.error==="string"?u.error:null;if(d.status===409)return{status:"exists",reason:x??`${r} already exists.`};if(d.ok&&u?.success&&typeof u.path==="string")return{status:"written",path:u.path};return{status:"failed",reason:x??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Ue(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Ge(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function yt(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function qe({fileName:t,filePath:r,content:l,eol:d,root:u,repo:x,onSaved:m,onClose:c}){let[b,k]=n(()=>yt(r)),[g,y]=n(()=>Ue(t)),[R,M]=n(!1),[P,L]=n(null),D=i(null);o(()=>{D.current?.focus(),D.current?.select()},[]);let O=Ge(g),A=async()=>{if(!O||R)return;M(!0),L(null);let f=await $e({parent:b,name:g,content:l,eol:d,root:u,repo:x});if(M(!1),f.status==="written"){m({path:f.path});return}L(f.reason)},F=(f)=>{if(f.key==="Enter"){f.preventDefault(),A();return}if(f.key==="Escape")f.preventDefault(),c()};return e(X,{onClose:c,maxWidthClass:"max-w-md",header:e("span",{className:"text-sm font-semibold text-ink",children:"Save as"}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:c,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>void A(),disabled:!O||R,className:"flex items-center gap-1.5 px-3 py-1.5 rounded bg-ink text-paper disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[R?e(p,{size:12,className:"animate-spin"}):e(Xe,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:b,onInput:(f)=>k(f.target.value),onKeyDown:F,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:D,value:g,onInput:(f)=>y(f.target.value),onKeyDown:F,"aria-label":"File name","aria-invalid":!O,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${O?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!O?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,P?e("div",{className:"text-[10px] text-error font-mono",children:P}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _e(){o(()=>{let t=(r)=>{if(!ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function We({fileName:t,onAnswer:r}){return e(X,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(I,{size:15,className:"text-warning"}),e("span",{className:"text-sm font-semibold text-ink",children:"Unsaved changes"})]}),footer:e("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:()=>r("cancel"),className:"px-3 py-1.5 rounded border border-ink/20 text-ink/80 hover:bg-ink/5 transition-colors cursor-pointer",children:"Cancel"}),e("button",{type:"button",onClick:()=>r("discard"),className:"px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer",children:"Discard"}),e("button",{type:"button",onClick:()=>r("save"),className:"px-3 py-1.5 rounded bg-ink text-paper hover:bg-ink/90 transition-colors cursor-pointer",children:"Save & close"})]}),children:e("div",{className:"px-4 py-3 text-xs text-ink/80",children:[e("span",{className:"font-mono text-ink",children:t})," has changes that are not on disk.",e("div",{className:"mt-1 text-ink/50",children:"Discarding them cannot be undone."})]})})}function Ve({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:d,onConfirmSaveMissing:u}){if(t.pending)return e(We,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Tu,{fileName:r.name,filePath:r.path,onClose:d,onConfirm:u});return null}function Je({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:d,asSplitPane:u,tabs:x,activeFile:m,editor:c,externalChange:b,conflict:k,onReload:g,onKeepMine:y,body:R,saveAsOpen:M,onSaveAsClose:P,onSavedAs:L,closeGuard:D}){let O=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:O,onKeyDownCapture:l,onFocusCapture:d,children:[u?null:x,e(Ke,{activeFile:m,externalChange:b,conflict:k,onReload:g,onKeepMine:y}),R,M&&m?e(qe,{fileName:m.name,filePath:m.path,content:c.content,eol:c.eol,root:m.root,repo:m.repo,onSaved:({path:A})=>L(A),onClose:P}):null,e(Ve,{closeGuard:D,activeFile:m,saveMissingConfirm:c.saveMissingConfirm,onCancelSaveMissing:c.cancelSaveMissing,onConfirmSaveMissing:c.confirmSaveMissing})]})}function Ye({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(h,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Ze({fraction:t,onFraction:r,rightPaneName:l,onClosePane:d,rightPane:u,children:x}){let m=i(null),c=i(null),b=Of(c),k=(g)=>{let y=g.currentTarget,R=m.current;if(!y||!R)return;y.setPointerCapture(g.pointerId);let M=(L)=>{let D=R.getBoundingClientRect();if(D.width===0)return;r(Y((L.clientX-D.left)/D.width))},P=()=>{y.releasePointerCapture(g.pointerId),y.removeEventListener("pointermove",M),y.removeEventListener("pointerup",P)};y.addEventListener("pointermove",M),y.addEventListener("pointerup",P)};return e("div",{ref:m,className:"flex w-full h-full","data-split-column":"",children:[e("div",{className:"flex flex-col min-w-0 h-full",style:{width:`${Math.round(Y(t)*100)}%`},children:x}),e("div",{ref:c,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${b?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:k}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Ye,{fileName:l,onClose:d,children:u})})]})}function Qe({openedFiles:t,activeFileId:r,enabled:l}){let[d,u]=T("editor.split",ee),x=t.map((y)=>y.id),m=Pe(De(d,x),r),c=l&&m.rightFileId!==null?t.find((y)=>y.id===m.rightFileId)??null:null,b=a((y)=>{if(y!==null&&!ne(y,r,x))return;u({...m,rightFileId:y})},[m,u,r,x]),k=a(()=>u({...m,rightFileId:null}),[m,u]),g=a((y)=>u({...m,fraction:Y(y)}),[m,u]);return{rightFile:c,fraction:m.fraction,splitTo:b,close:k,setFraction:g}}function je({find:t,runCommand:r,reopenClosed:l}){let d=i(t);d.current=t;let u=i(r);u.current=r;let x=i(l);return x.current=l,{onKeyDownCapture:a((c)=>{let b=d.current;if(c.key==="Escape"){if(!b.open)return;c.preventDefault(),c.stopPropagation(),b.close();return}if((c.metaKey||c.ctrlKey)&&c.shiftKey&&c.code==="KeyT"){if(x.current?.())c.preventDefault(),c.stopPropagation();return}let k=N0(Ni,c);if(!k||!eg(k))return;c.preventDefault(),c.stopPropagation(),u.current(k)},[])}}function et(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(u)=>r.current.runCommand(u)};return o(()=>{let u=l.current;if(!u)return;return hA(u)},[]),{onFocusCapture:a(()=>{if(l.current)hA(l.current)},[])}}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:d,saveNow:u}){let[x,m]=n(null);_e();let c=a((k)=>{let g=t.find((y)=>y.id===k);if(g&&Ce(k)){m(g);return}d(k)},[t,d]),b=a((k)=>{let g=x;if(!g)return;if(k==="cancel"){m(null);return}if(k==="save"){if(g.id!==r)l(g.id);u()}m(null),d(g.id)},[x,r,l,u,d]);return{requestClose:c,pending:x,answer:b}}function ot(){let[t,r]=n(0),[l,d]=n(!1),u=a(()=>r((x)=>x+1),[]);return{goToLineRequest:t,openGoToLine:u,saveAsOpen:l,setSaveAsOpen:d}}var Ct=Se(()=>import("./Body-a4dwe3hh.js").then((t)=>({default:t.EditorBody})));function rt(t){return e(Me,{fallback:e("div",{className:"h-full w-full"}),children:e(Ct,{...t})})}function kt({className:t="",openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m=0,onFileSaved:c,onOpenPath:b,onReopenClosed:k,reopenableCount:g,onCopyPath:y,onRevealInFiles:R,rootPath:M=null,repoPath:P=null,activeEditorPanelKey:L=null,forcedActiveFileId:D=null,asSplitPane:O=!1,onHidePanel:A}){let F=O?D:l,f=r.find((C)=>C.id===F),[Q,U,j]=T("editor.previewMode",{}),G=Du(String(F??"")),[v,w]=T("editor.zoomLevel",Oo),[S,q]=n(!1),[H,_]=T("editor.wordWrap",!0),J=ot(),{sessionId:le}=He(),B=Qe({openedFiles:r,activeFileId:F,enabled:!O}),W=i(null),it=Uo(),st=Li(),de=wu(r,m),ue=Boolean(f&&de.has(f.id)),N=Cu(f??null,{reportSaveError:!0,onFileSaved:c,missing:ue}),at=wA({path:f?.path??"",content:N.content,language:N.language}),lt=N.diskChange,pe=nt({openedFiles:r,activeFileId:F,onSelectFile:d,onCloseFile:u,saveNow:N.saveNow}),te=Eu({text:N.content,documentKey:`${f?.id??""}\x00${N.language}`,readSelection:()=>W.current?.getSelection()??null,select:(C,V,se=!0)=>W.current?.select(C,V,se),reveal:(C)=>W.current?.revealOffset(C),applyDocument:(C,V,se)=>W.current?.applyDocument(C,V,se),toggleWordWrap:()=>_((C)=>!C)}),ce=Bu(f?.path??null,N.content,N.loaded&&!N.loadError);Le({searchReveal:ce,revealMatch:te.revealMatch}),Iu({file:f,editor:N,surfaceRef:W,isPreview:f?Q[f.id]===!0:!1,exitPreview:()=>{let C=f?.id;if(C===void 0||C===null)return;U((V)=>({...V,[C]:!1}))}}),o(()=>{if(m>0)N.reset()},[m]),o(()=>{N.retain(r.map((C)=>C.id)),ye(r.map((C)=>C.id))},[r]),Be({openedFiles:r,dirtyKeys:N.dirtyKeys,activeFile:f,previewReady:j,setPreviewMode:U,sessionId:le});let dt=()=>{if(!f)return;U((C)=>({...C,[f.id]:!C[f.id]}))},oe=(C)=>{if(eg(C)){te.runCommand(C);return}if(C==="toggleWordWrap"){_((V)=>!V);return}if(C==="goToLine"){J.openGoToLine();return}W.current?.runCommand(C)},ut=je({find:te,runCommand:oe,reopenClosed:k}),pt=et({saveNow:N.saveNow,runCommand:oe}),re=H0(L);if(re)return e(Ae,{pluginId:re.pluginId,Component:re.Component,sessionId:le,className:t,onHide:A});if(r.length===0)return e(Fe,{className:t,onHide:A});let ct=N.viewerKind,me=f?Q[f.id]:!1,ft={activeFile:f,editor:N,find:te,surfaceRef:W,pluginFileView:at,wordWrap:H,setWordWrap:_,viewerKind:ct,isPreview:Boolean(me),isReviewing:Boolean(me)&&G.active,onToggleReview:G.toggle,isMaximized:S,setIsMaximized:q,zoomLevel:v,setZoomLevel:w,goToLineRequest:J.goToLineRequest,onSaveAs:()=>J.setSaveAsOpen(!0),onOpenPath:b,rootPath:M,repoPath:P,runCommand:oe,editorFontFamily:it,editorTheme:st,togglePreview:dt,revealActive:Boolean(ce),missing:ue,onConvertDiffToEditor:x,onFileSaved:c},bt=(C)=>({openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:u,onConvertDiffToEditor:x,refreshKey:m,onFileSaved:c,onOpenPath:b,rootPath:M,repoPath:P,forcedActiveFileId:C,asSplitPane:!0}),gt=e(Ie,{openedFiles:r,activeFileId:l,onSelectFile:d,onCloseFile:pe.requestClose,missingIds:de,onCopyPath:y,onRevealInFiles:R,onReopenClosed:k,reopenableCount:g,onSplitTo:B.splitTo,onUnsplit:B.close,splitRightFileId:B.rightFile?.id??null,onHide:A}),fe=e(Je,{className:t,isMaximized:S,onKeyDownCapture:ut.onKeyDownCapture,onFocusCapture:pt.onFocusCapture,asSplitPane:O,tabs:gt,activeFile:f,editor:N,externalChange:lt,conflict:N.conflict,onReload:N.resolveConflictByReload,onKeepMine:N.keepMineAgainstDisk,body:e(rt,{...ft}),saveAsOpen:J.saveAsOpen,onSaveAsClose:()=>J.setSaveAsOpen(!1),onSavedAs:(C)=>{J.setSaveAsOpen(!1),b?.(C)},closeGuard:pe});if(!B.rightFile)return fe;return e(Ze,{fraction:B.fraction,onFraction:B.setFraction,rightPaneName:B.rightFile.name,onClosePane:B.close,rightPane:e(kt,{...bt(B.rightFile.id)}),children:fe})}export{kt as Editor};
@@ -1,4 +1,4 @@
1
- import{n,o,i,u,a,ln,e,f,ae,Bt}from"./index-c8ta3k4g.js";function j(t,s){return{top:Math.min(t.row,s.row),left:Math.min(t.col,s.col),bottom:Math.max(t.row,s.row),right:Math.max(t.col,s.col)}}function q(t){return t.bottom-t.top+1}function z(t){return t.right-t.left+1}function H(t){let s=t+1,r="";while(s>0){let d=(s-1)%26;r=String.fromCharCode(65+d)+r,s=Math.floor((s-1)/26)}return r}function X(t){return`${H(t.col)}${t.row+1}`}function F(t){let s=X({row:t.top,col:t.left}),r=X({row:t.bottom,col:t.right});return s===r?s:`${s}:${r}`}function I(t,s,r){return{row:Math.min(Math.max(t.row,0),Math.max(s-1,0)),col:Math.min(Math.max(t.col,0),Math.max(r-1,0))}}function U(t,s,r,d,p){return I({row:t.row+s,col:t.col+r},d,p)}function W(t,s){if(t<=0||s<=0)return null;return{top:0,left:0,bottom:t-1,right:s-1}}function K(t,s){let r=[];for(let d=s.top;d<=s.bottom;d+=1){let p=[];for(let c=s.left;c<=s.right;c+=1){let g=t[d]?.[c]??"";p.push(/[\t\r\n"]/.test(g)?`"${g.replace(/"/g,'""')}"`:g)}r.push(p.join("\t"))}return r.join(`\r
1
+ import{n,o,i,u,a,ln,e,f,ae,Bt}from"./index-7ckzdf4r.js";function j(t,s){return{top:Math.min(t.row,s.row),left:Math.min(t.col,s.col),bottom:Math.max(t.row,s.row),right:Math.max(t.col,s.col)}}function q(t){return t.bottom-t.top+1}function z(t){return t.right-t.left+1}function H(t){let s=t+1,r="";while(s>0){let d=(s-1)%26;r=String.fromCharCode(65+d)+r,s=Math.floor((s-1)/26)}return r}function X(t){return`${H(t.col)}${t.row+1}`}function F(t){let s=X({row:t.top,col:t.left}),r=X({row:t.bottom,col:t.right});return s===r?s:`${s}:${r}`}function I(t,s,r){return{row:Math.min(Math.max(t.row,0),Math.max(s-1,0)),col:Math.min(Math.max(t.col,0),Math.max(r-1,0))}}function U(t,s,r,d,p){return I({row:t.row+s,col:t.col+r},d,p)}function W(t,s){if(t<=0||s<=0)return null;return{top:0,left:0,bottom:t-1,right:s-1}}function K(t,s){let r=[];for(let d=s.top;d<=s.bottom;d+=1){let p=[];for(let c=s.left;c<=s.right;c+=1){let g=t[d]?.[c]??"";p.push(/[\t\r\n"]/.test(g)?`"${g.replace(/"/g,'""')}"`:g)}r.push(p.join("\t"))}return r.join(`\r
2
2
  `)}function B(t,s){let[r,d]=n(null),[p,c]=n(null),[g,C]=n(!1),b=i(!1),m=a((v)=>I(v,t,s),[t,s]),y=a((v,E)=>{let G=m(v);if(E&&r)c(G);else d(G),c(G);b.current=!0,C(!0)},[r,m]),k=a((v)=>{if(!b.current)return;c(m(v))},[m]),N=a(()=>{b.current=!1,C(!1)},[]),T=a((v,E,G)=>{let S=U(p??{row:0,col:0},v,E,t,s);if(G&&r)c(S);else d(S),c(S)},[r,p,t,s]),A=a(()=>{let v=W(t,s);if(!v)return;d({row:v.top,col:v.left}),c({row:v.bottom,col:v.right})},[t,s]),L=a((v,E)=>{let G=m({row:t-1,col:v});if(E&&r)c(G);else d(m({row:0,col:v})),c(G)},[r,m,t]),P=a((v,E)=>{let G=m({row:v,col:s-1});if(E&&r)c(G);else d(m({row:v,col:0})),c(G)},[r,m,s]),l=a(()=>{d(null),c(null)},[]),x=u(()=>{if(!r||!p)return null;return j(m(r),m(p))},[r,p,m]),R=u(()=>p?m(p):null,[p,m]);return{range:x,active:R,dragging:g,begin:y,extendTo:k,endDrag:N,move:T,selectAll:A,selectColumn:L,selectRow:P,clear:l}}function Y(t){let[s,r]=n(null),d=a((C,b,m,y)=>{r({section:C,row:b,col:m,value:y,initial:y})},[]),p=a((C)=>{r((b)=>b?{...b,value:C}:b)},[]),c=a(()=>{if(s&&s.value!==s.initial)t(s);r(null)},[s,t]),g=a(()=>r(null),[]);return{edit:s,begin:d,change:p,commit:c,cancel:g}}function V(t){let s=t.target?.closest?.("[data-row][data-col]");if(!s)return null;return{row:Number(s.dataset.row),col:Number(s.dataset.col)}}function J({cells:t,width:s,selection:r,editor:d,scrollerRef:p,startEdit:c,onEditCell:g,setCopyState:C}){let b=d.edit,m=r.active;return{onPointerDown:(l)=>{if(l.button!==0)return;let x=l.target;if(x?.closest?.("[data-edit-input]"))return;if(b)d.commit();let R=V(l);if(R){p.current?.focus(),r.begin(R,l.shiftKey),l.preventDefault();return}let v=x?.closest?.("[data-col-header]");if(v){p.current?.focus(),r.selectColumn(Number(v.dataset.colHeader),l.shiftKey),l.preventDefault();return}let E=x?.closest?.("[data-row-header]");if(E){p.current?.focus(),r.selectRow(Number(E.dataset.rowHeader),l.shiftKey),l.preventDefault();return}if(x?.closest?.("[data-corner]"))p.current?.focus(),r.selectAll(),l.preventDefault()},onPointerOver:(l)=>{let x=V(l);if(x)r.extendTo(x)},onDoubleClick:(l)=>{let x=V(l);if(x){c("data",x.row,x.col);return}let R=l.target?.closest?.("[data-col-header]");if(R)c("header",0,Number(R.dataset.colHeader))},onInput:(l)=>{let x=l.target;if(x.matches?.("[data-edit-input]"))d.change(x.value)},onKeyDown:(l)=>{if(b){if(l.key==="Enter"){l.preventDefault(),d.commit(),r.move(l.shiftKey?-1:1,0,!1);return}if(l.key==="Tab"){l.preventDefault(),d.commit(),r.move(0,l.shiftKey?-1:1,!1);return}if(l.key==="Escape"){l.preventDefault(),d.cancel();return}return}let x=l.metaKey||l.ctrlKey;if(x&&l.key.toLowerCase()==="a"){l.preventDefault(),r.selectAll();return}if(l.key==="Escape"){r.clear();return}if(l.key==="Enter"||l.key==="F2"){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col);return}if(l.key==="Delete"||l.key==="Backspace"){if(!g||!m)return;l.preventDefault(),g(m.row,m.col,"");return}if(l.key.length===1&&!x&&!l.altKey){if(!g||!m)return;l.preventDefault(),c("data",m.row,m.col,l.key);return}let v={ArrowUp:[-1,0],ArrowDown:[1,0],ArrowLeft:[0,-1],ArrowRight:[0,1]}[l.key];if(v){l.preventDefault(),r.move(v[0],v[1],l.shiftKey);return}if(l.key==="Home"||l.key==="End"){l.preventDefault();let E=l.key==="Home"?0:s-1,G=x?l.key==="Home"?0:t.length-1:m?.row??0;r.move(G-(m?.row??0),E-(m?.col??0),l.shiftKey)}},onCopy:(l)=>{if(b)return;if(!r.range)return;l.clipboardData?.setData("text/plain",K(t,r.range)),l.preventDefault(),C("copied")},onPaste:(l)=>{if(b)return;l.preventDefault(),C("refused")}}}var Q=ln(function({cells:s,rowIndex:r,selectedLeft:d,selectedRight:p,activeCol:c,editingCol:g,editingValue:C}){let b=d>=0;return e("tr",{className:"odd:bg-ink/[0.02]",children:[e("th",{"data-row-header":r,className:`cursor-pointer border-b border-r border-ink/10 px-2 py-0.5 text-right font-normal tabular-nums ${b?"bg-info/10 text-ink/60":"text-ink/30"}`,title:`Select row ${r+1}`,children:r+1}),s.map((m,y)=>{let k=b&&y>=d&&y<=p;return e("td",{"data-row":r,"data-col":y,title:m,className:`cursor-cell border-b border-ink/10 px-2 py-0.5 text-ink ${k?"bg-info/10":""} ${y===c?"ring-1 ring-inset ring-info":""}`,children:y===g?e("input",{"data-edit-input":"true",value:C,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] text-ink outline-none"}):e("span",{className:"block truncate",children:m})},y)})]})});function Z({status:t,tone:s="muted",actions:r,canCopy:d,copyState:p,onCopy:c}){return e("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-ink/10 bg-canvas px-2 py-1 font-sans text-[11px]",children:[e("span",{className:`truncate ${s==="warning"?"text-warning":"text-ink/50"}`,children:t}),e("div",{className:"flex shrink-0 items-center gap-2",children:[r,e("button",{type:"button",onClick:c,disabled:!d,title:"Copy the selected cells as tab-separated text",className:`flex items-center gap-1 rounded px-1.5 py-0.5 transition-colors ${d?"text-ink/60 hover:bg-ink/5 hover:text-ink":"cursor-default text-ink/25"} ${p==="failed"?"text-error":""}`,children:[p==="copied"?e(f,{size:12}):e(ae,{size:12}),e("span",{children:p==="copied"?"Copied":p==="failed"?"Copy failed":"Copy"})]})]})]})}var ne=44,re=1600;function yu({header:t,rows:s,truncated:r,label:d,readOnlyNote:p,onEditCell:c,onEditHeader:g,actions:C}){let b=u(()=>s.reduce((h,w)=>Math.max(h,w.length),t.length),[t,s]),m=u(()=>Array.from({length:b},(h,w)=>t[w]??H(w)),[t,b]),y=u(()=>s.map((h)=>h.length===b?h:Array.from({length:b},(w,M)=>h[M]??"")),[s,b]),k=B(y.length,b),N=i(null),[T,A]=n("idle"),L=a((h)=>{if(h.section==="header")g?.(h.col,h.value);else c?.(h.row,h.col,h.value)},[c,g]),P=Y(L),l=P.edit,x=a((h,w,M,_)=>{if(h==="header"?!g:!c)return;let te=h==="header"?m[M]??"":y[w]?.[M]??"";P.begin(h,w,M,_??te)},[y,P,m,c,g]),R=a(async()=>{if(!k.range)return;let h=await Bt(K(y,k.range));A(h?"copied":"failed")},[y,k.range]);o(()=>{if(T==="idle")return;let h=setTimeout(()=>A("idle"),re);return()=>clearTimeout(h)},[T]);let{dragging:v,endDrag:E}=k;o(()=>{if(!v)return;let h=()=>E();return window.addEventListener("pointerup",h),window.addEventListener("pointercancel",h),()=>{window.removeEventListener("pointerup",h),window.removeEventListener("pointercancel",h)}},[v,E]);let G=k.active;o(()=>{if(!G)return;N.current?.querySelector(`[data-row="${G.row}"][data-col="${G.col}"]`)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[G]);let O=l?`${l.section}:${l.row}:${l.col}`:"";o(()=>{if(!O)return;let h=N.current?.querySelector("[data-edit-input]");h?.focus(),h?.select()},[O]);let S=J({cells:y,width:b,selection:k,editor:P,scrollerRef:N,startEdit:x,onEditCell:c,setCopyState:A});if(b===0&&y.length===0)return e("div",{className:"flex flex-1 items-center justify-center px-6 text-center text-xs text-ink/50",children:"This file has no rows."});let D=k.range,ee=T==="refused"?p??"This grid is read-only.":D?`${F(D)} · ${q(D)}×${z(D)}`:"Click a cell, drag to select a block";return e("div",{className:"flex min-h-0 flex-1 flex-col",children:[r&&e("div",{className:"shrink-0 border-b border-warning/30 bg-warning/10 px-3 py-1 font-sans text-[11px] text-warning",children:["Showing the first ",y.length.toLocaleString()," rows."]}),e(Z,{status:ee,tone:T==="refused"?"warning":"muted",actions:C,canCopy:D!==null,copyState:T,onCopy:()=>void R()}),e("div",{ref:N,tabIndex:0,role:"grid","aria-label":d??"Spreadsheet",className:"flex-1 overflow-auto outline-none",onPointerDown:S.onPointerDown,onPointerOver:S.onPointerOver,onDblClick:S.onDoubleClick,onInput:S.onInput,onKeyDown:S.onKeyDown,onCopy:S.onCopy,onPaste:S.onPaste,children:e("table",{className:"w-full table-fixed select-none border-collapse font-mono text-[11px]",children:[e("colgroup",{children:[e("col",{style:{width:`${ne}px`}}),m.map((h,w)=>e("col",{},w))]}),e("thead",{className:"sticky top-0 z-10 bg-canvas",children:e("tr",{children:[e("th",{"data-corner":!0,title:"Select all",className:"cursor-pointer border-b border-r border-ink/10 px-2 py-1 text-right font-normal text-ink/30",children:"#"}),m.map((h,w)=>{let M=D!==null&&w>=D.left&&w<=D.right,_=l?.section==="header"&&l.col===w;return e("th",{"data-col-header":w,title:h,className:`cursor-pointer border-b border-ink/10 px-2 py-1 text-left font-semibold ${M?"bg-info/10 text-ink":"text-ink/80"}`,children:_?e("input",{"data-edit-input":"true",value:l.value,spellcheck:!1,className:"w-full min-w-0 bg-transparent font-mono text-[11px] font-semibold text-ink outline-none"}):e("span",{className:"block truncate",children:h})},w)})]})}),e("tbody",{children:y.map((h,w)=>{let M=D!==null&&w>=D.top&&w<=D.bottom;return e(Q,{cells:h,rowIndex:w,selectedLeft:M?D.left:-1,selectedRight:M?D.right:-1,activeCol:G?.row===w?G.col:-1,editingCol:l?.section==="data"&&l.row===w?l.col:-1,editingValue:l?.section==="data"&&l.row===w?l.value:""},w)})})]})})]})}var sg=2000,lg=100;function oe(t,s){if(/\.tsv$/i.test(s??""))return"\t";let r=t.slice(0,t.indexOf(`
3
3
  `)===-1?t.length:t.indexOf(`
4
4
  `)),d=0,p=0,c=!1;for(let g=0;g<r.length;g+=1){let C=r[g];if(C==='"')c=!c;else if(!c&&C==="\t")d+=1;else if(!c&&C===",")p+=1}return d>p?"\t":","}function ie(t,s,r){let d=[],p=[],c="",g=!1,C=0,b=()=>{if(C<r)p.push(c);c="",C+=1},m=()=>{b(),d.push(p),p=[],C=0};for(let y=0;y<t.length;y+=1){let k=t[y];if(g){if(k==='"')if(t[y+1]==='"')c+='"',y+=1;else g=!1;else c+=k;continue}if(k==='"'&&c.length===0){g=!0;continue}if(k===s){b();continue}if(k==="\r"){if(t[y+1]===`
@@ -1,2 +1,2 @@
1
- import{t}from"./index-3amzzsdk.js";var $i=class{constructor(i){this.init=i,this.records=this.init()}static{t(this,"ImperativeState")}reset(){this.records=this.init()}};
1
+ import{t}from"./index-pqmvhqmj.js";var $i=class{constructor(i){this.init=i,this.records=this.init()}static{t(this,"ImperativeState")}reset(){this.records=this.init()}};
2
2
  export{$i};