@kabmo-labs/kabmo 0.38.2 → 0.39.1

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 (511) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +565 -537
  3. package/dist/client/static/js/{CsvGrid-4dpsfdrf.js → CsvGrid-7synegzg.js} +2 -2
  4. package/dist/client/static/js/{DocxView-crdgc0jd.js → DocxView-v5d9n5yw.js} +4 -4
  5. package/dist/client/static/js/DrawioView-ww7y98tt.js +5 -0
  6. package/dist/client/static/js/ImageView-t3rkypzs.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-th2pd4yt.js +2 -0
  8. package/dist/client/static/js/Modal-qj39shgb.js +38 -0
  9. package/dist/client/static/js/{PdfView-72c123a9.js → PdfView-t9v4datp.js} +1 -1
  10. package/dist/client/static/js/SessionsView-yqy0a1xg.js +1 -0
  11. package/dist/client/static/js/{SheetView-8xh69wgk.js → SheetView-6zkxbjd4.js} +31 -31
  12. package/dist/client/static/js/{SvgPreview-z3fm87h6.js → SvgPreview-7rt2p1y1.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-25r2p3vh.js → abnfDiagram-O67JEVCF-888zn5zg.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-y0zb4vqa.js +1 -0
  15. package/dist/client/static/js/architectureDiagram-NJMV4G6O-b04e26rb.js +36 -0
  16. package/dist/client/static/js/{astro-p3f5p9p2.js → astro-4ybhkc9b.js} +1 -1
  17. package/dist/client/static/js/bash-k6p3y3pr.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-vzamgz9s.js → blockDiagram-BEXU5L5S-32ph2m52.js} +8 -8
  19. package/dist/client/static/js/c-ve09y19q.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-jejafgn0.js → c4Diagram-YGBWAQC7-hwnaa333.js} +5 -5
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-qfa6mj0q.js → classDiagram-v2-NBCMYWYE-2kg7dqeb.js} +6 -6
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-9vzdgmk1.js → cose-bilkent-JH36ORCC-tj2sbtyv.js} +1 -1
  23. package/dist/client/static/js/cpp-vhqp7bcy.js +1 -0
  24. package/dist/client/static/js/css-77mvf0ca.js +1 -0
  25. package/dist/client/static/js/css-tys2rrny.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-nt1ed192.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-a3k3w1t5.js → cynefinDiagram-VND7K2PF-wx2y8dhm.js} +1 -1
  28. package/dist/client/static/js/{dagre-6A5THRUB-gf04dvxj.js → dagre-6A5THRUB-5v3rzdxd.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-a9e0a684.js → diagram-22UHCM2B-7er2jwy1.js} +19 -19
  30. package/dist/client/static/js/{diagram-3UASUU5V-fb73gfjd.js → diagram-3UASUU5V-2b7nmdha.js} +1 -1
  31. package/dist/client/static/js/{diagram-ATOU4E4O-yb9n3t30.js → diagram-ATOU4E4O-yf61ftn0.js} +3 -3
  32. package/dist/client/static/js/{diagram-CDSNMT55-adhbhw28.js → diagram-CDSNMT55-cn3rs9xn.js} +5 -5
  33. package/dist/client/static/js/{diagram-MLGK6HIB-v4yxyb8r.js → diagram-MLGK6HIB-7kvtsj6c.js} +2 -2
  34. package/dist/client/static/js/{diagram-MPIPVDR6-94ttsqy2.js → diagram-MPIPVDR6-g3zg3r5e.js} +3 -3
  35. package/dist/client/static/js/{dockerfile-mrranatf.js → dockerfile-f9j396wm.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-jj4f3pyq.js → ebnfDiagram-ZINNZB2B-ft02nzne.js} +1 -1
  37. package/dist/client/static/js/{elixir-jwphgp8j.js → elixir-v9bbxsgg.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-mtnkhyte.js → elk-276RUBZZ-87fvkn2k.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-18qdkhm5.js → erDiagram-OPXOYQCR-gh9mp6j8.js} +9 -9
  40. package/dist/client/static/js/{erlang-6m6tpt72.js → erlang-55r0skxa.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-v4edaxx7.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-6gc6gd1d.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-vz28h061.js → ganttDiagram-FUAMR5RP-227xs61z.js} +5 -5
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-adzhec96.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-cgq3r4rz.js → gitGraphDiagram-X574FWY7-4671gdym.js} +14 -14
  46. package/dist/client/static/js/graphql-g97hycb3.js +1 -0
  47. package/dist/client/static/js/html-2syect3n.js +1 -0
  48. package/dist/client/static/js/{index-3az1w5f8.js → index-0j518hqm.js} +2 -2
  49. package/dist/client/static/js/index-1jeyjqkh.js +2 -0
  50. package/dist/client/static/js/{index-t5t71dhp.js → index-1sgad84m.js} +2 -2
  51. package/dist/client/static/js/index-28a5kf88.js +1 -0
  52. package/dist/client/static/js/{index-sa9cp6km.js → index-2rs03vfy.js} +2 -2
  53. package/dist/client/static/js/index-35mh9kbs.js +3 -0
  54. package/dist/client/static/js/{index-xya34x4v.js → index-442mbhwb.js} +2 -2
  55. package/dist/client/static/js/index-4c2zcvem.js +474 -0
  56. package/dist/client/static/js/{index-qxb8k6py.js → index-4ry8kz8h.js} +3 -3
  57. package/dist/client/static/js/{index-dt7e1328.js → index-4wtr5wjp.js} +2 -2
  58. package/dist/client/static/js/{index-gr6jng0x.js → index-4wvtar0v.js} +2 -2
  59. package/dist/client/static/js/{index-12p63902.js → index-668chrpq.js} +2 -2
  60. package/dist/client/static/js/index-6rs8e8ng.js +1 -0
  61. package/dist/client/static/js/{index-6k3e5dph.js → index-72289dgx.js} +2 -2
  62. package/dist/client/static/js/{index-zdbvm01f.js → index-7qc2avfy.js} +2 -2
  63. package/dist/client/static/js/{index-4hsxaa87.js → index-87qandgr.js} +2 -2
  64. package/dist/client/static/js/{index-fghst0kd.js → index-8egjccbq.js} +34 -34
  65. package/dist/client/static/js/index-8xasfxf3.js +1 -0
  66. package/dist/client/static/js/{index-x07kp3jz.js → index-9d6x1f3t.js} +2 -2
  67. package/dist/client/static/js/{index-vb6t44dw.js → index-9gepbvdt.js} +2 -2
  68. package/dist/client/static/js/{index-7fdp9c7m.js → index-b08hx4tw.js} +2 -2
  69. package/dist/client/static/js/{index-nd4p98mc.js → index-c1be3rva.js} +2 -2
  70. package/dist/client/static/js/{index-3zc1b0dv.js → index-c36pag9y.js} +2 -2
  71. package/dist/client/static/js/{index-qkscve6n.js → index-cfnxda13.js} +2 -2
  72. package/dist/client/static/js/index-cst843zs.css +1 -0
  73. package/dist/client/static/js/index-d3prrt2q.js +1 -0
  74. package/dist/client/static/js/{index-1y9r4frb.js → index-drjtwfp5.js} +2 -2
  75. package/dist/client/static/js/{index-h7pn9qw6.js → index-enmh3w27.js} +2 -2
  76. package/dist/client/static/js/{index-95t1hwr8.js → index-f1nqk6z6.js} +2 -2
  77. package/dist/client/static/js/index-f73v86a3.js +4 -0
  78. package/dist/client/static/js/{index-ray2czf6.js → index-fjnkzk12.js} +4 -4
  79. package/dist/client/static/js/{index-z72wf7q4.js → index-fjqp03xe.js} +2 -2
  80. package/dist/client/static/js/index-fs3pbqwn.js +1 -0
  81. package/dist/client/static/js/{index-naz3px72.js → index-h8rr48px.js} +9 -9
  82. package/dist/client/static/js/{index-6j9h1fa7.js → index-hdd8nqz8.js} +1 -1
  83. package/dist/client/static/js/index-j2g39xq7.js +9 -0
  84. package/dist/client/static/js/index-jze0zg3z.js +2 -0
  85. package/dist/client/static/js/{index-8acv5b77.js → index-k7sdsmgv.js} +2 -2
  86. package/dist/client/static/js/{index-s16h2nmv.js → index-kkfbd1db.js} +6 -6
  87. package/dist/client/static/js/{index-gbdvr4rt.js → index-m847wafq.js} +2 -2
  88. package/dist/client/static/js/{index-ajtd1q1h.js → index-mtadrbxt.js} +2 -2
  89. package/dist/client/static/js/{index-y5y7smet.js → index-phm1zb8m.js} +1 -1
  90. package/dist/client/static/js/{index-qn4pkjfh.js → index-q0bph5x0.js} +2 -2
  91. package/dist/client/static/js/index-qbnd827h.js +1 -0
  92. package/dist/client/static/js/{index-gbfg0anm.js → index-qsrw5c67.js} +2 -2
  93. package/dist/client/static/js/{index-ashpbfqv.js → index-rj81xrvw.js} +2 -2
  94. package/dist/client/static/js/{index-kf9t3mzv.js → index-s80x8d58.js} +2 -2
  95. package/dist/client/static/js/{index-b9b2nwdd.js → index-t6gznaxm.js} +2 -2
  96. package/dist/client/static/js/index-tmnnafht.js +1 -0
  97. package/dist/client/static/js/{index-d146s9g3.js → index-vb3srfyc.js} +2 -2
  98. package/dist/client/static/js/{index-we2ezmn7.js → index-w0rbyw47.js} +2 -2
  99. package/dist/client/static/js/index-w0xvdda9.js +1 -0
  100. package/dist/client/static/js/index-wfcgqjzr.js +1 -0
  101. package/dist/client/static/js/{index-fqhpxzyb.js → index-wgvysmnr.js} +13 -13
  102. package/dist/client/static/js/{index-njqpkcvw.js → index-xfr6r539.js} +2 -2
  103. package/dist/client/static/js/index-xnk1500f.js +12 -0
  104. package/dist/client/static/js/{index-9wd9y6m0.js → index-xrp2zv8z.js} +2 -2
  105. package/dist/client/static/js/{index-y3hdv561.js → index-y3qxrs90.js} +2 -2
  106. package/dist/client/static/js/{index-5v9v41ap.js → index-y5ymgp20.js} +98 -98
  107. package/dist/client/static/js/{index-dr7nhha9.js → index-y91j4t1q.js} +2 -2
  108. package/dist/client/static/js/info-A6RAGUB7-2ye26vqn.js +1 -0
  109. package/dist/client/static/js/{infoDiagram-VRGFBTTK-jjwckbr9.js → infoDiagram-VRGFBTTK-k1jnhhbp.js} +2 -2
  110. package/dist/client/static/js/ini-7ffv28px.js +1 -0
  111. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-qzk5gejf.js → ishikawaDiagram-OU5B5YK6-ar94x2gr.js} +3 -3
  112. package/dist/client/static/js/java-4x5yky4a.js +1 -0
  113. package/dist/client/static/js/javascript-4kw2j9t3.js +1 -0
  114. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-maccpg3q.js → journeyDiagram-ZHPQQLJL-ntfp0w54.js} +5 -5
  115. package/dist/client/static/js/json-h3kwpty2.js +1 -0
  116. package/dist/client/static/js/jsx-jk20f0dr.js +1 -0
  117. package/dist/client/static/js/{julia-237yk557.js → julia-jhe2vd4f.js} +1 -1
  118. package/dist/client/static/js/{kanban-definition-PNTS6WVX-xv2azgws.js → kanban-definition-PNTS6WVX-q5rsr6j3.js} +6 -6
  119. package/dist/client/static/js/lua-k02dpxq8.js +1 -0
  120. package/dist/client/static/js/markdown-fhhg7ms6.js +1 -0
  121. package/dist/client/static/js/{mermaid.core-e4ys760s.js → mermaid.core-0gafsqrm.js} +8 -8
  122. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-b779wz81.js → mindmap-definition-NLK3R4M7-jgz6nyhk.js} +6 -6
  123. package/dist/client/static/js/one-dark-pro-n0as47q7.js +1 -0
  124. package/dist/client/static/js/one-light-05nw3mzj.js +1 -0
  125. package/dist/client/static/js/packet-AYTQ26CC-b0j3te0q.js +1 -0
  126. package/dist/client/static/js/{pegDiagram-GJSIUBJH-8sgdmhnw.js → pegDiagram-GJSIUBJH-b3e9ma2c.js} +1 -1
  127. package/dist/client/static/js/{perl-dvz4y1tb.js → perl-qhj6tk7k.js} +1 -1
  128. package/dist/client/static/js/{php-n6y7dzhm.js → php-arycc4w7.js} +1 -1
  129. package/dist/client/static/js/pie-WAS4IAKB-28qq62fn.js +1 -0
  130. package/dist/client/static/js/pieDiagram-5QR66LMP-66mn2qnt.js +39 -0
  131. package/dist/client/static/js/properties-qhvcxc13.js +1 -0
  132. package/dist/client/static/js/python-3qsrs510.js +1 -0
  133. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-47dpygk5.js → quadrantDiagram-O4NWA36T-n7warg0e.js} +6 -6
  134. package/dist/client/static/js/r-z2ng7mza.js +1 -0
  135. package/dist/client/static/js/radar-RG4KPBEZ-fyrcbpyd.js +1 -0
  136. package/dist/client/static/js/railroad-74A4TZTK-9s62qncd.js +1 -0
  137. package/dist/client/static/js/railroad-abnf-HS5TGJTU-f7yjmhrk.js +1 -0
  138. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-sfrw8gkz.js +1 -0
  139. package/dist/client/static/js/railroad-peg-WCYAUIDC-4mm4cern.js +1 -0
  140. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-wv0bvwve.js → railroadDiagram-XR7U4H2S-k8j43rxj.js} +1 -1
  141. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-w3r8r837.js → requirementDiagram-PLB6GJNP-ef2v7nyq.js} +13 -13
  142. package/dist/client/static/js/{ruby-7zye3g0e.js → ruby-fb6zzevm.js} +1 -1
  143. package/dist/client/static/js/{rust-42c4h7e4.js → rust-jvkbr060.js} +1 -1
  144. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-t55rjgad.js → sankeyDiagram-IPEJSGJF-3njbd1yd.js} +6 -6
  145. package/dist/client/static/js/{sass-m0h9yzfb.js → sass-fzs6a0kr.js} +1 -1
  146. package/dist/client/static/js/{scss-2pwwfkvn.js → scss-gdb52d0c.js} +1 -1
  147. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-yfwjwy37.js → sequenceDiagram-PO4LG4MO-k2wqc0qt.js} +21 -21
  148. package/dist/client/static/js/{sizeCapture-INFHLROL-nq6hy7ce.js → sizeCapture-INFHLROL-cpnd12ee.js} +1 -1
  149. package/dist/client/static/js/sql-ypk53ntb.js +1 -0
  150. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-4xy0atqh.js → stateDiagram-v2-GCMORJYK-1ydpxaeg.js} +3 -3
  151. package/dist/client/static/js/{svelte-x8f8c8hq.js → svelte-8s3k6qjd.js} +1 -1
  152. package/dist/client/static/js/{swimlanes-2SLR337P-np47cy1q.js → swimlanes-2SLR337P-4md43da2.js} +1 -1
  153. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-d48g5gjf.js +8 -0
  154. package/dist/client/static/js/{timeline-definition-EJHVYXUP-rb0gnm35.js → timeline-definition-EJHVYXUP-sp32bf3e.js} +7 -7
  155. package/dist/client/static/js/treeView-Q6P3EWNA-a5vgg4gz.js +1 -0
  156. package/dist/client/static/js/treemap-WGGIJYW6-ctqhajgg.js +1 -0
  157. package/dist/client/static/js/tsx-zy7hb2hw.js +1 -0
  158. package/dist/client/static/js/typescript-2hr53c8j.js +1 -0
  159. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-gatkznan.js → usecaseDiagram-POWQR4AR-p2ssettn.js} +51 -51
  160. package/dist/client/static/js/{vennDiagram-UO4OBE2U-r3f5xjjq.js → vennDiagram-UO4OBE2U-ejqq8b82.js} +5 -5
  161. package/dist/client/static/js/{vue-myjjd0gd.js → vue-k3f3chre.js} +1 -1
  162. package/dist/client/static/js/wardley-WFR3VGLG-ns7e0fqf.js +1 -0
  163. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-tpass65t.js → wardleyDiagram-VNRHLVJA-tkk79rsn.js} +4 -4
  164. package/dist/client/static/js/xml-p4742r9b.js +1 -0
  165. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-8xkh67cw.js → xychartDiagram-PMCCYNJV-zhgrsqpb.js} +6 -6
  166. package/dist/client/static/js/yaml-qbckg671.js +1 -0
  167. package/marketplace/plugins/command-runner/README.md +5 -0
  168. package/marketplace/plugins/command-runner/package.json +2 -2
  169. package/marketplace/plugins/command-runner/src/panel/Output.test.tsx +177 -0
  170. package/marketplace/plugins/command-runner/src/panel/Output.tsx +53 -2
  171. package/package.json +3 -1
  172. package/public/tray-monochrome-dark.png +0 -0
  173. package/public/tray-monochrome-light.png +0 -0
  174. package/src/client/App.tsx +4 -0
  175. package/src/client/components/common/NotificationPermissionDialog.test.tsx +166 -0
  176. package/src/client/components/common/NotificationPermissionDialog.tsx +167 -0
  177. package/src/client/components/common/batch-selection/BatchDeleteModal.test.tsx +97 -0
  178. package/src/client/components/common/batch-selection/BatchDeleteModal.tsx +24 -1
  179. package/src/client/components/common/context-usage-button/SessionStats.tsx +4 -8
  180. package/src/client/components/common/context-usage-button/TokenTotals.tsx +51 -0
  181. package/src/client/components/common/context-usage-button/index.test.tsx +26 -3
  182. package/src/client/components/common/context-usage-button/index.tsx +2 -0
  183. package/src/client/components/common/diagram-viewer/index.tsx +11 -235
  184. package/src/client/components/common/fullscreen-viewer/fullscreen-viewer.test.tsx +108 -0
  185. package/src/client/components/common/fullscreen-viewer/index.tsx +326 -0
  186. package/src/client/components/common/header-button/index.test.tsx +97 -0
  187. package/src/client/components/common/header-button/index.tsx +67 -0
  188. package/src/client/components/common/header-controls/index.test.tsx +17 -1
  189. package/src/client/components/common/header-controls/index.tsx +18 -8
  190. package/src/client/components/common/image-viewer/fullscreen.tsx +64 -0
  191. package/src/client/components/common/progress-bar/index.tsx +53 -0
  192. package/src/client/components/common/session-actions-menu/MenuItem.tsx +36 -0
  193. package/src/client/components/common/session-actions-menu/index.test.tsx +79 -0
  194. package/src/client/components/common/session-actions-menu/index.tsx +62 -69
  195. package/src/client/components/common/session-delete-modal/index.tsx +5 -0
  196. package/src/client/components/common/session-row/TimeCell.tsx +22 -6
  197. package/src/client/components/common/session-row/TrailingSlot.tsx +3 -3
  198. package/src/client/components/common/session-row/index.tsx +6 -3
  199. package/src/client/components/common/session-row/row-state.ts +18 -0
  200. package/src/client/components/common/session-row/session-row.test.tsx +24 -0
  201. package/src/client/components/common/session-row/time-cell.test.tsx +110 -0
  202. package/src/client/components/layout/ActivityBar.test.ts +10 -116
  203. package/src/client/components/layout/ActivityBar.tsx +138 -134
  204. package/src/client/components/layout/ActivityBarDrag.test.ts +334 -0
  205. package/src/client/components/layout/LeftActivityBar.test.ts +30 -5
  206. package/src/client/components/layout/LeftDock.tsx +19 -1
  207. package/src/client/components/layout/PanelButton.tsx +93 -0
  208. package/src/client/components/layout/{PanelVisibilityMenu.tsx → VisibilityMenu.tsx} +37 -18
  209. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +30 -1
  210. package/src/client/components/layout/desktop-layout/PanelSuspense.tsx +30 -0
  211. package/src/client/components/layout/desktop-layout/ResizeHandle.tsx +24 -3
  212. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +62 -6
  213. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +28 -19
  214. package/src/client/components/layout/desktop-layout/index.tsx +7 -5
  215. package/src/client/components/layout/desktop-layout/resizer/index.tsx +17 -4
  216. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +4 -2
  217. package/src/client/components/layout/session-sidebar/Footer.test.tsx +76 -0
  218. package/src/client/components/layout/session-sidebar/Footer.tsx +13 -9
  219. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -0
  220. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +21 -0
  221. package/src/client/components/layout/session-sidebar/SessionItem.tsx +7 -4
  222. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  223. package/src/client/components/layout/session-sidebar/SessionsView.tsx +1 -0
  224. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +3 -1
  225. package/src/client/components/layout/session-sidebar/modern/index.tsx +1 -1
  226. package/src/client/components/layout/session-sidebar/search-results.test.tsx +127 -0
  227. package/src/client/components/mobile/mobile-session-sidebar/Dialogs.tsx +1 -0
  228. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +31 -0
  229. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +8 -4
  230. package/src/client/components/mobile/mobile-session-sidebar/use-dock.test.ts +41 -0
  231. package/src/client/components/mobile/mobile-session-sidebar/use-dock.ts +4 -1
  232. package/src/client/components/mobile/mobile-session-sidebar/use-drawer.ts +2 -0
  233. package/src/client/components/mobile/panel-chips.test.tsx +18 -11
  234. package/src/client/components/settings/categories/AppearanceSettings.tsx +3 -0
  235. package/src/client/components/settings/categories/HarnessSettings.tsx +3 -1
  236. package/src/client/components/settings/categories/NotificationSettings.test.tsx +56 -2
  237. package/src/client/components/settings/categories/NotificationSettings.tsx +46 -6
  238. package/src/client/components/settings/categories/appearance-settings/TrayIconSection.test.tsx +81 -0
  239. package/src/client/components/settings/categories/appearance-settings/TrayIconSection.tsx +118 -0
  240. package/src/client/components/settings/categories/harness-settings/HarnessCard.import.test.tsx +124 -0
  241. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +21 -2
  242. package/src/client/components/settings/categories/harness-settings/HarnessImportControls.tsx +143 -0
  243. package/src/client/components/settings/categories/notification-settings/PermissionNotice.tsx +50 -0
  244. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +1 -1
  245. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.test.tsx +107 -0
  246. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +49 -24
  247. package/src/client/components/settings/categories/panel-plugins/Placement.test.tsx +3 -0
  248. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +4 -0
  249. package/src/client/components/settings/categories/panel-plugins/Section.tsx +1 -1
  250. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +6 -10
  251. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +45 -38
  252. package/src/client/components/settings/categories/plugin-settings/MarketplacePane.tsx +20 -18
  253. package/src/client/components/settings/categories/plugin-settings/PaneHeader.tsx +40 -0
  254. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +6 -9
  255. package/src/client/components/settings/categories/usage-settings/usage-icons.test.tsx +1 -25
  256. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.test.ts +9 -1
  257. package/src/client/components/workspace/chat-timeline/MessageItem.gutter.test.ts +4 -0
  258. package/src/client/components/workspace/chat-timeline/chat-input/expansion.test.ts +22 -2
  259. package/src/client/components/workspace/chat-timeline/chat-input/expansion.ts +15 -2
  260. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/wait-parts.tsx +6 -11
  261. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolScreenshots.test.tsx +9 -0
  262. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolScreenshots.tsx +9 -18
  263. package/src/client/components/workspace/context-panel/index.tsx +18 -19
  264. package/src/client/components/workspace/editor/SplitColumn.tsx +5 -1
  265. package/src/client/components/workspace/file-explorer/Toolbar.tsx +40 -28
  266. package/src/client/components/workspace/git-panel/RepoHeader.tsx +27 -25
  267. package/src/client/components/workspace/git-panel/commit-modal/CommitActions.tsx +28 -77
  268. package/src/client/components/workspace/git-panel/commit-modal/CommitDiffViewer.tsx +15 -15
  269. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +79 -5
  270. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +66 -45
  271. package/src/client/components/workspace/git-panel/commit-modal/GraphCanvas.tsx +1 -7
  272. package/src/client/components/workspace/git-panel/commit-modal/Header.test.tsx +90 -0
  273. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +28 -18
  274. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +24 -7
  275. package/src/client/components/workspace/git-panel/commit-modal.test.ts +16 -0
  276. package/src/client/components/workspace/panel-header/index.test.tsx +80 -0
  277. package/src/client/components/workspace/panel-header/index.tsx +46 -0
  278. package/src/client/components/workspace/plan-panel/index.tsx +24 -22
  279. package/src/client/components/workspace/plugin-panel/catalog.tsx +21 -13
  280. package/src/client/components/workspace/search-panel/Body.tsx +42 -37
  281. package/src/client/components/workspace/terminal-panel/Header.tsx +37 -38
  282. package/src/client/components/workspace/terminal-panel/fonts.test.ts +40 -0
  283. package/src/client/components/workspace/terminal-panel/fonts.ts +27 -0
  284. package/src/client/components/workspace/terminal-panel/mount.ts +2 -5
  285. package/src/client/components/workspace/todo-panel/index.tsx +28 -26
  286. package/src/client/components/workspace/usage-panel/index.test.tsx +91 -0
  287. package/src/client/components/workspace/usage-panel/index.tsx +31 -55
  288. package/src/client/components/workspace/wiki-panel/index.tsx +47 -46
  289. package/src/client/data/context-data/index.ts +16 -0
  290. package/src/client/data/settings/omp-schema.json +201 -151
  291. package/src/client/hooks/chat/composer/auto-grow.ts +13 -3
  292. package/src/client/hooks/chat/omp/session-sidebar-controller.folder-open.test.ts +140 -0
  293. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +33 -203
  294. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +8 -6
  295. package/src/client/hooks/chat/timeline/jump-landing.ts +27 -9
  296. package/src/client/hooks/chat/timeline/jump-rail.ts +1 -0
  297. package/src/client/hooks/chat/timeline/reader-input.ts +39 -0
  298. package/src/client/hooks/chat/timeline/restore-history.ts +55 -0
  299. package/src/client/hooks/chat/timeline/row-window.test.ts +36 -3
  300. package/src/client/hooks/chat/timeline/row-window.ts +12 -3
  301. package/src/client/hooks/chat/timeline/scroll-geometry.ts +95 -0
  302. package/src/client/hooks/chat/timeline/scroll-probe.test-util.ts +17 -4
  303. package/src/client/hooks/chat/timeline/scroll.test.ts +53 -0
  304. package/src/client/hooks/chat/timeline/scroll.ts +30 -70
  305. package/src/client/hooks/chat/timeline/session-load.test.ts +25 -0
  306. package/src/client/hooks/chat/timeline/session-load.ts +8 -1
  307. package/src/client/hooks/chat/timeline/session-shapes.ts +3 -0
  308. package/src/client/hooks/models/use-harnesses-controller.ts +8 -1
  309. package/src/client/hooks/models/use-harnesses.ts +68 -1
  310. package/src/client/hooks/ui/navbar-controls.test.ts +50 -0
  311. package/src/client/hooks/ui/navbar-controls.ts +118 -0
  312. package/src/client/hooks/ui/pointer-hover.test.ts +94 -0
  313. package/src/client/hooks/ui/pointer-hover.ts +62 -0
  314. package/src/client/hooks/ui/ui-sounds.test.ts +4 -0
  315. package/src/client/hooks/workspace/batch-archive.ts +19 -3
  316. package/src/client/hooks/workspace/batch-delete-run.ts +15 -3
  317. package/src/client/hooks/workspace/batch-delete.test.ts +112 -0
  318. package/src/client/hooks/workspace/batch-delete.ts +51 -5
  319. package/src/client/hooks/workspace/left-dock.ts +14 -0
  320. package/src/client/hooks/workspace/panel-drop-target.test.tsx +119 -0
  321. package/src/client/hooks/workspace/panel-drop-target.ts +76 -0
  322. package/src/client/hooks/workspace/panel-menu-items.ts +57 -0
  323. package/src/client/hooks/workspace/panel-reorder.ts +5 -2
  324. package/src/client/lib/browser/download.ts +12 -1
  325. package/src/client/lib/notifications/active.ts +26 -0
  326. package/src/client/lib/notifications/native-banner-sound.test.ts +34 -1
  327. package/src/client/lib/notifications/native-banner-sound.ts +7 -0
  328. package/src/client/lib/notifications/os.test.ts +53 -0
  329. package/src/client/lib/notifications/os.ts +129 -5
  330. package/src/client/lib/session-export.test.ts +72 -0
  331. package/src/client/lib/session-export.ts +60 -0
  332. package/src/client/lib/ui/control-plate.test.ts +29 -0
  333. package/src/client/lib/ui/control-plate.ts +42 -0
  334. package/src/client/main.tsx +7 -0
  335. package/src/client/tailwind.css +18 -7
  336. package/src/server/lib/changes/attach.test.ts +3 -1
  337. package/src/server/lib/changes/capture-bash.server.ts +15 -1
  338. package/src/server/lib/changes/capture.server.ts +2 -0
  339. package/src/server/lib/changes/capture.test.ts +40 -0
  340. package/src/server/lib/changes/journal-read.server.ts +204 -0
  341. package/src/server/lib/changes/reader.server.ts +28 -184
  342. package/src/server/lib/changes/reader.test.ts +40 -0
  343. package/src/server/lib/changes/scan.server.ts +86 -12
  344. package/src/server/lib/changes/scan.test.ts +56 -0
  345. package/src/server/lib/changes/sessions.server.ts +15 -0
  346. package/src/server/lib/changes/temp-path.test.ts +45 -0
  347. package/src/server/lib/changes/temp-path.ts +102 -0
  348. package/src/server/lib/db/schema.ts +9 -0
  349. package/src/server/lib/harness/acp/client.ts +12 -6
  350. package/src/server/lib/harness/acp/frames-replay.test.ts +55 -0
  351. package/src/server/lib/harness/acp/frames.ts +45 -3
  352. package/src/server/lib/harness/acp/protocol.ts +29 -0
  353. package/src/server/lib/harness/acp/replay-transcript.test.ts +47 -0
  354. package/src/server/lib/harness/acp/replay-transcript.ts +55 -0
  355. package/src/server/lib/harness/acp/replay.ts +78 -0
  356. package/src/server/lib/harness/acp/session-config.ts +36 -1
  357. package/src/server/lib/harness/acp/session-handshake.ts +32 -8
  358. package/src/server/lib/harness/acp/session-observers.test.ts +2 -2
  359. package/src/server/lib/harness/acp/session-options.ts +9 -0
  360. package/src/server/lib/harness/acp/session-start.ts +62 -0
  361. package/src/server/lib/harness/acp/session.test-util.ts +2 -0
  362. package/src/server/lib/harness/acp/session.ts +33 -37
  363. package/src/server/lib/harness/acp/v2.test.ts +44 -0
  364. package/src/server/lib/harness/acp/v2.ts +38 -0
  365. package/src/server/lib/harness/acp/verbs.test.ts +37 -1
  366. package/src/server/lib/harness/acp/verbs.ts +52 -6
  367. package/src/server/lib/harness/auto-import.server.test.ts +92 -0
  368. package/src/server/lib/harness/auto-import.server.ts +209 -0
  369. package/src/server/lib/harness/auto-probe.server.ts +9 -3
  370. package/src/server/lib/harness/codex/transcript.server.test.ts +67 -0
  371. package/src/server/lib/harness/codex/transcript.server.ts +222 -0
  372. package/src/server/lib/harness/schema.server.ts +15 -7
  373. package/src/server/lib/harness/session-delete.server.test.ts +156 -0
  374. package/src/server/lib/harness/session-delete.server.ts +198 -0
  375. package/src/server/lib/harness/session-import.server.ts +177 -0
  376. package/src/server/lib/harness/session-store.server.test.ts +85 -0
  377. package/src/server/lib/harness/session-store.server.ts +70 -3
  378. package/src/server/lib/harness/session-transcript.server.test.ts +183 -0
  379. package/src/server/lib/harness/session-transcript.server.ts +301 -0
  380. package/src/server/lib/harness/session.ts +4 -2
  381. package/src/server/lib/harness/spawn.server.ts +9 -0
  382. package/src/server/lib/lifecycle/after-listen.ts +11 -5
  383. package/src/server/lib/model-roles/mock.server.test.ts +35 -0
  384. package/src/server/lib/model-roles/mock.server.ts +1 -1
  385. package/src/server/lib/omp/rpc/frame-fold-frames.test.ts +15 -4
  386. package/src/server/lib/omp/session/delete-flow.server.ts +62 -9
  387. package/src/server/lib/omp/session/delete.server.ts +6 -0
  388. package/src/server/lib/omp/session/sidebar-data.harness.test.ts +86 -1
  389. package/src/server/lib/omp/session/sidebar-data.server.ts +41 -70
  390. package/src/server/lib/omp/session/sidebar-status.server.ts +82 -0
  391. package/src/server/lib/omp/session/telemetry/compute.ts +18 -0
  392. package/src/server/lib/omp/session/telemetry.test.ts +21 -0
  393. package/src/server/lib/realtime/topics/catalog.server.ts +2 -1
  394. package/src/server/lib/realtime/topics.server.ts +2 -1
  395. package/src/server/lib/sessions/deleted-sessions.server.test.ts +49 -0
  396. package/src/server/lib/sessions/deleted-sessions.server.ts +45 -0
  397. package/src/server/lib/terminal/attach-replay.test.ts +80 -17
  398. package/src/server/lib/tray/config.ts +19 -4
  399. package/src/server/lib/tray/host/darwin.js +6 -1
  400. package/src/server/lib/tray/host/linux.js +2 -1
  401. package/src/server/lib/tray/host/win32.ps1 +7 -1
  402. package/src/server/lib/tray/runtime.server.ts +81 -3
  403. package/src/server/lib/tray/tray.test.ts +20 -0
  404. package/src/server/plugins/static.test.ts +23 -1
  405. package/src/server/plugins/static.ts +24 -1
  406. package/src/server/routes/agent/command.ts +4 -0
  407. package/src/server/routes/agent/harness-command.ts +77 -3
  408. package/src/server/routes/agent/restore.ts +50 -0
  409. package/src/server/routes/chat/imported.ts +32 -0
  410. package/src/server/routes/chat/session.ts +33 -21
  411. package/src/server/routes/chat/window.ts +25 -0
  412. package/src/server/routes/folders/batch-delete.ts +3 -4
  413. package/src/server/routes/harness/root.ts +17 -1
  414. package/src/server/routes/harness/session-actions.ts +60 -0
  415. package/src/server/routes/harness/session-import.test.ts +81 -0
  416. package/src/server/routes/sessions/batch-archive.ts +5 -4
  417. package/src/server/routes/sessions/batch-delete.ts +23 -12
  418. package/src/server/routes/sessions/delete-acp.test.ts +70 -0
  419. package/src/server/routes/sessions/export.test.ts +83 -0
  420. package/src/server/routes/sessions/export.ts +59 -0
  421. package/src/server/routes/sessions/index.ts +4 -0
  422. package/src/server/routes/sessions/list.ts +5 -0
  423. package/src/server/routes/settings/root.ts +13 -0
  424. package/src/shared/lib/chat/export-markdown.test.ts +110 -0
  425. package/src/shared/lib/chat/export-markdown.ts +141 -0
  426. package/src/shared/lib/omp/config/schema-releases.test.ts +193 -0
  427. package/src/shared/lib/omp/config/schema.test.ts +0 -117
  428. package/src/shared/lib/realtime/connection.ts +4 -0
  429. package/src/shared/lib/sessions/batch-limits.test.ts +51 -0
  430. package/src/shared/lib/sessions/batch-limits.ts +42 -0
  431. package/src/shared/lib/settings/defaults.ts +2 -0
  432. package/src/shared/lib/theme/tray-icon-style.test.ts +43 -0
  433. package/src/shared/lib/theme/tray-icon-style.ts +69 -0
  434. package/src/shared/lib/workspace/left-dock-width.ts +23 -3
  435. package/src/shared/lib/workspace/left-dock.test.ts +38 -10
  436. package/src/shared/lib/workspace/left-dock.ts +39 -14
  437. package/src/shared/lib/workspace/panel-drag.test.ts +52 -0
  438. package/src/shared/lib/workspace/panel-drag.ts +34 -0
  439. package/src/shared/lib/workspace/panel-open.test.ts +7 -1
  440. package/src/shared/lib/workspace/session-state/store.ts +0 -1
  441. package/src/shared/types/context.ts +20 -0
  442. package/src/shared/types/harness.ts +26 -0
  443. package/src/shared/types/settings/state.ts +9 -0
  444. package/src/test-support/fake-acp-delete.ts +63 -0
  445. package/src/test-support/sidebar-controller-harness.test-util.ts +121 -0
  446. package/dist/client/static/js/DrawioView-1ts9y0yk.js +0 -5
  447. package/dist/client/static/js/ImageView-w2hyp129.js +0 -1
  448. package/dist/client/static/js/LayoutWrapper-pdvfkncm.js +0 -2
  449. package/dist/client/static/js/Modal-2sx1tgqr.js +0 -38
  450. package/dist/client/static/js/SessionsView-a8921ysr.js +0 -1
  451. package/dist/client/static/js/architecture-7GRP2DOG-r8sz34h3.js +0 -1
  452. package/dist/client/static/js/architectureDiagram-NJMV4G6O-z3n19xwk.js +0 -36
  453. package/dist/client/static/js/bash-b3rwyg5p.js +0 -1
  454. package/dist/client/static/js/c-jkdstn33.js +0 -1
  455. package/dist/client/static/js/cpp-9d3xdpe3.js +0 -1
  456. package/dist/client/static/js/css-r3wja1ze.js +0 -1
  457. package/dist/client/static/js/css-sebxkh5f.js +0 -1
  458. package/dist/client/static/js/cynefin-OW5HDTMX-w2f2vev7.js +0 -1
  459. package/dist/client/static/js/eventmodeling-NTZA5JFV-k5n61zzh.js +0 -1
  460. package/dist/client/static/js/flowDiagram-KWPJA3E3-zmz4grtx.js +0 -1
  461. package/dist/client/static/js/gitGraph-4MIJSDKK-2gf053bx.js +0 -1
  462. package/dist/client/static/js/graphql-p4cskvad.js +0 -1
  463. package/dist/client/static/js/html-f26r6vv5.js +0 -1
  464. package/dist/client/static/js/index-1c7294vk.js +0 -1
  465. package/dist/client/static/js/index-2mx9ej4k.css +0 -1
  466. package/dist/client/static/js/index-2xb54jt3.js +0 -4
  467. package/dist/client/static/js/index-6d5qj0kb.js +0 -1
  468. package/dist/client/static/js/index-6k2x281j.js +0 -12
  469. package/dist/client/static/js/index-6rt7gs1j.js +0 -1
  470. package/dist/client/static/js/index-737w2mqf.js +0 -1
  471. package/dist/client/static/js/index-a5ptb956.js +0 -3
  472. package/dist/client/static/js/index-aa6qdgmv.js +0 -1
  473. package/dist/client/static/js/index-arvqarv3.js +0 -7
  474. package/dist/client/static/js/index-bgcp21ed.js +0 -1
  475. package/dist/client/static/js/index-d8kjsgpt.js +0 -474
  476. package/dist/client/static/js/index-enxfdvdq.js +0 -1
  477. package/dist/client/static/js/index-hp8kfk9z.js +0 -1
  478. package/dist/client/static/js/index-r83kr4s5.js +0 -2
  479. package/dist/client/static/js/index-rtd9frp1.js +0 -2
  480. package/dist/client/static/js/index-s910y31q.js +0 -1
  481. package/dist/client/static/js/info-A6RAGUB7-3tr0y3s6.js +0 -1
  482. package/dist/client/static/js/ini-cg0a5wm3.js +0 -1
  483. package/dist/client/static/js/java-vcck089n.js +0 -1
  484. package/dist/client/static/js/javascript-nyf39d5r.js +0 -1
  485. package/dist/client/static/js/json-j5q8nt57.js +0 -1
  486. package/dist/client/static/js/jsx-ht9zyzwa.js +0 -1
  487. package/dist/client/static/js/lua-86fjqj8v.js +0 -1
  488. package/dist/client/static/js/markdown-gwmsh53r.js +0 -1
  489. package/dist/client/static/js/one-dark-pro-kckm8epj.js +0 -1
  490. package/dist/client/static/js/one-light-0v7rg9a7.js +0 -1
  491. package/dist/client/static/js/packet-AYTQ26CC-xbsyjzrh.js +0 -1
  492. package/dist/client/static/js/pie-WAS4IAKB-j2tpz0cs.js +0 -1
  493. package/dist/client/static/js/pieDiagram-5QR66LMP-nz6n95d6.js +0 -39
  494. package/dist/client/static/js/properties-mzvvbqg5.js +0 -1
  495. package/dist/client/static/js/python-3w64wsyd.js +0 -1
  496. package/dist/client/static/js/r-32re2zwb.js +0 -1
  497. package/dist/client/static/js/radar-RG4KPBEZ-m3tsyfv0.js +0 -1
  498. package/dist/client/static/js/railroad-74A4TZTK-5p202a4q.js +0 -1
  499. package/dist/client/static/js/railroad-abnf-HS5TGJTU-hj0y9tgn.js +0 -1
  500. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-8c5dct8f.js +0 -1
  501. package/dist/client/static/js/railroad-peg-WCYAUIDC-3tx8z65q.js +0 -1
  502. package/dist/client/static/js/sql-0e9mnrda.js +0 -1
  503. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-56rk9kxv.js +0 -8
  504. package/dist/client/static/js/treeView-Q6P3EWNA-mf0rb2yv.js +0 -1
  505. package/dist/client/static/js/treemap-WGGIJYW6-0x5gf06b.js +0 -1
  506. package/dist/client/static/js/tsx-nm94hed6.js +0 -1
  507. package/dist/client/static/js/typescript-5nmrzgkj.js +0 -1
  508. package/dist/client/static/js/wardley-WFR3VGLG-x7ej8dms.js +0 -1
  509. package/dist/client/static/js/xml-3dd1pter.js +0 -1
  510. package/dist/client/static/js/yaml-yssayv8a.js +0 -1
  511. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +0 -229
@@ -1,3 +0,0 @@
1
- import{d,n,i,V,o,u,a,He,se,e,Gn,Ze,ze,S,s,I,m,Kt,D,f,B,ae,tt,he,wt,Ge,Zi,en,qr,C,F,b,Wr,Ke,ce,dr,J,at,$s,xi,zs,Us,Ci,Eg,Pg,Ys,Ne,re,jt,T,ye,Fi,lo,Um,Vf}from"./index-d8kjsgpt.js";import{yt,uo,Gc,jc,Hc,os,po,cd}from"./index-rtd9frp1.js";import{Cc,ed,td,eA,tA,Ec,Zn,ns,Bc,Ic,_c,Sc,Tc,rs,Li,as,Qc,al,il,Nc,Rc,Fc,Lc,Mc,Pc,Oc,$c,zc}from"./index-6k2x281j.js";import{Sa,Ta,fo}from"./index-d146s9g3.js";var fn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},Le=s(fn);var bn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},xe=s(bn);var gn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},we=s(gn);var hn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},ke=s(hn);var oe=new Set,Be=new Set,Fe=new Set;function $e(){Fe=new Set(oe);for(let t of[...Be])t()}function Ve(t){let r=new Set(t);if(r.size===oe.size){let l=!0;for(let c of r)if(!oe.has(c)){l=!1;break}if(l)return}oe.clear();for(let l of r)oe.add(l);$e()}function We(t){let r=new Set(t),l=!1;for(let c of[...oe])if(!r.has(c))oe.delete(c),l=!0;if(l)$e()}function Ue(t){return oe.has(t)}function _e(){return oe.size>0}function vn(t){return Be.add(t),()=>{Be.delete(t)}}var yn=vn;function qe(){return He(yn,()=>Fe)}function Xe({x:t,y:r,rows:l,onAction:c,onClose:p}){let g=o(null),[h,v]=n({left:t,top:r});return V(()=>{let x=g.current;if(!x)return;let{width:y,height:w}=x.getBoundingClientRect();v({left:Math.min(t,Math.max(0,window.innerWidth-y-8)),top:Math.min(r,Math.max(0,window.innerHeight-w-8))})},[t,r,l.length]),se(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(x)=>{x.preventDefault(),p()},children:e("div",{ref:g,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:`${h.left}px`,top:`${h.top}px`},onClick:(x)=>x.stopPropagation(),children:l.map((x)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(x.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:x.label},x.action))})}),document.body)}var be={rightFileId:null,fraction:0.5};function Se(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ye(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function je(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function pe(t){if(!Number.isFinite(t))return be.fraction;return Math.max(0.2,Math.min(0.8,t))}function Je(t,r){if(typeof t!=="object"||t===null)return be;let l=t,c=typeof l.fraction==="number"?pe(l.fraction):be.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function Qe({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:g}){let h=r.filter((w)=>w.id!==t.id),v=r.filter((w)=>!l.has(w.id)),x=r.map((w)=>w.id);return[{action:"split-right",label:"Split right",enabled:Se(t.id,p,x)},{action:"unsplit",label:"Unsplit",enabled:g!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:h.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:v.some((w)=>w.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:c>0}].filter((w)=>w.enabled)}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:g,onRevealInFiles:h,onReopenClosed:v,reopenableCount:x,onSplitTo:y,onUnsplit:w,splitRightFileId:k=null}){let A=qe(),E=o(null),M=o(null),[H,K]=n(5),[W,z]=n(!1),[L,_]=n(null);ce(M,()=>z(!1)),i(()=>{let N=new ResizeObserver((R)=>{for(let P of R){let Q=P.contentRect.width,X=Math.max(1,Math.floor((Q-60)/150));K(X)}});if(E.current)N.observe(E.current);return()=>N.disconnect()},[]);let O=Ye(r,t.map((N)=>N.id)),G=[],Z=[];if(t.length<=H)G=t;else{let N=t.findIndex((P)=>P.id===r),R=new Set;if(N!==-1&&r!==null)R.add(r);for(let P=t.length-1;P>=0;P--){if(R.size>=H)break;R.add(t[P].id)}G=t.filter((P)=>R.has(P.id)),Z=t.filter((P)=>!R.has(P.id))}return e("div",{className:"flex bg-ink/10 w-full relative border-b border-ink/10",ref:E,children:[e("div",{className:"flex overflow-hidden",children:G.map((N)=>{let R=N.id===r,P=Boolean(N.isDiff),Q=P?Gn(N.diffStatus||"M",N.diffStaged):null,X=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(j)=>{j.preventDefault(),_({tab:N,x:j.clientX,y:j.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 ${R?"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:X?`${N.path} — file no longer exists`:N.path,children:[P?e(Zi,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(at,{name:N.name,size:14,className:`flex-shrink-0${R||X?"":" opacity-60"}${X?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${X?" text-error line-through":""}`,children:N.name}),Q&&e("span",{className:`px-1 text-[10px] font-mono font-bold rounded ${Q.badgeBgClass}`,children:Q.charStatus}),e(et,{dirty:A.has(N.id),active:R,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),L?e(Xe,{x:L.x,y:L.y,rows:Qe({tab:L.tab,openedFiles:t,dirtyIds:A,reopenable:x?.()??0,activeFileId:r,splitRightFileId:k}),onAction:(N)=>{let R=L.tab;switch(N){case"close":c(R.id);return;case"close-others":for(let P of[...t].reverse())if(P.id!==R.id)c(P.id);l(R.id);return;case"close-all":for(let P of[...t].reverse())c(P.id);return;case"close-saved":for(let P of[...t].reverse())if(!A.has(P.id))c(P.id);return;case"copy-path":g?.(R);return;case"reveal-in-files":h?.(R);return;case"reopen-closed":v?.();return;case"split-right":y?.(R.id);return;case"unsplit":w?.();return}},onClose:()=>_(null)}):null,e("div",{className:"ml-auto flex items-center",children:e("button",{type:"button",onClick:()=>k!==null?w?.():y?.(O),disabled:k===null&&O===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":O===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 ${k!==null?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/10"}`,children:e(qr,{size:14})})}),Z.length>0&&e("div",{className:"relative flex items-center bg-ink/10",ref:M,children:[e("button",{className:`p-1.5 mx-1 rounded hover:bg-ink/10 text-ink/60 ${W?"bg-ink/10 text-ink":""}`,onClick:()=>z(!W),title:"More open files",children:e(B,{size:14})}),W&&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"}),Z.map((N)=>{let R=Boolean(p?.has(N.id));return e("div",{onClick:()=>{l(N.id),z(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(Zi,{size:14,className:"text-info/80"}):e(at,{name:N.name,size:14,className:R?"text-error":"opacity-60"}),e("span",{className:`text-xs font-mono truncate flex-1 ${R?"text-error line-through":"text-ink/80"}`,children:N.name}),e(et,{dirty:A.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Z.length===1)z(!1)}})]},N.id)})]})]})]})}function et({dirty:t,active:r,label:l,onClose:c}){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:(p)=>{p.stopPropagation(),c()},children:t?e("span",{className:"block w-2 h-2 rounded-full bg-current mx-0.5","data-tab-dirty":"","aria-hidden":"true"}):e(b,{size:12})})}function xn(t){if(t===null)return null;let r=new Date(t);if(Number.isNaN(r.getTime()))return null;return r.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Ce({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=xn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(D,{size:13,className:"text-warning flex-shrink-0 mt-0.5"}),e("div",{className:"min-w-0 flex-1",children:[e("div",{className:"font-medium",children:[e("span",{className:"font-mono",children:r})," changed on disk",p?e("span",{className:"text-ink/60",children:[" at ",p]}):null,"."]}),e("div",{className:"text-ink/60 mt-0.5",children:"Your save was refused so nothing was overwritten."})]}),e("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e("button",{type:"button",onClick:l,className:"px-2 py-1 rounded border border-ink/20 hover:bg-ink/5 transition-colors cursor-pointer",title:"Discard my changes and take the file from disk",children:"Reload"}),e("button",{type:"button",onClick:c,className:"px-2 py-1 rounded border border-warning/50 text-warning hover:bg-warning/10 transition-colors cursor-pointer",title:"Write my buffer over the file on disk",children:"Keep mine"})]})]})}function ot(t){if(t.byteViewer)return[];return[{id:"save",pinned:!0,actions:[{label:"Save file",icon:ke,onSelect:t.onSave,disabled:t.saveDisabled}],children:t.saveButton},{id:"save-as",actions:[{label:"Save as…",icon:ke,onSelect:t.onSaveAs}],children:e("button",{type:"button",onClick:t.onSaveAs,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:"Save the buffer to a new file","aria-label":"Save as",children:e(ke,{size:14})})}]}function rt(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:en,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(ns,{label:r,pressed:t.isReviewing,title:t.isReviewing?"Review mode is on — click a block to judge it":"Review: click blocks to mark them good or needing work",onClick:t.onToggleReview,children:e(en,{size:14})})}]}function it(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?wt:Ge,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(ns,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(wt,{size:14}):e(Ge,{size:14})})}]}function st(t){let r=[];if(r.push(...ot(t),...rt(t),...it(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:F,onSelect:t.onToggleFind,active:t.findOpen}],children:e(ns,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(F,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:Kt,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(ns,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(Kt,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:Le,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(ns,{label:t.blameInline?"Hide line blame":"Show line blame",pressed:t.blameInline,title:"Who last changed each block, from git (hover a line for the commit)",onClick:t.onToggleBlameInline,children:e(Le,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Ta,onSelect:t.onZoomOut},{label:"Increase font size",icon:Sa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Ta,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Sa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:C,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:!t.canReload?"Nothing to reload — this tab has no file on disk":t.reloadDiscardsEdits?"Discard my changes and reload from disk":"Reload from disk","aria-label":"Reload from disk",children:e(C,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:ae,onSelect:t.onCopy},{label:"Download file",icon:he,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(ae,{size:14,className:"text-success"}):e(ae,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${Zn} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(he,{size:14})})]})}),r.push({id:"view-modes",pinned:!0,actions:t.viewModeActions,children:t.viewModeButtons}),r.push({id:"maximize",pinned:!0,actions:[{label:t.maximizeLabel,icon:t.isMaximized?we:xe,onSelect:t.onToggleMaximize,active:t.isMaximized}],children:t.maximizeButton}),r}function lt({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:g,isReviewing:h,copied:v,byteViewer:x=!1,saveDisabled:y=!1,unsupported:w=!1,handleMissing:k=!1,readOnly:A=!1,isMaximized:E=!1,findOpen:M=!1,onToggleFind:H,onSave:K,onTogglePreview:W,onToggleReview:z,onToggleWordWrap:L,onZoomIn:_,onZoomOut:O,onCopy:G,onDownload:Z,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:X,onToggleMaximize:j}){let ne=y?A?"Read-only — this file was opened from the phone, not from a workspace":k?"Cannot save — reopen the file from the system to restore write access":w?"Nothing to save — this file cannot be opened as a document":"Nothing to save — this file could not be read":r==="needs-permission"?"Click Save to allow writing this file":r==="saving"?"Saving…":r==="error"?"Save failed — the file on disk was not changed":"Save file (Ctrl+S)",me=e("button",{type:"button",onClick:K,disabled:y||r==="saving",className:`${Zn} hover:bg-ink/5`,title:ne,"aria-label":ne,children:r==="saving"?e(yt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(I,{size:14,className:"text-error"}):r==="needs-permission"?e(yt,{size:14,className:"text-warning"}):e(yt,{size:14,className:"hover:text-ink"})}),ee=E?"Exit full screen":"Full screen",te=e("button",{type:"button",onClick:j,className:`${Zn} hover:bg-ink/5 hover:text-ink ${E?"text-ink":""}`,title:ee,"aria-label":ee,"aria-pressed":E,children:E?e(we,{size:14}):e(xe,{size:14})}),ue=cd(),ie=ed(),le=st({byteViewer:x,hasPreview:c,isPreview:p,wordWrap:l,hasReview:g,isReviewing:h,blameInline:ue.inline,findOpen:M,copied:v,isMaximized:E,saveDisabled:y,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:me,maximizeButton:te,viewModeButtons:e(td,{size:14}),viewModeActions:ie,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:v?"Copied":x?"Copy image":"Copy content",maximizeLabel:ee,onTogglePreview:W,onToggleReview:z,onToggleFind:H,onToggleWordWrap:L,onToggleBlameInline:()=>{let fe={...po(),inline:!ue.inline};Wr({editorBlameInline:fe.inline}),window.dispatchEvent(new CustomEvent(os,{detail:fe}))},onZoomIn:_,onZoomOut:O,onCopy:G,onDownload:Z,onReload:N,onSaveAs:X,onToggleMaximize:j,onSave:K});return e("div",{className:"@container flex items-center justify-between gap-2 px-3 py-2 border-b border-ink/10 bg-paper flex-shrink-0",children:[e("div",{className:"hidden @[420px]:flex items-center space-x-2 text-xs font-mono text-ink/40 min-w-0",children:e("span",{className:"truncate max-w-[300px]",title:t,children:t})}),e(fo,{clusters:le,className:"text-ink/40 ml-auto"})]})}function dt({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:g,onScroll:h}){return e("div",{ref:g,onScroll:h,"data-testid":"editor-scroller",className:"flex-1 overflow-auto bg-paper flex",children:e("div",{className:"p-6 max-w-4xl mx-auto font-sans flex-1",style:{fontSize:`${l}px`},children:e(Bc,{content:t,file:r,active:c,onExit:p})})})}function wn(t,r){return r?`Spaces: ${t}`:"Tabs"}function ct({caret:t,eol:r,onSetEol:l,indentWidth:c,insertSpaces:p,language:g,byteViewer:h,viewerKind:v,lineCount:x,conflicts:y=0}){return e("footer",{className:"flex bg-canvas border-t border-ink/10 px-3 items-center justify-between text-[10px] text-ink/50 flex-shrink-0 font-mono h-6","data-editor-status-bar":"",children:[e("div",{className:"flex items-center gap-3 min-w-0",children:h?e("span",{className:"uppercase",children:Li[v]}):e(d,{children:[e("span",{className:"tabular-nums",children:t?`Ln ${t.line}, Col ${t.column}`:"Ln —, Col —"}),e("span",{children:wn(c,p)}),e("button",{type:"button",onClick:()=>l(r==="lf"?"crlf":"lf"),className:"uppercase hover:text-ink transition-colors cursor-pointer",title:`Line endings: ${r.toUpperCase()} — click to switch`,"aria-label":`Line endings ${r.toUpperCase()}, switch`,children:r}),e("span",{children:[x," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[y>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${y} unresolved conflict${y===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",y," conflict",y===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:g})]})]})}function kn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Sn(t,r,l=zs,c=Us){return Math.max(l,Math.min(c,t+r))}function Cn(t,r){let l=t instanceof HTMLElement?t:null;while(l&&l!==r){let c=getComputedStyle(l);if(/(auto|scroll)/.test(c.overflowY)&&l.scrollHeight>l.clientHeight)return!0;l=l.parentElement}return!1}function mt(t,r){i(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(g)=>{if(!g.ctrlKey&&!g.metaKey)return;if(g.preventDefault(),Cn(g.target,c))return;let h=kn(g.deltaY);if(h===0)return;r((v)=>Sn(v,h))};return t.addEventListener("wheel",p,{passive:!1}),()=>t.removeEventListener("wheel",p)},[t,r])}function ut(t,r){let l=t.trim();if(!/^\d+$/.test(l))return null;let c=Number(l);if(c<1)return null;return Math.min(c,Math.max(r,1))}function pt({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),g=o(null);i(()=>{g.current?.focus(),g.current?.select()},[]);let h=()=>{let y=ut(c,t);if(y===null)return;r(y)},v=(y)=>{if(y.key==="Enter"){y.preventDefault(),h();return}if(y.key==="Escape")y.preventDefault(),l()},x=ut(c,t);return e(J,{onClose:l,maxWidthClass:"max-w-xs",header:e("span",{className:"text-sm font-semibold text-ink",children:"Go to line"}),children:e("div",{className:"px-4 py-3 space-y-2",children:[e("div",{className:"flex items-center gap-2",children:[e("input",{ref:g,value:c,onInput:(y)=>p(y.target.value),onKeyDown:v,inputMode:"numeric",placeholder:"1","aria-label":"Line number",className:"flex-1 bg-paper border border-ink/20 rounded px-2 py-1 text-xs font-mono text-ink outline-none focus:border-ink/40"}),e("span",{className:"text-[10px] font-mono text-ink/40",children:["/ ",t]}),e("button",{type:"button",onClick:h,disabled:x===null,className:"flex items-center gap-1 px-2 py-1 rounded bg-ink text-paper text-xs disabled:opacity-40 disabled:cursor-default cursor-pointer",children:[e(tt,{size:12}),"Go"]})]}),c&&x!==null&&String(x)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",x," (the last line)"]}):null,c&&x===null?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a line number"}):null]})})}var ft={status:"idle",payload:null,message:null};function bt(t){if(!t?.path)return"";return`${t.root??""}\x00${t.repo??""}\x00${t.path}`}function gt(t,r={}){let l=r.enabled!==!1&&Boolean(t?.path)&&t?.deviceFile!==!0,c=r.dirty===!0,p=bt(t),[g,h]=n({key:"",value:ft}),v=o(t);v.current=t;let x=o(p);x.current=p;let y=o(l);y.current=l;let w=o(c);w.current=c;let k=o(g);k.current=g;let A=o(0),E=o(""),M=o(new Map),H=o(new Set),K=a(async()=>{let O=v.current;if(!O?.path)return;let G=bt(O),Z=++A.current;E.current=G,h((R)=>({key:G,value:{status:"loading",payload:R.key===G?R.value.payload:null,message:null}}));let N=new URLSearchParams({blame:"1",file:O.path,repo:O.repo||"."});if(O.root)N.set("root",O.root);try{let R=await fetch(`/api/fs/git?${N.toString()}`),P=await R.json().catch(()=>null);if(Z!==A.current)return;if(!R.ok||!P){h({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${R.status})`}});return}h({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(R){if(Z!==A.current)return;h({key:G,value:{status:"error",payload:null,message:R instanceof Error?R.message:"Blame failed"}})}finally{if(E.current===G)E.current=""}},[]),W=a(async(O)=>{let G=M.current.get(O);if(G)return G;let Z=v.current;if(!Z?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:Z.path,line:String(O),repo:Z.repo||"."});if(Z.root)N.set("root",Z.root);try{let P=await(await fetch(`/api/fs/git?${N.toString()}`)).json().catch(()=>null),Q={entries:Array.isArray(P?.entries)?P.entries:[],truncated:P?.truncated===!0};return M.current.set(O,Q),Q}catch{return{entries:[],truncated:!1}}},[]),z=o(null);if(!z.current)z.current={ensure:()=>{if(!y.current||w.current)return;let O=k.current;if(O.key===x.current&&O.value.status!=="idle")return;if(E.current===x.current)return;K()},reload:()=>{M.current.clear(),K()},history:W,snapshot:()=>{let O=k.current;return O.key===x.current?O.value:ft},stale:()=>w.current,subscribe:(O)=>(H.current.add(O),()=>{H.current.delete(O)})};i(()=>{if(!l||c||!p)return;M.current.clear(),K()},[l,c,p,K]);let L=o(c);return i(()=>{if(L.current===c)return;L.current=c;for(let O of H.current)O()},[c]),i(()=>{for(let O of H.current)O()},[g]),z.current}var En="0".repeat(40);function Ee(t){return t===En}function ge(t,r=Date.now()){let l=Math.max(0,Math.floor(r/1000)-t);if(l<60)return"just now";let c=Math.floor(l/60);if(c<60)return`${c}m ago`;let p=Math.floor(c/60);if(p<24)return`${p}h ago`;let g=Math.floor(p/24);if(g<30)return`${g}d ago`;let h=Math.floor(g/30);if(h<12)return`${h}mo ago`;return`${Math.floor(g/365)}y ago`}function ht(t,r){switch(t){case"not-repo":return"This folder is not a git repository.";case"no-commit":return"This repository has no commits yet.";case"untracked":return"This file has never been committed, so it has no history.";case"too-large":return r??"This file is too large to blame.";case"empty":return"This file is empty.";default:return r??"git could not read this file."}}var St="fixed z-50 w-[min(340px,92vw)] rounded-xl border border-ink/20 bg-paper p-3 shadow-xl font-sans text-xs text-ink",vt="flex items-baseline justify-between gap-2",xt="truncate text-xs font-semibold text-ink",Tn="shrink-0 font-mono text-[10px] text-ink/40",Mn="mt-1 line-clamp-2 text-[11px] leading-snug text-ink/80",Nn="mt-2 border-t border-ink/10 pt-2",Rn="flex items-center gap-2 font-mono text-[10px] text-ink/40",kt="mt-1 text-[10px] leading-snug text-ink/50",Pn="mt-2 flex w-full items-center gap-1.5 text-left text-[10px] text-ink/50 hover:text-ink cursor-pointer",Ln="mt-1.5 space-y-1 border-t border-ink/10 pt-1.5",Te="flex items-center gap-1.5 font-mono text-[10px]";function q(t,r,l){let c=document.createElement(t);if(c.className=r,l!==void 0)c.textContent=l;return c}function Bn(t){return new Date(t*1000).toLocaleDateString(void 0,{day:"numeric",month:"short",year:"numeric"})}function Dn(t){let r=t.payload;if(t.status==="error")return{title:"Blame failed",body:t.message??"git could not read this file."};if(t.status==="unavailable")return{title:r?.reason==="untracked"?"Not tracked":"No history",body:ht(r?.reason??"error",t.message??void 0)};if(!r)return null;if(t.stale)return{title:"Not committed yet",body:"This line changed in the editor. Save the file to see its blame."};if(t.line>r.lines)return{title:"Not committed yet",body:`Line ${t.line} is past the end of the file at HEAD (${r.lines} lines).`};let l=r.runs.length>0?Ct(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Ee(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function Ct(t,r){for(let l of t.runs)if(r>=l.from&&r<=l.to)return t.commits[l.sha]??null;return null}function On(t,r){t.replaceChildren(),t.className=St;let l=Dn(r);if(l){let y=q("div",vt);if(y.append(q("span",xt,l.title)),r.status==="error"&&r.message){let w=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");w.type="button",w.setAttribute("aria-label","Read the blame again"),y.append(w)}t.append(y,q("p",kt,l.body));return}let c=r.payload;if(!c){t.append(q("p",kt,"Reading blame…"));return}let p=Ct(c,r.line),g=q("div",vt);if(g.append(q("span",xt,p.author.trim()||"Unknown"),q("span",Tn,ge(p.time))),t.append(g),p.summary)t.append(q("p",Mn,p.summary));let h=q("div",`${Rn} ${Nn}`);if(h.append(q("code","truncate",p.sha.slice(0,7)),q("span","",Bn(p.time))),p.mail){let y=q("span","truncate",p.mail);y.title=p.mail,h.append(y)}t.append(h);let v=q("button",Pn);if(v.type="button",v.setAttribute("aria-expanded",r.historyOpen?"true":"false"),v.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(v),!r.historyOpen)return;let x=q("ol",Ln);if(r.historyLoading)x.append(q("li",`${Te} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)x.append(q("li",`${Te} text-ink/40`,"No commits touched this line."));else{let y=r.history.entries;if(y.forEach((w,k)=>{let A=q("li",Te),E=k===y.length-1?"new":"edit";A.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",w.sha.slice(0,7)),q("span","truncate text-ink/80",w.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",ge(w.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",E)),x.append(A)}),r.history.truncated)x.append(q("li",`${Te} text-ink/40`,"Older commits are not shown."))}t.append(x)}function Et(t,r,l){let c=q("div",St);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(w)=>w.stopPropagation());let p=null,g=!1,h=!1,v=()=>{let w=r.snapshot();return{line:t,status:w.status,payload:w.payload,message:w.message,stale:r.stale(),history:p,historyOpen:g,historyLoading:h}},x=()=>{On(c,v());let w=c.querySelector('[aria-label="Read the blame again"]');if(w)w.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),g=!g,x(),!g||p||h)return;h=!0,x(),r.history(t).then((A)=>{p=A,h=!1,x()})})};x();let y=r.subscribe(x);return{element:c,place(w){let k=c.ownerDocument.defaultView,A=k?.innerWidth??1024,E=k?.innerHeight??768,M=c.offsetWidth||340,H=c.offsetHeight||120,K=8,W=Math.max(8,Math.min(w.left,A-M-8)),z=w.bottom+6,L=w.top-H-6,_=z+H>E-8&&L>8?L:z;c.style.left=`${W}px`,c.style.top=`${Math.max(8,_)}px`},destroy(){y(),c.remove()}}}function Tt(t){return ye.define((r)=>{let l=null,c=0,p,g=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},h=(E,M)=>{let H=E.getBoundingClientRect();if(H.width>0)return{left:H.left,top:H.top,bottom:H.bottom};let K=r.state.doc.line(Math.min(M,r.state.doc.lines)),W=null;try{W=r.coordsAtPos(K.from)}catch{W=null}if(W)return W;let z=r.scrollDOM.getBoundingClientRect();return{left:z.left,top:z.top+24,bottom:z.top+24}},v=(E,M)=>{if(c===E&&l)return;g(),c=E,l=Et(E,t,()=>{t.reload(),g()}),document.body.append(l.element),l.place(M)},x=(E)=>{let M=E.target,H=M?.closest?.(".cm-blame-label");if(H){let z=Number(H.dataset.blameLine);return Number.isInteger(z)&&z>0?{line:z,anchor:H}:null}let K=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!K)return null;let W=Number((K.textContent??"").trim());return Number.isInteger(W)&&W>0?{line:W,anchor:K}:null},y=(E)=>{let M=x(E);if(!M)return;v(M.line,h(M.anchor,M.line))},w=(E)=>{let M=x(E);if(M){E.preventDefault(),v(M.line,h(M.anchor,M.line));return}if(l&&!l.element.contains(E.target))g()},k=(E)=>{if(E.key==="Escape"&&l)g(),E.stopPropagation()},A=(E)=>{if(!l)return;let M=E.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(g,200)};return r.scrollDOM.addEventListener("mouseover",y),r.scrollDOM.addEventListener("mouseleave",A),r.scrollDOM.addEventListener("mousedown",w),document.addEventListener("mousedown",w),document.addEventListener("keydown",k,!0),{update(E){if(E.docChanged&&l)g()},destroy(){g(),r.scrollDOM.removeEventListener("mouseover",y),r.scrollDOM.removeEventListener("mouseleave",A),r.scrollDOM.removeEventListener("mousedown",w),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",k,!0)}}})}var Mt=40,Rt=re.define();function An(t){return Ne.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Rt))continue;c=p.value.payload!==r.payload?{payload:p.value.payload,stale:!1}:{payload:r.payload,stale:r.stale}}if(l.docChanged&&!c.stale)c={payload:c.payload,stale:!0};return c}})}function In(t,r,l){let c=t.commits[r];if(!c||Ee(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${ge(c.time)}`}class Pt extends jt{constructor(t,r,l){super();this.line=t;this.text=r;this.title=l}eq(t){return t.line===this.line&&t.text===this.text&&t.title===this.title}toDOM(){let t=document.createElement("span");return t.className="cm-blame-label",t.dataset.blameLine=String(this.line),t.title=this.title,t.textContent=this.text,t}}function Nt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let g=Math.min(c.lines,r.state.doc.lines);if(g<1)return T.none;let h=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,x=Math.max(1,h-Mt),y=Math.min(g,v+Mt),w=[];for(let k of c.runs){let A=Math.max(k.from,x);if(A>k.to||A>y)continue;let E=In(c,k.sha,l);if(!E)continue;let M=c.commits[k.sha],H=r.state.doc.line(A);w.push({from:H.to,deco:T.widget({widget:new Pt(H.number,E,M.summary||M.sha),side:1})})}return T.set(w.map((k)=>k.deco.range(k.from)),!0)}function Fn(t,r){return ye.fromClass(class{constructor(l){this.view=l;this.decorations=Nt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Nt(l.state.field(t),l.view,r)}},{decorations:(l)=>l.decorations})}function zn(t){return ye.define((r)=>{let l=!0,c=()=>{if(!l)return;let g=t.snapshot();r.dispatch({effects:Rt.of({payload:g.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Lt({controller:t,inline:r=!0,compact:l=!1}){let c=An(t);return[c,zn(t),r?Fn(c,l):[],Tt(t)]}function Bt({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:g=null,repoPath:h=null,onRunCommand:v,wordWrap:x,zoomLevel:y,setZoomLevel:w,editorFontFamily:k,editorTheme:A,viewerKind:E,isPreview:M,reviewActive:H,onToggleReview:K,revealActive:W}){let z=E==="markdown",L=jc(),_=Hc(),O=cd(),G=gt({name:t.name,path:t.path,root:t.root??g??void 0,repo:t.repo??h??"."},{enabled:O.enabled,dirty:r.isDirty}),Z=u(()=>O.enabled?Lt({controller:G,inline:O.inline}):null,[O.enabled,O.inline,G]),[N,R]=n(null),P=u(()=>Ic(r.content),[r.content]),[Q,X]=n(!1);i(()=>{if(p>0)X(!0)},[p]);let[j,ne]=n(null),[me,ee]=n(null);mt(j,w);let te=Ys({tabKey:String(t.id),surface:z&&M?"rendered":"code",ready:r.loaded,element:z&&M?void 0:j}),ue=a((ie)=>{te.ref(ie),ee(ie)},[te.ref]);return Tc({path:t.path,scroller:me,preview:z&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Sc,{find:l}):null,Q?e(pt,{lineCount:r.content?r.content.split(`
2
- `).length:1,onGo:(ie)=>{X(!1);let le=dr(r.content,ie-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>X(!1)}):null,z&&M?e(dt,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:y,reviewActive:H,onExitReview:K,scrollRef:ue,onScroll:te.onScroll}):e(_c,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:x,documentKey:String(t.id),marks:l.open||W?l.matches:void 0,currentMark:l.currentIndex,onCommand:v,onScroller:ne,onCaret:R,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:Z,themeVars:A.vars,themes:A.themes,indentUnitText:Gc(L),typing:_,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${y}px`,lineHeight:$s}}),!z||!M?e(ct,{caret:N,eol:r.eol,onSetEol:r.setEol,indentWidth:L.width,insertSpaces:L.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:E,lineCount:r.content?r.content.split(`
3
- `).length:0,conflicts:P}):null]})}function Dt({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:h,viewerKind:v,isPreview:x,isReviewing:y,onToggleReview:w,isMaximized:k,setIsMaximized:A,zoomLevel:E,setZoomLevel:M,goToLineRequest:H,onSaveAs:K,rootPath:W=null,repoPath:z=null,runCommand:L,editorFontFamily:_,editorTheme:O,togglePreview:G,revealActive:Z,missing:N}){let R=v==="image"||v==="pdf"||v==="docx"||v==="spreadsheet",P=rs[v]===!0,Q=a(async(X)=>{let j=await Rc(t,X,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(j.status==="written")return{ok:!0};if(j.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(j.status==="needs-permission")return{ok:!1,error:"Click Save again to grant write access."};return{ok:!1,error:j.error}},[t,r.baseMtimeMs]);return e(d,{children:[e(lt,{path:t.path,saveStatus:r.saveStatus,wordWrap:g,hasPreview:P,isPreview:x,hasReview:v==="markdown"&&x,isReviewing:y,copied:r.copied,byteViewer:R,saveDisabled:Boolean(r.loadError)||r.handleMissing||r.deviceBacked,unsupported:Boolean(r.unsupported),handleMissing:r.handleMissing,readOnly:r.deviceBacked,isMaximized:k,findOpen:l.open,onToggleFind:()=>l.open?l.close():l.openFind(),onSave:r.saveNow,onTogglePreview:G,onToggleReview:w,onToggleWordWrap:()=>h(!g),onZoomIn:()=>M((X)=>Math.min(Us,X+1)),onZoomOut:()=>M((X)=>Math.max(zs,X-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:K,canReload:il(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>A(!k)}),N&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error",children:[e(D,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was deleted from disk."}),e("div",{className:"text-[11px] font-sans text-error/80",children:"The buffer is still here. Saving recreates the file — autosave is off until then."})]})]}),r.conflict&&e(Ce,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(D,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(D,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(Fi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(al,{kind:"image",path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision}):r.isLoading?e("div",{className:"flex-1 flex items-center justify-center gap-2 text-ink/40 text-xs font-mono",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content…"})]}):r.unsupported?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Cc,{size:20,className:"text-ink/40"}),e("span",{className:"text-xs text-ink/70 font-sans",children:[t.name," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:r.unsupported})]}):r.loadError?e("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 px-6 text-center",children:[e(D,{size:20,className:"text-error"}),e("span",{className:"text-xs text-error font-sans",children:["Could not read ",t.name]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:r.loadError})]}):p&&!r.isImage?e(tA,{view:p}):Qc(v)&&(R||x)?e(al,{kind:v,path:t.path,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:Q,onDirtyChange:r.setBinaryDirty}):e(Bt,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:H,rootPath:W,repoPath:z,onRunCommand:L,wordWrap:g,zoomLevel:E,setZoomLevel:M,editorFontFamily:_,editorTheme:O,isPreview:x,reviewActive:y,onToggleReview:w,viewerKind:v,revealActive:Z})]})}function Ot({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:h,viewerKind:v,isPreview:x,isReviewing:y,onToggleReview:w,isMaximized:k,setIsMaximized:A,zoomLevel:E,setZoomLevel:M,goToLineRequest:H,onSaveAs:K,rootPath:W=null,repoPath:z=null,runCommand:L,editorFontFamily:_,editorTheme:O,togglePreview:G,revealActive:Z,missing:N,onConvertDiffToEditor:R,onFileSaved:P}){if(!t)return e("div",{className:"flex-1 flex items-center justify-center text-ink/40",children:e("p",{className:"font-mono text-sm",children:"Select a tab to view content"})});if(t.isDiff)return e(Ec,{filePath:t.path,status:t.diffStatus||"M",isStaged:Boolean(t.diffStaged),root:t.root,repo:t.repo||".",journalDiff:t.journalDiff,readOnly:t.diffSource==="journal",onOpenInEditor:()=>R(t.id),onFileSaved:P,className:"flex-1",tabKey:String(t.id)});return e(Dt,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:g,setWordWrap:h,viewerKind:v,isPreview:x,isReviewing:y,onToggleReview:w,isMaximized:k,setIsMaximized:A,zoomLevel:E,setZoomLevel:M,goToLineRequest:H,onSaveAs:K,rootPath:W,repoPath:z,runCommand:L,editorFontFamily:_,editorTheme:O,togglePreview:G,revealActive:Z,missing:N})}function At({pluginId:t,Component:r,sessionId:l,className:c=""}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:e(Ke,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})})}function It({className:t=""}){return e("div",{className:`flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[e(at,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Ft({searchReveal:t,revealMatch:r}){let l=o(r);l.current=r;let c=o(null);i(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function zt({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:g}){i(()=>{let h=new Set(t.filter((v)=>!v.isDiff&&v.content===void 0).map((v)=>v.id));Ve([...r].filter((v)=>h.has(v)))},[r,t]),i(()=>{if(!c)return;let h=l?.id;if(!l||h===void 0||h===null)return;if(!rs[as(l.name)])return;let v=ze(g,"editor.previewMode");if(v&&v[h]!==void 0)return;p((x)=>x[h]===void 0?{...x,[h]:!0}:x)},[c,l])}function Ht({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ce,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(Oc,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function $t(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 c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),g=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:g??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:g??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Vt(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Wt(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Hn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Ut({fileName:t,filePath:r,content:l,eol:c,root:p,repo:g,onSaved:h,onClose:v}){let[x,y]=n(()=>Hn(r)),[w,k]=n(()=>Vt(t)),[A,E]=n(!1),[M,H]=n(null),K=o(null);i(()=>{K.current?.focus(),K.current?.select()},[]);let W=Wt(w),z=async()=>{if(!W||A)return;E(!0),H(null);let _=await $t({parent:x,name:w,content:l,eol:c,root:p,repo:g});if(E(!1),_.status==="written"){h({path:_.path});return}H(_.reason)},L=(_)=>{if(_.key==="Enter"){_.preventDefault(),z();return}if(_.key==="Escape")_.preventDefault(),v()};return e(J,{onClose:v,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:v,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 z(),disabled:!W||A,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:[A?e(m,{size:12,className:"animate-spin"}):e(tt,{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:x,onInput:(_)=>y(_.target.value),onKeyDown:L,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:K,value:w,onInput:(_)=>k(_.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!W,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${W?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!W?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function _t(){i(()=>{let t=(r)=>{if(!_e())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function Gt({fileName:t,onAnswer:r}){return e(J,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(D,{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 qt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(Gt,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e($c,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function Zt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:g,activeFile:h,editor:v,externalChange:x,conflict:y,onReload:w,onKeepMine:k,body:A,saveAsOpen:E,onSaveAsClose:M,onSavedAs:H,closeGuard:K}){let W=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:W,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:g,e(Ht,{activeFile:h,externalChange:x,conflict:y,onReload:w,onKeepMine:k}),A,E&&h?e(Ut,{fileName:h.name,filePath:h.path,content:v.content,eol:v.eol,root:h.root,repo:h.repo,onSaved:({path:z})=>H(z),onClose:M}):null,e(qt,{closeGuard:K,activeFile:h,saveMissingConfirm:v.saveMissingConfirm,onCancelSaveMissing:v.cancelSaveMissing,onConfirmSaveMissing:v.confirmSaveMissing})]})}function Xt({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(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Yt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:g}){let h=o(null),v=(x)=>{let y=x.currentTarget,w=h.current;if(!y||!w)return;y.setPointerCapture(x.pointerId);let k=(E)=>{let M=w.getBoundingClientRect();if(M.width===0)return;r(pe((E.clientX-M.left)/M.width))},A=()=>{y.releasePointerCapture(x.pointerId),y.removeEventListener("pointermove",k),y.removeEventListener("pointerup",A)};y.addEventListener("pointermove",k),y.addEventListener("pointerup",A)};return e("div",{ref:h,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(pe(t)*100)}%`},children:g}),e("div",{className:"w-[3px] flex-shrink-0 cursor-col-resize bg-ink/10 hover:bg-ink/40 transition-colors",role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:v}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Xt,{fileName:l,onClose:c,children:p})})]})}function Jt({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=S("editor.split",be),g=t.map((k)=>k.id),h=je(Je(c,g),r),v=l&&h.rightFileId!==null?t.find((k)=>k.id===h.rightFileId)??null:null,x=a((k)=>{if(k!==null&&!Se(k,r,g))return;p({...h,rightFileId:k})},[h,p,r,g]),y=a(()=>p({...h,rightFileId:null}),[h,p]),w=a((k)=>p({...h,fraction:pe(k)}),[h,p]);return{rightFile:v,fraction:h.fraction,splitTo:x,close:y,setFraction:w}}function Qt({find:t,runCommand:r,reopenClosed:l}){let c=o(t);c.current=t;let p=o(r);p.current=r;let g=o(l);return g.current=l,{onKeyDownCapture:a((v)=>{let x=c.current;if(v.key==="Escape"){if(!x.open)return;v.preventDefault(),v.stopPropagation(),x.close();return}if((v.metaKey||v.ctrlKey)&&v.shiftKey&&v.code==="KeyT"){if(g.current?.())v.preventDefault(),v.stopPropagation();return}let y=Eg(lo,v);if(!y||!Um(y))return;v.preventDefault(),v.stopPropagation(),p.current(y)},[])}}function tn(t){let r=o(t);r.current=t;let l=o(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return i(()=>{let p=l.current;if(!p)return;return Vf(p)},[]),{onFocusCapture:a(()=>{if(l.current)Vf(l.current)},[])}}function nn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[g,h]=n(null);_t();let v=a((y)=>{let w=t.find((k)=>k.id===y);if(w&&Ue(y)){h(w);return}c(y)},[t,c]),x=a((y)=>{let w=g;if(!w)return;if(y==="cancel"){h(null);return}if(y==="save"){if(w.id!==r)l(w.id);p()}h(null),c(w.id)},[g,r,l,p,c]);return{requestClose:v,pending:g,answer:x}}function on(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((g)=>g+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function $n({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:h=0,onFileSaved:v,onOpenPath:x,onReopenClosed:y,reopenableCount:w,onCopyPath:k,onRevealInFiles:A,rootPath:E=null,repoPath:M=null,activeEditorPanelKey:H=null,forcedActiveFileId:K=null,asSplitPane:W=!1}){let z=W?K:l,L=r.find((U)=>U.id===z),[_,O,G]=S("editor.previewMode",{}),Z=zc(String(z??"")),[N,R]=S("editor.zoomLevel",xi),[P,Q]=n(!1),[X,j]=S("editor.wordWrap",!0),ne=on(),{sessionId:me}=Ze(),ee=Jt({openedFiles:r,activeFileId:z,enabled:!W}),te=o(null),ue=Ci(),ie=uo(),le=Nc(r,h),fe=Boolean(L&&le.has(L.id)),Y=Fc(L??null,{reportSaveError:!0,onFileSaved:v,missing:fe}),rn=eA({path:L?.path??"",content:Y.content,language:Y.language}),an=Y.diskChange,De=nn({openedFiles:r,activeFileId:z,onSelectFile:c,onCloseFile:p,saveNow:Y.saveNow}),ve=Lc({text:Y.content,documentKey:`${L?.id??""}\x00${Y.language}`,readSelection:()=>te.current?.getSelection()??null,select:(U,de,Pe=!0)=>te.current?.select(U,de,Pe),reveal:(U)=>te.current?.revealOffset(U),applyDocument:(U,de,Pe)=>te.current?.applyDocument(U,de,Pe),toggleWordWrap:()=>j((U)=>!U)}),Oe=Mc(L?.path??null,Y.content,Y.loaded&&!Y.loadError);Ft({searchReveal:Oe,revealMatch:ve.revealMatch}),Pc({file:L,editor:Y,surfaceRef:te,isPreview:L?_[L.id]===!0:!1,exitPreview:()=>{let U=L?.id;if(U===void 0||U===null)return;O((de)=>({...de,[U]:!1}))}}),i(()=>{if(h>0)Y.reset()},[h]),i(()=>{Y.retain(r.map((U)=>U.id)),We(r.map((U)=>U.id))},[r]),zt({openedFiles:r,dirtyKeys:Y.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:O,sessionId:me});let sn=()=>{if(!L)return;O((U)=>({...U,[L.id]:!U[L.id]}))},Me=(U)=>{if(Um(U)){ve.runCommand(U);return}if(U==="toggleWordWrap"){j((de)=>!de);return}if(U==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(U)},ln=Qt({find:ve,runCommand:Me,reopenClosed:y}),dn=tn({saveNow:Y.saveNow,runCommand:Me}),Re=Pg(H);if(Re)return e(At,{pluginId:Re.pluginId,Component:Re.Component,sessionId:me,className:t});if(r.length===0)return e(It,{className:t});let cn=Y.viewerKind,Ae=L?_[L.id]:!1,mn={activeFile:L,editor:Y,find:ve,surfaceRef:te,pluginFileView:rn,wordWrap:X,setWordWrap:j,viewerKind:cn,isPreview:Boolean(Ae),isReviewing:Boolean(Ae)&&Z.active,onToggleReview:Z.toggle,isMaximized:P,setIsMaximized:Q,zoomLevel:N,setZoomLevel:R,goToLineRequest:ne.goToLineRequest,onSaveAs:()=>ne.setSaveAsOpen(!0),onOpenPath:x,rootPath:E,repoPath:M,runCommand:Me,editorFontFamily:ue,editorTheme:ie,togglePreview:sn,revealActive:Boolean(Oe),missing:fe,onConvertDiffToEditor:g,onFileSaved:v},un=(U)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:g,refreshKey:h,onFileSaved:v,onOpenPath:x,rootPath:E,repoPath:M,forcedActiveFileId:U,asSplitPane:!0}),pn=e(nt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:De.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:A,onReopenClosed:y,reopenableCount:w,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Ie=e(Zt,{className:t,isMaximized:P,onKeyDownCapture:ln.onKeyDownCapture,onFocusCapture:dn.onFocusCapture,asSplitPane:W,tabs:pn,activeFile:L,editor:Y,externalChange:an,conflict:Y.conflict,onReload:Y.resolveConflictByReload,onKeepMine:Y.keepMineAgainstDisk,body:e(Ot,{...mn}),saveAsOpen:ne.saveAsOpen,onSaveAsClose:()=>ne.setSaveAsOpen(!1),onSavedAs:(U)=>{ne.setSaveAsOpen(!1),x?.(U)},closeGuard:De});if(!ee.rightFile)return Ie;return e(Yt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Ie})}export{$n as Editor};
@@ -1 +0,0 @@
1
- import{d,u,le,e,IA,we,I,B,ie,vr,C,Fs,Fu,Lp,lg,Mp,Pp}from"./index-d8kjsgpt.js";function k({phase:t,index:o,collapsed:a,currentKey:i,onToggle:x}){let m=Mp(t),r=t.tasks.length>0&&m===t.tasks.length;return e("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[e("button",{type:"button",onClick:x,"aria-expanded":!a,className:"flex w-full items-center gap-1.5 border-b border-ink/8 bg-canvas/40 px-2.5 py-1.5 text-left hover:bg-ink/5",children:[a?e(ie,{size:12,className:"shrink-0 text-ink/40"}):e(B,{size:12,className:"shrink-0 text-ink/40"}),e("span",{className:`min-w-0 flex-1 truncate text-[10px] font-semibold uppercase tracking-wider ${r?"text-ink/35":"text-ink/60"}`,title:t.name,children:[o+1,". ",t.name]}),e("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:[m,"/",t.tasks.length]})]}),!a&&e("div",{className:"divide-y divide-ink/[0.05] p-0.5",children:t.tasks.length===0?e("div",{className:"px-2.5 py-1.5 text-[11px] text-ink/40",children:"No tasks in this phase"}):t.tasks.map((l,f)=>e(Pp,{task:l,current:i===`${o}:${f}`},`${f}-${l.content}`))})]})}function j({className:t="",active:o=!0}){let[a]=le(),i=a.get("sessionId"),[x,m]=Fs("todo.collapsedPhases",{}),{data:r,isLoading:l,refreshing:f,stale:g,refresh:b}=we(i?IA(i):null,{enabled:o}),s=r?.snapshot??null,p=r?.progress??null,v=u(()=>{let n=lg(s?.phases??[]);return n?`${n.phase}:${n.task}`:null},[s]);if(!i)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex h-full w-full min-w-0 flex-col overflow-hidden bg-paper text-ink ${t}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-3 border-b border-ink/10 px-3.5 py-2.5",children:[e("div",{className:"flex min-w-0 items-center gap-2",children:[e("h2",{className:"text-xs font-semibold uppercase tracking-wider text-ink",children:"Todos"}),s&&e("span",{className:"truncate font-mono text-[10.5px] text-ink/50",title:Fu(p),children:Fu(p)}),r?.isMock&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",children:"Mock"})]}),e("button",{type:"button",onClick:b,disabled:l,title:"Refresh todos","aria-label":"Refresh todos",className:"flex-shrink-0 rounded-md border border-ink/15 bg-paper p-1.5 text-ink/80 transition-colors hover:bg-ink/5 disabled:opacity-50",children:e(C,{size:12,className:l||f?"animate-spin text-ink":""})})]}),p&&p.total>0&&e("div",{className:"flex-shrink-0 border-b border-ink/10 px-3.5 py-2.5",children:e("div",{className:"h-1.5 overflow-hidden rounded-full bg-ink/8",children:e("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${Lp(p)}%`}})})}),e("div",{className:"min-h-0 flex-1 space-y-2 overflow-y-auto scrollbar-overlay-container p-3.5",children:[g&&e("div",{className:"flex items-start gap-2 rounded-lg border border-ink/15 bg-ink/5 px-3 py-2 text-[11px] text-ink/60",children:[e(I,{size:13,className:"mt-[1px] shrink-0"}),e("span",{className:"min-w-0 break-words",children:"Reconnecting: this list may be out of date."})]}),!s?e("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-ink/40",children:[e(vr,{size:20}),e("p",{className:"max-w-[240px] text-[11.5px] leading-relaxed",children:["No todo list in this session. The agent writes one with the ",e("span",{className:"font-mono",children:"todo"})," tool when a task is worth planning."]})]}):e(d,{children:[s.phases.map((n,c)=>e(k,{phase:n,index:c,collapsed:Boolean(x[String(c)]),currentKey:v,onToggle:()=>m((h)=>({...h,[String(c)]:!h[String(c)]}))},`${c}-${n.name}`)),e("p",{className:"pt-1 text-[10.5px] leading-relaxed text-ink/35",children:["Read from this session's transcript",s.updatedAt?` · updated ${N(s.updatedAt)}`:"",s.source==="custom"?" · edited by hand":"","."]})]})]})]})}function N(t){let o=new Date(t);if(Number.isNaN(o.getTime()))return t;return o.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}export{j as TodoPanel};
@@ -1,7 +0,0 @@
1
- import{d,n,i,V,o,u,a,Ar,e,gr,ui,Gn,gp,we,S,bp,Rf,ir,or,s,Pa,Be,Oa,m,In,M,D,Xe,f,B,ie,et,ae,he,fe,Tn,Jt,Dn,Y,C,ut,va,F,gi,tn,b,ce,Tu,ro,J,at,it,pt,Ve,ge}from"./index-d8kjsgpt.js";import{pp,fr}from"./index-z72wf7q4.js";var Tt={name:"folder-tree",size:24,node:[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]},_e=s(Tt);var At={name:"list",size:24,node:[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]},je=s(At);function Ue({message:t,hasStagedChanges:c,isBusy:l=!1,amend:r=!1,seeded:p=!1,onToggleAmend:h,onChangeMessage:g,onCommit:v}){let y=t.trim().length>0&&!l&&(r||c),L=r?"Rewrite the previous commit with this message":c?"Commit staged changes":"Stage changes first";return e("div",{className:"border-t border-ink/10 bg-canvas/50 p-3 flex flex-col gap-2",children:[e("textarea",{value:t,onChange:(N)=>g(N.currentTarget.value),onKeyDown:(N)=>{if(N.key==="Enter"&&(N.metaKey||N.ctrlKey)&&y)N.preventDefault(),v()},placeholder:r?"New message for the previous commit (⌘/Ctrl+Enter to commit)":"Commit message (⌘/Ctrl+Enter to commit)",rows:5,className:"w-full resize-y min-h-[100px] max-h-[200px] bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("div",{className:"flex items-center gap-2",children:[e("label",{className:"flex items-center gap-1.5 text-[11px] text-ink/70 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:r,onChange:(N)=>h?.(N.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"Amend"]}),r&&p&&e("span",{className:"text-[10px] text-ink/40",title:"The previous commit's message, loaded as an editable starting point",children:"previous message loaded"}),e("button",{type:"button",onClick:v,disabled:!y,title:L,className:"ml-auto flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(f,{size:12}),r?"Amend commit":"Commit"]})]})]})}function We({operation:t,conflicts:c,isBusy:l,onAbort:r,onContinue:p}){let h=ui[t],g=c.length,v=g===0,y=t!=="stash-pop";return e("div",{className:"border-t border-warning/30 bg-warning/5 p-3 flex flex-col gap-2",children:[e("div",{className:"flex items-center gap-2 text-xs text-ink",children:[e(D,{size:13,className:"text-warning flex-shrink-0"}),e("span",{className:"font-medium",children:[h.charAt(0).toUpperCase()+h.slice(1)," in progress"]}),e("span",{className:`font-mono tabular-nums text-[10px] ${v?"text-success":"text-warning"}`,children:v?"all conflicts resolved":`${g} conflict${g===1?"":"s"} left`})]}),!v&&e("div",{className:"max-h-20 overflow-y-auto scrollbar-overlay-container font-mono text-[10px] text-warning/90 space-y-0.5",children:c.map((L)=>e("div",{className:"truncate",title:L,children:L},L))}),e("div",{className:"flex items-stretch gap-2",children:[e("button",{type:"button",onClick:r,disabled:l,title:`Abort the ${h} and restore the previous state`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-error/40 text-error hover:bg-error/10 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(tn,{size:12}),"Abort ",h]}),y&&e("button",{type:"button",onClick:p,disabled:l||!v,title:v?`Conclude the ${h}`:`Resolve all ${g} conflict(s) first`,className:"flex-1 flex items-center justify-center gap-1.5 px-3 py-1.5 rounded border border-transparent bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Tn,{size:12}),"Continue ",h]})]})]})}function qe({branchRef:t,showBranchMenu:c,setShowBranchMenu:l,branch:r,branches:p,remoteBranches:h,onCheckout:g,onMerge:v,onOpenBranchPrompt:y,onManageBranches:L,optionsRef:N,showOptions:G,setShowOptions:R,onHistory:P,onGraph:T,viewMode:k,setViewMode:x,isBusy:w=!1,syncCount:E={ahead:0,behind:0},syncing:z=!1,onSync:I,onFetch:A,detached:H=!1}){return e("div",{className:"p-3 border-b border-ink/10 bg-canvas/50 flex items-center justify-between",children:[e("div",{className:"relative",ref:t,children:[e("button",{onClick:()=>l(!c),className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 -ml-2 rounded transition-colors text-[11px] text-ink/80 font-medium",title:H?`Detached HEAD at ${r}`:`On branch ${r}`,children:[e(fe,{size:12,className:H?"text-warning":"text-ink/60"}),e("span",{className:`truncate max-w-[140px] ${H?"font-mono text-warning":""}`,children:r}),e(B,{size:12,className:"text-ink/40"})]}),c&&e("div",{className:"glass-popover absolute top-full left-0 mt-1 w-56 bg-paper border border-ink/20 rounded-md shadow-lg z-50 flex flex-col overflow-hidden text-xs",children:e("div",{className:"max-h-48 scrollbar-overlay-container py-1",children:[p.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Local"}),p.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Tn,{size:12})})]},O))]}),h.length>0&&e(d,{children:[e("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold",children:"Remote"}),h.map((O)=>e("div",{className:"flex items-center group/branch",children:[e("button",{onClick:()=>{g(O),l(!1)},className:"flex-1 min-w-0 text-left px-3 py-2 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("span",{className:"truncate",children:O}),r===O&&e(f,{size:12,className:"text-ink flex-shrink-0"})]}),r!==O&&e("button",{type:"button",onClick:()=>{v(O),l(!1)},title:`Merge ${O} into ${r}`,"aria-label":`Merge ${O} into ${r}`,className:"touch-visible opacity-0 group-hover/branch:opacity-100 px-2 py-2 text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors cursor-pointer flex-shrink-0",children:e(Tn,{size:12})})]},O))]}),e("div",{className:"w-full h-px bg-ink/10 my-1"}),e("button",{onClick:()=>{y(),l(!1)},className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80 italic",children:[e(Y,{size:12}),e("span",{children:"Create new branch..."})]}),e("button",{onClick:L,className:"w-full text-left px-3 py-2 hover:bg-ink/5 flex items-center space-x-2 transition-colors text-ink/80",children:[e(gi,{size:12}),e("span",{children:"Manage branches..."})]})]})})]}),e("div",{className:"flex items-center space-x-2 text-ink/40 relative",ref:N,children:[e("button",{type:"button",onClick:A,disabled:w,title:"Fetch from all remotes and prune deleted branches","aria-label":"Fetch",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:e(Pa,{size:13})}),e("button",{type:"button",onClick:I,disabled:w,title:z?"Syncing with upstream…":E.ahead>0&&E.behind>0?`Pull ${E.behind} then push ${E.ahead} commit(s)`:E.ahead>0?`Push ${E.ahead} commit(s)`:E.behind>0?`Pull ${E.behind} commit(s)`:"Up to date — sync anyway","aria-label":"Sync with upstream","aria-busy":z,className:`flex items-center gap-1 p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors disabled:cursor-not-allowed ${z?"":"disabled:opacity-40"}`,children:[e(C,{size:13,className:z?"animate-spin":"","aria-hidden":"true"}),e("span",{className:"font-mono tabular-nums text-[10px]",children:["↑",E.ahead," ↓",E.behind]})]}),e("button",{type:"button",onClick:P,title:"Commit History","aria-label":"Commit History",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(In,{size:13})}),e("button",{type:"button",onClick:T,title:"Git Graph","aria-label":"Git Graph",className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Tn,{size:13})}),e("button",{type:"button",onClick:()=>R(!G),title:"View Options","aria-label":"View Options","aria-expanded":G,className:"p-1 rounded hover:text-ink hover:bg-ink/5 cursor-pointer transition-colors",children:e(Be,{size:13})}),G&&e("div",{className:"glass-popover absolute right-0 top-full mt-1 w-36 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 font-mono text-xs",children:[e("button",{type:"button",onClick:()=>{x("flat"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(je,{size:12,className:"text-ink/60"}),e("span",{children:"View as List"})]}),k==="flat"&&e(f,{size:12,className:"text-ink"})]}),e("button",{type:"button",onClick:()=>{x("tree"),R(!1)},className:"w-full px-3 py-1.5 text-left text-ink hover:bg-ink/5 flex items-center justify-between transition-colors",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(_e,{size:12,className:"text-ink/60"}),e("span",{children:"View as Tree"})]}),k==="tree"&&e(f,{size:12,className:"text-ink"})]})]})]})]})}function Ke({activeRepo:t,repos:c,isRefreshing:l,rootPath:r,reposScanning:p,onSelectRepo:h,onRefresh:g,onRefreshRepos:v}){return e("div",{className:"p-3 border-b border-ink/10 flex items-center justify-between",children:[e("div",{className:"flex items-center gap-1.5 min-w-0",children:[e(pp,{size:12,className:"text-ink/50 flex-shrink-0","aria-hidden":!0}),e(fr,{rootPath:r,activeRepo:t,onSelectRepo:h,repos:c,scanning:p,onRefreshRepos:v})]}),e("div",{className:"flex space-x-2 text-ink/40",children:e("button",{type:"button",onClick:g,title:"Refresh","aria-label":"Refresh",className:"hover:text-ink cursor-pointer inline-flex",children:e(ut,{size:14,className:l?"animate-spin":""})})})]})}function Te({change:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let h=Gn(t.status,c),{charStatus:g,colorClass:v}=h,y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"";return e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-ink/5 cursor-pointer group text-[11px] transition-colors",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:c,status:g,repo:l||".",root:r}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e("span",{className:`font-bold font-mono text-[10px] w-3 flex-shrink-0 text-center ${v}`,title:`Status: ${h.label}`,children:g}),e(at,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${v}`,title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:[!c&&e(d,{children:[e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("revert",t.file)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("stage",t.file)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}),c&&e("button",{type:"button",onClick:(R)=>{R.stopPropagation(),p("unstage",t.file)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})]})})]})}function Ye({change:t,repo:c,rootPath:l,onResolve:r}){let[p,h]=n(!1),[g,v]=n(null),y=t.file.split("/"),L=y.pop()||t.file,N=y.length>0?y.join("/"):"",G=()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:t.file,staged:!1,status:t.status,repo:c,root:l}}))},R=async()=>{let k=!p;if(h(k),k&&g===null){let x=new URLSearchParams({conflictMarkers:"1",file:t.file,repo:c||"."});if(l)x.set("root",l);try{let E=await(await fetch(`/api/fs/git?${x.toString()}`)).json();v(E.markers??{})}catch{v({})}}},P=g?.ours||"ours",T=g?.theirs||"theirs";return e("div",{className:"border-b border-warning/20 last:border-b-0",children:[e("div",{className:"flex items-center justify-between px-3 py-1 hover:bg-warning/5 cursor-pointer group text-[11px] transition-colors",onClick:G,children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-2",children:[e(Oa,{size:11,className:"text-warning flex-shrink-0"}),e(at,{name:L,size:12,className:"flex-shrink-0"}),e("span",{className:"truncate text-warning",title:t.file,children:L}),N&&e("span",{className:"text-[10px] text-ink/40 truncate ml-1",children:N}),gr(t.status)&&e("span",{className:"text-[10px] text-warning/70 font-mono flex-shrink-0",children:t.status})]}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),R()},title:p?"Hide resolve actions":"Show resolve actions","aria-label":p?"Hide resolve actions":"Show resolve actions","aria-expanded":p,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors flex-shrink-0",children:p?e(et,{size:11}):e(B,{size:11})})]}),p&&e("div",{className:"px-3 pb-2 pt-0.5 flex flex-wrap items-center gap-1.5",children:[e("button",{type:"button",onClick:()=>r(t.file,"ours"),title:`Take ${P} — \`git checkout --ours\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",P]}),e("button",{type:"button",onClick:()=>r(t.file,"theirs"),title:`Take ${T} — \`git checkout --theirs\` then stage`,className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer max-w-[45%] truncate",children:["take ",T]}),e("button",{type:"button",onClick:()=>r(t.file,""),title:"Mark resolved: the file was edited by hand, this stages it",className:"px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer flex items-center gap-1",children:[e(f,{size:10}),"mark resolved"]})]})]})}function Bt(t){let c={id:"",name:"",path:"",type:"folder",children:[],changeCount:0};for(let r of t){let p=r.file.replace(/^[./]+/,""),h=p.endsWith("/"),g=p.replace(/\/$/,"").split("/").filter(Boolean),v=c,y="";for(let L=0;L<g.length;L++){let N=g[L];y=y?`${y}/${N}`:N;let G=L===g.length-1;if(G&&!h)v.children.push({id:y,name:N,path:y,type:"file",change:r,children:[],changeCount:1});else{let P=v.children.find((T)=>T.type==="folder"&&T.name===N);if(!P)P={id:y,name:N,path:y,type:"folder",children:[],changeCount:0,change:G&&h?r:void 0},v.children.push(P);v=P}}}function l(r){if(r.type==="file")return 1;let p=r.change?1:0;for(let h of r.children)p+=l(h);return r.changeCount=p,r.children.sort((h,g)=>{if(h.type==="folder"&&g.type==="file")return-1;if(h.type==="file"&&g.type==="folder")return 1;return h.name.localeCompare(g.name)}),p}return l(c),c.children}function Ze(t){let{sessionId:c,ready:l,read:r}=bp(),p=u(()=>Bt(t),[t]),h=u(()=>{let R=new Set;function P(T){for(let k of T)if(k.type==="folder"){if(R.add(k.id),k.children&&k.children.length>0)P(k.children)}}return P(p),R},[p]),[g,v]=S("git.expandedFolders",[]),y=u(()=>new Set(g),[g]),L=o(null);i(()=>{if(!l||L.current===c)return;if(h.size===0)return;if(L.current=c,r("git.expandedFolders",[]).length>0)return;v(Array.from(h))},[l,c,h,r,v]);let N=a((R)=>{v((P)=>{let T=new Set(P);if(T.has(R))T.delete(R);else T.add(R);return Array.from(T)})},[v]),G=a((R)=>y.has(R),[y]);return{tree:p,expandedFolders:y,toggleFolder:N,isFolderOpen:G,expandAll:()=>v(Array.from(h)),collapseAll:()=>v([])}}function Ae({node:t,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g}){let v=t.type==="folder",y=v?l(t.id):!1;if(v)return e("div",{className:"select-none",children:[e("div",{className:"flex items-center justify-between px-2 py-1 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>r(t.id),children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center text-ink/40 flex-shrink-0",children:y?e(B,{size:12}):e(ie,{size:12})}),e(at,{name:t.name,isFolder:!0,isOpen:y,size:13,className:"flex-shrink-0"}),e("span",{className:"font-medium text-ink truncate",children:t.name}),e("span",{className:"text-[10px] text-ink/40 font-normal px-1 py-0.2 bg-ink/5 rounded-full ml-1",children:t.changeCount})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",t.path)},title:`Discard changes in ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",t.path)},title:`Stage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",t.path)},title:`Unstage ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]}),y&&t.children&&t.children.length>0&&e("div",{className:"ml-3 border-l border-ink/10 pl-1",children:t.children.map((k)=>e(Ae,{node:k,isStaged:c,isFolderOpen:l,toggleFolder:r,onAction:p,repo:h,rootPath:g},k.id))})]});let L=t.change,N=Gn(L?.status||"M",c),{charStatus:G,colorClass:R}=N,P=L?L.file:t.path;return e("div",{className:"flex items-center justify-between px-2 py-0.5 hover:bg-ink/5 cursor-pointer rounded group transition-colors text-[11px]",onClick:()=>{window.dispatchEvent(new CustomEvent("omp:open-diff",{detail:{file:P,staged:c,status:G,repo:h||".",root:g}}))},children:[e("div",{className:"flex items-center space-x-1.5 flex-1 min-w-0 pr-1",children:[e("span",{className:"w-3.5 h-3.5 flex items-center justify-center flex-shrink-0",children:e("span",{className:`font-bold font-mono text-[10px] ${R}`,title:`Status: ${N.label}`,children:G})}),e(at,{name:t.name,size:12,className:"flex-shrink-0"}),e("span",{className:`truncate ${R}`,title:P,children:t.name})]}),e("div",{className:"flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("div",{className:"flex items-center touch-visible opacity-0 group-hover:opacity-100 space-x-1",children:!c?e(d,{children:[e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("revert",P)},title:"Discard Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:11})}),e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("stage",P)},title:"Stage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:11})})]}):e("button",{type:"button",onClick:(k)=>{k.stopPropagation(),p("unstage",P)},title:"Unstage Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:11})})})})]})}function Fe({changes:t,isStaged:c,repo:l,rootPath:r,onAction:p}){let{tree:h,isFolderOpen:g,toggleFolder:v}=Ze(t);if(h.length===0)return null;return e("div",{className:"py-0.5",children:h.map((y)=>e(Ae,{node:y,isStaged:c,isFolderOpen:g,toggleFolder:v,onAction:p,repo:l,rootPath:r},y.id))})}function Qe({changes:t,isLoading:c,viewMode:l,repo:r,rootPath:p,onAction:h,onResolve:g}){let[v,y]=S("git.stagedExpanded",!0),[L,N]=S("git.unstagedExpanded",!0),[G,R]=S("git.conflictsExpanded",!0),P=t.filter((x)=>gr(x.status)),T=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[0]!==" "&&w[0]!=="?"}),k=t.filter((x)=>{if(gr(x.status))return!1;let w=x.status;return w&&w[1]!==" "&&w[1]!=="?"||w==="??"});if(c&&t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"Loading..."})});if(t.length===0)return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"p-4 text-center text-ink/40 italic",children:"No changes found."})});return e("div",{className:"flex-1 scrollbar-overlay-container font-mono text-[11px] text-ink/80",children:e("div",{className:"py-1",children:[P.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-warning/5 cursor-pointer transition-colors",onClick:()=>R(!G),children:e("div",{className:"flex items-center space-x-1 font-semibold text-warning text-xs",children:[e("span",{className:"w-3 text-center",children:G?"▾":"▸"}),e("span",{children:"Conflicts"}),e("span",{className:"text-warning/70 font-normal ml-1 border border-warning/30 rounded-full px-1.5 text-[10px] bg-paper",children:P.length})]})}),G&&P.map((x)=>e(Ye,{change:x,repo:r,rootPath:p,onResolve:g??(()=>{})},`conflict-${x.file}`))]}),T.length>0&&e("div",{className:"mb-2",children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>y(!v),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:v?"▾":"▸"}),e("span",{children:"Staged Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:T.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("unstage_all")},title:"Unstage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Jt,{size:12})})})]}),v&&(l==="tree"?e(Fe,{changes:T,isStaged:!0,repo:r,rootPath:p,onAction:h}):T.map((x)=>e(Te,{change:x,isStaged:!0,repo:r,rootPath:p,onAction:h},x.file+"staged")))]}),k.length>0&&e("div",{children:[e("div",{className:"flex items-center justify-between px-3 py-1 group hover:bg-ink/5 cursor-pointer transition-colors",onClick:()=>N(!L),children:[e("div",{className:"flex items-center space-x-1 font-semibold text-ink text-xs",children:[e("span",{className:"w-3 text-center",children:L?"▾":"▸"}),e("span",{children:"Changes"}),e("span",{className:"text-ink/40 font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] bg-paper",children:k.length})]}),e("div",{className:"touch-visible opacity-0 group-hover:opacity-100 flex items-center space-x-1 text-ink/40 flex-shrink-0",children:[e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("revert_all")},title:"Discard All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(tn,{size:12})}),e("button",{type:"button",onClick:(x)=>{x.stopPropagation(),h("stage_all")},title:"Stage All Changes",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Y,{size:12})})]})]}),L&&(l==="tree"?e(Fe,{changes:k,isStaged:!1,repo:r,rootPath:p,onAction:h}):k.map((x)=>e(Te,{change:x,isStaged:!1,repo:r,rootPath:p,onAction:h},x.file+"unstaged")))]})]})})}function Je({matches:t,loaded:c,total:l,hasMore:r,isFiltering:p}){if(p)return`${t} of ${c} loaded`;if(typeof l==="number"&&l>0)return r||c<l?`${c} of ${l}`:`${l} commits`;return r?`${c}+ commits`:`${c} commits`}function tt({isGraphMode:t,onToggleMode:c,searchQuery:l,onSearchChange:r,onRefresh:p,onClose:h,isRefreshing:g,totalCommits:v,loadedCount:y,totalCount:L,hasMore:N}){let G=Je({matches:v,loaded:y,total:L,hasMore:N,isFiltering:l.trim().length>0});return e("div",{className:`flex flex-col gap-2 px-3 lg:px-5 py-3 border-b border-ink/10 bg-paper select-none
2
- pl-[max(0.75rem,env(safe-area-inset-left,0px))] pr-[max(0.75rem,env(safe-area-inset-right,0px))]`,children:[e("div",{className:"flex items-center justify-between gap-2 lg:gap-4",children:[e("div",{className:"flex flex-col min-w-0",children:[e("div",{className:"flex items-center gap-2.5 min-w-0",children:[e("h2",{className:"text-base font-semibold text-ink tracking-tight",children:t?"Graph":"History"}),e("span",{className:"text-[11px] font-mono px-2 py-0.5 rounded-full bg-ink/5 text-ink/50 border border-ink/10 whitespace-nowrap",children:G})]}),e("p",{className:"text-xs text-ink/50 mt-0.5 hidden lg:block",children:"Browse recent commits and inspect changed files."})]}),e("div",{className:"flex items-center gap-1.5 lg:gap-2 flex-shrink-0",children:[e("div",{className:"flex items-center bg-ink/5 p-0.5 rounded-lg border border-ink/10 text-xs",children:[e("button",{type:"button",onClick:()=>c(!1),title:"History view",className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${!t?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:[e(In,{size:13}),e("span",{className:"hidden lg:inline",children:"History"})]}),e("button",{type:"button",onClick:()=>c(!0),title:"Graph view",className:`flex items-center gap-1.5 px-2.5 py-1 rounded-md font-medium transition-colors cursor-pointer ${t?"bg-paper text-ink shadow-xs":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:[e(Tn,{size:13}),e("span",{className:"hidden lg:inline",children:"Graph"})]})]}),e("button",{type:"button",onClick:p,disabled:g,className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md border border-ink/15 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40",title:"Refresh commit history",children:[e(va,{size:13,className:g?"animate-spin text-ink":""}),e("span",{className:"hidden lg:inline",children:"refresh"})]}),e("button",{type:"button",onClick:h,className:"p-2 -mr-1 rounded-md hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors cursor-pointer",title:"Close modal",children:e(b,{size:16})})]})]}),e("div",{className:"relative mt-1",children:[e(F,{size:13,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-ink/40"}),e("input",{type:"text",value:l,onChange:(R)=>r(R.currentTarget.value),placeholder:"Filter commits by message, author, or hash...",className:"w-full bg-ink/[0.03] border border-ink/15 rounded-md pl-8 pr-3 py-1.5 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),l&&e("button",{type:"button",onClick:()=>r(""),className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-ink/40 hover:text-ink cursor-pointer",children:e(b,{size:12})})]})]})}var le=["#38bdf8","#f97316","#a855f7","#10b981","#ec4899","#eab308","#06b6d4","#6366f1"];function Ee(t,c){if(!t||!c)return!1;if(t===c)return!0;let l=Math.min(t.length,c.length);if(l>=4)return t.substring(0,l)===c.substring(0,l);return!1}function Re(t){let c=new Map,l=[];for(let r of t){if(typeof r.lane==="number"){c.set(r.hash,r.lane);continue}let p=l.findIndex((g)=>Ee(g,r.hash)||Ee(g,r.shortHash));if(p===-1)if(p=l.indexOf(null),p===-1)p=l.length,l.push(r.hash);else l[p]=r.hash;c.set(r.hash,p);let h=r.parents&&r.parents[0];if(h)l[p]=h;else l[p]=null;if(r.parents&&r.parents.length>1)for(let g=1;g<r.parents.length;g++){let v=r.parents[g];if(!l.some((L)=>Ee(L,v))){let L=l.indexOf(null);if(L===-1)l.push(v);else l[L]=v}}}return c}function nt(t,c,l,r){let p=[],h=new Map;t.forEach((g,v)=>{if(h.set(g.hash,v),g.shortHash)h.set(g.shortHash,v);if(g.hash.length>=7)h.set(g.hash.substring(0,7),v)});for(let g of t){let v=c.get(g.hash)??0,y=l[g.hash]??0,L=le[v%le.length];if(!g.parents||g.parents.length===0)continue;for(let N of g.parents){let G=h.get(N);if(typeof G!=="number"&&N.length>=7)G=h.get(N.substring(0,7));if(typeof G==="number"){let R=t[G],P=c.get(R.hash)??v,T=l[R.hash]??y+60;p.push({fromHash:g.hash,toHash:R.hash,fromLane:v,toLane:P,fromY:y,toY:T,color:le[v%le.length]})}else p.push({fromHash:g.hash,toHash:"tail-"+g.hash,fromLane:v,toLane:v,fromY:y,toY:Math.max(y+80,r),color:L})}}return p}function ot(t,c,l,r){if(Math.abs(t-l)<1)return`M ${t} ${c} L ${l} ${r}`;let p=r-c,h=c+p*0.45,g=r-p*0.45;return`M ${t} ${c} C ${t} ${h}, ${l} ${g}, ${l} ${r}`}function st({commits:t,nodePositions:c,selectedHash:l,hoveredHash:r,isGraphMode:p,laneWidth:h=18,paddingLeft:g=16,totalHeight:v}){let y=u(()=>{if(!p){let R=new Map;return t.forEach((P)=>R.set(P.hash,0)),R}return Re(t)},[t,p]),L=u(()=>{let R=0;return y.forEach((P)=>{if(P>R)R=P}),R},[y]),N=p?(L+1)*h+g*2:36,G=u(()=>{if(!p){let R=[];for(let P=0;P<t.length-1;P++){let T=c[t[P].hash]??P*60+20,k=c[t[P+1].hash]??(P+1)*60+20;R.push({fromHash:t[P].hash,toHash:t[P+1].hash,fromLane:0,toLane:0,fromY:T,toY:k,color:"var(--theme-ink)"})}return R}return nt(t,y,c,v)},[t,y,c,v,p]);return e("div",{className:"absolute top-0 left-0 pointer-events-none z-10",style:{width:N,height:v},children:e("svg",{className:"w-full h-full overflow-visible",style:{width:N,height:v},children:[e("defs",{children:e("filter",{id:"node-glow",x:"-20%",y:"-20%",width:"140%",height:"140%",children:e("feDropShadow",{dx:"0",dy:"0",stdDeviation:"2",floodOpacity:"0.35"})})}),G.map((R)=>{let P=p?g+R.fromLane*h:16,T=p?g+R.toLane*h:16,k=p?R.color:"currentColor",x=p?0.95:0.25,w=ot(P,R.fromY,T,R.toY);return e("path",{d:w,fill:"none",stroke:k,strokeWidth:p?2.25:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:x},`${R.fromHash}->${R.toHash}`)}),t.map((R)=>{let P=y.get(R.hash)??0,T=p?g+P*h:16,k=c[R.hash]??20,x=l===R.hash||l===R.shortHash,w=r===R.hash||r===R.shortHash,E=p?le[P%le.length]:"var(--theme-success)";return e("g",{"data-commit-node":R.hash,children:[(x||w)&&e("circle",{cx:T,cy:k,r:8,fill:E,fillOpacity:x?0.35:0.2,stroke:E,strokeWidth:1}),e("circle",{"data-commit-dot":"",cx:T,cy:k,r:p?4:4.5,fill:p?"var(--theme-paper)":E,stroke:E,strokeWidth:p?2.5:1.5,filter:"url(#node-glow)"}),p&&e("circle",{cx:T,cy:k,r:1.8,fill:E})]},`node-${R.hash}`)})]})})}function rt({commit:t,onAction:c}){return e("div",{className:"flex flex-wrap items-center gap-1.5 pt-1.5 pb-2",children:[e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("checkout",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"checkout"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("create_branch_here",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"create branch here"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("cherry_pick",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"cherry-pick"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("revert",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"revert"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("reset",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"reset..."}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("merge",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"merge into current"}),e("button",{type:"button",onClick:(l)=>{l.stopPropagation(),c("rebase",t)},className:"px-2.5 py-1 text-[11px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/80 hover:text-ink transition-colors cursor-pointer disabled:opacity-40",children:"rebase onto this"})]})}var Ge=3;function Ft(t){let c=[];for(let l=0;l<t.length;l+=1){if(t[l].type!=="context"){c.push({row:t[l],index:l});continue}let r=l;while(r<t.length&&t[r].type==="context")r+=1;let p=r-l;if(p>Ge*2+1){for(let h=l;h<l+Ge;h+=1)c.push({row:t[h],index:h});c.push({row:{type:"elided",count:p-Ge*2},index:-1});for(let h=r-Ge;h<r;h+=1)c.push({row:t[h],index:h})}else for(let h=l;h<r;h+=1)c.push({row:t[h],index:h});l=r-1}return c}function lt({diffText:t,isLoading:c,filePath:l,fullContext:r=!1,onToggleContext:p}){let h=ro(),g=u(()=>{if(!t)return[];let N=[],G=1,R=1,P=t.split(/\r?\n/),k=P.some((x)=>x.startsWith("@@"))?P:[`@@ -0,0 +1,${P.length} @@`,...P.map((x)=>x.startsWith("+")||x.startsWith("-")?x:`+${x}`)];for(let x of k){if(x.startsWith("diff --git")||x.startsWith("index ")||x.startsWith("---")||x.startsWith("+++")||x.startsWith("new file mode")||x.startsWith("deleted file mode")||x.startsWith("similarity index")||x.startsWith("old mode")||x.startsWith("new mode")||x.startsWith("\\ No newline"))continue;if(x.startsWith("@@")){let w=x.match(/@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@/);if(w)G=parseInt(w[1],10),R=parseInt(w[2],10);N.push({type:"meta",text:x})}else if(x.startsWith("+"))N.push({type:"add",text:x.slice(1),newNum:R++});else if(x.startsWith("-"))N.push({type:"del",text:x.slice(1),oldNum:G++});else{let w=x.startsWith(" ")?x.slice(1):x;N.push({type:"context",text:w,oldNum:G++,newNum:R++})}}return N},[t]),v=pt(l),y=u(()=>{let N=Array(g.length).fill(""),G=-1,R=(P)=>{if(G<0)return;let T=Tu(g.slice(G,P).map((k)=>k.text).join(`
3
- `),v);for(let k=G;k<P;k++)N[k]=T[k-G]??"";G=-1};return g.forEach((P,T)=>{if(P.type==="meta")R(T);else if(G<0)G=T}),R(g.length),N},[g,v,h]),L=u(()=>r?g.map((N,G)=>({row:N,index:G})):Ft(g),[g,r]);if(c)return e("div",{className:"my-2 p-4 rounded bg-canvas border border-ink/10 text-ink/40 font-mono text-xs flex items-center justify-center",children:"Loading commit diff..."});if(!t||g.length===0)return e("div",{className:"my-2 p-3 rounded bg-canvas border border-ink/10 text-ink/40 font-mono text-xs text-center",children:"No diff content available for this file."});return e("div",{className:"my-2 rounded border border-ink/15 bg-paper overflow-hidden text-[11px] font-mono leading-relaxed shadow-xs text-ink",children:[e("div",{className:"flex items-center justify-between px-3 py-1.5 bg-canvas border-b border-ink/10 text-ink/70 text-[10.5px]",children:[e("span",{className:"font-semibold text-meta",children:"Diff preview"}),e("button",{type:"button",onClick:p,disabled:!p,className:"hover:text-ink flex items-center gap-1 cursor-pointer transition-colors disabled:opacity-40 disabled:cursor-default",title:r?"Show only the changed hunks":"Read the whole file around the change","aria-pressed":r,children:r?e(d,{children:[e(et,{size:12})," Collapse context"]}):e(d,{children:[e(B,{size:12})," Expand all context"]})})]}),e("div",{className:"overflow-x-auto max-h-72 select-text",children:e("div",{className:"w-max min-w-full divide-y divide-ink/[0.04]",children:L.map(({row:N,index:G},R)=>{if(N.type==="elided")return e("div",{className:"px-3 py-1 bg-canvas text-ink/40 text-[10px] text-center select-none",title:`${N.count} unchanged line(s) hidden`,children:["⋯ ",N.count," unchanged line",N.count===1?"":"s"," hidden ⋯"]},`elided-${R}`);let P=N,T=G;if(P.type==="meta")return e("div",{className:"flex items-center gap-2 px-3 py-1 bg-canvas border-y border-ink/10 text-meta text-[10px] font-semibold",children:[e("span",{children:"↕"}),e("span",{children:P.text})]},T);let k=P.type==="add",x=P.type==="del";return e("div",{className:`flex items-start font-mono ${k?"bg-success/10 hover:bg-success/15":x?"bg-error/10 hover:bg-error/15":"text-ink hover:bg-ink/[0.02]"}`,children:[e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${x?"bg-error/15 text-error font-semibold":k?"bg-success/15 text-success/70":"bg-canvas/50 text-ink/40"}`,children:P.oldNum??(k?"+":"")}),e("div",{className:`w-10 flex-shrink-0 text-right pr-2 py-0.5 select-none border-r border-ink/10 text-[10px] tabular-nums font-mono ${k?"bg-success/15 text-success font-semibold":x?"bg-error/15 text-error/70":"bg-canvas/50 text-ink/40"}`,children:P.newNum??(x?"-":"")}),e("div",{className:`w-4 flex-shrink-0 text-center py-0.5 select-none font-bold ${k?"text-success":x?"text-error":"opacity-0"}`,children:k?"+":x?"-":" "}),e("div",{className:"flex-1 py-0.5 pr-3 whitespace-pre text-ink",children:P.text?e("span",{className:"shiki",dangerouslySetInnerHTML:{__html:y[T]}}):" "})]},T)})})})]})}function ct({commit:t,isSelected:c,isGraphMode:l,onSelect:r,onAction:p,onToggleFile:h,isExpandedFile:g,isLoadingFile:v,isFullContextFile:y,onToggleContext:L,fileDiffs:N,headerRef:G}){let[R,P]=n(!1),[T,k]=n(!1),x=t.body?.trim()??"",w=x.length>0,E=(A)=>{A.stopPropagation(),navigator.clipboard.writeText(t.hash),P(!0),setTimeout(()=>P(!1),2000)},z=(A,H)=>{A.stopPropagation(),h(t.hash,H)};return e("div",{onClick:()=>{if(r(t),!w)return;let A=globalThis.getSelection?.();if(A&&!A.isCollapsed)return;k((H)=>!H)},"data-testid":"commit-row","data-commit-hash":t.hash,className:`border-b border-ink/5 transition-colors cursor-pointer ${c?"bg-ink/[0.03]":"hover:bg-ink/[0.015]"}`,children:e("div",{className:"py-2.5 pr-4 pl-1 flex flex-col",children:[e("div",{className:"flex flex-col gap-1",children:[t.refs&&t.refs.length>0&&e("div",{className:"flex flex-wrap items-center gap-1.5 pb-0.5",children:t.refs.map((A,H)=>{let O=A.includes("stash"),X=A.includes("HEAD")||A.includes("main")||A.includes("master");return e("span",{className:`px-2 py-0.5 rounded text-[10px] font-mono border ${O?"bg-warning/10 text-warning border-warning/25 font-semibold":X?"bg-ink/10 text-ink font-semibold border-ink/20":"bg-canvas text-meta border-ink/10 font-medium"}`,children:A},H)})}),e("div",{ref:G,className:"flex items-start gap-1.5",children:[e("span",{"data-commit-title":"",className:"text-[13px] font-semibold text-ink leading-snug break-words flex-1 min-w-0",children:t.message}),w&&e("span",{className:"text-ink/40 flex-shrink-0 mt-0.5","aria-hidden":"true",children:T?e(B,{size:13}):e(ie,{size:13})})]}),w&&T&&e("div",{className:"text-[12px] text-ink/70 leading-relaxed whitespace-pre-wrap break-words border-l-2 border-ink/15 pl-2.5 py-0.5 font-mono",children:x}),e("div",{className:"flex items-center gap-2 text-[11px] text-ink/50 font-mono flex-wrap",children:[e("span",{children:t.author}),e("span",{children:"•"}),e("span",{children:t.date}),e("span",{children:"•"}),e("button",{type:"button",onClick:E,title:"Copy commit hash",className:"inline-flex items-center gap-1 hover:text-ink transition-colors cursor-pointer text-ink/70",children:[e("span",{children:t.shortHash}),R?e(f,{size:11,className:"text-success"}):e(ae,{size:11})]})]})]}),(c||l)&&e("div",{className:"mt-2",children:e(rt,{commit:t,onAction:p})}),t.files&&t.files.length>0&&e("div",{className:"mt-2 flex flex-col gap-1",children:t.files.map((A,H)=>{let O=g(t.hash,A.file),X=`${t.hash}:${A.file}`,te=N[X]!==void 0?N[X]:A.diff,j=v(t.hash,A.file),K=A.status==="A"?"text-success font-bold":A.status==="D"?"text-error font-bold":A.status==="R"?"text-meta font-bold":"text-info font-bold";return e("div",{className:"flex flex-col",children:[e("div",{onClick:(W)=>z(W,A),className:"flex items-center gap-2 py-1 px-2 rounded hover:bg-ink/5 text-[11.5px] font-mono text-ink/80 transition-colors group cursor-pointer border border-transparent hover:border-ink/10",children:[e("span",{className:`w-3.5 text-center flex-shrink-0 text-[11px] ${K}`,children:A.status||"M"}),e("span",{className:"truncate flex-1 min-w-0 text-ink/90 group-hover:text-ink font-medium",children:A.file}),e("span",{className:"flex items-center gap-1 text-[10.5px] tabular-nums flex-shrink-0 font-medium",children:[e("span",{className:"text-success",children:["+",A.additions]}),e("span",{className:"text-ink/30",children:"/"}),e("span",{className:"text-error",children:["-",A.deletions]})]}),e("span",{className:"text-ink/40 group-hover:text-ink flex-shrink-0",children:O?e(B,{size:13}):e(ie,{size:13})})]}),O&&e("div",{className:"pl-4 pr-1",children:e(lt,{diffText:te,isLoading:j,filePath:A.file,fullContext:y(t.hash,A.file),onToggleContext:()=>L(t.hash,A)})})]},H)})})]})})}var xe=50;function Et(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l;if(typeof r.file!=="string"||!r.file)continue;c.push({file:r.file,status:typeof r.status==="string"?r.status:"M",additions:typeof r.additions==="number"&&Number.isFinite(r.additions)?r.additions:0,deletions:typeof r.deletions==="number"&&Number.isFinite(r.deletions)?r.deletions:0,diff:typeof r.diff==="string"?r.diff:void 0})}return c}function ze(t){if(!Array.isArray(t))return[];let c=[];for(let l of t){if(!l||typeof l!=="object")continue;let r=l,p=typeof r.hash==="string"&&r.hash?r.hash:"";if(!p)continue;c.push({hash:p,shortHash:typeof r.shortHash==="string"&&r.shortHash?r.shortHash:p.slice(0,8),author:typeof r.author==="string"?r.author:"Unknown",date:typeof r.date==="string"?r.date:typeof r.time==="string"?r.time:"",message:typeof r.message==="string"?r.message:"",body:typeof r.body==="string"?r.body:void 0,parents:Array.isArray(r.parents)?r.parents.filter((h)=>typeof h==="string"):[],refs:Array.isArray(r.refs)?r.refs.filter((h)=>typeof h==="string"):[],files:Et(r.files),lane:typeof r.lane==="number"?r.lane:void 0})}return c}function dt({output:t,isGraphMode:c,rootPath:l,activeRepo:r}){let[p,h]=n(!1),[g,v]=n(t?.hasMore??t?.data?.length===xe),[y,L]=n(t?.total),N=u(()=>ze(t?.data),[t?.data]),G=Array.isArray(t?.data)?t.data.length:0,[R,P]=n(N),[T,k]=n(G);i(()=>{if(P(N),k(G),v(t?.hasMore??G===xe),typeof t?.total==="number")L(t.total)},[N,G,t?.hasMore,t?.total]);let x=a(async()=>{if(p||!g)return;h(!0);try{let w=new FormData;if(w.set("actionType",c?"graph":"history"),w.set("limit",String(xe)),w.set("skip",String(T)),l)w.set("root",l);if(r)w.set("repo",r);let z=await(await fetch("/api/fs/git",{method:"POST",body:w})).json();if(z.success&&Array.isArray(z.data)){let I=ze(z.data),A=z.data.length;if(P((H)=>{let O=new Set(H.map((te)=>te.hash)),X=I.filter((te)=>!O.has(te.hash));return[...H,...X]}),k((H)=>H+A),v(Boolean(z.hasMore??A===xe)),typeof z.total==="number")L(z.total)}else v(!1)}catch(w){console.error("Failed to load more commits:",w)}finally{h(!1)}},[p,g,c,T,l,r]);return{commits:R,hasMore:g,totalCount:y,isLoadingMore:p,handleLoadMore:x}}function mt({onExecuteAction:t,rootPath:c,activeRepo:l}){let[r,p]=n({}),[h,g]=n(new Set),[v,y]=n(new Set),[L,N]=n(new Set),G=a(async(k,x,w)=>{let E=`${k}:${x.file}`;y((z)=>new Set(z).add(E));try{let z=new FormData;if(z.set("actionType","commit_diff"),z.set("hash",k),z.set("file",x.file),w)z.set("full","1");if(c)z.set("root",c);if(l&&l!==".")z.set("repo",l);let A=await(await fetch("/api/fs/git",{method:"POST",body:z})).json();if(A&&typeof A.diff==="string")p((H)=>({...H,[E]:A.diff}));else if(A&&A.error)p((H)=>({...H,[E]:`// Error: ${A.error}`}))}catch(z){console.error("Failed to load file diff:",z);let I=z instanceof Error?z.message:"Network error";p((A)=>({...A,[E]:`// Error loading diff: ${I}`}))}finally{y((z)=>{let I=new Set(z);return I.delete(E),I})}},[c,l]),R=a(async(k,x)=>{let w=`${k}:${x.file}`,E=!h.has(w);if(g((z)=>{let I=new Set(z);if(I.has(w))I.delete(w);else I.add(w);return I}),E&&r[w]===void 0&&!x.diff)await G(k,x,!1)},[h,r,G]),P=a(async(k,x)=>{let w=`${k}:${x.file}`,E=!L.has(w);N((z)=>{let I=new Set(z);if(I.has(w))I.delete(w);else I.add(w);return I}),await G(k,x,E)},[L,G]),T=a((k,x)=>{if(!t)return;if(k==="checkout")t("checkout",void 0,{branch:x.hash});else if(k==="create_branch_here"){let w=window.prompt(`Create new branch at commit ${x.shortHash}:`,`branch-${x.shortHash}`);if(w?.trim())t("create_branch_at",void 0,{branch:w.trim(),hash:x.hash})}else if(k==="cherry_pick"){if(window.confirm(`Cherry-pick commit ${x.shortHash} onto current branch?`))t("cherry_pick",void 0,{hash:x.hash})}else if(k==="revert"){if(window.confirm(`Revert commit ${x.shortHash}?`))t("revert_commit",void 0,{hash:x.hash})}else if(k==="reset"){let w=window.prompt(`Reset current branch to ${x.shortHash} (soft, mixed, hard):`,"soft");if(w&&["soft","mixed","hard"].includes(w.toLowerCase()))t("reset_commit",void 0,{hash:x.hash,mode:w.toLowerCase()})}else if(k==="merge"){if(window.confirm(`Merge commit ${x.shortHash} into current branch?`))t("merge_commit",void 0,{hash:x.hash})}else if(k==="rebase"){if(window.confirm(`Rebase current branch onto commit ${x.shortHash}?`))t("rebase_commit",void 0,{hash:x.hash})}},[t]);return{fileDiffs:r,expandedFiles:h,loadingFiles:v,fullContextFiles:L,handleToggleFile:R,handleToggleContext:P,handleCommitAction:T}}function He({output:t,onClose:c,onRefresh:l,onExecuteAction:r,rootPath:p,activeRepo:h}){if(!t)return null;let[g,v]=n(()=>({title:t.title,graph:t.title.toLowerCase().includes("graph")}));if(g.title!==t.title)v({title:t.title,graph:t.title.toLowerCase().includes("graph")});let y=g.graph,L=(U)=>v((_)=>({..._,graph:U})),[N,G]=n(""),[R,P]=n(""),[T,k]=n(!1),{commits:x,hasMore:w,totalCount:E,isLoadingMore:z,handleLoadMore:I}=dt({output:t,isGraphMode:y,rootPath:p,activeRepo:h}),{fileDiffs:A,expandedFiles:H,loadingFiles:O,fullContextFiles:X,handleToggleFile:te,handleToggleContext:j,handleCommitAction:K}=mt({onExecuteAction:r,rootPath:p,activeRepo:h});i(()=>{if(x.length>0&&!R)P(x[0].hash)},[x,R]);let W=u(()=>{if(!N.trim())return x;let U=N.toLowerCase().trim();return x.filter((_)=>_.message.toLowerCase().includes(U)||_.author.toLowerCase().includes(U)||_.shortHash.toLowerCase().includes(U)||_.hash.toLowerCase().includes(U)||_.refs?.some((ee)=>ee.toLowerCase().includes(U)))},[x,N]),ne=o(null),se=o(null),be=o(null),de=o({}),[pe,ve]=n({}),[Se,Pe]=n(800);i(()=>{let U=be.current;if(!U||!w||z||N.trim())return;let _=new IntersectionObserver((ee)=>{if(ee[0].isIntersecting)I()},{root:ne.current,threshold:0.1});return _.observe(U),()=>_.disconnect()},[w,z,N,I]);let re=a(()=>{if(!ne.current||!se.current)return;let U=ne.current.getBoundingClientRect(),_=ne.current.scrollTop,ee={};W.forEach((me,Le)=>{let ue=de.current[me.hash];if(ue){let oe=ue.getBoundingClientRect();ee[me.hash]=oe.top+oe.height/2-U.top+_}else ee[me.hash]=Le*60+20}),ve(ee);let Ce=se.current.offsetHeight;Pe(Math.max(Ce,ne.current.clientHeight,600))},[W]);V(()=>{re();let U=requestAnimationFrame(()=>{re()});return()=>cancelAnimationFrame(U)},[re,W,A,H,y,R]),i(()=>{let U=se.current;if(!U)return;let _=new ResizeObserver(()=>{re()});_.observe(U);for(let ee of Array.from(U.children))_.observe(ee);return()=>_.disconnect()},[re,W]);let Z=u(()=>Re(W),[W]),$e=u(()=>{let U=0;return Z.forEach((_)=>{if(_>U)U=_}),U},[Z]),ye=18,ke=16,Me=y?($e+1)*ye+ke*2:36;return e("div",{className:"fixed inset-0 z-50 modal-scrim backdrop-blur-xs flex items-center justify-center p-0 lg:p-5",onClick:c,role:"dialog","aria-modal":"true",children:e("div",{className:`glass-overlay bg-paper border-ink/20 shadow-2xl flex flex-col overflow-hidden
4
- w-full h-full rounded-none border-0
5
- lg:w-[min(94vw,1200px)] lg:h-[88vh] lg:rounded-xl lg:border
6
- pt-[env(safe-area-inset-top,0px)] lg:pt-0`,onClick:(U)=>U.stopPropagation(),children:[e(tt,{isGraphMode:y,onToggleMode:L,searchQuery:N,onSearchChange:G,onRefresh:()=>{k(!0),l?.(),setTimeout(()=>k(!1),600)},onClose:c,isRefreshing:T,totalCommits:W.length,loadedCount:x.length,totalCount:E,hasMore:w}),e("div",{ref:ne,className:"flex-1 overflow-y-auto scrollbar-overlay-container relative select-text",children:W.length===0?e("div",{className:"flex flex-col items-center justify-center py-20 text-ink/40 font-mono text-xs",children:N.trim()?"No matching commits found.":"No commits in this branch."}):e("div",{className:"relative min-h-full pb-8",children:[e(st,{commits:W,nodePositions:pe,selectedHash:R,isGraphMode:y,laneWidth:ye,paddingLeft:ke,totalHeight:Se}),e("div",{ref:se,className:"flex flex-col relative z-20",style:{paddingLeft:`${Me}px`},children:[W.map((U)=>e(ct,{commit:U,isSelected:R===U.hash,isGraphMode:y,onSelect:(_)=>P(_.hash),onAction:K,onToggleFile:te,isExpandedFile:(_,ee)=>H.has(`${_}:${ee}`),isLoadingFile:(_,ee)=>O.has(`${_}:${ee}`),isFullContextFile:(_,ee)=>X.has(`${_}:${ee}`),onToggleContext:j,fileDiffs:A,headerRef:(_)=>{de.current[U.hash]=_}},U.hash)),e("div",{ref:be,className:"pt-3 pb-4 px-4 flex items-center justify-center",children:z?e("div",{className:"flex items-center gap-2 text-xs text-ink/60 font-mono py-2",children:[e(m,{size:14,className:"animate-spin text-info"}),e("span",{children:"Loading more commits..."})]}):w&&!N.trim()?e("button",{type:"button",onClick:I,className:"px-3 py-1.5 text-xs font-mono text-ink/70 hover:text-ink bg-ink/5 hover:bg-ink/10 rounded-md border border-ink/10 transition-colors cursor-pointer",children:"Load more commits..."}):W.length>10?e("div",{className:"text-[11px] font-mono text-ink/40 py-2",children:["End of commit history (",typeof E==="number"&&E>0?E:x.length," commits)"]}):null})]})]})})]})})}function ft({children:t,onClose:c}){return e("div",{className:"fixed inset-0 z-50 modal-scrim flex items-center justify-center p-4",onClick:c,role:"dialog","aria-modal":"true",children:e("div",{className:"glass-overlay bg-paper border border-ink/20 rounded-lg shadow-xl flex flex-col overflow-hidden w-[min(94vw,420px)] max-h-[80vh]",onClick:(l)=>l.stopPropagation(),children:t})})}function ht({modal:t,onClose:c,onConfirm:l}){if(!t)return null;return e(ft,{onClose:c,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(D,{size:16,className:"text-error flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Confirm Action"})]}),e("div",{className:"px-4 py-4 text-xs text-ink/80 leading-relaxed",children:t.message}),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/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:l,className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:"Confirm"})]})]})}function gt({isOpen:t,branchName:c,inputRef:l,onChange:r,onClose:p,onCreate:h}){if(!t)return null;let g=a(()=>{if(c.trim())h()},[c,h]);return e(ft,{onClose:p,children:[e("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[e(Tn,{size:16,className:"text-ink/60 flex-shrink-0"}),e("h3",{className:"text-sm font-semibold text-ink",children:"Create New Branch"})]}),e("div",{className:"px-4 py-4",children:e("input",{ref:l,type:"text",value:c,onChange:(v)=>r(v.currentTarget.value),onKeyDown:(v)=>{if(v.key==="Enter")g();if(v.key==="Escape")p()},placeholder:"branch-name",className:"w-full bg-canvas border border-ink/20 rounded px-3 py-2 text-xs focus:outline-none focus:border-ink/40 text-ink placeholder-ink/40 transition-colors"})}),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:p,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:g,disabled:!c.trim(),className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Create"})]})]})}function xt({branch:t,detached:c,onCheckout:l,onMerge:r,onRename:p,onDelete:h}){let g=t.current&&!c;return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_minmax(0,9.5rem)_4.25rem_4rem] items-start gap-x-2 px-4 py-2 border-b border-ink/5 last:border-b-0 hover:bg-ink/[0.02] group/row transition-colors",children:[e("div",{className:"h-5 flex items-center justify-center",children:g&&e(f,{size:12,className:"text-ink","aria-label":"Current branch"})}),e("button",{type:"button",onClick:l,disabled:g,title:g?"Already on this branch":`Check out ${t.name}`,className:"min-w-0 text-left cursor-pointer disabled:cursor-default",children:[e("div",{className:"h-5 flex items-center gap-1.5 min-w-0",children:[e(fe,{size:11,className:g?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${g?"font-semibold text-ink":"text-ink/90"}`,children:t.name})]}),t.subject&&e("div",{className:"h-4 flex items-center pl-[18px] min-w-0",children:e("span",{className:"truncate text-[10px] text-ink/40",title:t.subject,children:t.subject})})]}),e("div",{className:"h-5 flex items-center justify-end min-w-0",children:e(zt,{branch:t})}),e("div",{className:"h-5 flex items-center justify-end",children:t.date&&e("span",{className:"text-[10px] text-ink/40 truncate",children:t.date})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[!g&&e("button",{type:"button",onClick:r,title:`Merge ${t.name} into the current branch`,"aria-label":`Merge ${t.name} into the current branch`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Tn,{size:11})}),e("button",{type:"button",onClick:p,title:`Rename ${t.name}`,"aria-label":`Rename ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors",children:e(Dn,{size:11})}),!g&&e("button",{type:"button",onClick:h,title:`Delete ${t.name}`,"aria-label":`Delete ${t.name}`,className:"w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/10 cursor-pointer transition-colors",children:e(M,{size:11})})]})]})}function zt({branch:t}){if(t.gone)return e("span",{className:"text-[10px] font-mono text-warning border border-warning/30 rounded px-1 truncate",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"});if(!t.upstream)return e("span",{className:"text-[10px] font-mono text-ink/40 truncate",title:"No upstream: this branch has never been published",children:"unpublished"});return e("span",{className:"flex items-center gap-1 text-[10px] font-mono text-ink/50 min-w-0",children:[e("span",{className:"truncate",title:t.upstream,children:t.upstream}),(t.ahead>0||t.behind>0)&&e("span",{className:"tabular-nums text-ink/70 flex-shrink-0",children:[t.ahead>0&&`↑${t.ahead}`,t.behind>0&&`↓${t.behind}`]})]})}function bt({branch:t,onClose:c,onSubmit:l}){if(!t)return null;return e(Ht,{branch:t,onClose:c,onSubmit:l})}function Ht({branch:t,onClose:c,onSubmit:l}){let[r,p]=n(t.name),[h,g]=n(!1),v=r.trim(),y=v===t.name,L=v.length>0&&!y,N=()=>{if(L)l(t.name,v,h)};return e(J,{onClose:c,maxWidthClass:"max-w-[min(94vw,460px)]",header:e("div",{className:"flex items-center gap-2",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Rename branch"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:t.name})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3",children:[e("div",{children:[e("label",{className:"text-[10px] uppercase tracking-wider text-ink/50 font-semibold",htmlFor:"branch-rename-input",children:"New name"}),e("input",{id:"branch-rename-input",type:"text",value:r,autoFocus:!0,onChange:(G)=>p(G.currentTarget.value),onKeyDown:(G)=>{if(G.key==="Enter")N();if(G.key==="Escape")c()},className:"mt-1 w-full bg-paper border border-ink/20 rounded px-2.5 py-1.5 text-xs font-mono text-ink focus:outline-none focus:border-ink/40 transition-colors"}),y&&v.length>0&&e("p",{className:"mt-1 text-[10px] text-ink/50",children:"The name is unchanged."})]}),e("div",{className:"text-[10px] font-mono text-ink/60 flex flex-col gap-0.5 border border-ink/10 rounded p-2 bg-canvas/40",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"upstream"}),e("span",{className:"truncate",children:t.upstream||"none (unpublished)"})]}),e("p",{className:"text-ink/40 leading-relaxed mt-0.5",children:"A local rename keeps this upstream unchanged — a plain push afterwards will refuse until the upstream matches the new name, which is what the remote option below does."})]}),e("label",{className:"flex items-start gap-2 text-[11px] text-ink/80 cursor-pointer select-none",children:[e("input",{type:"checkbox",checked:h,onChange:(G)=>g(G.currentTarget.checked),className:`${ge} accent-ink cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{children:"Also rename it on the remote"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git push -u ",t.upstream?t.upstream.split("/")[0]:"origin"," ",v||"<new>",e("br",{}),"git push ",t.upstream?t.upstream.split("/")[0]:"origin"," --delete ",t.name,e("br",{}),"git fetch --prune"]})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 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/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:N,disabled:!L,className:"px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:"Rename"})]})]})}function vt({branch:t,force:c,onForceChange:l,onClose:r,onConfirm:p}){if(!t)return null;return e(J,{onClose:r,maxWidthClass:"max-w-[min(94vw,440px)]",header:e("div",{className:"flex items-center gap-2",children:[e(D,{size:15,className:"text-error flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Delete branch"})]}),children:[e("div",{className:"px-5 py-4 flex flex-col gap-3 text-xs text-ink/80 leading-relaxed",children:[e("p",{children:["Delete ",e("span",{className:"font-mono font-semibold text-ink",children:t.name}),t.upstream&&e(d,{children:[" ","(tracks ",e("span",{className:"font-mono",children:t.upstream}),")"]}),"?"]}),e("div",{className:"text-[10px] font-mono text-ink/60 border border-ink/10 rounded p-2 bg-canvas/40 flex flex-col gap-0.5",children:[e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"last commit"}),e("span",{className:"truncate",children:t.subject||"–"})]}),e("div",{className:"flex items-center justify-between gap-2",children:[e("span",{className:"text-ink/40",children:"when"}),e("span",{children:t.date||"–"})]})]}),e("label",{className:"flex items-start gap-2 cursor-pointer select-none text-[11px]",children:[e("input",{type:"checkbox",checked:c,onChange:(h)=>l(h.currentTarget.checked),className:`${ge} accent-error cursor-pointer mt-0.5`}),e("span",{className:"flex flex-col gap-0.5",children:[e("span",{className:"text-error font-medium",children:"Delete even if its commits are not merged"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:["git branch ",c?"-D":"-d"," ",t.name]}),e("span",{className:"text-ink/50",children:"Without this, git refuses when the branch holds commits no other branch has. Leaving it off is the safe default."})]})]})]}),e("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-ink/10",children:[e("button",{type:"button",onClick:r,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs",children:"Cancel"}),e("button",{type:"button",onClick:()=>p(t.name),className:"px-3 py-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer text-xs font-medium",children:["Delete ",c?"(force)":""]})]})]})}function yt({isOpen:t,rootPath:c,repo:l,currentBranch:r,detached:p,isBusy:h,onClose:g,onAction:v,onConfirmDelete:y}){let[L,N]=n([]),[G,R]=n(!1),[P,T]=n(null),[k,x]=n(""),[w,E]=n(null),[z,I]=n(null),[A,H]=n(!1),O=a(async()=>{R(!0),T(null);let j=new URLSearchParams({branches:"1",repo:l||"."});if(c)j.set("root",c);try{let K=await fetch(`/api/fs/git?${j.toString()}`),W=await K.json();if(W.success&&Array.isArray(W.branches))N(W.branches);else T(W.error||`Failed to read branches (HTTP ${K.status})`)}catch(K){T(K instanceof Error?K.message:"Failed to read branches")}finally{R(!1)}},[c,l]);i(()=>{if(t)O()},[t,O]);let X=o(!1);i(()=>{if(!t){X.current=!1;return}if(X.current&&!h)O();X.current=h},[t,h,O]),i(()=>{if(!t)E(null),I(null),H(!1),x("")},[t]);let te=u(()=>{let j=k.trim().toLowerCase();if(!j)return L;return L.filter((K)=>K.name.toLowerCase().includes(j)||K.upstream.toLowerCase().includes(j))},[L,k]);if(!t)return null;return e(d,{children:[e(J,{onClose:g,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e("h2",{className:"text-sm font-semibold text-ink",children:"Branches"}),e("span",{className:"text-[10px] font-mono text-ink/50",children:p?`detached at ${r}`:`on ${r}`})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(F,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:k,onChange:(j)=>x(j.currentTarget.value),placeholder:"Filter branches…","aria-label":"Filter branches",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:()=>void O(),disabled:G,title:"Refresh","aria-label":"Refresh branches",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(C,{size:12,className:G?"animate-spin":""})})]}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:G&&L.length===0?e("div",{className:"flex items-center justify-center gap-2 py-12 text-xs text-ink/50 font-mono",children:[e(m,{size:14,className:"animate-spin text-info"}),"Loading branches…"]}):P?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:P}):te.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:k.trim()?"No matching branches.":"No branches."}):te.map((j)=>e(xt,{branch:j,detached:p,onCheckout:()=>{v("checkout",{branch:j.name}),g()},onMerge:()=>{v("merge_branch",{branch:j.name}),g()},onRename:()=>E(j),onDelete:()=>{I(j),H(!1)}},j.name))})]}),e(bt,{branch:w,onClose:()=>E(null),onSubmit:(j,K,W)=>{v("rename_branch",{branch:j,newName:K,...W?{remote:"1"}:{}}),E(null)}},w?.name??"none"),e(vt,{branch:z,force:A,onForceChange:H,onClose:()=>{I(null),H(!1)},onConfirm:(j)=>{y(j,A),I(null),H(!1)}})]})}function kt({mounted:t,confirmModal:c,onCloseConfirm:l,onConfirm:r,branchPrompt:p,newBranchName:h,newBranchInputRef:g,onNewBranchNameChange:v,onCloseBranchPrompt:y,onCreateBranch:L,viewingOutput:N,onCloseOutput:G,onRefreshOutput:R,onExecuteAction:P,branchModalOpen:T,onCloseBranchModal:k,rootPath:x,activeRepo:w,currentBranch:E,detached:z,isBusy:I,onBranchAction:A,onConfirmDeleteBranch:H}){if(!t)return null;return e(d,{children:[e(ht,{modal:c,onClose:l,onConfirm:r}),e(gt,{isOpen:p,branchName:h,inputRef:g,onChange:v,onClose:y,onCreate:L}),e(He,{output:N,onClose:G,onRefresh:R,onExecuteAction:P,rootPath:x,activeRepo:w}),e(yt,{isOpen:T,rootPath:x,repo:w,currentBranch:E,detached:z,isBusy:I,onClose:k,onAction:A,onConfirmDelete:H})]})}function Ct({rootPath:t,repo:c,isBusy:l,onAction:r}){let[p,h]=S("git.stashExpanded",!1),[g,v]=n([]),[y,L]=n(!1),[N,G]=n(""),[R,P]=n(!1),T=Ar(),k=a(async()=>{L(!0);let w=new URLSearchParams({stashes:"1",repo:c||"."});if(t)w.set("root",t);try{let z=await(await fetch(`/api/fs/git?${w.toString()}`)).json();v(z.stashes??[])}catch{v([])}finally{L(!1)}},[t,c]);i(()=>{if(p)k()},[p,k,l]);let x=(w,E)=>{if(r(w,E),w==="stash_push")G(""),P(!1)};return e("div",{className:"border-t border-ink/10 bg-canvas/30 flex-shrink-0",children:[e("div",{className:"flex items-center hover:bg-ink/5 transition-colors",children:[e("button",{type:"button",onClick:()=>h(!p),"aria-expanded":p,"aria-controls":T,title:p?"Hide stashes":"Show stashes",className:"flex flex-1 min-w-0 items-center space-x-1 py-1.5 pl-3 pr-2 text-left font-semibold text-xs text-ink transition-colors cursor-pointer",children:[e("span",{className:"w-3 text-center font-mono","aria-hidden":"true",children:p?"▾":"▸"}),e(Xe,{size:12}),e("span",{children:"Stash"}),g.length>0&&e("span",{className:"font-normal ml-1 border border-ink/20 rounded-full px-1.5 text-[10px] text-ink/50",children:g.length})]}),e("button",{type:"button",onClick:()=>x("stash_push",{...N.trim()?{message:N.trim()}:{},...R?{untracked:"1"}:{}}),disabled:l,title:"Stash the working tree",className:"mr-3 flex flex-shrink-0 items-center gap-1 px-2 py-0.5 text-[10px] font-mono rounded border border-ink/20 hover:bg-ink/5 text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed",children:[e(Y,{size:10}),"Save"]})]}),e("div",{className:"section-reveal","data-expanded":p,id:T,inert:!p,children:e("div",{children:e("div",{className:"px-3 pb-2 flex flex-col gap-1.5",children:[e("div",{className:"flex items-center gap-1.5",children:[e("input",{type:"text",value:N,onChange:(w)=>G(w.currentTarget.value),placeholder:"Stash message (optional)","aria-label":"Stash message",className:"flex-1 min-w-0 bg-paper border border-ink/20 rounded px-2 py-1 text-[11px] text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),e("label",{className:"flex items-center gap-1 text-[10px] text-ink/60 cursor-pointer select-none flex-shrink-0",title:"Also stash untracked files (-u)",children:[e("input",{type:"checkbox",checked:R,onChange:(w)=>P(w.currentTarget.checked),className:`${ge} accent-ink cursor-pointer`}),"-u"]})]}),y&&g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"Loading…"}):g.length===0?e("div",{className:"text-[10px] text-ink/40 italic py-1",children:"No stash entries."}):e("div",{className:"max-h-40 overflow-y-auto scrollbar-overlay-container flex flex-col",children:g.map((w)=>e("div",{className:"grid grid-cols-[4rem_minmax(0,1fr)_3.5rem_4.5rem] items-center gap-x-1 group/stash py-0.5",children:[e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:w.ref}),e("span",{className:"min-w-0 truncate text-[10px] text-ink/80",title:w.subject,children:w.subject}),e("span",{className:"text-[10px] text-ink/40 text-right truncate",children:w.date}),e("div",{className:"flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/stash:opacity-100",children:[e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref,pop:"1"}),disabled:l,title:"Pop: apply and remove the entry","aria-label":"Pop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(he,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_apply",{ref:w.ref}),disabled:l,title:"Apply: keep the entry","aria-label":"Apply stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-ink hover:bg-ink/10 cursor-pointer transition-colors disabled:opacity-40",children:e(Xe,{size:10})}),e("button",{type:"button",onClick:()=>x("stash_drop",{ref:w.ref}),disabled:l,title:"Drop: discard the entry (the stash is not recoverable from the panel)","aria-label":"Drop stash",className:"w-5 h-5 flex items-center justify-center rounded hover:text-error hover:bg-error/10 cursor-pointer transition-colors disabled:opacity-40",children:e(M,{size:10})})]})]},w.ref))})]})})})]})}function Nt({repo:t,isBusy:c,onInit:l}){let r=t==="."?"this folder":t;return e("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 px-6 text-center",children:[e(fe,{size:26,className:"text-ink/25","aria-hidden":!0}),e("div",{className:"font-mono space-y-1",children:[e("p",{className:"text-xs text-ink/70",children:"Not a Git repository"}),e("p",{className:"text-[11px] leading-4 text-ink/40",children:["Initialize one in ",r," to track changes, commit and manage branches."]})]}),e("button",{type:"button",onClick:l,disabled:c,"aria-label":"Initialize Git repository",title:`git init in ${r}`,className:"flex items-center justify-center gap-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-40 disabled:cursor-not-allowed",children:[e(fe,{size:12,"aria-hidden":!0}),"Initialize repository"]})]})}function wt(t,c,l){let r=it(),{activeRepo:p,setActiveRepo:h,ready:g}=ir(t),{repos:v,scanning:y,rescan:L}=or(t,c),N=Rf(p,v),G=o(N);G.current=N;let R=o("");R.current=`${t??""}\x00${N}`;let P=o(""),T=o(""),k=o(void 0);if(r.data!==k.current)k.current=r.data,T.current=P.current;let x=c&&g?gp(`${t??""}\x00${N}`):null,w=we(x),E=o(w.refresh);E.current=w.refresh;let z=T.current===R.current?r.data:void 0,I=w.data??z,A=I?.syncCount??z?.syncCount,H=a((te)=>{if(!c)return;let j=te??G.current,K=new URLSearchParams;if(t)K.set("root",t);if(j&&j!==".")K.set("repo",j);K.set("sync","1"),K.set("t",String(Date.now())),P.current=R.current;let W=E.current;r.load(`/api/fs/git?${K.toString()}`).then(()=>W())},[c,t,r.load]);i(()=>{if(!g)return;H()},[l,t,c,g,N,H]);let O=r.state==="loading",X=O||w.refreshing;return{activeRepo:N,setActiveRepo:h,repos:v,reposScanning:y,refreshRepos:L,isReading:O,isRefreshing:X,data:I,syncCount:A,loadRepo:H,refreshTopic:w.refresh}}function Rt(t,c){let l=it(),r=o(null),p=a((h,g,v)=>{r.current={actionType:h,extra:v};let y=new FormData;if(y.append("actionType",h),y.append("repo",c),t)y.append("root",t);if(g)y.append("file",g);if(v)Object.entries(v).forEach(([L,N])=>y.append(L,N));l.submit(y,{method:"POST",action:"/api/fs/git"})},[c,t,l]);return{state:l.state,execute:p,data:l.data,lastAction:r.current}}function Gt({rootPath:t,repo:c,execute:l}){let{sessionId:r}=bp(),[p,h]=S("git.commitDraft",""),[g,v]=S("git.amend",!1),y=o(null),L=o(p);L.current=p;let N=o(g);N.current=g;let G=o(h);G.current=h,i(()=>{if(!g)return;if(L.current.trim().length>0)return;let T=new URLSearchParams({headMessage:"1"});if(t)T.set("root",t);if(c&&c!==".")T.set("repo",c);let k=!1;return fetch(`/api/fs/git?${T.toString()}`).then((x)=>x.json()).then((x)=>{if(k)return;if(!N.current||L.current.trim().length>0)return;let w=typeof x?.message==="string"?x.message:"";if(w.length===0)return;y.current=w,G.current(w)}).catch(()=>{}),()=>{k=!0}},[g,r,t,c]);let R=a((T)=>{if(T){v(!0);return}if(y.current!==null&&L.current===y.current)h("");y.current=null,v(!1)},[v,h]),P=a(()=>{l("commit",void 0,{message:L.current,...N.current?{amend:"1"}:{}}),h(""),v(!1),y.current=null},[l,v,h]);return{message:p,setMessage:h,amend:g,seeded:y.current!==null&&p===y.current,toggleAmend:R,commit:P}}var St=48;function Ot(t,c){let l=c?.branch?.trim()??"",r=(c?.hash??"").slice(0,7),p=c?.ref?.trim()||"stash@{0}";switch(t){case"init":return{done:"Initialized the repository"};case"fetch":return{done:"Fetched every remote"};case"push":return{done:"Pushed to upstream"};case"pull":return{done:"Pulled from upstream",stopped:"Pulled"};case"sync":return{done:"Synced with upstream",stopped:"Pulled, but nothing was pushed"};case"abort_operation":return{done:"Aborted the operation in progress"};case"continue_operation":return{done:"Concluded the operation"};case"commit":{if(c?.amend==="1")return{done:"Amended the last commit"};let h=(c?.message??"").split(`
7
- `)[0].trim();if(!h)return{done:"Commit created"};return{done:`Committed “${h.length>St?`${h.slice(0,St-1)}…`:h}”`}}case"checkout":return{done:l?`Switched to ${l}`:"Switched branch"};case"create_branch":case"create_branch_at":return{done:l?`Created branch ${l}`:"Created branch"};case"rename_branch":{let h=c?.newName?.trim()??"";return{done:l&&h?`Renamed ${l} to ${h}`:"Renamed branch"}}case"delete_branch":return{done:l?`Deleted branch ${l}`:"Deleted branch"};case"merge_branch":return{done:l?`Merged ${l}`:"Merged branch",stopped:l?`Merging ${l}`:"Merging the branch"};case"merge_commit":return{done:r?`Merged commit ${r}`:"Merged commit",stopped:r?`Merging ${r}`:"Merging the commit"};case"cherry_pick":return{done:r?`Cherry-picked ${r}`:"Cherry-picked commit",stopped:r?`Cherry-picking ${r}`:"Cherry-picking the commit"};case"revert_commit":return{done:r?`Reverted commit ${r}`:"Reverted commit",stopped:r?`Reverting ${r}`:"Reverting the commit"};case"rebase_commit":return{done:r?`Rebased onto ${r}`:"Rebased",stopped:r?`Rebasing onto ${r}`:"Rebasing"};case"reset_commit":{let h=c?.mode??"mixed";return{done:r?`Reset to ${r} (${h})`:`Reset (${h})`}}case"stash_push":return{done:"Stashed your changes"};case"stash_apply":return{done:c?.pop==="1"?`Popped ${p}`:`Applied ${p}`,stopped:c?.pop==="1"?`Popping ${p}`:`Applying ${p}`};case"stash_drop":return{done:`Dropped ${p}`};default:return null}}function Pt({actionType:t,extra:c,stopped:l}){let r=Ot(t,c);if(!l)return r?.done??null;let p=ui[l]??l,h=r?.stopped??r?.done??"",g=t==="sync"?"resolve it above, then Sync again":"resolve it above";return h?`${h} — the ${p} stopped on a conflict; ${g}`:`The ${p} stopped on a conflict; ${g}`}function $t(t){let{fetcher:c,onPage:l,onReload:r,onSuccess:p,onError:h}=t,g=o(null),v=o({onPage:l,onReload:r,onSuccess:p,onError:h});v.current={onPage:l,onReload:r,onSuccess:p,onError:h},i(()=>{if(c.state!=="idle"||!c.data)return;let y=c.data;if(y===g.current)return;g.current=y;let L=v.current;if(y.type==="history"||y.type==="graph"){L.onPage({title:y.type==="graph"?"Git Graph":"Commit History",data:y.data||[],hasMore:y.hasMore,total:y.total});return}if(!y.success){L.onError(y.error||"Git operation failed");return}L.onReload();let N=c.lastAction,G=N?Pt({...N,stopped:y.stopped}):null;if(G)L.onSuccess(G,y.stopped?"warning":"success")},[c.state,c.data,c.lastAction])}function Mt(t,c,l,r){if(t==="revert")return{type:t,file:c,message:`Are you sure you want to discard changes in ${c}?`};if(t==="revert_all")return{type:t,message:"Are you sure you want to discard ALL unstaged changes? This cannot be undone."};if(t==="abort_operation"){let p=r?ui[r]:"operation";return{type:t,message:`Abort the ${p}? Everything resolved so far is discarded and the working tree returns to its pre-${p} state.`}}if(t==="delete_branch"){let p=l?.branch??"",h=l?.force==="1";return{type:t,extra:{branch:p,...h?{force:"1"}:{}},message:h?`Delete branch ${p} even though its commits are not merged? This cannot be undone from the panel.`:`Delete branch ${p}?`}}if(t==="stash_drop"){let p=l?.ref||"the top entry";return{type:t,extra:{ref:l?.ref??""},message:`Drop ${p}? The stash entry is removed — this cannot be undone from the panel.`}}return null}function sr({className:t="",enabled:c=!0,rootPath:l,refreshKey:r=0}){let{activeRepo:p,setActiveRepo:h,repos:g,reposScanning:v,refreshRepos:y,isReading:L,isRefreshing:N,data:G,syncCount:R,loadRepo:P,refreshTopic:T}=wt(l,c,r),k=Rt(l,p),[x,w]=S("git.viewMode","flat"),[E,z]=n(!1),I=o(null),[A,H]=n(!1),O=o(null),[X,te]=n(null),[j,K]=n(!1),[W,ne]=n(""),se=o(null),[be,de]=n(!1),[pe,ve]=n(null),[Se,Pe]=n(!1),{pushToast:re}=Ve();i(()=>{Pe(!0)},[]),i(()=>{if(j&&se.current)se.current.focus()},[j]),$t({fetcher:k,onPage:ve,onReload:P,onSuccess:(q,Q)=>re(q,Q),onError:(q)=>re(q,"error")}),ce(I,()=>z(!1)),ce(O,()=>H(!1));let Z=k.execute,{message:$e,setMessage:ye,amend:ke,seeded:Me,toggleAmend:Oe,commit:U}=Gt({rootPath:l,repo:p,execute:Z}),_=(q,Q,Ne)=>{let Ie=Mt(q,Q,Ne,G?.state?.operation??null);if(Ie){te(Ie);return}Z(q,Q,Ne)},ee=(q,Q)=>{Z("resolve_conflict",q,Q?{side:Q}:void 0)},Ce=G?.branch||"main",me=G?.branches||["main"],Le=G?.remoteBranches||[],ue=G?.changes||[],oe=L||k.state!=="idle",De=k.state==="idle"?null:k.lastAction?.actionType??null,Lt=De==="sync"||De==="push"||De==="pull",Dt=ue.filter((q)=>{if(gr(q.status))return!1;let Q=q.status;return Q&&Q[0]!==" "&&Q[0]!=="?"});if(!c)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${t}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`flex flex-col h-full bg-paper relative ${t}`,children:[e(kt,{mounted:Se,confirmModal:X,onCloseConfirm:()=>te(null),onConfirm:()=>{if(X)Z(X.type,X.file,X.extra),te(null)},branchPrompt:j,newBranchName:W,newBranchInputRef:se,onNewBranchNameChange:ne,onCloseBranchPrompt:()=>{K(!1),ne("")},onCreateBranch:()=>{if(W.trim())Z("create_branch",void 0,{branch:W.trim()}),K(!1),ne("")},viewingOutput:pe,onCloseOutput:()=>ve(null),onRefreshOutput:()=>{if(pe)Z(pe.title.toLowerCase().includes("graph")?"graph":"history")},onExecuteAction:(q,Q,Ne)=>Z(q,Q,Ne),branchModalOpen:be,onCloseBranchModal:()=>de(!1),rootPath:l,activeRepo:p,currentBranch:Ce,detached:G?.state?.detached??!1,isBusy:oe,onBranchAction:(q,Q)=>Z(q,void 0,Q),onConfirmDeleteBranch:(q,Q)=>{Z("delete_branch",void 0,{branch:q,...Q?{force:"1"}:{}})}}),e(Ke,{activeRepo:p,repos:g,isRefreshing:N,rootPath:l,reposScanning:v,onSelectRepo:(q)=>{if(q!==p)h(q)},onRefresh:()=>{T(),P()},onRefreshRepos:y}),G?.isRepo===!1?e(Nt,{repo:p,isBusy:oe,onInit:()=>Z("init")}):e(d,{children:[e(qe,{branchRef:O,showBranchMenu:A,setShowBranchMenu:H,branch:Ce,branches:me,remoteBranches:Le,onCheckout:(q)=>Z("checkout",void 0,{branch:q}),onMerge:(q)=>Z("merge_branch",void 0,{branch:q}),onOpenBranchPrompt:()=>K(!0),onManageBranches:()=>{de(!0),H(!1)},optionsRef:I,showOptions:E,setShowOptions:z,onHistory:()=>Z("history"),onGraph:()=>Z("graph"),viewMode:x,setViewMode:w,isBusy:oe,syncCount:R,syncing:Lt,onSync:()=>Z("sync"),onFetch:()=>Z("fetch"),detached:G?.state?.detached??!1}),G?.state?.operation?e(We,{operation:G.state.operation,conflicts:G.state.conflicts,isBusy:oe,onAbort:()=>_("abort_operation"),onContinue:()=>Z("continue_operation")}):e(Ue,{message:$e,hasStagedChanges:Dt.length>0,isBusy:oe,amend:ke,seeded:Me,onToggleAmend:Oe,onChangeMessage:ye,onCommit:U}),e(Qe,{changes:ue,isLoading:oe,viewMode:x,repo:p,rootPath:l,onAction:_,onResolve:ee}),e(Ct,{rootPath:l,repo:p,isBusy:oe,onAction:(q,Q)=>_(q,void 0,Q)})]})]})}export{sr as GitPanel};
@@ -1 +0,0 @@
1
- import{n,i,o,u,a,e,TA,we,S,ir,or,I,m,Vt,Yt,Ce,Gr,C,F,J,ee}from"./index-d8kjsgpt.js";import{fr}from"./index-z72wf7q4.js";function K({sections:c,selected:t,onSelect:l}){let[r,d]=n(""),k=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((x)=>({...x,links:x.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((x)=>x.links.length>0)},[c,r]),f=c.some((p)=>p.links.length>0);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-canvas/40",children:[e("div",{className:"flex items-center gap-1.5 border-b border-ink/10 px-2 py-1.5 flex-shrink-0",children:[e(F,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>d(p.currentTarget.value),placeholder:"Filter pages…",title:"Filter wiki pages",className:"w-full min-w-0 bg-transparent text-xs text-ink outline-none placeholder-ink/40"}),r&&e("button",{type:"button",onClick:()=>d(""),title:"Clear filter",className:"flex-shrink-0 text-ink/40 hover:text-ink",children:"×"})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:f?"No page matches the filter":"This wiki has no pages"}):k.map((p,x)=>e("div",{className:"py-0.5",children:[p.title&&e("div",{className:"px-2.5 py-1 text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:p.title}),p.links.map((s,h)=>{let v=s.path!==null&&s.path===t,b=`${s.path??s.target}-${h}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":v?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${v?"bg-ink/8 font-medium text-ink":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,children:e("span",{className:"truncate",children:s.label})},b);if(s.url)return e("a",{href:s.url,target:"_blank",rel:"noopener noreferrer",title:s.url,className:"flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs text-ink/70 hover:bg-ink/5 hover:text-ink",children:[e("span",{className:"truncate",children:s.label}),e(Ce,{size:10,className:"flex-shrink-0 text-ink/30"})]},b);return e("div",{title:`Not in this wiki: ${s.target}`,className:"flex w-full items-center px-2.5 py-1 text-left text-xs text-ink/35 line-through decoration-ink/20",children:e("span",{className:"truncate",children:s.label})},b)}),p.notes.map((s,h)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${h}`))]},`${p.title??"links"}-${x}`))})]})}function q({open:c,onClick:t}){return e("button",{type:"button",onClick:t,title:"Browse wiki pages","aria-label":"Browse wiki pages","aria-expanded":c,className:"absolute bottom-3 right-3 z-20 flex h-9 w-9 items-center justify-center rounded-full border border-ink/20 bg-paper text-ink/60 shadow-sm transition-all hover:bg-ink/5 hover:text-ink active:scale-95",children:e(Gr,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:d}){if(i(()=>{if(!c)return;let k=(f)=>{if(f.key==="Escape")d()};return document.addEventListener("keydown",k),()=>document.removeEventListener("keydown",k)},[c,d]),!c)return null;return e(J,{onClose:d,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(Gr,{size:15,className:"flex-shrink-0 text-ink/50"}),e("span",{className:"text-sm font-medium",children:"Wiki pages"})]}),children:e("div",{className:"flex h-[60vh] min-h-0 flex-col",children:e(K,{sections:t,selected:l,onSelect:(k)=>{r(k),d()}})})})}function re(c,t){if(!c.webUrl)return null;let r=(t.split("/").pop()??t).replace(/\.(md|markdown)$/i,"");return c.provider==="gitlab"?`${c.webUrl.replace(/\/home$/,"")}/${encodeURIComponent(t.replace(/\.(md|markdown)$/i,""))}`:`${c.webUrl}/${encodeURIComponent(r)}`}function G({repo:c,entries:t,path:l,page:r,isLoading:d,error:k,rootPath:f,repoScope:p,onNavigate:x,onBack:s}){let h=re(c,l),v=u(()=>({path:l,entries:t,root:f,repo:p}),[l,t,f,p]);return e("div",{className:"flex h-full min-h-0 w-full flex-col bg-paper",children:[e("div",{className:"flex flex-shrink-0 items-center gap-1.5 border-b border-ink/10 px-2.5 py-1.5",children:[s&&e("button",{type:"button",onClick:s,title:"Back to the page list","aria-label":"Back to the page list",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink @[520px]:hidden",children:e(Vt,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),d&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),h&&e("a",{href:h,target:"_blank",rel:"noopener noreferrer",title:"Open this page on the wiki host","aria-label":"Open this page on the wiki host",className:"flex-shrink-0 rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:k?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:k})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:d?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(ee,{content:r.content,className:"max-w-none",wikiScope:v,onWikiNavigate:x}),r.truncated&&e("p",{className:"mt-4 border-t border-ink/10 pt-2 text-[11px] text-ink/50",children:"This page is longer than the reader's budget and was cut off."})]})})]})}function B(c,t){return`${c??""}\x00${t}`}function X(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function H(c){let{rootPath:t,repo:l,enabled:r,active:d,revisionKey:k=0}=c,f=B(t,l),[p,x]=n(null),s=o(f);s.current=f;let h=we(TA(f),{enabled:r&&d}),{refresh:v}=h;i(()=>{x(null)},[f]);let b=a((P)=>{if(!r)return;if(!P?.force){v();return}let y=s.current,R=X(t,l);R.set("refresh","1"),fetch(`/api/wiki?${R.toString()}`).then(async(w)=>{let N=await w.json();if(!w.ok)throw Error(N?.error||`Wiki request failed (${w.status})`)}).then(()=>{if(s.current!==y)return;x(null),v()}).catch((w)=>{if(s.current!==y)return;x(w instanceof Error?w.message:"Failed to load the wiki")})},[r,t,l,v]);return i(()=>{if(k>0)v()},[k]),{data:h.data,isLoading:h.isLoading,refreshing:h.refreshing,error:p,reload:b}}function Q(c){let{rootPath:t,repo:l,path:r,enabled:d,active:k,revisionKey:f=0}=c,p=`${B(t,l)}\x00${r??""}`,[x,s]=n({scope:p,data:null}),[h,v]=n(!1),[b,P]=n(null),y=o(0);return i(()=>{if(!d||!k||!r){s({scope:p,data:null}),P(null);return}let R=++y.current;v(!0);let w=X(t,l);w.set("path",r),fetch(`/api/wiki/page?${w.toString()}`).then(async(N)=>{let T=await N.json();if(!N.ok)throw Error(T?.error||`Page request failed (${N.status})`);return T}).then((N)=>{if(y.current!==R)return;s({scope:p,data:N}),P(null)}).catch((N)=>{if(y.current!==R)return;P(N instanceof Error?N.message:"Failed to load the page")}).finally(()=>{if(y.current===R)v(!1)})},[p,t,l,r,d,k,f]),{data:x.scope===p?x.data:null,isLoading:h,error:b}}function Y(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],d={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(d);continue}t.push({title:l.folder||"Pages",links:[d],notes:[]})}return t}var ae={"no-remote":"This repository has no origin remote, so there is no wiki to find.","unsupported-remote":"The origin remote is not a URL a wiki can be derived from.","no-wiki":"This project has no wiki (or Kabmo cannot read it).",unreachable:"The wiki could not be reached."};function Oe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:d=0,layout:k="desktop"}){let f=k==="phone",{activeRepo:p,setActiveRepo:x}=ir(r),{repos:s,scanning:h,rescan:v}=or(r,t),b=B(r,p),[P,y]=S("wiki.selectedPage",null),[R,w]=n(!1),[N,T]=n(!1),[Z,te]=n(0),g=H({rootPath:r,repo:p,enabled:t,active:l,revisionKey:d}),z=g.data?.entries??[],A=u(()=>z.filter((L)=>L.isMarkdown),[z]),M=u(()=>g.data?.sidebar??Y(z),[g.data?.sidebar,z]),ie=u(()=>M.some((L)=>L.links.length>0),[M]),_=P&&P.scope===b?P.path:null,E=u(()=>{if(_&&A.some((j)=>j.path===_))return _;return(A.find((j)=>j.title.toLowerCase()==="home")??A[0])?.path??null},[_,A]),O=Q({rootPath:r,repo:p,path:E,enabled:t,active:l,revisionKey:Z});i(()=>{if(!E||E===_)return;y({scope:b,path:E})},[E,_,b,y]),i(()=>{w(!1),T(!1)},[b]);let D=(L)=>{if(y({scope:b,path:L}),!f)T(!0)},ne=()=>{g.reload({force:!0}),te((L)=>L+1)},W=g.data?.repo??null,U=g.data&&!W?g.data:null;if(!t)return e("div",{className:`flex h-full flex-col items-center justify-center bg-paper text-ink/40 ${c}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});return e("div",{className:`@container flex h-full min-h-0 w-full flex-col bg-paper text-xs text-ink ${c}`,children:[e("div",{className:"flex flex-shrink-0 items-center justify-between gap-2 border-b border-ink/10 px-2 py-1.5",children:[e("div",{className:"flex min-w-0 items-center gap-1.5",children:[e(fr,{rootPath:r,activeRepo:p,onSelectRepo:x,repos:s,scanning:h,onRefreshRepos:v}),W&&e("span",{className:"flex-shrink-0 rounded border border-ink/15 bg-ink/5 px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-wider text-ink/60",title:`${W.host}/${W.slug} · ${W.revision.slice(0,8)}`,children:W.provider})]}),e("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:[W?.webUrl&&e("a",{href:W.webUrl,target:"_blank",rel:"noopener noreferrer",title:"Open the wiki on its host","aria-label":"Open the wiki on its host",className:"rounded p-1 text-ink/60 hover:bg-ink/5 hover:text-ink",children:e(Ce,{size:13})}),e("button",{type:"button",onClick:ne,disabled:g.isLoading,title:"Re-fetch the wiki","aria-label":"Re-fetch the wiki",className:"rounded p-1 text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink disabled:opacity-50",children:e(C,{size:13,className:g.isLoading||g.refreshing?"animate-spin":""})})]})]}),g.error&&!g.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(I,{size:16,className:"text-error"}),e("p",{className:"text-error",children:g.error}),e("button",{type:"button",onClick:()=>g.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!g.data?e("div",{className:"flex flex-1 items-center justify-center gap-2 text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Reading the wiki…"})]}):U?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(Yt,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:ae[U.reason??"no-wiki"]}),U.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:U.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${f?"hidden":N?"hidden @[520px]:flex":"flex"} min-h-0 w-full flex-col @[520px]:w-52 @[520px]:flex-shrink-0 @[520px]:border-l @[520px]:border-ink/10`,children:e(K,{sections:M,selected:E,onSelect:D})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${f?"flex":N?"flex":"hidden @[520px]:flex"} flex-col`,children:[W&&E?e(G,{repo:W,entries:z,path:E,page:O.data,isLoading:O.isLoading,error:O.error,rootPath:r,repoScope:p,onNavigate:D,onBack:f?void 0:()=>T(!1)}):e("div",{className:"flex h-full items-center justify-center px-6 text-center text-[11px] text-ink/40",children:"This wiki has no markdown pages."}),f&&ie&&e(q,{open:R,onClick:()=>w(!0)}),e(V,{open:R,sections:M,selected:E,onSelect:D,onClose:()=>w(!1)})]})]})]})}export{Oe as WikiPanel};