@kabmo-labs/kabmo 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +533 -518
  3. package/dist/client/static/js/{CsvGrid-60njj97j.js → CsvGrid-20k047ht.js} +2 -2
  4. package/dist/client/static/js/{DocxView-rsv0j46a.js → DocxView-qpvhfcmg.js} +5 -5
  5. package/dist/client/static/js/{DrawioView-n2g5df3a.js → DrawioView-178skky8.js} +2 -2
  6. package/dist/client/static/js/ImageView-460th5qa.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-5cv0dty8.js +2 -0
  8. package/dist/client/static/js/Modal-wks6p4r5.js +38 -0
  9. package/dist/client/static/js/{PdfView-1r7a0qkp.js → PdfView-y51g03nr.js} +1 -1
  10. package/dist/client/static/js/SessionsView-rsmvn7ks.js +1 -0
  11. package/dist/client/static/js/{SheetView-bt5pp042.js → SheetView-z7yvb05v.js} +25 -25
  12. package/dist/client/static/js/{SvgPreview-vfmqgmrx.js → SvgPreview-yehgzhem.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-8k5hk1yx.js → abnfDiagram-O67JEVCF-6zxpcy8b.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +1 -0
  15. package/dist/client/static/js/architectureDiagram-NJMV4G6O-m98sgh3c.js +36 -0
  16. package/dist/client/static/js/{astro-0rh34hha.js → astro-nn7xg0we.js} +1 -1
  17. package/dist/client/static/js/bash-fjzhxy10.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-04sbtdth.js → blockDiagram-BEXU5L5S-cp7rervg.js} +5 -5
  19. package/dist/client/static/js/c-wqtyezvw.js +1 -0
  20. package/dist/client/static/js/c4Diagram-YGBWAQC7-t31recqm.js +38 -0
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-18cc0bsb.js → classDiagram-v2-NBCMYWYE-fy8x3dkx.js} +5 -5
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dk683zvp.js → cose-bilkent-JH36ORCC-va7ybm9e.js} +1 -1
  23. package/dist/client/static/js/cpp-y0nzwner.js +1 -0
  24. package/dist/client/static/js/css-a13jmmnc.js +1 -0
  25. package/dist/client/static/js/css-n2waj098.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-m2sx8d8s.js → cynefinDiagram-VND7K2PF-4k0k429c.js} +2 -2
  28. package/dist/client/static/js/{dagre-6A5THRUB-qf3pr59p.js → dagre-6A5THRUB-ykdhxq6t.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-twnz23mt.js → diagram-22UHCM2B-5nvwx7b6.js} +8 -8
  30. package/dist/client/static/js/{diagram-3UASUU5V-417bas6t.js → diagram-3UASUU5V-hc7zsjgw.js} +1 -1
  31. package/dist/client/static/js/diagram-ATOU4E4O-97ae07y7.js +3 -0
  32. package/dist/client/static/js/diagram-CDSNMT55-b56nnbbs.js +30 -0
  33. package/dist/client/static/js/{diagram-MLGK6HIB-7a0h1hs3.js → diagram-MLGK6HIB-37rygr9k.js} +1 -1
  34. package/dist/client/static/js/{diagram-MPIPVDR6-w75bftmd.js → diagram-MPIPVDR6-wv3vhhfk.js} +2 -2
  35. package/dist/client/static/js/{dockerfile-g5qbaeq3.js → dockerfile-0efb1z6e.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-vdzm3tsv.js → ebnfDiagram-ZINNZB2B-13fv7vxg.js} +1 -1
  37. package/dist/client/static/js/{elixir-gpez1k9m.js → elixir-mabagxwa.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-2fsbb484.js → elk-276RUBZZ-xam60ktz.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-vnkztq7d.js → erDiagram-OPXOYQCR-24ctv2ee.js} +6 -6
  40. package/dist/client/static/js/{erlang-jqqa3ehb.js → erlang-zwy7cqdk.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-pbvcch52.js → ganttDiagram-FUAMR5RP-766a8fqw.js} +2 -2
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-dkvktvzr.js → gitGraphDiagram-X574FWY7-fmwjkgh6.js} +2 -2
  46. package/dist/client/static/js/graphql-gvb7e2eb.js +1 -0
  47. package/dist/client/static/js/html-bwyt0ayy.js +1 -0
  48. package/dist/client/static/js/{index-rc8wrs2a.js → index-03pyvmcz.js} +2 -2
  49. package/dist/client/static/js/index-13dr1t1r.js +314 -0
  50. package/dist/client/static/js/{index-rebnv57p.js → index-13xbwcbz.js} +2 -2
  51. package/dist/client/static/js/{index-pbsm2vw7.js → index-1c0pnsjd.js} +2 -2
  52. package/dist/client/static/js/index-1rxa9zxp.js +1 -0
  53. package/dist/client/static/js/{index-c6kx7s6a.js → index-2hpy58d0.js} +2 -2
  54. package/dist/client/static/js/{index-f8pq132s.js → index-2x9eqztp.js} +1 -1
  55. package/dist/client/static/js/{index-pn91shfp.js → index-4cncqz8j.js} +2 -2
  56. package/dist/client/static/js/index-4j8rgr4p.js +1 -0
  57. package/dist/client/static/js/{index-x2kb1kx5.js → index-4mstdh41.js} +3 -3
  58. package/dist/client/static/js/index-4z4ax55k.js +12 -0
  59. package/dist/client/static/js/{index-55hq7tnj.js → index-6ge6gk9w.js} +1 -1
  60. package/dist/client/static/js/{index-re1xz433.js → index-7t63akyt.js} +1 -1
  61. package/dist/client/static/js/{index-zye9309h.js → index-8b3t2y77.js} +2 -2
  62. package/dist/client/static/js/index-8hgm0abr.js +474 -0
  63. package/dist/client/static/js/index-8jqawh3r.js +2 -0
  64. package/dist/client/static/js/index-95en3p3g.js +9 -0
  65. package/dist/client/static/js/{index-rdqn92tc.js → index-97qst4k9.js} +2 -2
  66. package/dist/client/static/js/{index-xfa5hswh.js → index-9vdbnvmk.js} +1 -1
  67. package/dist/client/static/js/{index-zfykeg7x.js → index-a9t9gdew.js} +9 -9
  68. package/dist/client/static/js/{index-ds6a2cx7.js → index-b4y5g48d.js} +5 -5
  69. package/dist/client/static/js/{index-hz177dr2.js → index-czagykbq.js} +2 -2
  70. package/dist/client/static/js/{index-yq9vnd1y.js → index-dfqmwm7j.js} +2 -2
  71. package/dist/client/static/js/{index-tgper3yy.js → index-dydwcp3n.js} +2 -2
  72. package/dist/client/static/js/{index-0c6vpk89.js → index-e1yz59fa.js} +2 -2
  73. package/dist/client/static/js/{index-ce4vytm6.js → index-e6any867.js} +2 -2
  74. package/dist/client/static/js/{index-j5ram1ve.js → index-ejdnjh5c.js} +2 -2
  75. package/dist/client/static/js/index-f4vr1c6e.css +1 -0
  76. package/dist/client/static/js/{index-cytks03p.js → index-feffxxss.js} +2 -2
  77. package/dist/client/static/js/{index-6fx2t6y7.js → index-grczkttn.js} +12 -12
  78. package/dist/client/static/js/{index-s78n0dtv.js → index-hga3e13s.js} +2 -2
  79. package/dist/client/static/js/{index-ajjq0b8y.js → index-hw14rhen.js} +2 -2
  80. package/dist/client/static/js/index-hzwr5fm9.js +4 -0
  81. package/dist/client/static/js/{index-sj4y8kj2.js → index-j17h4z6f.js} +2 -2
  82. package/dist/client/static/js/{index-a4ed3mks.js → index-ka2rc2cr.js} +5 -5
  83. package/dist/client/static/js/{index-djv15k5s.js → index-ktbrmp29.js} +2 -2
  84. package/dist/client/static/js/{index-3rymer2w.js → index-nbexks3x.js} +1 -1
  85. package/dist/client/static/js/{index-ngk9h0v9.js → index-nh29fkk9.js} +2 -2
  86. package/dist/client/static/js/{index-gn92c6hp.js → index-p0ez6hqd.js} +2 -2
  87. package/dist/client/static/js/{index-e7yf273s.js → index-pkes9492.js} +2 -2
  88. package/dist/client/static/js/{index-fg965t62.js → index-pysqpc5n.js} +2 -2
  89. package/dist/client/static/js/index-qj34r6d0.js +1 -0
  90. package/dist/client/static/js/{index-ntcqyqd5.js → index-qx6x4z0y.js} +2 -2
  91. package/dist/client/static/js/{index-agdbjh5k.js → index-r8cc80w5.js} +2 -2
  92. package/dist/client/static/js/{index-9dnkfpx4.js → index-rab39785.js} +2 -2
  93. package/dist/client/static/js/{index-haaz8t7e.js → index-sk9ej289.js} +2 -2
  94. package/dist/client/static/js/{index-9fnzcg2x.js → index-sq3r1xhf.js} +2 -2
  95. package/dist/client/static/js/{index-pfbyfab5.js → index-sx809d6d.js} +2 -2
  96. package/dist/client/static/js/{index-7w3gqw2b.js → index-sz3mxjvy.js} +1 -1
  97. package/dist/client/static/js/{index-4jk8ngjg.js → index-tqycj126.js} +2 -2
  98. package/dist/client/static/js/{index-0xaz2eyv.js → index-vcn1kcpy.js} +3 -3
  99. package/dist/client/static/js/{index-2z9wrb46.js → index-x7f5ysch.js} +2 -2
  100. package/dist/client/static/js/index-xe5cqwnf.js +1 -0
  101. package/dist/client/static/js/index-xxe52zrm.js +2 -0
  102. package/dist/client/static/js/{index-amawahyh.js → index-yvxa7hd8.js} +2 -2
  103. package/dist/client/static/js/{index-e6qjfcz9.js → index-z6kpc98a.js} +1 -1
  104. package/dist/client/static/js/{index-yzg9mbsv.js → index-zjydzxhm.js} +1 -1
  105. package/dist/client/static/js/{index-ne131hmw.js → index-zvazj4va.js} +2 -2
  106. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +1 -0
  107. package/dist/client/static/js/{infoDiagram-VRGFBTTK-mh6yks62.js → infoDiagram-VRGFBTTK-tqytmzp1.js} +1 -1
  108. package/dist/client/static/js/ini-2gvjwh83.js +1 -0
  109. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-hnfqppnv.js → ishikawaDiagram-OU5B5YK6-rp77ff6m.js} +1 -1
  110. package/dist/client/static/js/java-1xwcq79s.js +1 -0
  111. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-s4nv1f3q.js → journeyDiagram-ZHPQQLJL-c7bxrhf1.js} +2 -2
  112. package/dist/client/static/js/json-4pqjabgq.js +1 -0
  113. package/dist/client/static/js/jsx-wcsss15s.js +1 -0
  114. package/dist/client/static/js/{julia-yre4bxb9.js → julia-2eekpjq8.js} +1 -1
  115. package/dist/client/static/js/{kanban-definition-PNTS6WVX-t8kbfefp.js → kanban-definition-PNTS6WVX-j2pxewqq.js} +5 -5
  116. package/dist/client/static/js/lua-h7vjcn0h.js +1 -0
  117. package/dist/client/static/js/markdown-f30jjjh9.js +1 -0
  118. package/dist/client/static/js/{mermaid.core-0784021p.js → mermaid.core-cqqe1krg.js} +6 -6
  119. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-swkkze8c.js → mindmap-definition-NLK3R4M7-s03k32p9.js} +5 -5
  120. package/dist/client/static/js/one-dark-pro-9tt0a020.js +1 -0
  121. package/dist/client/static/js/one-light-5fg4r0ra.js +1 -0
  122. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +1 -0
  123. package/dist/client/static/js/{pegDiagram-GJSIUBJH-jqayzh7z.js → pegDiagram-GJSIUBJH-dfg2j0zc.js} +1 -1
  124. package/dist/client/static/js/{perl-weeskn1v.js → perl-5vxax0nr.js} +1 -1
  125. package/dist/client/static/js/{php-vf3045p9.js → php-hgrgdq63.js} +1 -1
  126. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +1 -0
  127. package/dist/client/static/js/{pieDiagram-5QR66LMP-w03a65ky.js → pieDiagram-5QR66LMP-pshd1j79.js} +1 -1
  128. package/dist/client/static/js/properties-ymexza6q.js +1 -0
  129. package/dist/client/static/js/python-31ycwa66.js +1 -0
  130. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-2j7sfa9s.js → quadrantDiagram-O4NWA36T-cvvvmtk2.js} +4 -4
  131. package/dist/client/static/js/r-t2nne4xp.js +1 -0
  132. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +1 -0
  133. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +1 -0
  134. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +1 -0
  135. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +1 -0
  136. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +1 -0
  137. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-jtkkgy34.js → railroadDiagram-XR7U4H2S-h53p3sha.js} +1 -1
  138. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-t85ckjdb.js → requirementDiagram-PLB6GJNP-bdv2fkxd.js} +4 -4
  139. package/dist/client/static/js/{ruby-1a2ryzy6.js → ruby-8pxcn21w.js} +1 -1
  140. package/dist/client/static/js/{rust-736r0f0v.js → rust-j80dxgjg.js} +1 -1
  141. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-5pfkw8ne.js → sankeyDiagram-IPEJSGJF-xqnnvmhy.js} +2 -2
  142. package/dist/client/static/js/{sass-tq4vw7hd.js → sass-bm32bb5k.js} +1 -1
  143. package/dist/client/static/js/{scss-x7ddw6gb.js → scss-e2dndbfa.js} +1 -1
  144. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-55vs9zv5.js → sequenceDiagram-PO4LG4MO-3p67305f.js} +10 -10
  145. package/dist/client/static/js/{sizeCapture-INFHLROL-pzqqd7f4.js → sizeCapture-INFHLROL-f87525h7.js} +1 -1
  146. package/dist/client/static/js/sql-bwnasywx.js +1 -0
  147. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-6nhrph8n.js → stateDiagram-v2-GCMORJYK-e5st1fy3.js} +6 -6
  148. package/dist/client/static/js/{svelte-0hv6pak2.js → svelte-ztkaww47.js} +1 -1
  149. package/dist/client/static/js/{swimlanes-2SLR337P-6tcnxfbv.js → swimlanes-2SLR337P-ceghkbez.js} +1 -1
  150. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-vc8hvfya.js +8 -0
  151. package/dist/client/static/js/{timeline-definition-EJHVYXUP-1dz46nt5.js → timeline-definition-EJHVYXUP-f7evs443.js} +2 -2
  152. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +1 -0
  153. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +1 -0
  154. package/dist/client/static/js/tsx-zfy727zs.js +1 -0
  155. package/dist/client/static/js/typescript-p3syh43m.js +1 -0
  156. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-b3jfveq6.js → usecaseDiagram-POWQR4AR-0gpn21p7.js} +27 -27
  157. package/dist/client/static/js/{vennDiagram-UO4OBE2U-dnc3jqvp.js → vennDiagram-UO4OBE2U-4spzy428.js} +1 -1
  158. package/dist/client/static/js/{vue-zccj3qa5.js → vue-xm1dxpmy.js} +1 -1
  159. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +1 -0
  160. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-466m8400.js → wardleyDiagram-VNRHLVJA-745xr2pa.js} +4 -4
  161. package/dist/client/static/js/xml-4enq788a.js +1 -0
  162. package/dist/client/static/js/xychartDiagram-PMCCYNJV-7dr9qwx5.js +7 -0
  163. package/dist/client/static/js/yaml-pjtt3jsc.js +1 -0
  164. package/package.json +1 -1
  165. package/src/client/components/common/batch-selection/folder-state.ts +2 -2
  166. package/src/client/components/common/server-control/Panel.tsx +16 -5
  167. package/src/client/components/common/server-control/index.test.tsx +63 -9
  168. package/src/client/components/common/session-row/TrailingSlot.tsx +8 -0
  169. package/src/client/components/common/session-row/index.tsx +16 -9
  170. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +1 -1
  171. package/src/client/components/layout/session-sidebar/ClassicView.tsx +13 -0
  172. package/src/client/components/layout/session-sidebar/HarnessFilter.tsx +175 -0
  173. package/src/client/components/layout/session-sidebar/SessionList.tsx +9 -1
  174. package/src/client/components/layout/session-sidebar/SessionsView.tsx +6 -0
  175. package/src/client/components/layout/session-sidebar/harness-filter.test.tsx +173 -0
  176. package/src/client/components/layout/session-sidebar/modern/FilterChips.tsx +63 -18
  177. package/src/client/components/layout/session-sidebar/modern/SearchField.tsx +1 -1
  178. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +21 -12
  179. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +1 -1
  180. package/src/client/components/layout/session-sidebar/modern/index.tsx +11 -2
  181. package/src/client/components/layout/session-sidebar/modern/search-field.test.tsx +96 -0
  182. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +3 -0
  183. package/src/client/components/layout/session-sidebar/variant-props.ts +7 -0
  184. package/src/client/components/mobile/SessionSidebar.tsx +14 -25
  185. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +19 -0
  186. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +1 -1
  187. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +1 -1
  188. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.image.test.ts +147 -0
  189. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +51 -83
  190. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +44 -63
  191. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadDirectory.tsx +72 -0
  192. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ReadImage.tsx +51 -0
  193. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/read-test-util.ts +91 -0
  194. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +80 -62
  195. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +15 -33
  196. package/src/client/components/workspace/git-panel/commit-modal/Header.tsx +1 -1
  197. package/src/client/components/workspace/terminal-panel/copy.test.ts +179 -0
  198. package/src/client/components/workspace/terminal-panel/copy.ts +76 -0
  199. package/src/client/components/workspace/terminal-panel/mount.ts +13 -0
  200. package/src/client/data/settings/omp-schema.json +39 -18
  201. package/src/client/hooks/chat/omp/pending-child.test.ts +1 -1
  202. package/src/client/hooks/chat/omp/session-sidebar-controller.test.ts +61 -0
  203. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +37 -39
  204. package/src/client/hooks/chat/omp/sidebar-filter.ts +62 -0
  205. package/src/client/hooks/chat/timeline/session-changes.test.ts +85 -0
  206. package/src/client/hooks/chat/timeline/session-changes.ts +8 -5
  207. package/src/client/hooks/shell/servers.ts +60 -2
  208. package/src/client/hooks/ui/updates/mobile-flow.ts +56 -0
  209. package/src/client/tailwind.css +58 -0
  210. package/src/server/lib/harness/acp/commands.test.ts +1 -0
  211. package/src/server/lib/harness/acp/commands.ts +12 -4
  212. package/src/server/lib/harness/acp/replay-transcript.ts +32 -13
  213. package/src/server/lib/harness/acp/session-transcript.server.test.ts +162 -0
  214. package/src/server/lib/harness/acp/session-transcript.server.ts +350 -0
  215. package/src/server/lib/harness/acp/session.ts +6 -1
  216. package/src/server/lib/harness/schema.server.ts +18 -0
  217. package/src/server/lib/harness/spawn.server.ts +14 -1
  218. package/src/server/lib/models/provider-icon-fetch.ts +2 -2
  219. package/src/server/lib/models/provider-icon-parse.test.ts +0 -12
  220. package/src/server/lib/models/provider-icon-parse.ts +0 -8
  221. package/src/server/lib/omp/rpc/frame-fold.test.ts +16 -1
  222. package/src/server/lib/omp/rpc/frame-fold.ts +17 -4
  223. package/src/server/lib/omp/session/blobs.server.test.ts +34 -0
  224. package/src/server/lib/omp/session/blobs.server.ts +8 -3
  225. package/src/server/lib/omp/session/delete.server.ts +4 -0
  226. package/src/server/lib/omp/session/sidebar-activity.server.test.ts +2 -1
  227. package/src/server/routes/agent/harness-command.test.ts +71 -0
  228. package/src/server/routes/agent/harness-command.ts +27 -13
  229. package/src/server/routes/chat/imported.ts +5 -2
  230. package/src/server/routes/chat/live-meta.ts +42 -0
  231. package/src/server/routes/chat/session.test.ts +110 -0
  232. package/src/server/routes/chat/session.ts +31 -34
  233. package/src/shared/lib/chat/transcript-rows.ts +22 -0
  234. package/src/shared/lib/fs/file-kind.test.ts +46 -3
  235. package/src/shared/lib/fs/file-kind.ts +40 -9
  236. package/src/shared/lib/omp/config/schema-releases.test.ts +29 -0
  237. package/src/shared/lib/workspace/harness-filter.test.ts +89 -0
  238. package/src/shared/lib/workspace/harness-filter.ts +75 -0
  239. package/src/{client/lib → shared/lib/workspace}/session-tree.test.ts +1 -1
  240. package/src/shared/lib/workspace/session-visibility.test.ts +71 -0
  241. package/src/shared/lib/workspace/session-visibility.ts +48 -23
  242. package/src/shared/lib/workspace/sidebar-filter-row.test.ts +64 -23
  243. package/src/shared/lib/workspace/sidebar-filter-row.ts +89 -31
  244. package/dist/client/static/js/ImageView-t330jx6y.js +0 -1
  245. package/dist/client/static/js/LayoutWrapper-qp6nsw65.js +0 -2
  246. package/dist/client/static/js/Modal-sbya4ahp.js +0 -38
  247. package/dist/client/static/js/SessionsView-yqs5m8tj.js +0 -1
  248. package/dist/client/static/js/architecture-7GRP2DOG-1wqga929.js +0 -1
  249. package/dist/client/static/js/architectureDiagram-NJMV4G6O-7jcb7fgy.js +0 -36
  250. package/dist/client/static/js/bash-vv2ysp0a.js +0 -1
  251. package/dist/client/static/js/c-67jyc7sg.js +0 -1
  252. package/dist/client/static/js/c4Diagram-YGBWAQC7-vwac9za0.js +0 -38
  253. package/dist/client/static/js/cpp-crfbnwv8.js +0 -1
  254. package/dist/client/static/js/css-2re5mbea.js +0 -1
  255. package/dist/client/static/js/css-983fbv00.js +0 -1
  256. package/dist/client/static/js/cynefin-OW5HDTMX-j2dpdgkh.js +0 -1
  257. package/dist/client/static/js/diagram-ATOU4E4O-n63cpdnx.js +0 -3
  258. package/dist/client/static/js/diagram-CDSNMT55-v86p14dd.js +0 -30
  259. package/dist/client/static/js/eventmodeling-NTZA5JFV-xjvjawd3.js +0 -1
  260. package/dist/client/static/js/flowDiagram-KWPJA3E3-j21f2bfg.js +0 -1
  261. package/dist/client/static/js/gitGraph-4MIJSDKK-r0zbk95f.js +0 -1
  262. package/dist/client/static/js/graphql-npbd9fdx.js +0 -1
  263. package/dist/client/static/js/html-1cpe2xc8.js +0 -1
  264. package/dist/client/static/js/index-1sw00wm0.js +0 -2
  265. package/dist/client/static/js/index-7fwppdkn.js +0 -1
  266. package/dist/client/static/js/index-ae91g8ka.js +0 -9
  267. package/dist/client/static/js/index-b6cyn4hr.js +0 -314
  268. package/dist/client/static/js/index-efn233xp.js +0 -4
  269. package/dist/client/static/js/index-esx3zwnt.js +0 -1
  270. package/dist/client/static/js/index-fbbp5cwj.js +0 -2
  271. package/dist/client/static/js/index-g1cggqgx.js +0 -12
  272. package/dist/client/static/js/index-ghsdzs4m.js +0 -1
  273. package/dist/client/static/js/index-gs7ytgdw.js +0 -474
  274. package/dist/client/static/js/index-jqs23cc7.css +0 -1
  275. package/dist/client/static/js/index-qjsy6p86.js +0 -1
  276. package/dist/client/static/js/info-A6RAGUB7-a8xap43w.js +0 -1
  277. package/dist/client/static/js/ini-df5bw23e.js +0 -1
  278. package/dist/client/static/js/java-8j33rj1p.js +0 -1
  279. package/dist/client/static/js/json-g5ggnd94.js +0 -1
  280. package/dist/client/static/js/jsx-f6p72qpc.js +0 -1
  281. package/dist/client/static/js/lua-bahx6qze.js +0 -1
  282. package/dist/client/static/js/markdown-9dhg1fax.js +0 -1
  283. package/dist/client/static/js/one-dark-pro-h5tmw145.js +0 -1
  284. package/dist/client/static/js/one-light-x7vj1pxr.js +0 -1
  285. package/dist/client/static/js/packet-AYTQ26CC-b5bvg6v1.js +0 -1
  286. package/dist/client/static/js/pie-WAS4IAKB-77ee73zg.js +0 -1
  287. package/dist/client/static/js/properties-49mfnee4.js +0 -1
  288. package/dist/client/static/js/python-qb69wp1s.js +0 -1
  289. package/dist/client/static/js/r-s3mf2tch.js +0 -1
  290. package/dist/client/static/js/radar-RG4KPBEZ-cp79xtvb.js +0 -1
  291. package/dist/client/static/js/railroad-74A4TZTK-dcpgqhcb.js +0 -1
  292. package/dist/client/static/js/railroad-abnf-HS5TGJTU-qasqv686.js +0 -1
  293. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-e46908rd.js +0 -1
  294. package/dist/client/static/js/railroad-peg-WCYAUIDC-7009t6bk.js +0 -1
  295. package/dist/client/static/js/sql-aczp05f2.js +0 -1
  296. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-7xrkrkpa.js +0 -8
  297. package/dist/client/static/js/treeView-Q6P3EWNA-tpn62q8j.js +0 -1
  298. package/dist/client/static/js/treemap-WGGIJYW6-w910f1g4.js +0 -1
  299. package/dist/client/static/js/tsx-s1shkfg9.js +0 -1
  300. package/dist/client/static/js/typescript-htx9v6bf.js +0 -1
  301. package/dist/client/static/js/wardley-WFR3VGLG-pt9tq808.js +0 -1
  302. package/dist/client/static/js/xml-wr1dxav5.js +0 -1
  303. package/dist/client/static/js/xychartDiagram-PMCCYNJV-kryrpqp1.js +0 -7
  304. package/dist/client/static/js/yaml-0y9fdskg.js +0 -1
  305. /package/src/{client/lib → shared/lib/workspace}/session-tree.ts +0 -0
@@ -1,3 +1,3 @@
1
- import{d,n,o,W,i,u,a,Ue,oe,e,Kn,Ze,Se,S,s,E,m,en,_,f,B,re,tt,fe,Et,qe,ai,ln,Yr,D,O,b,Zr,Ve,pe,gr,J,it,Vs,_o,Ys,Js,To,KA,sh,Rm,ol,Re,ae,Yt,T,ye,mi,lf,Ag}from"./index-gs7ytgdw.js";import{kt,Ai,nu,ru,ou,fs,hi,Bd}from"./index-fbbp5cwj.js";import{Mc,Ad,hd,kg,xg,Pc,nr,us,Oc,$c,zc,Uc,Gc,ds,Uo,ps,gi,qc,ml,fl,Hc,Wc,Kc,Vc,Yc,Jc,Zc,Xc,eu}from"./index-g1cggqgx.js";import{Qa,Na,yi}from"./index-pfbyfab5.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"}]]},Be=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 ie=new Set,De=new Set,ze=new Set;function He(){ze=new Set(ie);for(let t of[...De])t()}function $e(t){let r=new Set(t);if(r.size===ie.size){let l=!0;for(let c of r)if(!ie.has(c)){l=!1;break}if(l)return}ie.clear();for(let l of r)ie.add(l);He()}function We(t){let r=new Set(t),l=!1;for(let c of[...ie])if(!r.has(c))ie.delete(c),l=!0;if(l)He()}function Ke(t){return ie.has(t)}function _e(){return ie.size>0}function vn(t){return De.add(t),()=>{De.delete(t)}}var yn=vn;function Ge(){return Ue(yn,()=>ze)}function Xe({x:t,y:r,rows:l,onAction:c,onClose:p}){let h=i(null),[v,g]=n({left:t,top:r});return W(()=>{let y=h.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();g({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:h,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:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var ge={rightFileId:null,fraction:0.5};function Ce(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 ue(t){if(!Number.isFinite(t))return ge.fraction;return Math.max(0.2,Math.min(0.8,t))}function Je(t,r){if(typeof t!=="object"||t===null)return ge;let l=t,c=typeof l.fraction==="number"?ue(l.fraction):ge.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:h}){let v=r.filter((x)=>x.id!==t.id),g=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Ce(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:h!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:g.some((x)=>x.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((x)=>x.enabled)}function nt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:h,onRevealInFiles:v,onReopenClosed:g,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null}){let I=Ge(),C=i(null),M=i(null),[z,V]=n(5),[H,F]=n(!1),[L,U]=n(null);pe(M,()=>F(!1)),o(()=>{let N=new ResizeObserver((R)=>{for(let P of R){let Q=P.contentRect.width,X=Math.max(1,Math.floor((Q-60)/150));V(X)}});if(C.current)N.observe(C.current);return()=>N.disconnect()},[]);let A=Ye(r,t.map((N)=>N.id)),G=[],Z=[];if(t.length<=z)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>=z)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:C,children:[e("div",{className:"flex overflow-hidden",children:G.map((N)=>{let R=N.id===r,P=Boolean(N.isDiff),Q=P?Kn(N.diffStatus||"M",N.diffStaged):null,X=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(j)=>{j.preventDefault(),U({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(ai,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(it,{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:I.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:I,reopenable:y?.()??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(!I.has(P.id))c(P.id);return;case"copy-path":h?.(R);return;case"reveal-in-files":v?.(R);return;case"reopen-closed":g?.();return;case"split-right":w?.(R.id);return;case"unsplit":x?.();return}},onClose:()=>U(null)}):null,e("div",{className:"ml-auto flex items-center",children:e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(A),disabled:k===null&&A===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":A===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(Yr,{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 ${H?"bg-ink/10 text-ink":""}`,onClick:()=>F(!H),title:"More open files",children:e(B,{size:14})}),H&&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),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(ai,{size:14,className:"text-info/80"}):e(it,{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:I.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Z.length===1)F(!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 Ee({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(_,{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:`${nr} 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:ln,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(us,{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(ln,{size:14})})}]}function at(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?Et:qe,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(us,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(Et,{size:14}):e(qe,{size:14})})}]}function st(t){let r=[];if(r.push(...ot(t),...rt(t),...at(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:O,onSelect:t.onToggleFind,active:t.findOpen}],children:e(us,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(O,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:en,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(us,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(en,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:Be,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(us,{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(Be,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Na,onSelect:t.onZoomOut},{label:"Increase font size",icon:Qa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Na,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Qa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${nr} 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(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:fe,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(fe,{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:h,isReviewing:v,copied:g,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:I=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:z,onSave:V,onTogglePreview:H,onToggleReview:F,onToggleWordWrap:L,onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:X,onToggleMaximize:j}){let ne=w?I?"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":x?"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)",ce=e("button",{type:"button",onClick:V,disabled:w||r==="saving",className:`${nr} hover:bg-ink/5`,title:ne,"aria-label":ne,children:r==="saving"?e(kt,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(kt,{size:14,className:"text-warning"}):e(kt,{size:14,className:"hover:text-ink"})}),ee=C?"Exit full screen":"Full screen",te=e("button",{type:"button",onClick:j,className:`${nr} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:ee,"aria-label":ee,"aria-pressed":C,children:C?e(we,{size:14}):e(xe,{size:14})}),me=Bd(),se=Ad(),le=st({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:h,isReviewing:v,blameInline:me.inline,findOpen:M,copied:g,isMaximized:C,saveDisabled:w,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:ce,maximizeButton:te,viewModeButtons:e(hd,{size:14}),viewModeActions:se,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:g?"Copied":y?"Copy image":"Copy content",maximizeLabel:ee,onTogglePreview:H,onToggleReview:F,onToggleFind:z,onToggleWordWrap:L,onToggleBlameInline:()=>{let be={...hi(),inline:!me.inline};Zr({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(fs,{detail:be}))},onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,onSaveAs:X,onToggleMaximize:j,onSave:V});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(yi,{clusters:le,className:"text-ink/40 ml-auto"})]})}function dt({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:h,onScroll:v}){return e("div",{ref:h,onScroll:v,"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(Oc,{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:h,byteViewer:v,viewerKind:g,lineCount:y,conflicts:w=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:v?e("span",{className:"uppercase",children:Uo[g]}):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:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:h})]})]})}function kn(t){if(t===0)return 0;return Math.max(-1,Math.min(1,-Math.sign(t)))}function Sn(t,r,l=Ys,c=Js){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){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(h)=>{if(!h.ctrlKey&&!h.metaKey)return;if(h.preventDefault(),Cn(h.target,c))return;let v=kn(h.deltaY);if(v===0)return;r((g)=>Sn(g,v))};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(""),h=i(null);o(()=>{h.current?.focus(),h.current?.select()},[]);let v=()=>{let w=ut(c,t);if(w===null)return;r(w)},g=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=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:h,value:c,onInput:(w)=>p(w.target.value),onKeyDown:g,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:v,disabled:y===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&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===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),[h,v]=n({key:"",value:ft}),g=i(t);g.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(h);k.current=h;let I=i(0),C=i(""),M=i(new Map),z=i(new Set),V=a(async()=>{let A=g.current;if(!A?.path)return;let G=bt(A),Z=++I.current;C.current=G,v((R)=>({key:G,value:{status:"loading",payload:R.key===G?R.value.payload:null,message:null}}));let N=new URLSearchParams({blame:"1",file:A.path,repo:A.repo||"."});if(A.root)N.set("root",A.root);try{let R=await fetch(`/api/fs/git?${N.toString()}`),P=await R.json().catch(()=>null);if(Z!==I.current)return;if(!R.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${R.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(R){if(Z!==I.current)return;v({key:G,value:{status:"error",payload:null,message:R instanceof Error?R.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),H=a(async(A)=>{let G=M.current.get(A);if(G)return G;let Z=g.current;if(!Z?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:Z.path,line:String(A),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(A,Q),Q}catch{return{entries:[],truncated:!1}}},[]),F=i(null);if(!F.current)F.current={ensure:()=>{if(!w.current||x.current)return;let A=k.current;if(A.key===y.current&&A.value.status!=="idle")return;if(C.current===y.current)return;V()},reload:()=>{M.current.clear(),V()},history:H,snapshot:()=>{let A=k.current;return A.key===y.current?A.value:ft},stale:()=>x.current,subscribe:(A)=>(z.current.add(A),()=>{z.current.delete(A)})};o(()=>{if(!l||c||!p)return;M.current.clear(),V()},[l,c,p,V]);let L=i(c);return o(()=>{if(L.current===c)return;L.current=c;for(let A of z.current)A()},[c]),o(()=>{for(let A of z.current)A()},[h]),F.current}var En="0".repeat(40);function Te(t){return t===En}function he(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 h=Math.floor(p/24);if(h<30)return`${h}d ago`;let v=Math.floor(h/30);if(v<12)return`${v}mo ago`;return`${Math.floor(h/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 wt="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",yt="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",xt="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",Me="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?St(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Te(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function St(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=wt;let l=Dn(r);if(l){let w=q("div",vt);if(w.append(q("span",yt,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",xt,l.body));return}let c=r.payload;if(!c){t.append(q("p",xt,"Reading blame…"));return}let p=St(c,r.line),h=q("div",vt);if(h.append(q("span",yt,p.author.trim()||"Unknown"),q("span",Tn,he(p.time))),t.append(h),p.summary)t.append(q("p",Mn,p.summary));let v=q("div",`${Rn} ${Nn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",Bn(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let g=q("button",Pn);if(g.type="button",g.setAttribute("aria-expanded",r.historyOpen?"true":"false"),g.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(g),!r.historyOpen)return;let y=q("ol",Ln);if(r.historyLoading)y.append(q("li",`${Me} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Me} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let I=q("li",Me),C=k===w.length-1?"new":"edit";I.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",he(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(I)}),r.history.truncated)y.append(q("li",`${Me} text-ink/40`,"Older commits are not shown."))}t.append(y)}function Ct(t,r,l){let c=q("div",wt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,h=!1,v=!1,g=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:h,historyLoading:v}},y=()=>{On(c,g());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),h=!h,y(),!h||p||v)return;v=!0,y(),r.history(t).then((I)=>{p=I,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,I=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,z=c.offsetHeight||120,V=8,H=Math.max(8,Math.min(x.left,I-M-8)),F=x.bottom+6,L=x.top-z-6,U=F+z>C-8&&L>8?L:F;c.style.left=`${H}px`,c.style.top=`${Math.max(8,U)}px`},destroy(){w(),c.remove()}}}function Tt(t){return ye.define((r)=>{let l=null,c=0,p,h=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let z=C.getBoundingClientRect();if(z.width>0)return{left:z.left,top:z.top,bottom:z.bottom};let V=r.state.doc.line(Math.min(M,r.state.doc.lines)),H=null;try{H=r.coordsAtPos(V.from)}catch{H=null}if(H)return H;let F=r.scrollDOM.getBoundingClientRect();return{left:F.left,top:F.top+24,bottom:F.top+24}},g=(C,M)=>{if(c===C&&l)return;h(),c=C,l=Ct(C,t,()=>{t.reload(),h()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,z=M?.closest?.(".cm-blame-label");if(z){let F=Number(z.dataset.blameLine);return Number.isInteger(F)&&F>0?{line:F,anchor:z}:null}let V=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!V)return null;let H=Number((V.textContent??"").trim());return Number.isInteger(H)&&H>0?{line:H,anchor:V}:null},w=(C)=>{let M=y(C);if(!M)return;g(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),g(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))h()},k=(C)=>{if(C.key==="Escape"&&l)h(),C.stopPropagation()},I=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(h,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",I),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)h()},destroy(){h(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",I),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Mt=40,Rt=ae.define();function An(t){return Re.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||Te(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${he(c.time)}`}class Pt extends Yt{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 h=Math.min(c.lines,r.state.doc.lines);if(h<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,g=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Mt),w=Math.min(h,g+Mt),x=[];for(let k of c.runs){let I=Math.max(k.from,y);if(I>k.to||I>w)continue;let C=In(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],z=r.state.doc.line(I);x.push({from:z.to,deco:T.widget({widget:new Pt(z.number,C,M.summary||M.sha),side:1})})}return T.set(x.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 h=t.snapshot();r.dispatch({effects:Rt.of({payload:h.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:h=null,repoPath:v=null,onRunCommand:g,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:I,viewerKind:C,isPreview:M,reviewActive:z,onToggleReview:V,revealActive:H}){let F=C==="markdown",L=ru(),U=ou(),A=Bd(),G=gt({name:t.name,path:t.path,root:t.root??h??void 0,repo:t.repo??v??"."},{enabled:A.enabled,dirty:r.isDirty}),Z=u(()=>A.enabled?Lt({controller:G,inline:A.inline}):null,[A.enabled,A.inline,G]),[N,R]=n(null),P=u(()=>$c(r.content),[r.content]),[Q,X]=n(!1);o(()=>{if(p>0)X(!0)},[p]);let[j,ne]=n(null),[ce,ee]=n(null);mt(j,x);let te=ol({tabKey:String(t.id),surface:F&&M?"rendered":"code",ready:r.loaded,element:F&&M?void 0:j}),me=a((se)=>{te.ref(se),ee(se)},[te.ref]);return Gc({path:t.path,scroller:ce,preview:F&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(Uc,{find:l}):null,Q?e(pt,{lineCount:r.content?r.content.split(`
2
- `).length:1,onGo:(se)=>{X(!1);let le=gr(r.content,se-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>X(!1)}):null,F&&M?e(dt,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:z,onExitReview:V,scrollRef:me,onScroll:te.onScroll}):e(zc,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:y,documentKey:String(t.id),marks:l.open||H?l.matches:void 0,currentMark:l.currentIndex,onCommand:g,onScroller:ne,onCaret:R,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:Z,themeVars:I.vars,themes:I.themes,indentUnitText:nu(L),typing:U,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${w}px`,lineHeight:Vs}}),!F||!M?e(ct,{caret:N,eol:r.eol,onSetEol:r.setEol,indentWidth:L.width,insertSpaces:L.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:C,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:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N}){let R=g==="image"||g==="pdf"||g==="docx"||g==="spreadsheet",P=ds[g]===!0,Q=a(async(X)=>{let j=await Wc(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:h,hasPreview:P,isPreview:y,hasReview:g==="markdown"&&y,isReviewing:w,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:x,onToggleWordWrap:()=>v(!h),onZoomIn:()=>M((X)=>Math.min(Js,X+1)),onZoomOut:()=>M((X)=>Math.max(Ys,X-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:V,canReload:fl(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>I(!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(_,{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(Ee,{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(_,{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(_,{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(gi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(ml,{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(Mc,{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(_,{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(xg,{view:p}):qc(g)&&(R||y)?e(ml,{kind:g,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:z,rootPath:H,repoPath:F,onRunCommand:L,wordWrap:h,zoomLevel:C,setZoomLevel:M,editorFontFamily:U,editorTheme:A,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:g,revealActive:Z})]})}function Ot({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,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(Pc,{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:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H,repoPath:F,runCommand:L,editorFontFamily:U,editorTheme:A,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(Ve,{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(it,{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=i(r);l.current=r;let c=i(null);o(()=>{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:h}){o(()=>{let v=new Set(t.filter((g)=>!g.isDiff&&g.content===void 0).map((g)=>g.id));$e([...r].filter((g)=>v.has(g)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!ds[ps(l.name)])return;let g=Se(h,"editor.previewMode");if(g&&g[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Ht({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ee,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(Zc,{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),h=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:h??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:h??"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 Kt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:h,onSaved:v,onClose:g}){let[y,w]=n(()=>Hn(r)),[x,k]=n(()=>Vt(t)),[I,C]=n(!1),[M,z]=n(null),V=i(null);o(()=>{V.current?.focus(),V.current?.select()},[]);let H=Wt(x),F=async()=>{if(!H||I)return;C(!0),z(null);let U=await $t({parent:y,name:x,content:l,eol:c,root:p,repo:h});if(C(!1),U.status==="written"){v({path:U.path});return}z(U.reason)},L=(U)=>{if(U.key==="Enter"){U.preventDefault(),F();return}if(U.key==="Escape")U.preventDefault(),g()};return e(J,{onClose:g,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:g,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 F(),disabled:!H||I,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:[I?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:y,onInput:(U)=>w(U.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:V,value:x,onInput:(U)=>k(U.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!H,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${H?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!H?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 Ut(){o(()=>{let t=(r)=>{if(!_e())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function _t({fileName:t,onAnswer:r}){return e(J,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(_,{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 Gt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(_t,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(Xc,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function qt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:h,activeFile:v,editor:g,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:I,saveAsOpen:C,onSaveAsClose:M,onSavedAs:z,closeGuard:V}){let H=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:H,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:h,e(Ht,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),I,C&&v?e(Kt,{fileName:v.name,filePath:v.path,content:g.content,eol:g.eol,root:v.root,repo:v.repo,onSaved:({path:F})=>z(F),onClose:M}):null,e(Gt,{closeGuard:V,activeFile:v,saveMissingConfirm:g.saveMissingConfirm,onCancelSaveMissing:g.cancelSaveMissing,onConfirmSaveMissing:g.confirmSaveMissing})]})}function Zt({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 Xt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:h}){let v=i(null),g=i(null),y=Rm(g),w=(x)=>{let k=x.currentTarget,I=v.current;if(!k||!I)return;k.setPointerCapture(x.pointerId);let C=(z)=>{let V=I.getBoundingClientRect();if(V.width===0)return;r(ue((z.clientX-V.left)/V.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,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(ue(t)*100)}%`},children:h}),e("div",{ref:g,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Zt,{fileName:l,onClose:c,children:p})})]})}function jt({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=S("editor.split",ge),h=t.map((k)=>k.id),v=je(Je(c,h),r),g=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Ce(k,r,h))return;p({...v,rightFileId:k})},[v,p,r,h]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:ue(k)}),[v,p]);return{rightFile:g,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function Jt({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let h=i(l);return h.current=l,{onKeyDownCapture:a((g)=>{let y=c.current;if(g.key==="Escape"){if(!y.open)return;g.preventDefault(),g.stopPropagation(),y.close();return}if((g.metaKey||g.ctrlKey)&&g.shiftKey&&g.code==="KeyT"){if(h.current?.())g.preventDefault(),g.stopPropagation();return}let w=KA(mi,g);if(!w||!lf(w))return;g.preventDefault(),g.stopPropagation(),p.current(w)},[])}}function Qt(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return Ag(p)},[]),{onFocusCapture:a(()=>{if(l.current)Ag(l.current)},[])}}function tn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[h,v]=n(null);Ut();let g=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&Ke(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=h;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[h,r,l,p,c]);return{requestClose:g,pending:h,answer:y}}function nn(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((h)=>h+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function $n({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v=0,onFileSaved:g,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:I,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:z=null,forcedActiveFileId:V=null,asSplitPane:H=!1}){let F=H?V:l,L=r.find((K)=>K.id===F),[U,A,G]=S("editor.previewMode",{}),Z=eu(String(F??"")),[N,R]=S("editor.zoomLevel",_o),[P,Q]=n(!1),[X,j]=S("editor.wordWrap",!0),ne=nn(),{sessionId:ce}=Ze(),ee=jt({openedFiles:r,activeFileId:F,enabled:!H}),te=i(null),me=To(),se=Ai(),le=Hc(r,v),be=Boolean(L&&le.has(L.id)),Y=Kc(L??null,{reportSaveError:!0,onFileSaved:g,missing:be}),on=kg({path:L?.path??"",content:Y.content,language:Y.language}),rn=Y.diskChange,Oe=tn({openedFiles:r,activeFileId:F,onSelectFile:c,onCloseFile:p,saveNow:Y.saveNow}),ve=Vc({text:Y.content,documentKey:`${L?.id??""}\x00${Y.language}`,readSelection:()=>te.current?.getSelection()??null,select:(K,de,Le=!0)=>te.current?.select(K,de,Le),reveal:(K)=>te.current?.revealOffset(K),applyDocument:(K,de,Le)=>te.current?.applyDocument(K,de,Le),toggleWordWrap:()=>j((K)=>!K)}),Ae=Yc(L?.path??null,Y.content,Y.loaded&&!Y.loadError);Ft({searchReveal:Ae,revealMatch:ve.revealMatch}),Jc({file:L,editor:Y,surfaceRef:te,isPreview:L?U[L.id]===!0:!1,exitPreview:()=>{let K=L?.id;if(K===void 0||K===null)return;A((de)=>({...de,[K]:!1}))}}),o(()=>{if(v>0)Y.reset()},[v]),o(()=>{Y.retain(r.map((K)=>K.id)),We(r.map((K)=>K.id))},[r]),zt({openedFiles:r,dirtyKeys:Y.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:A,sessionId:ce});let an=()=>{if(!L)return;A((K)=>({...K,[L.id]:!K[L.id]}))},Ne=(K)=>{if(lf(K)){ve.runCommand(K);return}if(K==="toggleWordWrap"){j((de)=>!de);return}if(K==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(K)},sn=Jt({find:ve,runCommand:Ne,reopenClosed:w}),dn=Qt({saveNow:Y.saveNow,runCommand:Ne}),Pe=sh(z);if(Pe)return e(At,{pluginId:Pe.pluginId,Component:Pe.Component,sessionId:ce,className:t});if(r.length===0)return e(It,{className:t});let cn=Y.viewerKind,Ie=L?U[L.id]:!1,mn={activeFile:L,editor:Y,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:X,setWordWrap:j,viewerKind:cn,isPreview:Boolean(Ie),isReviewing:Boolean(Ie)&&Z.active,onToggleReview:Z.toggle,isMaximized:P,setIsMaximized:Q,zoomLevel:N,setZoomLevel:R,goToLineRequest:ne.goToLineRequest,onSaveAs:()=>ne.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Ne,editorFontFamily:me,editorTheme:se,togglePreview:an,revealActive:Boolean(Ae),missing:be,onConvertDiffToEditor:h,onFileSaved:g},un=(K)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v,onFileSaved:g,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:K,asSplitPane:!0}),pn=e(nt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:Oe.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:I,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Fe=e(qt,{className:t,isMaximized:P,onKeyDownCapture:sn.onKeyDownCapture,onFocusCapture:dn.onFocusCapture,asSplitPane:H,tabs:pn,activeFile:L,editor:Y,externalChange:rn,conflict:Y.conflict,onReload:Y.resolveConflictByReload,onKeepMine:Y.keepMineAgainstDisk,body:e(Ot,{...mn}),saveAsOpen:ne.saveAsOpen,onSaveAsClose:()=>ne.setSaveAsOpen(!1),onSavedAs:(K)=>{ne.setSaveAsOpen(!1),y?.(K)},closeGuard:Oe});if(!ee.rightFile)return Fe;return e(Xt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Fe})}export{$n as Editor};
1
+ import{d,n,o,W,i,u,a,Ue,oe,e,Kn,et,Se,S,s,E,m,en,_,f,B,re,rt,fe,_t,qe,oi,ln,Yr,D,O,b,Zr,Ye,pe,gr,J,lt,Js,_o,Zs,Xs,To,YA,ch,Mm,sl,Re,ae,Yt,T,ye,fi,df,yg}from"./index-8hgm0abr.js";import{Et,hi,au,ou,su,As,bi,_d}from"./index-xxe52zrm.js";import{Oc,bd,yd,Cg,Eg,$c,nr,ps,zc,Uc,Gc,jc,qc,ms,Uo,fs,Ai,Wc,gl,Al,Kc,Vc,Yc,Jc,Zc,Xc,eu,tu,nu}from"./index-4z4ax55k.js";import{Qa,Ra,ki}from"./index-sx809d6d.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"}]]},Be=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 ie=new Set,De=new Set,ze=new Set;function He(){ze=new Set(ie);for(let t of[...De])t()}function $e(t){let r=new Set(t);if(r.size===ie.size){let l=!0;for(let c of r)if(!ie.has(c)){l=!1;break}if(l)return}ie.clear();for(let l of r)ie.add(l);He()}function Ve(t){let r=new Set(t),l=!1;for(let c of[...ie])if(!r.has(c))ie.delete(c),l=!0;if(l)He()}function We(t){return ie.has(t)}function Ke(){return ie.size>0}function vn(t){return De.add(t),()=>{De.delete(t)}}var yn=vn;function _e(){return Ue(yn,()=>ze)}function Ge({x:t,y:r,rows:l,onAction:c,onClose:p}){let h=i(null),[v,g]=n({left:t,top:r});return W(()=>{let y=h.current;if(!y)return;let{width:w,height:x}=y.getBoundingClientRect();g({left:Math.min(t,Math.max(0,window.innerWidth-w-8)),top:Math.min(r,Math.max(0,window.innerHeight-x-8))})},[t,r,l.length]),oe(e("div",{className:"fixed inset-0 z-[70]",onClick:p,onContextMenu:(y)=>{y.preventDefault(),p()},children:e("div",{ref:h,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:`${v.left}px`,top:`${v.top}px`},onClick:(y)=>y.stopPropagation(),children:l.map((y)=>e("button",{type:"button",role:"menuitem",onClick:()=>{c(y.action),p()},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 transition-colors cursor-pointer",children:y.label},y.action))})}),document.body)}var ge={rightFileId:null,fraction:0.5};function Ce(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function Ze(t,r){for(let l=r.length-1;l>=0;l-=1){let c=r[l];if(c!==t)return c}return null}function Xe(t,r){if(t.rightFileId===null)return t;if(t.rightFileId!==r)return t;return{...t,rightFileId:null}}function ue(t){if(!Number.isFinite(t))return ge.fraction;return Math.max(0.2,Math.min(0.8,t))}function je(t,r){if(typeof t!=="object"||t===null)return ge;let l=t,c=typeof l.fraction==="number"?ue(l.fraction):ge.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 Je({tab:t,openedFiles:r,dirtyIds:l,reopenable:c,activeFileId:p,splitRightFileId:h}){let v=r.filter((x)=>x.id!==t.id),g=r.filter((x)=>!l.has(x.id)),y=r.map((x)=>x.id);return[{action:"split-right",label:"Split right",enabled:Ce(t.id,p,y)},{action:"unsplit",label:"Unsplit",enabled:h!==null},{action:"close",label:"Close",enabled:!0},{action:"close-others",label:"Close others",enabled:v.length>0},{action:"close-all",label:"Close all",enabled:r.length>0},{action:"close-saved",label:"Close saved",enabled:g.some((x)=>x.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((x)=>x.enabled)}function tt({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,missingIds:p,onCopyPath:h,onRevealInFiles:v,onReopenClosed:g,reopenableCount:y,onSplitTo:w,onUnsplit:x,splitRightFileId:k=null}){let I=_e(),C=i(null),M=i(null),[z,V]=n(5),[H,F]=n(!1),[L,U]=n(null);pe(M,()=>F(!1)),o(()=>{let N=new ResizeObserver((R)=>{for(let P of R){let Q=P.contentRect.width,X=Math.max(1,Math.floor((Q-60)/150));V(X)}});if(C.current)N.observe(C.current);return()=>N.disconnect()},[]);let A=Ze(r,t.map((N)=>N.id)),G=[],Z=[];if(t.length<=z)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>=z)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:C,children:[e("div",{className:"flex overflow-hidden",children:G.map((N)=>{let R=N.id===r,P=Boolean(N.isDiff),Q=P?Kn(N.diffStatus||"M",N.diffStaged):null,X=Boolean(p?.has(N.id));return e("div",{onClick:()=>l(N.id),onContextMenu:(j)=>{j.preventDefault(),U({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(oi,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(lt,{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(Qe,{dirty:I.has(N.id),active:R,label:`Close ${N.name}`,onClose:()=>c(N.id)})]},N.id)})}),L?e(Ge,{x:L.x,y:L.y,rows:Je({tab:L.tab,openedFiles:t,dirtyIds:I,reopenable:y?.()??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(!I.has(P.id))c(P.id);return;case"copy-path":h?.(R);return;case"reveal-in-files":v?.(R);return;case"reopen-closed":g?.();return;case"split-right":w?.(R.id);return;case"unsplit":x?.();return}},onClose:()=>U(null)}):null,e("div",{className:"ml-auto flex items-center",children:e("button",{type:"button",onClick:()=>k!==null?x?.():w?.(A),disabled:k===null&&A===null,"aria-pressed":k!==null,"aria-label":"Split editor",title:k!==null?"Close the split pane (the tab stays open)":A===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(Yr,{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 ${H?"bg-ink/10 text-ink":""}`,onClick:()=>F(!H),title:"More open files",children:e(B,{size:14})}),H&&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),F(!1)},className:"flex items-center space-x-2 px-3 py-1.5 hover:bg-ink/5 cursor-pointer group",children:[N.isDiff?e(oi,{size:14,className:"text-info/80"}):e(lt,{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(Qe,{dirty:I.has(N.id),active:!1,label:`Close ${N.name}`,onClose:()=>{if(c(N.id),Z.length===1)F(!1)}})]},N.id)})]})]})]})}function Qe({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 Ee({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(_,{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 nt(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:`${nr} 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 ot(t){if(!t.hasReview)return[];let r=t.isReviewing?"Exit review mode":"Review this document";return[{id:"review",actions:[{label:r,icon:ln,onSelect:t.onToggleReview,active:t.isReviewing}],children:e(ps,{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(ln,{size:14})})}]}function it(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?_t:qe,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(ps,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(_t,{size:14}):e(qe,{size:14})})}]}function at(t){let r=[];if(r.push(...nt(t),...ot(t),...it(t)),!t.byteViewer)r.push({id:"find",actions:[{label:t.findLabel,icon:O,onSelect:t.onToggleFind,active:t.findOpen}],children:e(ps,{label:t.findLabel,pressed:t.findOpen,title:`${t.findLabel} (Ctrl+F)`,onClick:t.onToggleFind,children:e(O,{size:14})})}),r.push({id:"wrap",actions:[{label:t.wordWrapLabel,icon:en,onSelect:t.onToggleWordWrap,active:t.wordWrap}],children:e(ps,{label:t.wordWrapLabel,pressed:t.wordWrap,onClick:t.onToggleWordWrap,children:e(en,{size:14})})}),r.push({id:"blame",actions:[{label:t.blameInline?"Hide line blame":"Show line blame",icon:Be,onSelect:t.onToggleBlameInline,active:t.blameInline}],children:e(ps,{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(Be,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Ra,onSelect:t.onZoomOut},{label:"Increase font size",icon:Qa,onSelect:t.onZoomIn}],children:e(d,{children:[e("button",{type:"button",onClick:t.onZoomOut,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Decrease font size","aria-label":"Decrease font size",children:e(Ra,{size:14})}),e("button",{type:"button",onClick:t.onZoomIn,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Increase font size","aria-label":"Increase font size",children:e(Qa,{size:14})})]})}),r.push({id:"reload",actions:[{label:"Reload from disk",icon:D,onSelect:t.onReload,disabled:!t.canReload}],children:e("button",{type:"button",onClick:t.onReload,disabled:!t.canReload||t.refreshing,"aria-busy":t.refreshing,className:`${nr} 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(D,{size:14,className:t.refreshing?"animate-spin":void 0})})});return r.push({id:"copy",actions:[{label:t.copyLabel,icon:re,onSelect:t.onCopy},{label:"Download file",icon:fe,onSelect:t.onDownload}],children:e(d,{children:[e("button",{type:"button",onClick:t.onCopy,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:t.copyLabel,"aria-label":t.copyLabel,children:t.copied?e(re,{size:14,className:"text-success"}):e(re,{size:14})}),e("button",{type:"button",onClick:t.onDownload,className:`${nr} hover:bg-ink/5 hover:text-ink`,title:"Download file","aria-label":"Download file",children:e(fe,{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 st({path:t,saveStatus:r,wordWrap:l,hasPreview:c,isPreview:p,hasReview:h,isReviewing:v,copied:g,byteViewer:y=!1,saveDisabled:w=!1,unsupported:x=!1,handleMissing:k=!1,readOnly:I=!1,isMaximized:C=!1,findOpen:M=!1,onToggleFind:z,onSave:V,onTogglePreview:H,onToggleReview:F,onToggleWordWrap:L,onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:X,onToggleMaximize:j}){let ne=w?I?"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":x?"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)",ce=e("button",{type:"button",onClick:V,disabled:w||r==="saving",className:`${nr} hover:bg-ink/5`,title:ne,"aria-label":ne,children:r==="saving"?e(Et,{size:14,className:"text-warning animate-pulse"}):r==="saved"?e(f,{size:14,className:"text-success"}):r==="error"?e(E,{size:14,className:"text-error"}):r==="needs-permission"?e(Et,{size:14,className:"text-warning"}):e(Et,{size:14,className:"hover:text-ink"})}),ee=C?"Exit full screen":"Full screen",te=e("button",{type:"button",onClick:j,className:`${nr} hover:bg-ink/5 hover:text-ink ${C?"text-ink":""}`,title:ee,"aria-label":ee,"aria-pressed":C,children:C?e(we,{size:14}):e(xe,{size:14})}),me=_d(),se=bd(),le=at({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:h,isReviewing:v,blameInline:me.inline,findOpen:M,copied:g,isMaximized:C,saveDisabled:w,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:ce,maximizeButton:te,viewModeButtons:e(yd,{size:14}),viewModeActions:se,previewLabel:p?"Show source":"Show preview",findLabel:"Find and replace",wordWrapLabel:l?"Word wrap on":"Word wrap off",copyLabel:g?"Copied":y?"Copy image":"Copy content",maximizeLabel:ee,onTogglePreview:H,onToggleReview:F,onToggleFind:z,onToggleWordWrap:L,onToggleBlameInline:()=>{let be={...bi(),inline:!me.inline};Zr({editorBlameInline:be.inline}),window.dispatchEvent(new CustomEvent(As,{detail:be}))},onZoomIn:U,onZoomOut:A,onCopy:G,onDownload:Z,onReload:N,onSaveAs:X,onToggleMaximize:j,onSave:V});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(ki,{clusters:le,className:"text-ink/40 ml-auto"})]})}function dt({content:t,file:r,zoomLevel:l,reviewActive:c,onExitReview:p,scrollRef:h,onScroll:v}){return e("div",{ref:h,onScroll:v,"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(zc,{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:h,byteViewer:v,viewerKind:g,lineCount:y,conflicts:w=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:v?e("span",{className:"uppercase",children:Uo[g]}):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:[y," lines"]})]})}),e("div",{className:"flex items-center gap-3 min-w-0",children:[w>0&&e("span",{className:"text-error font-semibold tabular-nums",title:`${w} unresolved conflict${w===1?"":"s"} — markers are highlighted in the file`,children:["⚠ ",w," conflict",w===1?"":"s"]}),e("span",{className:"uppercase text-ink/40",children:h})]})]})}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=Xs){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){o(()=>{if(!t)return;let l=t.closest("[data-code-surface]"),c=l instanceof HTMLElement?l:t,p=(h)=>{if(!h.ctrlKey&&!h.metaKey)return;if(h.preventDefault(),Cn(h.target,c))return;let v=kn(h.deltaY);if(v===0)return;r((g)=>Sn(g,v))};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(""),h=i(null);o(()=>{h.current?.focus(),h.current?.select()},[]);let v=()=>{let w=ut(c,t);if(w===null)return;r(w)},g=(w)=>{if(w.key==="Enter"){w.preventDefault(),v();return}if(w.key==="Escape")w.preventDefault(),l()},y=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:h,value:c,onInput:(w)=>p(w.target.value),onKeyDown:g,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:v,disabled:y===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(rt,{size:12}),"Go"]})]}),c&&y!==null&&String(y)!==c.trim()?e("div",{className:"text-[10px] text-ink/50 font-mono",children:["line ",y," (the last line)"]}):null,c&&y===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),[h,v]=n({key:"",value:ft}),g=i(t);g.current=t;let y=i(p);y.current=p;let w=i(l);w.current=l;let x=i(c);x.current=c;let k=i(h);k.current=h;let I=i(0),C=i(""),M=i(new Map),z=i(new Set),V=a(async()=>{let A=g.current;if(!A?.path)return;let G=bt(A),Z=++I.current;C.current=G,v((R)=>({key:G,value:{status:"loading",payload:R.key===G?R.value.payload:null,message:null}}));let N=new URLSearchParams({blame:"1",file:A.path,repo:A.repo||"."});if(A.root)N.set("root",A.root);try{let R=await fetch(`/api/fs/git?${N.toString()}`),P=await R.json().catch(()=>null);if(Z!==I.current)return;if(!R.ok||!P){v({key:G,value:{status:"error",payload:null,message:P?.error??`Blame request failed (HTTP ${R.status})`}});return}v({key:G,value:P.available?{status:"ready",payload:P,message:null}:{status:"unavailable",payload:P,message:P.message??null}})}catch(R){if(Z!==I.current)return;v({key:G,value:{status:"error",payload:null,message:R instanceof Error?R.message:"Blame failed"}})}finally{if(C.current===G)C.current=""}},[]),H=a(async(A)=>{let G=M.current.get(A);if(G)return G;let Z=g.current;if(!Z?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:Z.path,line:String(A),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(A,Q),Q}catch{return{entries:[],truncated:!1}}},[]),F=i(null);if(!F.current)F.current={ensure:()=>{if(!w.current||x.current)return;let A=k.current;if(A.key===y.current&&A.value.status!=="idle")return;if(C.current===y.current)return;V()},reload:()=>{M.current.clear(),V()},history:H,snapshot:()=>{let A=k.current;return A.key===y.current?A.value:ft},stale:()=>x.current,subscribe:(A)=>(z.current.add(A),()=>{z.current.delete(A)})};o(()=>{if(!l||c||!p)return;M.current.clear(),V()},[l,c,p,V]);let L=i(c);return o(()=>{if(L.current===c)return;L.current=c;for(let A of z.current)A()},[c]),o(()=>{for(let A of z.current)A()},[h]),F.current}var En="0".repeat(40);function Te(t){return t===En}function he(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 h=Math.floor(p/24);if(h<30)return`${h}d ago`;let v=Math.floor(h/30);if(v<12)return`${v}mo ago`;return`${Math.floor(h/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 wt="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",yt="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",xt="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",Me="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?kt(r,t.line):null;if(!l)return{title:"Not committed yet",body:`git has no attribution for line ${t.line}.`};if(Te(l.sha))return{title:"Not committed yet",body:"This line differs from the last commit."};return null}function kt(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=wt;let l=Dn(r);if(l){let w=q("div",vt);if(w.append(q("span",yt,l.title)),r.status==="error"&&r.message){let x=q("button","shrink-0 cursor-pointer text-[10px] text-ink/50 hover:text-ink","Try again");x.type="button",x.setAttribute("aria-label","Read the blame again"),w.append(x)}t.append(w,q("p",xt,l.body));return}let c=r.payload;if(!c){t.append(q("p",xt,"Reading blame…"));return}let p=kt(c,r.line),h=q("div",vt);if(h.append(q("span",yt,p.author.trim()||"Unknown"),q("span",Tn,he(p.time))),t.append(h),p.summary)t.append(q("p",Mn,p.summary));let v=q("div",`${Rn} ${Nn}`);if(v.append(q("code","truncate",p.sha.slice(0,7)),q("span","",Bn(p.time))),p.mail){let w=q("span","truncate",p.mail);w.title=p.mail,v.append(w)}t.append(v);let g=q("button",Pn);if(g.type="button",g.setAttribute("aria-expanded",r.historyOpen?"true":"false"),g.textContent=`${r.historyOpen?"▾":"▸"} Line history`,t.append(g),!r.historyOpen)return;let y=q("ol",Ln);if(r.historyLoading)y.append(q("li",`${Me} text-ink/40`,"Reading history…"));else if(!r.history||r.history.entries.length===0)y.append(q("li",`${Me} text-ink/40`,"No commits touched this line."));else{let w=r.history.entries;if(w.forEach((x,k)=>{let I=q("li",Me),C=k===w.length-1?"new":"edit";I.append(q("span","text-ink/40",k===0?"●":"○"),q("code","text-ink/60",x.sha.slice(0,7)),q("span","truncate text-ink/80",x.author.trim()||"Unknown"),q("span","ml-auto shrink-0 text-ink/40",he(x.time)),q("span","shrink-0 rounded bg-ink/5 px-1 text-[8.5px] uppercase tracking-wider text-ink/45",C)),y.append(I)}),r.history.truncated)y.append(q("li",`${Me} text-ink/40`,"Older commits are not shown."))}t.append(y)}function St(t,r,l){let c=q("div",wt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,h=!1,v=!1,g=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:h,historyLoading:v}},y=()=>{On(c,g());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),h=!h,y(),!h||p||v)return;v=!0,y(),r.history(t).then((I)=>{p=I,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,I=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,z=c.offsetHeight||120,V=8,H=Math.max(8,Math.min(x.left,I-M-8)),F=x.bottom+6,L=x.top-z-6,U=F+z>C-8&&L>8?L:F;c.style.left=`${H}px`,c.style.top=`${Math.max(8,U)}px`},destroy(){w(),c.remove()}}}function Ct(t){return ye.define((r)=>{let l=null,c=0,p,h=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let z=C.getBoundingClientRect();if(z.width>0)return{left:z.left,top:z.top,bottom:z.bottom};let V=r.state.doc.line(Math.min(M,r.state.doc.lines)),H=null;try{H=r.coordsAtPos(V.from)}catch{H=null}if(H)return H;let F=r.scrollDOM.getBoundingClientRect();return{left:F.left,top:F.top+24,bottom:F.top+24}},g=(C,M)=>{if(c===C&&l)return;h(),c=C,l=St(C,t,()=>{t.reload(),h()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,z=M?.closest?.(".cm-blame-label");if(z){let F=Number(z.dataset.blameLine);return Number.isInteger(F)&&F>0?{line:F,anchor:z}:null}let V=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!V)return null;let H=Number((V.textContent??"").trim());return Number.isInteger(H)&&H>0?{line:H,anchor:V}:null},w=(C)=>{let M=y(C);if(!M)return;g(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),g(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))h()},k=(C)=>{if(C.key==="Escape"&&l)h(),C.stopPropagation()},I=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(h,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",I),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)h()},destroy(){h(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",I),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Tt=40,Nt=ae.define();function An(t){return Re.define({create:()=>({payload:t.snapshot().payload,stale:!1}),update(r,l){let c=r;for(let p of l.effects){if(!p.is(Nt))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||Te(r))return null;let p=c.author.trim()||"Unknown";return l?p:`${p} · ${he(c.time)}`}class Rt extends Yt{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 Mt(t,r,l){let{payload:c,stale:p}=t;if(!c?.available||p)return T.none;let h=Math.min(c.lines,r.state.doc.lines);if(h<1)return T.none;let v=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.from,r.state.doc.length))).number,g=r.state.doc.lineAt(Math.max(0,Math.min(r.viewport.to,r.state.doc.length))).number,y=Math.max(1,v-Tt),w=Math.min(h,g+Tt),x=[];for(let k of c.runs){let I=Math.max(k.from,y);if(I>k.to||I>w)continue;let C=In(c,k.sha,l);if(!C)continue;let M=c.commits[k.sha],z=r.state.doc.line(I);x.push({from:z.to,deco:T.widget({widget:new Rt(z.number,C,M.summary||M.sha),side:1})})}return T.set(x.map((k)=>k.deco.range(k.from)),!0)}function Fn(t,r){return ye.fromClass(class{constructor(l){this.view=l;this.decorations=Mt(l.state.field(t),l,r)}update(l){if(l.startState.field(t)===l.state.field(t)&&!l.docChanged&&!l.viewportChanged)return;this.decorations=Mt(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 h=t.snapshot();r.dispatch({effects:Nt.of({payload:h.payload,stale:!1})})},p=t.subscribe(c);return{destroy(){l=!1,p()}}})}function Pt({controller:t,inline:r=!0,compact:l=!1}){let c=An(t);return[c,zn(t),r?Fn(c,l):[],Ct(t)]}function Lt({activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:p,rootPath:h=null,repoPath:v=null,onRunCommand:g,wordWrap:y,zoomLevel:w,setZoomLevel:x,editorFontFamily:k,editorTheme:I,viewerKind:C,isPreview:M,reviewActive:z,onToggleReview:V,revealActive:H}){let F=C==="markdown",L=ou(),U=su(),A=_d(),G=gt({name:t.name,path:t.path,root:t.root??h??void 0,repo:t.repo??v??"."},{enabled:A.enabled,dirty:r.isDirty}),Z=u(()=>A.enabled?Pt({controller:G,inline:A.inline}):null,[A.enabled,A.inline,G]),[N,R]=n(null),P=u(()=>Uc(r.content),[r.content]),[Q,X]=n(!1);o(()=>{if(p>0)X(!0)},[p]);let[j,ne]=n(null),[ce,ee]=n(null);mt(j,x);let te=sl({tabKey:String(t.id),surface:F&&M?"rendered":"code",ready:r.loaded,element:F&&M?void 0:j}),me=a((se)=>{te.ref(se),ee(se)},[te.ref]);return qc({path:t.path,scroller:ce,preview:F&&M}),e("div",{className:"relative flex-1 min-h-0 flex flex-col",children:[l.open?e(jc,{find:l}):null,Q?e(pt,{lineCount:r.content?r.content.split(`
2
+ `).length:1,onGo:(se)=>{X(!1);let le=gr(r.content,se-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>X(!1)}):null,F&&M?e(dt,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:z,onExitReview:V,scrollRef:me,onScroll:te.onScroll}):e(Gc,{ref:c,value:r.content,onValueChange:r.onChange,language:r.language,wordWrap:y,documentKey:String(t.id),marks:l.open||H?l.matches:void 0,currentMark:l.currentIndex,onCommand:g,onScroller:ne,onCaret:R,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",blame:Z,themeVars:I.vars,themes:I.themes,indentUnitText:au(L),typing:U,padding:16,placeholder:"This file is empty",style:{fontFamily:k,fontSize:`${w}px`,lineHeight:Js}}),!F||!M?e(ct,{caret:N,eol:r.eol,onSetEol:r.setEol,indentWidth:L.width,insertSpaces:L.insertSpaces,language:r.language,byteViewer:r.isBinaryViewer,viewerKind:C,lineCount:r.content?r.content.split(`
3
+ `).length:0,conflicts:P}):null]})}function Bt({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N}){let R=g==="image"||g==="pdf"||g==="docx"||g==="spreadsheet",P=ms[g]===!0,Q=a(async(X)=>{let j=await Vc(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(st,{path:t.path,saveStatus:r.saveStatus,wordWrap:h,hasPreview:P,isPreview:y,hasReview:g==="markdown"&&y,isReviewing:w,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:x,onToggleWordWrap:()=>v(!h),onZoomIn:()=>M((X)=>Math.min(Xs,X+1)),onZoomOut:()=>M((X)=>Math.max(Zs,X-1)),onCopy:r.copy,onDownload:r.download,onReload:r.reloadFromDisk,onSaveAs:V,canReload:Al(t)&&!r.loadError&&!r.unsupported,refreshing:r.isReading,reloadDiscardsEdits:r.isDirty,onToggleMaximize:()=>I(!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(_,{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(Ee,{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(_,{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(_,{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(Ai,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(gl,{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(Oc,{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(_,{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(Eg,{view:p}):Wc(g)&&(R||y)?e(gl,{kind:g,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(Lt,{activeFile:t,editor:r,find:l,surfaceRef:c,goToLineRequest:z,rootPath:H,repoPath:F,onRunCommand:L,wordWrap:h,zoomLevel:C,setZoomLevel:M,editorFontFamily:U,editorTheme:A,isPreview:y,reviewActive:w,onToggleReview:x,viewerKind:g,revealActive:Z})]})}function Dt({activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H=null,repoPath:F=null,runCommand:L,editorFontFamily:U,editorTheme:A,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($c,{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(Bt,{activeFile:t,editor:r,find:l,surfaceRef:c,pluginFileView:p,wordWrap:h,setWordWrap:v,viewerKind:g,isPreview:y,isReviewing:w,onToggleReview:x,isMaximized:k,setIsMaximized:I,zoomLevel:C,setZoomLevel:M,goToLineRequest:z,onSaveAs:V,rootPath:H,repoPath:F,runCommand:L,editorFontFamily:U,editorTheme:A,togglePreview:G,revealActive:Z,missing:N})}function Ot({pluginId:t,Component:r,sessionId:l,className:c=""}){return e("div",{className:`flex flex-col h-full bg-canvas ${c}`,children:e(Ye,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})})}function At({className:t=""}){return e("div",{className:`flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[e(lt,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function It({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{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 Ft({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:h}){o(()=>{let v=new Set(t.filter((g)=>!g.isDiff&&g.content===void 0).map((g)=>g.id));$e([...r].filter((g)=>v.has(g)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!ms[fs(l.name)])return;let g=Se(h,"editor.previewMode");if(g&&g[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function zt({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ee,{diskMtimeMs:l.diskMtimeMs,fileName:t.name,onReload:c,onKeepMine:p});if(r)return e(eu,{fileName:t.name,onReload:c,onKeepMine:p});return null}async function Ht(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),h=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:h??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:h??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function $t(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Vt(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 Wt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:h,onSaved:v,onClose:g}){let[y,w]=n(()=>Hn(r)),[x,k]=n(()=>$t(t)),[I,C]=n(!1),[M,z]=n(null),V=i(null);o(()=>{V.current?.focus(),V.current?.select()},[]);let H=Vt(x),F=async()=>{if(!H||I)return;C(!0),z(null);let U=await Ht({parent:y,name:x,content:l,eol:c,root:p,repo:h});if(C(!1),U.status==="written"){v({path:U.path});return}z(U.reason)},L=(U)=>{if(U.key==="Enter"){U.preventDefault(),F();return}if(U.key==="Escape")U.preventDefault(),g()};return e(J,{onClose:g,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:g,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 F(),disabled:!H||I,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:[I?e(m,{size:12,className:"animate-spin"}):e(rt,{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:y,onInput:(U)=>w(U.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:V,value:x,onInput:(U)=>k(U.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!H,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${H?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!H?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 Kt(){o(()=>{let t=(r)=>{if(!Ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function Ut({fileName:t,onAnswer:r}){return e(J,{onClose:()=>r("cancel"),header:e("div",{className:"flex items-center gap-2",children:[e(_,{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 Gt({closeGuard:t,activeFile:r,saveMissingConfirm:l,onCancelSaveMissing:c,onConfirmSaveMissing:p}){if(t.pending)return e(Ut,{fileName:t.pending.name,onAnswer:t.answer});if(l&&r)return e(tu,{fileName:r.name,filePath:r.path,onClose:c,onConfirm:p});return null}function qt({className:t="",isMaximized:r,onKeyDownCapture:l,onFocusCapture:c,asSplitPane:p,tabs:h,activeFile:v,editor:g,externalChange:y,conflict:w,onReload:x,onKeepMine:k,body:I,saveAsOpen:C,onSaveAsClose:M,onSavedAs:z,closeGuard:V}){let H=r?"fixed inset-0 z-50 flex flex-col bg-canvas":`flex flex-col h-full bg-canvas ${t}`;return e("div",{className:H,onKeyDownCapture:l,onFocusCapture:c,children:[p?null:h,e(zt,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),I,C&&v?e(Wt,{fileName:v.name,filePath:v.path,content:g.content,eol:g.eol,root:v.root,repo:v.repo,onSaved:({path:F})=>z(F),onClose:M}):null,e(Gt,{closeGuard:V,activeFile:v,saveMissingConfirm:g.saveMissingConfirm,onCancelSaveMissing:g.cancelSaveMissing,onConfirmSaveMissing:g.confirmSaveMissing})]})}function Zt({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 Xt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:h}){let v=i(null),g=i(null),y=Mm(g),w=(x)=>{let k=x.currentTarget,I=v.current;if(!k||!I)return;k.setPointerCapture(x.pointerId);let C=(z)=>{let V=I.getBoundingClientRect();if(V.width===0)return;r(ue((z.clientX-V.left)/V.width))},M=()=>{k.releasePointerCapture(x.pointerId),k.removeEventListener("pointermove",C),k.removeEventListener("pointerup",M)};k.addEventListener("pointermove",C),k.addEventListener("pointerup",M)};return e("div",{ref:v,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(ue(t)*100)}%`},children:h}),e("div",{ref:g,className:`w-[3px] flex-shrink-0 cursor-col-resize transition-colors active:bg-ink/40 ${y?"bg-ink/40":"bg-ink/10"}`,role:"separator","aria-orientation":"vertical","aria-label":"Resize split panes",onPointerDown:w}),e("div",{className:"flex-1 min-w-0 h-full",children:e(Zt,{fileName:l,onClose:c,children:p})})]})}function jt({openedFiles:t,activeFileId:r,enabled:l}){let[c,p]=S("editor.split",ge),h=t.map((k)=>k.id),v=Xe(je(c,h),r),g=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Ce(k,r,h))return;p({...v,rightFileId:k})},[v,p,r,h]),w=a(()=>p({...v,rightFileId:null}),[v,p]),x=a((k)=>p({...v,fraction:ue(k)}),[v,p]);return{rightFile:g,fraction:v.fraction,splitTo:y,close:w,setFraction:x}}function Jt({find:t,runCommand:r,reopenClosed:l}){let c=i(t);c.current=t;let p=i(r);p.current=r;let h=i(l);return h.current=l,{onKeyDownCapture:a((g)=>{let y=c.current;if(g.key==="Escape"){if(!y.open)return;g.preventDefault(),g.stopPropagation(),y.close();return}if((g.metaKey||g.ctrlKey)&&g.shiftKey&&g.code==="KeyT"){if(h.current?.())g.preventDefault(),g.stopPropagation();return}let w=YA(fi,g);if(!w||!df(w))return;g.preventDefault(),g.stopPropagation(),p.current(w)},[])}}function Qt(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return yg(p)},[]),{onFocusCapture:a(()=>{if(l.current)yg(l.current)},[])}}function tn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[h,v]=n(null);Kt();let g=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&We(w)){v(x);return}c(w)},[t,c]),y=a((w)=>{let x=h;if(!x)return;if(w==="cancel"){v(null);return}if(w==="save"){if(x.id!==r)l(x.id);p()}v(null),c(x.id)},[h,r,l,p,c]);return{requestClose:g,pending:h,answer:y}}function nn(){let[t,r]=n(0),[l,c]=n(!1),p=a(()=>r((h)=>h+1),[]);return{goToLineRequest:t,openGoToLine:p,saveAsOpen:l,setSaveAsOpen:c}}function $n({className:t="",openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v=0,onFileSaved:g,onOpenPath:y,onReopenClosed:w,reopenableCount:x,onCopyPath:k,onRevealInFiles:I,rootPath:C=null,repoPath:M=null,activeEditorPanelKey:z=null,forcedActiveFileId:V=null,asSplitPane:H=!1}){let F=H?V:l,L=r.find((K)=>K.id===F),[U,A,G]=S("editor.previewMode",{}),Z=nu(String(F??"")),[N,R]=S("editor.zoomLevel",_o),[P,Q]=n(!1),[X,j]=S("editor.wordWrap",!0),ne=nn(),{sessionId:ce}=et(),ee=jt({openedFiles:r,activeFileId:F,enabled:!H}),te=i(null),me=To(),se=hi(),le=Kc(r,v),be=Boolean(L&&le.has(L.id)),Y=Yc(L??null,{reportSaveError:!0,onFileSaved:g,missing:be}),on=Cg({path:L?.path??"",content:Y.content,language:Y.language}),rn=Y.diskChange,Oe=tn({openedFiles:r,activeFileId:F,onSelectFile:c,onCloseFile:p,saveNow:Y.saveNow}),ve=Jc({text:Y.content,documentKey:`${L?.id??""}\x00${Y.language}`,readSelection:()=>te.current?.getSelection()??null,select:(K,de,Le=!0)=>te.current?.select(K,de,Le),reveal:(K)=>te.current?.revealOffset(K),applyDocument:(K,de,Le)=>te.current?.applyDocument(K,de,Le),toggleWordWrap:()=>j((K)=>!K)}),Ae=Zc(L?.path??null,Y.content,Y.loaded&&!Y.loadError);It({searchReveal:Ae,revealMatch:ve.revealMatch}),Xc({file:L,editor:Y,surfaceRef:te,isPreview:L?U[L.id]===!0:!1,exitPreview:()=>{let K=L?.id;if(K===void 0||K===null)return;A((de)=>({...de,[K]:!1}))}}),o(()=>{if(v>0)Y.reset()},[v]),o(()=>{Y.retain(r.map((K)=>K.id)),Ve(r.map((K)=>K.id))},[r]),Ft({openedFiles:r,dirtyKeys:Y.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:A,sessionId:ce});let an=()=>{if(!L)return;A((K)=>({...K,[L.id]:!K[L.id]}))},Ne=(K)=>{if(df(K)){ve.runCommand(K);return}if(K==="toggleWordWrap"){j((de)=>!de);return}if(K==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(K)},sn=Jt({find:ve,runCommand:Ne,reopenClosed:w}),dn=Qt({saveNow:Y.saveNow,runCommand:Ne}),Pe=ch(z);if(Pe)return e(Ot,{pluginId:Pe.pluginId,Component:Pe.Component,sessionId:ce,className:t});if(r.length===0)return e(At,{className:t});let cn=Y.viewerKind,Ie=L?U[L.id]:!1,mn={activeFile:L,editor:Y,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:X,setWordWrap:j,viewerKind:cn,isPreview:Boolean(Ie),isReviewing:Boolean(Ie)&&Z.active,onToggleReview:Z.toggle,isMaximized:P,setIsMaximized:Q,zoomLevel:N,setZoomLevel:R,goToLineRequest:ne.goToLineRequest,onSaveAs:()=>ne.setSaveAsOpen(!0),onOpenPath:y,rootPath:C,repoPath:M,runCommand:Ne,editorFontFamily:me,editorTheme:se,togglePreview:an,revealActive:Boolean(Ae),missing:be,onConvertDiffToEditor:h,onFileSaved:g},un=(K)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v,onFileSaved:g,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:K,asSplitPane:!0}),pn=e(tt,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:Oe.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:I,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Fe=e(qt,{className:t,isMaximized:P,onKeyDownCapture:sn.onKeyDownCapture,onFocusCapture:dn.onFocusCapture,asSplitPane:H,tabs:pn,activeFile:L,editor:Y,externalChange:rn,conflict:Y.conflict,onReload:Y.resolveConflictByReload,onKeepMine:Y.keepMineAgainstDisk,body:e(Dt,{...mn}),saveAsOpen:ne.saveAsOpen,onSaveAsClose:()=>ne.setSaveAsOpen(!1),onSavedAs:(K)=>{ne.setSaveAsOpen(!1),y?.(K)},closeGuard:Oe});if(!ee.rightFile)return Fe;return e(Xt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Fe})}export{$n as Editor};
@@ -1,2 +1,2 @@
1
- import{d,n,o,i,u,a,e,Ao,s,m,_,qr,Pi,f,re,Rt,ge,D,O,Pp,J,qt,Xl,Op,qu}from"./index-gs7ytgdw.js";var U={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},Sp=s(U);function H({row:t,active:r,name:l,loading:h,onSelect:p,onCopyPath:g,onReveal:C}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] 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:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:p,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,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(ge,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,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 disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:C,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,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(Rt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${Ao[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),Ao[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Pi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(qr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function B(t){let{open:r,rootPath:l,scanning:h}=t,[p,g]=n([]),[C,y]=n(!1),[G,z]=n(!1),[k,v]=n(null),[A,E]=n(0),L=t.repos.join("\x00"),S=i(!0),b=i(null);o(()=>(S.current=!0,()=>{S.current=!1,b.current?.abort(),b.current=null}),[]);let P=a(async()=>{b.current?.abort();let R=new AbortController;b.current=R,z(!0),y(!0);try{let N=new URLSearchParams({repoDetails:"1"});if(l)N.set("root",l);let j=await fetch(`/api/fs/git?${N.toString()}`,{signal:R.signal}),F=await j.json();if(!S.current||b.current!==R)return;if(!j.ok||!Array.isArray(F.details)){v(F.error||`Failed to read repositories (HTTP ${j.status})`);return}g(F.details),v(null)}catch(N){if(!S.current||b.current!==R)return;if(N instanceof Error&&N.name==="AbortError")return;v(N instanceof Error?N.message:"Failed to read repositories")}finally{if(S.current&&b.current===R)b.current=null,z(!1),y(!1)}},[l]);o(()=>{if(!r){g([]),v(null),y(!1);return}P()},[r,P,L,h,A]);let w=a(()=>E((R)=>R+1),[]);return{details:p,loading:C,reading:G,error:k,refresh:w}}function W(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),p=h===-1?"":l.slice(0,h),g=r.get(p);if(!g)g={key:p,label:p===""?null:p,paths:[]},r.set(p,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,p)=>h==="."?-1:p==="."?1:h.localeCompare(p));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function q(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function I({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:p,onSelectRepo:g,onRefreshRepos:C,onClose:y}){let[G,z]=n(""),[k,v]=n(null),{details:A,loading:E,reading:L,error:S,refresh:b}=B({open:t,rootPath:r,repos:h,scanning:p});o(()=>{if(!t)z(""),v(null)},[t]);let P=u(()=>{let x=G.trim().toLowerCase();if(!x)return A;return A.filter((c)=>c.path.toLowerCase().includes(x))},[A,G]),w=u(()=>W(P.map((x)=>x.path)),[P]),R=u(()=>{let x=new Map;for(let c of A)x.set(c.path,c);return x},[A]),N=a(()=>{C(),b()},[C,b]),j=a(async(x)=>{let c=r?qu(r,x==="."?"":x):x,M=await qt(c);v(M?{text:`Copied ${c}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let c=new FormData;if(c.append("actionType","open_explorer"),c.append("path","."),c.append("repo",x),r)c.append("root",r);try{let M=await fetch("/api/fs/action",{method:"POST",body:c}),T=await M.json();if(!M.ok||T.error)v({text:T.error||"Could not open the file manager",kind:"error"})}catch{v({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(J,{onClose:y,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Sp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:G,onChange:(x)=>z(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:N,disabled:L||p,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:L||p?"animate-spin":""})})]}),p&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),k&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${k.kind==="error"?"text-error":"text-ink/60"}`,title:k.text,role:"status",children:k.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&A.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"}),"Reading repositories…"]}):S?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:S}):P.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:G.trim()?"No matching repositories.":"No repositories in this workspace."}):w.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??Xl(".",r)}),x.paths.map((c)=>{let M=R.get(c);if(!M)return null;return e(H,{row:M,active:c===l,name:q(c,x.key),loading:L,onSelect:()=>{g(c),y()},onCopyPath:()=>void j(c),onReveal:()=>void F(c)},c)})]},x.key))})]})}function br({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:p,onRefreshRepos:g}){let[C,y]=n(!1),G=u(()=>({root:t??null,repo:r,rows:h.map((k)=>({repo:k,label:Xl(k,t),short:Op(k,t)})),scanning:p,ready:!0,setRepo:l,refresh:g}),[t,r,h,p,l,g]),z=a(()=>y(!0),[]);return e("div",{className:"relative",children:[e(Pp,{scope:G,onManage:z}),e(I,{isOpen:C,rootPath:t,activeRepo:r,repos:h,scanning:p,onSelectRepo:l,onRefreshRepos:g,onClose:()=>y(!1)})]})}
2
- export{Sp,br};
1
+ import{d,n,o,i,u,a,e,ho,s,m,_,qr,Oi,f,re,Mt,ge,D,O,$p,J,kt,tc,Up,Wu}from"./index-8hgm0abr.js";var U={name:"folder-git-2",size:24,node:[["path",{d:"M18 19a5 5 0 0 1-5-5v8",key:"sz5oeg"}],["path",{d:"M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]},Dp=s(U);function H({row:t,active:r,name:l,loading:h,onSelect:p,onCopyPath:g,onReveal:C}){return e("div",{className:"grid grid-cols-[1rem_minmax(0,1fr)_3.5rem] 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:r&&e(f,{size:12,className:"text-ink","aria-label":"Selected repository"})}),e("button",{type:"button",onClick:p,disabled:r||!t.isRepo,title:!t.isRepo?t.error??"Not a git repository":r?"Already showing this repository":`Show ${t.path}`,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(ge,{size:11,className:r?"text-ink/60 flex-shrink-0":"text-ink/40 flex-shrink-0"}),e("span",{className:`truncate text-xs ${r?"font-semibold text-ink":"text-ink/90"}`,children:l})]})}),e("div",{className:"h-5 flex items-center justify-end gap-0.5 touch-visible opacity-0 group-hover/row:opacity-100",children:[e("button",{type:"button",onClick:g,disabled:h,title:`Copy the absolute path of ${t.path}`,"aria-label":`Copy path of ${t.path}`,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 disabled:opacity-30 disabled:cursor-default",children:e(re,{size:11})}),e("button",{type:"button",onClick:C,title:`Reveal ${t.path} in the file manager`,"aria-label":`Reveal ${t.path}`,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(Mt,{size:11})})]}),e("div",{className:"col-start-2 col-span-2 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0 mt-0.5",children:[t.isRepo?e(d,{children:[e("span",{className:`text-[10px] font-mono truncate ${t.detached?"text-warning":"text-ink/50"}`,title:t.detached?`Detached HEAD at ${t.branch}`:`On branch ${t.branch}`,children:t.branch}),e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e(Q,{row:t})]}):e("span",{className:"text-[10px] text-ink/40 truncate",children:t.error??"Not a git repository"}),t.isRepo&&t.subject&&e(d,{children:[e("span",{className:"text-[10px] text-ink/25","aria-hidden":!0,children:"·"}),e("span",{className:"text-[10px] text-ink/40 truncate min-w-0",title:t.subject,children:t.subject})]})]})]})}function Q({row:t}){let r=[];if(t.operation)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:t.operation==="stash-pop"?`A stash pop stopped on ${t.conflicts} conflict(s)`:`A ${ho[t.operation]} is in progress, stopped on ${t.conflicts} conflict(s)`,children:[e(_,{size:9}),ho[t.operation]]},"operation"));else if(t.conflicts>0)r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.conflicts} conflicted path(s)`,children:[e(_,{size:9}),t.conflicts]},"conflicts"));if(t.changed>0||t.untracked>0)r.push(e("span",{className:"flex-shrink-0 rounded border border-info/30 px-1 text-[10px] font-mono tabular-nums text-info",title:`${t.changed} changed, ${t.untracked} untracked`,children:[t.changed>0?`${t.changed}±`:"",t.changed>0&&t.untracked>0?" ":"",t.untracked>0?`${t.untracked}?`:""]},"dirty"));if(t.gone)r.push(e("span",{className:"flex-shrink-0 rounded border border-warning/30 px-1 text-[10px] font-mono text-warning",title:`${t.upstream} no longer exists on the remote — fetch --prune to drop it`,children:"gone"},"gone"));else if(t.upstream&&(t.ahead>0||t.behind>0))r.push(e("span",{className:"flex flex-shrink-0 items-center gap-0.5 text-[10px] font-mono tabular-nums text-ink/60",title:`${t.ahead} ahead of, ${t.behind} behind ${t.upstream}`,children:[t.ahead>0&&e("span",{className:"flex items-center",children:[e(Oi,{size:9}),t.ahead]}),t.behind>0&&e("span",{className:"flex items-center",children:[e(qr,{size:9}),t.behind]})]},"track"));if(r.length===0)return e("span",{className:"text-[10px] font-mono text-ink/30",title:"Nothing to report: clean and in sync",children:"clean, in sync"});return e(d,{children:r})}function B(t){let{open:r,rootPath:l,scanning:h}=t,[p,g]=n([]),[C,y]=n(!1),[G,z]=n(!1),[k,v]=n(null),[A,E]=n(0),L=t.repos.join("\x00"),S=i(!0),b=i(null);o(()=>(S.current=!0,()=>{S.current=!1,b.current?.abort(),b.current=null}),[]);let P=a(async()=>{b.current?.abort();let R=new AbortController;b.current=R,z(!0),y(!0);try{let N=new URLSearchParams({repoDetails:"1"});if(l)N.set("root",l);let j=await fetch(`/api/fs/git?${N.toString()}`,{signal:R.signal}),F=await j.json();if(!S.current||b.current!==R)return;if(!j.ok||!Array.isArray(F.details)){v(F.error||`Failed to read repositories (HTTP ${j.status})`);return}g(F.details),v(null)}catch(N){if(!S.current||b.current!==R)return;if(N instanceof Error&&N.name==="AbortError")return;v(N instanceof Error?N.message:"Failed to read repositories")}finally{if(S.current&&b.current===R)b.current=null,z(!1),y(!1)}},[l]);o(()=>{if(!r){g([]),v(null),y(!1);return}P()},[r,P,L,h,A]);let w=a(()=>E((R)=>R+1),[]);return{details:p,loading:C,reading:G,error:k,refresh:w}}function W(t){let r=new Map;for(let l of t){if(!l||l==="."){if(!r.has(""))r.set("",{key:"",label:null,paths:[]});r.get("").paths.push(".");continue}let h=l.indexOf("/"),p=h===-1?"":l.slice(0,h),g=r.get(p);if(!g)g={key:p,label:p===""?null:p,paths:[]},r.set(p,g);g.paths.push(l)}for(let l of r.values())l.paths.sort((h,p)=>h==="."?-1:p==="."?1:h.localeCompare(p));return[...r.values()].sort((l,h)=>{if(l.key==="")return-1;if(h.key==="")return 1;return l.key.localeCompare(h.key)})}function q(t,r){if(t===".")return"workspace root";if(r==="")return t;return t.slice(r.length+1)}function I({isOpen:t,rootPath:r,activeRepo:l,repos:h,scanning:p,onSelectRepo:g,onRefreshRepos:C,onClose:y}){let[G,z]=n(""),[k,v]=n(null),{details:A,loading:E,reading:L,error:S,refresh:b}=B({open:t,rootPath:r,repos:h,scanning:p});o(()=>{if(!t)z(""),v(null)},[t]);let P=u(()=>{let x=G.trim().toLowerCase();if(!x)return A;return A.filter((c)=>c.path.toLowerCase().includes(x))},[A,G]),w=u(()=>W(P.map((x)=>x.path)),[P]),R=u(()=>{let x=new Map;for(let c of A)x.set(c.path,c);return x},[A]),N=a(()=>{C(),b()},[C,b]),j=a(async(x)=>{let c=r?Wu(r,x==="."?"":x):x,M=await kt(c);v(M?{text:`Copied ${c}`,kind:"success"}:{text:"Clipboard unavailable",kind:"error"})},[r]),F=a(async(x)=>{let c=new FormData;if(c.append("actionType","open_explorer"),c.append("path","."),c.append("repo",x),r)c.append("root",r);try{let M=await fetch("/api/fs/action",{method:"POST",body:c}),T=await M.json();if(!M.ok||T.error)v({text:T.error||"Could not open the file manager",kind:"error"})}catch{v({text:"Could not open the file manager",kind:"error"})}},[r]);if(!t)return null;return e(J,{onClose:y,maxWidthClass:"max-w-[min(96vw,720px)]",header:e("div",{className:"flex items-center gap-2 min-w-0",children:[e(Dp,{size:14,className:"text-ink/60 flex-shrink-0"}),e("h2",{className:"text-sm font-semibold text-ink",children:"Repositories"}),e("span",{className:"text-[10px] font-mono text-ink/50 truncate",children:[h.length," in this workspace"]})]}),children:[e("div",{className:"px-5 py-3 flex items-center gap-2 border-b border-ink/10",children:[e(O,{size:12,className:"text-ink/40 flex-shrink-0"}),e("input",{type:"text",value:G,onChange:(x)=>z(x.currentTarget.value),placeholder:"Filter repositories…","aria-label":"Filter repositories",className:"flex-1 min-w-0 bg-transparent outline-none text-xs text-ink placeholder-ink/40",autoFocus:!0}),e("button",{type:"button",onClick:N,disabled:L||p,title:"Re-discover repositories and re-read their state","aria-label":"Refresh repositories",className:"text-ink/40 hover:text-ink transition-colors cursor-pointer disabled:opacity-40 flex-shrink-0",children:e(D,{size:12,className:L||p?"animate-spin":""})})]}),p&&e("div",{className:"px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono text-ink/50 flex items-center gap-1.5",children:[e(m,{size:10,className:"animate-spin"}),"Still discovering repositories in this workspace…"]}),k&&e("div",{className:`px-5 py-1.5 border-b border-ink/10 text-[10px] font-mono truncate ${k.kind==="error"?"text-error":"text-ink/60"}`,title:k.text,role:"status",children:k.text}),e("div",{className:"min-h-[40vh] max-h-[60vh] overflow-y-auto scrollbar-overlay-container",children:E&&A.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"}),"Reading repositories…"]}):S?e("div",{className:"py-12 px-6 text-center text-xs text-error font-mono",children:S}):P.length===0?e("div",{className:"py-12 text-center text-xs text-ink/40 font-mono",children:G.trim()?"No matching repositories.":"No repositories in this workspace."}):w.map((x)=>e("div",{children:[e("div",{className:"px-4 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold bg-canvas/40 border-b border-ink/5 sticky top-0",children:x.label??tc(".",r)}),x.paths.map((c)=>{let M=R.get(c);if(!M)return null;return e(H,{row:M,active:c===l,name:q(c,x.key),loading:L,onSelect:()=>{g(c),y()},onCopyPath:()=>void j(c),onReveal:()=>void F(c)},c)})]},x.key))})]})}function br({rootPath:t,activeRepo:r,onSelectRepo:l,repos:h,scanning:p,onRefreshRepos:g}){let[C,y]=n(!1),G=u(()=>({root:t??null,repo:r,rows:h.map((k)=>({repo:k,label:tc(k,t),short:Up(k,t)})),scanning:p,ready:!0,setRepo:l,refresh:g}),[t,r,h,p,l,g]),z=a(()=>y(!0),[]);return e("div",{className:"relative",children:[e($p,{scope:G,onManage:z}),e(I,{isOpen:C,rootPath:t,activeRepo:r,repos:h,scanning:p,onSelectRepo:l,onRefreshRepos:g,onClose:()=>y(!1)})]})}
2
+ export{Dp,br};
@@ -0,0 +1 @@
1
+ import{d,n,o,i,u,a,e,tA,Ce,S,cr,ur,E,m,tn,nn,Ee,Kr,O,ht,it,J,X}from"./index-8hgm0abr.js";import{br}from"./index-x7f5ysch.js";function K({sections:c,selected:t,onSelect:l}){let[r,f]=n(""),x=u(()=>{let p=r.trim().toLowerCase();if(!p)return c;return c.map((h)=>({...h,links:h.links.filter((s)=>s.label.toLowerCase().includes(p)||(s.path??s.target).toLowerCase().includes(p))})).filter((h)=>h.links.length>0)},[c,r]),k=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(O,{size:11,className:"flex-shrink-0 text-ink/40"}),e("input",{type:"text",value:r,onChange:(p)=>f(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:()=>f(""),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:x.length===0?e("p",{className:"px-3 py-2 text-[11px] italic text-ink/40",children:k?"No page matches the filter":"This wiki has no pages"}):x.map((p,h)=>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,g)=>{let b=s.path!==null&&s.path===t,w=`${s.path??s.target}-${g}`;if(s.path)return e("button",{type:"button",onClick:()=>l(s.path),title:s.path,"aria-current":b?"page":void 0,className:`flex w-full items-center gap-1 px-2.5 py-1 text-left text-xs transition-colors ${b?"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})},w);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(Ee,{size:10,className:"flex-shrink-0 text-ink/30"})]},w);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})},w)}),p.notes.map((s,g)=>e("p",{className:"px-2.5 py-0.5 text-[10px] leading-snug text-ink/50",children:s},`note-${g}`))]},`${p.title??"links"}-${h}`))})]})}function j({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(Kr,{size:16})})}function V({open:c,sections:t,selected:l,onSelect:r,onClose:f}){if(o(()=>{if(!c)return;let x=(k)=>{if(k.key==="Escape")f()};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[c,f]),!c)return null;return e(J,{onClose:f,maxWidthClass:"max-w-sm",zClass:"z-[70]",ariaLabel:"Wiki pages",header:e("div",{className:"flex min-w-0 items-center gap-2",children:[e(Kr,{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:(x)=>{r(x),f()}})})})}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:f,error:x,rootPath:k,repoScope:p,onNavigate:h,onBack:s}){let g=re(c,l),b=u(()=>({path:l,entries:t,root:k,repo:p}),[l,t,k,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(tn,{size:13})}),e("span",{className:"min-w-0 flex-1 truncate text-[11px] text-ink/50",title:l,children:l}),f&&e(m,{size:12,className:"flex-shrink-0 animate-spin text-ink/40"}),g&&e("a",{href:g,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(Ee,{size:13})})]}),e("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-overlay-container",children:x?e("div",{className:"flex flex-col items-center gap-2 px-6 py-8 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-xs text-error",children:x})]}):!r?e("div",{className:"px-6 py-8 text-center text-xs text-ink/40",children:f?"Loading page…":"No page selected"}):e("article",{className:"mx-auto max-w-4xl px-5 py-4",children:[e(X,{content:r.content,className:"max-w-none",wikiScope:b,onWikiNavigate:h}),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 H(c,t){let l=new URLSearchParams;if(c)l.set("root",c);if(t&&t!==".")l.set("repo",t);return l}function Q(c){let{rootPath:t,repo:l,enabled:r,active:f,revisionKey:x=0}=c,k=B(t,l),[p,h]=n(null),s=i(k);s.current=k;let g=Ce(tA(k),{enabled:r&&f}),{refresh:b}=g;o(()=>{h(null)},[k]);let w=a((R)=>{if(!r)return;if(!R?.force){b();return}let W=s.current,L=H(t,l);L.set("refresh","1"),fetch(`/api/wiki?${L.toString()}`).then(async(N)=>{let y=await N.json();if(!N.ok)throw Error(y?.error||`Wiki request failed (${N.status})`)}).then(()=>{if(s.current!==W)return;h(null),b()}).catch((N)=>{if(s.current!==W)return;h(N instanceof Error?N.message:"Failed to load the wiki")})},[r,t,l,b]);return o(()=>{if(x>0)b()},[x]),{data:g.data,isLoading:g.isLoading,refreshing:g.refreshing,error:p,reload:w}}function Y(c){let{rootPath:t,repo:l,path:r,enabled:f,active:x,revisionKey:k=0}=c,p=`${B(t,l)}\x00${r??""}`,[h,s]=n({scope:p,data:null}),[g,b]=n(!1),[w,R]=n(null),W=i(0);return o(()=>{if(!f||!x||!r){s({scope:p,data:null}),R(null);return}let L=++W.current;b(!0);let N=H(t,l);N.set("path",r),fetch(`/api/wiki/page?${N.toString()}`).then(async(y)=>{let _=await y.json();if(!y.ok)throw Error(_?.error||`Page request failed (${y.status})`);return _}).then((y)=>{if(W.current!==L)return;s({scope:p,data:y}),R(null)}).catch((y)=>{if(W.current!==L)return;R(y instanceof Error?y.message:"Failed to load the page")}).finally(()=>{if(W.current===L)b(!1)})},[p,t,l,r,f,x,k]),{data:h.scope===p?h.data:null,isLoading:g,error:w}}function Z(c){let t=[];for(let l of c){if(!l.isMarkdown)continue;let r=t[t.length-1],f={label:l.title,target:l.path,path:l.path,url:null};if(r&&r.title===(l.folder||"Pages")){r.links.push(f);continue}t.push({title:l.folder||"Pages",links:[f],notes:[]})}return t}var oe={"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 qe({className:c="",enabled:t=!0,active:l=!0,rootPath:r,refreshKey:f=0,layout:x="desktop"}){let k=x==="phone",{activeRepo:p,setActiveRepo:h}=cr(r),{repos:s,scanning:g,rescan:b}=ur(r,t),w=B(r,p),[R,W]=S("wiki.selectedPage",null),[L,N]=n(!1),[y,_]=n(!1),[ee,te]=n(0),v=Q({rootPath:r,repo:p,enabled:t,active:l,revisionKey:f}),M=v.data?.entries??[],z=u(()=>M.filter((C)=>C.isMarkdown),[M]),U=u(()=>v.data?.sidebar??Z(M),[v.data?.sidebar,M]),ie=u(()=>U.some((C)=>C.links.length>0),[U]),A=R&&R.scope===w?R.path:null,T=u(()=>{if(A&&z.some((F)=>F.path===A))return A;return(z.find((F)=>F.title.toLowerCase()==="home")??z[0])?.path??null},[A,z]),D=Y({rootPath:r,repo:p,path:T,enabled:t,active:l,revisionKey:ee});o(()=>{if(!T||T===A)return;W({scope:w,path:T})},[T,A,w,W]),o(()=>{N(!1),_(!1)},[w]);let q=(C)=>{if(W({scope:w,path:C}),!k)_(!0)},ne=()=>{v.reload({force:!0}),te((C)=>C+1)},P=v.data?.repo??null,I=v.data&&!P?v.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(ht,{left:e(d,{children:[e(br,{rootPath:r,activeRepo:p,onSelectRepo:h,repos:s,scanning:g,onRefreshRepos:b}),P&&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:`${P.host}/${P.slug} · ${P.revision.slice(0,8)}`,children:P.provider})]}),right:e(d,{children:[P?.webUrl&&e("a",{href:P.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(Ee,{size:13})}),e(it,{label:"Re-fetch the wiki",onClick:ne,busy:v.isLoading||v.refreshing,disabled:v.isLoading})]})}),v.error&&!v.data?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(E,{size:16,className:"text-error"}),e("p",{className:"text-error",children:v.error}),e("button",{type:"button",onClick:()=>v.reload(),className:"text-[11px] font-semibold text-ink/70 underline underline-offset-2 hover:text-ink",children:"Try again"})]}):!v.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…"})]}):I?e("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 px-6 text-center",children:[e(nn,{size:18,className:"text-ink/30"}),e("p",{className:"max-w-sm text-[11px] leading-relaxed text-ink/60",children:oe[I.reason??"no-wiki"]}),I.detail&&e("p",{className:"max-w-sm break-words font-mono text-[10px] text-ink/40",children:I.detail})]}):e("div",{className:"flex min-h-0 flex-1 flex-col @[520px]:flex-row-reverse",children:[e("div",{className:`${k?"hidden":y?"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:U,selected:T,onSelect:q})}),e("div",{className:`relative min-w-0 min-h-0 flex-1 ${k?"flex":y?"flex":"hidden @[520px]:flex"} flex-col`,children:[P&&T?e(G,{repo:P,entries:M,path:T,page:D.data,isLoading:D.isLoading,error:D.error,rootPath:r,repoScope:p,onNavigate:q,onBack:k?void 0:()=>_(!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."}),k&&ie&&e(j,{open:L,onClick:()=>N(!0)}),e(V,{open:L,sections:U,selected:T,onSelect:q,onClose:()=>N(!1)})]})]})]})}export{qe as WikiPanel};
@@ -0,0 +1,2 @@
1
+ import{n,o,s,G,Xr,uc,sg,lg,qA,dm}from"./index-8hgm0abr.js";var p={name:"save",size:24,node:[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]},Et=s(p);var wd="omp:editor-theme-changed";function a(){if(typeof window>"u")return uc;return G("editorTheme")??uc}var m={theme:null,vars:{},themes:lg(null)};function hi(){let[e,t]=n(a);if(o(()=>{let i=(d)=>{let E=d.detail;t(E||a())};return window.addEventListener(wd,i),()=>window.removeEventListener(wd,i)},[]),o(()=>{dm(e)},[e]),e===Xr)return m;let r=sg(e);return{theme:r,vars:qA(r),themes:lg(e)}}var Cd="omp:editor-indent-changed",Ed=[2,4,8],ru={width:2,insertSpaces:!0};function Bd(){if(typeof window>"u")return ru;let e=G("editorIndentWidth"),t=G("editorInsertSpaces");return{width:typeof e==="number"&&Ed.includes(e)?e:ru.width,insertSpaces:typeof t==="boolean"?t:ru.insertSpaces}}function au(e){return e.insertSpaces?" ".repeat(e.width):"\t"}function ou(){let[e,t]=n(Bd);return o(()=>{let r=(i)=>{let d=i.detail;t(d??Bd())};return window.addEventListener(Cd,r),()=>window.removeEventListener(Cd,r)},[]),e}var Id="omp:editor-typing-changed",hl={autoCloseBrackets:!0,autocomplete:!0};function iu(){if(typeof window>"u")return hl;let e=G("editorAutoCloseBrackets"),t=G("editorAutocomplete");return{autoCloseBrackets:typeof e==="boolean"?e:hl.autoCloseBrackets,autocomplete:typeof t==="boolean"?t:hl.autocomplete}}function su(){let[e,t]=n(iu);return o(()=>{let r=(i)=>{let d=i.detail;t(d??iu())};return window.addEventListener(Id,r),()=>window.removeEventListener(Id,r)},[]),e}var As="omp:editor-blame-changed",bl={enabled:!0,inline:!1};function bi(){if(typeof window>"u")return bl;let e=G("editorBlame"),t=G("editorBlameInline");return{enabled:typeof e==="boolean"?e:bl.enabled,inline:typeof t==="boolean"?t:bl.inline}}function _d(){let[e,t]=n(bi);return o(()=>{let r=(i)=>{let d=i.detail;t(d??bi())};return window.addEventListener(As,r),()=>window.removeEventListener(As,r)},[]),e}
2
+ export{Et,wd,hi,Cd,Ed,ru,Bd,au,ou,Id,hl,iu,su,As,bl,bi,_d};
@@ -1,2 +1,2 @@
1
- import{t,l,C,p,K,Z,pa,ma,jg,Gr,po,qg,Fs,jt,Hg,jf,fa,mo,Ms}from"./index-b6cyn4hr.js";import{ze}from"./index-c6kx7s6a.js";function Qd(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Qd,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await Z(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Nd(e,r,n){let i=await ma(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Nd,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new ze({multigraph:!0,compound:!0}),s=[...r.edges],o=p(),c=Qd(e),{edgeLabels:f,nodes:a}=c,d=new Map,m=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,b=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(b){let h=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,h?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(b){let h=await Nd(a,u,{config:o,dir:D(u,m,y)});d.set(u.id,h)}i.setNode(u.id,{...u})}}));for(let u of s){if(b&&jf(u))await fa(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-pzqqd7f4.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var Ae=new Map,g=new Map,P=new Map,V=t(()=>{g.clear(),P.clear(),Ae.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),W=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(W(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(m){l.error(m)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),Y=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),Ts=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=Ts(o,r,n),f=Y(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!Ae.has(e))return e;if(!Ae.get(e).externalConnections)return e;if(Ae.has(e))return Ae.get(e).id;return e},"getAnchorId"),Dg=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",Ts(n,e,n)),g.set(n,T(n,e)),Ae.set(n,{id:Ts(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),Ae.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of Ae.keys()){let i=Ae.get(n).id,s=e.parent(i);if(s!==n&&Ae.has(s)&&!Ae.get(s).externalConnections)Ae.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&Ae.get(n)?.externalConnections&&o&&M(e,i,n)){let c=q(e,n,e.parent(i));if(c)Ae.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",Ae,"ids:",n.v,n.w,"Translating: ",Ae.get(n.v)," --- ",Ae.get(n.w)),Ae.get(n.v)||Ae.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);Ae.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);Ae.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(Ae)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,Ae,Ae.has(s)&&!Ae.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!Ae.has(s))l.debug("Not a cluster",s,r);else if(!Ae.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(Ae.get(s)?.clusterData?.dir)c=Ae.get(s).clusterData.dir,l.debug("Fixing dir",Ae.get(s).clusterData.dir,c);let f=new ze({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:Ae.get(s).clusterData,label:Ae.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!Ae.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(Ae);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),Rd=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=Ae.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),q=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=Ts(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function qo({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??Fd;return t(async function(a,d,m,y){let b=d.select("g");(m?.insertMarkers??Ms)(b,a.markers,a.type,a.diagramId),X();let u={element:b,helpers:m,options:y};u.preparedLayout=await e?.(a,u);let h=await c(a,u),v=await n(a,u),E={...u,measure:h};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(qo,"createCommonLayoutRenderer");function X(){jg(),Hg(),qg(),V()}t(X,"clearLayoutRenderState");async function Fd(e,{element:r},n){return await S(r,e,n)}t(Fd,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)Gr(r);else if(A(r,n,i))await po(e.clusters,r);else Gr(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=mo(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(jf(r)){if(!Fs.has(r.id))await fa(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=pa({flowchart:i.flowchart??{}});if(e.label){let o=Fs.get(e.id),{x:c,y:f}=e;if(n){let a=K.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=jt.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=jt.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=jt.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=jt.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
2
- export{Qd,Nd,Ae,Ts,Dg,Rd,qo,Fd};
1
+ import{t,l,C,p,K,Z,ma,fa,Wg,Gr,mo,Kg,Ms,Wt,Vg,Wf,ga,fo,Os}from"./index-13dr1t1r.js";import{ze}from"./index-2hpy58d0.js";function Rd(e,{edgePathsClass:r="edges edgePaths"}={}){let n=e.insert("g").attr("class","root"),i=n.insert("g").attr("class","clusters"),s=n.insert("g").attr("class",r),o=n.insert("g").attr("class","edgeLabels"),c=n.insert("g").attr("class","nodes");return{clusters:i,edgePaths:s,edgeLabels:o,nodes:c,rootGroups:n}}t(Rd,"createLayoutElementGroups");async function L(e,r,n){if(r.label){let{shapeSvg:i,bbox:s}=await Z(e,n===void 0?r:{...r,width:n});r.labelBBox={width:s.width,height:s.height},i.remove()}else r.labelBBox={width:0,height:0}}t(L,"measureGroupLabel");async function Fd(e,r,n){let i=await fa(e,r,n),s=i.node()?.getBBox()??{width:0,height:0};return r.width=s.width,r.height=s.height,i}t(Fd,"insertMeasuredNode");function D(e,r,n){let i=e,s=new Set;while(i){if(i.dir)return i.dir;if(!i.parentId||s.has(i.parentId))break;s.add(i.parentId),i=r.get(i.parentId)}return n}t(D,"resolveNodeDir");async function S(e,r,n={}){let i=new ze({multigraph:!0,compound:!0}),s=[...r.edges],o=p(),c=Rd(e),{edgeLabels:f,nodes:a}=c,d=new Map,m=new Map(r.nodes.map((u)=>[u.id,u])),y=r.direction,b=e.node()!=null;await Promise.all(r.nodes.map(async(u)=>{if(u.isGroup){if(b){let h=n.unwrapGroupLabels&&u.labelType!=="markdown";await L(a,u,h?Number.POSITIVE_INFINITY:void 0)}i.setNode(u.id,{...u})}else{if(b){let h=await Fd(a,u,{config:o,dir:D(u,m,y)});d.set(u.id,h)}i.setNode(u.id,{...u})}}));for(let u of s){if(b&&Wf(u))await ga(f,u);if(i.setEdge(u.start,u.end,{...u},u.id),!r.edges.some((v)=>v.id===u.id))r.edges.push(u)}if(globalThis.mermaidCaptureSizes){let{captureNodeSizes:u}=await import("./sizeCapture-INFHLROL-f87525h7.js");u(e,r)}return{graph:i,groups:c,nodeElements:d}}t(S,"createGraphWithElements");var Ae=new Map,g=new Map,P=new Map,V=t(()=>{g.clear(),P.clear(),Ae.clear()},"clear"),w=t((e,r)=>{let n=g.get(r)||[];return l.trace("In isDescendant",r," ",e," = ",n.includes(e)),n.includes(e)},"isDescendant"),W=t((e,r)=>{let n=g.get(r)||[];if(l.info("Descendants of ",r," is ",n),l.info("Edge is ",e),e.v===r||e.w===r)return!1;if(!n)return l.debug("Tilt, ",r,",not in descendants"),!1;return n.includes(e.v)||w(e.v,r)||w(e.w,r)||n.includes(e.w)},"edgeInCluster"),k=t((e,r,n,i)=>{l.debug("Copying children of ",e,"root",i,"data",r.node(e),i);let s=r.children(e)||[];if(e!==i)s.push(e);l.debug("Copying (nodes) clusterId",e,"nodes",s),s.forEach((o)=>{if(r.children(o).length>0)k(o,r,n,i);else{let c=r.node(o);if(l.info("cp ",o," to ",i," with parent ",e),n.setNode(o,c),i!==r.parent(o))l.debug("Setting parent",o,r.parent(o)),n.setParent(o,r.parent(o));if(e!==i&&o!==e)l.debug("Setting parent",o,e),n.setParent(o,e);else l.info("In copy ",e,"root",i,"data",r.node(e),i),l.debug("Not Setting parent for node=",o,"cluster!==rootId",e!==i,"node!==clusterId",o!==e);let f=r.edges(o);l.debug("Copying Edges",f),f.forEach((a)=>{l.info("Edge",a);let d=r.edge(a.v,a.w,a.name);l.info("Edge data",d,i);try{if(W(a,i))l.info("Copying as ",a.v,a.w,d,a.name),n.setEdge(a.v,a.w,d,a.name),l.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]));else l.info("Skipping copy of edge ",a.v,"-->",a.w," rootId: ",i," clusterId:",e)}catch(m){l.error(m)}})}l.debug("Removing node",o),r.removeNode(o)})},"copy"),T=t((e,r)=>{let n=r.children(e),i=[...n];for(let s of n)P.set(s,e),i=[...i,...T(s,r)];return i},"extractDescendants"),Y=t((e,r,n)=>{let i=e.edges().filter((a)=>a.v===r||a.w===r),s=e.edges().filter((a)=>a.v===n||a.w===n),o=i.map((a)=>({v:a.v===r?n:a.v,w:a.w===r?r:a.w})),c=s.map((a)=>({v:a.v,w:a.w}));return o.filter((a)=>c.some((d)=>a.v===d.v&&a.w===d.w))},"findCommonEdges"),Ns=t((e,r,n)=>{let i=r.children(e);if(l.trace("Searching children of id ",e,i),i.length<1)return e;let s;for(let o of i){let c=Ns(o,r,n),f=Y(r,n,c);if(c)if(f.length>0)s=c;else return c}return s},"findNonClusterChild"),N=t((e)=>{if(!Ae.has(e))return e;if(!Ae.get(e).externalConnections)return e;if(Ae.has(e))return Ae.get(e).id;return e},"getAnchorId"),Rg=t((e,r)=>{if(!e||r>10){l.debug("Opting out, no graph ");return}else l.debug("Opting in, graph ");e.nodes().forEach(function(n){if(e.children(n).length>0)l.debug("Cluster identified",n," Replacement id in edges: ",Ns(n,e,n)),g.set(n,T(n,e)),Ae.set(n,{id:Ns(n,e,n),clusterData:e.node(n)})}),e.nodes().forEach(function(n){let i=e.children(n),s=e.edges();if(i.length>0)l.debug("Cluster identified",n,g),s.forEach((o)=>{let c=w(o.v,n),f=w(o.w,n);if(c^f)l.debug("Edge: ",o," leaves cluster ",n),l.debug("Descendants of XXX ",n,": ",g.get(n)),Ae.get(n).externalConnections=!0});else l.debug("Not a cluster ",n,g)});for(let n of Ae.keys()){let i=Ae.get(n).id,s=e.parent(i);if(s!==n&&Ae.has(s)&&!Ae.get(s).externalConnections)Ae.get(n).id=s;let o=e.edges().some((c)=>c.v===n);if(i&&Ae.get(n)?.externalConnections&&o&&M(e,i,n)){let c=q(e,n,e.parent(i));if(c)Ae.get(n).id=c}}e.edges().forEach(function(n){let i=e.edge(n);l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),l.debug("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));let{v:s,w:o}=n;if(l.debug("Fix XXX",Ae,"ids:",n.v,n.w,"Translating: ",Ae.get(n.v)," --- ",Ae.get(n.w)),Ae.get(n.v)||Ae.get(n.w)){if(l.debug("Fixing and trying - removing XXX",n.v,n.w,n.name),s=N(n.v),o=N(n.w),e.removeEdge(n.v,n.w,n.name),s!==n.v){let c=e.parent(s);Ae.get(c).externalConnections=!0,i.fromCluster=n.v}if(o!==n.w){let c=e.parent(o);Ae.get(c).externalConnections=!0,i.toCluster=n.w}l.debug("Fix Replacing with XXX",s,o,n.name),e.setEdge(s,o,i,n.name)}}),R(e,0),l.trace(Ae)},"adjustClustersAndEdges"),R=t((e,r)=>{if(r>10){l.error("Bailing out");return}let n=e.nodes(),i=!1;for(let s of n){let o=e.children(s);i=i||o.length>0}if(!i){l.debug("Done, no node has children",e.nodes());return}l.debug("Nodes = ",n,r);for(let s of n)if(l.debug("Extracting node",s,Ae,Ae.has(s)&&!Ae.get(s).externalConnections,!e.parent(s),e.node(s),e.children("D")," Depth ",r),!Ae.has(s))l.debug("Not a cluster",s,r);else if(!Ae.get(s).externalConnections&&e.children(s)&&e.children(s).length>0){l.debug("Cluster without external connections, without a parent and with children",s,r);let c=e.graph().rankdir==="TB"?"LR":"TB";if(Ae.get(s)?.clusterData?.dir)c=Ae.get(s).clusterData.dir,l.debug("Fixing dir",Ae.get(s).clusterData.dir,c);let f=new ze({multigraph:!0,compound:!0}).setGraph({rankdir:c,nodesep:50,ranksep:50,marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});k(s,e,f,s),e.setNode(s,{clusterNode:!0,id:s,clusterData:Ae.get(s).clusterData,label:Ae.get(s).label,graph:f})}else l.debug("Cluster ** ",s," **not meeting the criteria !externalConnections:",!Ae.get(s).externalConnections," no parent: ",!e.parent(s)," children ",e.children(s)&&e.children(s).length>0,e.children("D"),r),l.debug(Ae);n=e.nodes(),l.debug("New list of nodes",n);for(let s of n){let o=e.node(s);if(l.debug(" Now next level",s,o),o?.clusterNode)R(o.graph,r+1)}},"extractor"),B=t((e,r)=>{if(r.length===0)return[];let n=Object.assign([],r);return r.forEach((i)=>{let s=e.children(i),o=B(e,s);n=[...n,...o]}),n},"sorter"),Ld=t((e)=>B(e,e.children()),"sortNodesByHierarchy"),M=t((e,r,n)=>{let i=e.parent(r);while(i&&i!==n){let s=Ae.get(i);if(s&&!s.externalConnections)return!0;i=e.parent(i)}return!1},"isNodeInExtractableCluster"),q=t((e,r,n)=>{let i=e.children(r)??[];for(let s of i){if(s===n||w(s,n))continue;let o=Ns(s,e,r);if(!o)continue;if(!M(e,o,r))return o}return null},"findSafeAnchorNode");function Ho({prepareLayout:e,measureLayout:r,runLayoutCore:n,paintLayout:i,afterPaint:s,paintOptions:o}){let c=r??Md;return t(async function(a,d,m,y){let b=d.select("g");(m?.insertMarkers??Os)(b,a.markers,a.type,a.diagramId),X();let u={element:b,helpers:m,options:y};u.preparedLayout=await e?.(a,u);let h=await c(a,u),v=await n(a,u),E={...u,measure:h};if(i)await i(a,E,v);else await G(a,E,o);await s?.(a,E,v)},"render")}t(Ho,"createCommonLayoutRenderer");function X(){Wg(),Vg(),Kg(),V()}t(X,"clearLayoutRenderState");async function Md(e,{element:r},n){return await S(r,e,n)}t(Md,"defaultMeasureLayout");async function G(e,r,n={}){let{measure:i}=r,{groups:s}=i;for(let c of n.getNodes?.(e,r)??e.nodes){if(n.skipNode?.(c,r))continue;await _(s,c,r,n)}let o=O(e.nodes);for(let c of e.edges){if(F(c,n))continue;await j(s,c,o,e,n,r)}}t(G,"paintLayoutData");async function _(e,r,n,i){if(r.clusterNode)Gr(r);else if(A(r,n,i))await mo(e.clusters,r);else Gr(r)}t(_,"paintLayoutNode");function A(e,r,n){return e.isGroup===!0&&(n.isCluster?.(e,r)??!0)}t(A,"shouldPaintAsCluster");function O(e){let r=new Map;for(let n of e)if(n?.id)r.set(n.id,n);return r}t(O,"buildNodeLookup");function F(e,r){return e.isLayoutOnly||Boolean(r.skipEdge?.(e))}t(F,"shouldSkipPaintEdge");async function j(e,r,n,i,s,o){let c=fo(e.edgePaths,{...r},s.clusterDb??new Map,i.type,x(r.start,r,n,o,s),x(r.end,r,n,o,s),i.diagramId,H(r,s));if(Wf(r)){if(!Ms.has(r.id))await ga(e.edgeLabels,r);z(r,c)}}t(j,"paintLayoutEdge");function x(e,r,n,i,s){return s.getEdgeNode?.(e,r,i)??(e?n.get(e)??{}:{})}t(x,"getRenderedNode");function H(e,r){return typeof r.skipIntersect==="function"?r.skipIntersect(e):r.skipIntersect??!1}t(H,"shouldSkipIntersect");function z(e,r){let n=r?.updatedPath??r?.originalPath,i=C(),{subGraphTitleTotalMargin:s}=ma({flowchart:i.flowchart??{}});if(e.label){let o=Ms.get(e.id),{x:c,y:f}=e;if(n){let a=K.calcLabelPosition(n);if(l.debug("Moving label "+e.label+" from (",c,",",f,") to (",a.x,",",a.y,") abc88"),r?.updatedPath)c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f+s/2})`)}if(e?.startLabelLeft){let o=Wt.get(e.id).startLeft,c=e?.x,f=e?.y;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.startLabelRight){let o=Wt.get(e.id).startRight,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeStart?10:0,"start_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelLeft){let o=Wt.get(e.id).endLeft,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_left",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}if(e.endLabelRight){let o=Wt.get(e.id).endRight,{x:c,y:f}=e;if(n){let a=K.calcTerminalLabelPosition(e.arrowTypeEnd?10:0,"end_right",n);c=a.x,f=a.y}o.attr("transform",`translate(${c}, ${f})`)}}t(z,"positionRenderedEdgeLabel");
2
+ export{Rd,Fd,Ae,Ns,Rg,Ld,Ho,Md};
@@ -1 +1 @@
1
- import{d,n,o,i,u,a,le,e,Dp,Ce,S,s,f,B,ie,ya,re,de,b,ft,at,pe,ot,iA,ci}from"./index-gs7ytgdw.js";var se={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},H=s(se);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function L(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=i(null);if(pe(m,r),!l)return null;let t=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((h)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:h.label}),e("span",{className:`${h.strong?"font-semibold text-ink":"text-ink/80"}`,children:h.value})]},h.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[h,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"Messages",value:l}),e(ot,{variant:"compact",label:"User",value:r}),e(ot,{variant:"compact",label:"Assistant",value:c}),e(ot,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(de,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(Z,{open:h,onClose:()=>g(!1),breakdown:t,costFormatted:x})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(ot,{variant:"compact",label:"In",value:l.toLocaleString()}),e(ot,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(ot,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(ot,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(ot,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function G({data:l}){ci();let[r,c]=n(!1),x=i(null),m=i(null),t=JSON.stringify(l,null,2),h=iA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:h}}),e("pre",{ref:x,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],_=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(h,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((h)=>c.add(h));if(l>=r-2)[r-3,r-2,r-1].forEach((h)=>c.add(h));let x=[...c].filter((h)=>h>=1&&h<=r).sort((h,g)=>h-g),m=[],t=0;for(let h of x){if(h-t>1)m.push("…");m.push(h),t=h}return m}function X({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[h,g]=n(1),[w,y]=n([]),[v,I]=n(0),[R,C]=n(!1),W=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++W.current;if(!p?.silent)C(!0);let P=new URLSearchParams({page:String(h),pageSize:String(_),role:m});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==W.current)return;y(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==W.current)return;y([]),I(0)}).finally(()=>{if(!p?.silent&&k===W.current)C(!1)})},[l,h,m]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(v/_)),M=Math.min(h,T),U=(p)=>g(Math.min(Math.max(1,p),T)),ee=(p)=>{x((k)=>({...k,[p]:!k[p]}))},te=()=>{if(w.every((k)=>c[k.id]))x({});else{let k={};w.forEach((P)=>{k[P.id]=!0}),x(k)}},A=u(()=>{let p=[];for(let k of w){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[w]),F=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[A.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:A.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(H,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!R&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${R?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),T>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*_+1,"–",Math.min(M*_,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(ya,{size:14})}),Y(M,T).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=T,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function pt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=le(),m=x.get("sessionId"),[t,h]=n(()=>O(m||"default","Session not started")),g=i(!1),w=a(()=>{if(typeof window>"u")return;let R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).then((C)=>C.ok?C.json():null).then((C)=>{if(!g.current&&C&&C.telemetry)h(C.telemetry)}).catch((C)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",C)})},[m]);o(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=Ce(m?Dp(m):null,{enabled:r}),[v,I]=n(0);if(o(()=>{if(y.data)h(y.data),I((R)=>R+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(ft,{left:e(d,{children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(at,{label:"Refresh context telemetry",onClick:()=>{y.refresh(),w()},busy:y.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+v})]})]})}export{pt as ContextPanel};
1
+ import{d,n,o,i,u,a,le,e,Qp,Ce,S,s,f,B,ie,va,re,de,b,ht,it,pe,st,cA,ui}from"./index-8hgm0abr.js";var se={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},H=s(se);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function L(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=i(null);if(pe(m,r),!l)return null;let t=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((h)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:h.label}),e("span",{className:`${h.strong?"font-semibold text-ink":"text-ink/80"}`,children:h.value})]},h.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[h,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(st,{variant:"compact",label:"Messages",value:l}),e(st,{variant:"compact",label:"User",value:r}),e(st,{variant:"compact",label:"Assistant",value:c}),e(st,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(de,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(Z,{open:h,onClose:()=>g(!1),breakdown:t,costFormatted:x})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(st,{variant:"compact",label:"In",value:l.toLocaleString()}),e(st,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(st,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(st,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(st,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function G({data:l}){ui();let[r,c]=n(!1),x=i(null),m=i(null),t=JSON.stringify(l,null,2),h=cA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:h}}),e("pre",{ref:x,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],_=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(h,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((h)=>c.add(h));if(l>=r-2)[r-3,r-2,r-1].forEach((h)=>c.add(h));let x=[...c].filter((h)=>h>=1&&h<=r).sort((h,g)=>h-g),m=[],t=0;for(let h of x){if(h-t>1)m.push("…");m.push(h),t=h}return m}function X({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[h,g]=n(1),[w,y]=n([]),[v,I]=n(0),[R,C]=n(!1),W=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++W.current;if(!p?.silent)C(!0);let P=new URLSearchParams({page:String(h),pageSize:String(_),role:m});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==W.current)return;y(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==W.current)return;y([]),I(0)}).finally(()=>{if(!p?.silent&&k===W.current)C(!1)})},[l,h,m]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(v/_)),M=Math.min(h,T),U=(p)=>g(Math.min(Math.max(1,p),T)),ee=(p)=>{x((k)=>({...k,[p]:!k[p]}))},te=()=>{if(w.every((k)=>c[k.id]))x({});else{let k={};w.forEach((P)=>{k[P.id]=!0}),x(k)}},A=u(()=>{let p=[];for(let k of w){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[w]),F=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[A.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:A.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(H,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!R&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${R?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(ie,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),T>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*_+1,"–",Math.min(M*_,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(va,{size:14})}),Y(M,T).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=T,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(ie,{size:14})})]})]})]})}function pt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=le(),m=x.get("sessionId"),[t,h]=n(()=>O(m||"default","Session not started")),g=i(!1),w=a(()=>{if(typeof window>"u")return;let R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).then((C)=>C.ok?C.json():null).then((C)=>{if(!g.current&&C&&C.telemetry)h(C.telemetry)}).catch((C)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",C)})},[m]);o(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=Ce(m?Qp(m):null,{enabled:r}),[v,I]=n(0);if(o(()=>{if(y.data)h(y.data),I((R)=>R+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(it,{label:"Refresh context telemetry",onClick:()=>{y.refresh(),w()},busy:y.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+v})]})]})}export{pt as ContextPanel};