@kabmo-labs/kabmo 0.42.0 → 0.42.2

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 (195) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +592 -593
  3. package/dist/client/static/js/{CsvGrid-20k047ht.js → CsvGrid-g6rek8y9.js} +1 -1
  4. package/dist/client/static/js/{DocxView-qpvhfcmg.js → DocxView-41t9ryws.js} +2 -2
  5. package/dist/client/static/js/{DrawioView-178skky8.js → DrawioView-mfxhfz1h.js} +1 -1
  6. package/dist/client/static/js/{ImageView-460th5qa.js → ImageView-bxqw3t4k.js} +1 -1
  7. package/dist/client/static/js/{LayoutWrapper-5cv0dty8.js → LayoutWrapper-zt14rv9m.js} +2 -2
  8. package/dist/client/static/js/{Modal-wks6p4r5.js → Modal-cm35g20x.js} +10 -10
  9. package/dist/client/static/js/{PdfView-y51g03nr.js → PdfView-bek8k888.js} +1 -1
  10. package/dist/client/static/js/{SessionsView-rsmvn7ks.js → SessionsView-gn53zyn7.js} +1 -1
  11. package/dist/client/static/js/{SheetView-z7yvb05v.js → SheetView-vezssf6b.js} +1 -1
  12. package/dist/client/static/js/{SvgPreview-yehgzhem.js → SvgPreview-f1qaw73k.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-6zxpcy8b.js → abnfDiagram-O67JEVCF-4qn94h52.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-cagtcfhk.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-m98sgh3c.js → architectureDiagram-NJMV4G6O-tbewzdya.js} +3 -3
  16. package/dist/client/static/js/{blockDiagram-BEXU5L5S-cp7rervg.js → blockDiagram-BEXU5L5S-njgnwckz.js} +2 -2
  17. package/dist/client/static/js/{c4Diagram-YGBWAQC7-t31recqm.js → c4Diagram-YGBWAQC7-f58pcvbk.js} +1 -1
  18. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-fy8x3dkx.js → classDiagram-v2-NBCMYWYE-52g73vyw.js} +3 -3
  19. package/dist/client/static/js/{cose-bilkent-JH36ORCC-va7ybm9e.js → cose-bilkent-JH36ORCC-ptdnshzh.js} +1 -1
  20. package/dist/client/static/js/cynefin-OW5HDTMX-6g2ydrss.js +1 -0
  21. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-4k0k429c.js → cynefinDiagram-VND7K2PF-qabfdkzr.js} +1 -1
  22. package/dist/client/static/js/{dagre-6A5THRUB-ykdhxq6t.js → dagre-6A5THRUB-kyf5jetf.js} +2 -2
  23. package/dist/client/static/js/{diagram-22UHCM2B-5nvwx7b6.js → diagram-22UHCM2B-bxrsjtv9.js} +4 -4
  24. package/dist/client/static/js/{diagram-3UASUU5V-hc7zsjgw.js → diagram-3UASUU5V-0f41s00j.js} +1 -1
  25. package/dist/client/static/js/{diagram-ATOU4E4O-97ae07y7.js → diagram-ATOU4E4O-0z1zx9h1.js} +1 -1
  26. package/dist/client/static/js/{diagram-CDSNMT55-b56nnbbs.js → diagram-CDSNMT55-znrmr6bk.js} +3 -3
  27. package/dist/client/static/js/{diagram-MLGK6HIB-37rygr9k.js → diagram-MLGK6HIB-jfe2jhk0.js} +1 -1
  28. package/dist/client/static/js/{diagram-MPIPVDR6-wv3vhhfk.js → diagram-MPIPVDR6-2kaawmwa.js} +1 -1
  29. package/dist/client/static/js/{dockerfile-0efb1z6e.js → dockerfile-12exatm9.js} +1 -1
  30. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-13fv7vxg.js → ebnfDiagram-ZINNZB2B-s5n37rfp.js} +1 -1
  31. package/dist/client/static/js/{elixir-mabagxwa.js → elixir-szk51ehr.js} +1 -1
  32. package/dist/client/static/js/{elk-276RUBZZ-xam60ktz.js → elk-276RUBZZ-433rd9fp.js} +1 -1
  33. package/dist/client/static/js/{erDiagram-OPXOYQCR-24ctv2ee.js → erDiagram-OPXOYQCR-key6ah0b.js} +2 -2
  34. package/dist/client/static/js/eventmodeling-NTZA5JFV-b774qbn2.js +1 -0
  35. package/dist/client/static/js/flowDiagram-KWPJA3E3-nznq0n36.js +1 -0
  36. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-766a8fqw.js → ganttDiagram-FUAMR5RP-4efkhmca.js} +2 -2
  37. package/dist/client/static/js/gitGraph-4MIJSDKK-b047d6vk.js +1 -0
  38. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-fmwjkgh6.js → gitGraphDiagram-X574FWY7-ac376y2k.js} +1 -1
  39. package/dist/client/static/js/html-tbz83eke.js +1 -0
  40. package/dist/client/static/js/{index-13xbwcbz.js → index-02543wk3.js} +1 -1
  41. package/dist/client/static/js/{index-sx809d6d.js → index-0e9nkc0g.js} +1 -1
  42. package/dist/client/static/js/{index-1c0pnsjd.js → index-0gbj4270.js} +1 -1
  43. package/dist/client/static/js/{index-z6kpc98a.js → index-0pabfaac.js} +1 -1
  44. package/dist/client/static/js/{index-4mstdh41.js → index-1t5ybx9v.js} +1 -1
  45. package/dist/client/static/js/{index-9vdbnvmk.js → index-1y3rzw6b.js} +1 -1
  46. package/dist/client/static/js/{index-qj34r6d0.js → index-38xv8h4t.js} +1 -1
  47. package/dist/client/static/js/{index-4j8rgr4p.js → index-50mdqev0.js} +1 -1
  48. package/dist/client/static/js/{index-zvazj4va.js → index-5jnvz9hw.js} +1 -1
  49. package/dist/client/static/js/{index-97qst4k9.js → index-77t0nvt1.js} +1 -1
  50. package/dist/client/static/js/{index-x7f5ysch.js → index-7a2efrbj.js} +1 -1
  51. package/dist/client/static/js/{index-yvxa7hd8.js → index-82vk27q1.js} +1 -1
  52. package/dist/client/static/js/{index-nbexks3x.js → index-8k7vjp8b.js} +1 -1
  53. package/dist/client/static/js/{index-sq3r1xhf.js → index-8kbp24xg.js} +1 -1
  54. package/dist/client/static/js/{index-zjydzxhm.js → index-b0v6gwym.js} +2 -2
  55. package/dist/client/static/js/{index-grczkttn.js → index-b42t14wk.js} +7 -7
  56. package/dist/client/static/js/{index-13dr1t1r.js → index-cz50ha6x.js} +23 -23
  57. package/dist/client/static/js/{index-8jqawh3r.js → index-dtj73vs1.js} +1 -1
  58. package/dist/client/static/js/{index-7t63akyt.js → index-dzmar8jr.js} +1 -1
  59. package/dist/client/static/js/{index-2x9eqztp.js → index-f33c4paw.js} +1 -1
  60. package/dist/client/static/js/{index-xxe52zrm.js → index-fb6pw9xb.js} +1 -1
  61. package/dist/client/static/js/{index-6ge6gk9w.js → index-gp57dx2v.js} +1 -1
  62. package/dist/client/static/js/{index-2hpy58d0.js → index-gsxebrq9.js} +2 -2
  63. package/dist/client/static/js/{index-czagykbq.js → index-pxtff3ez.js} +2 -2
  64. package/dist/client/static/js/{index-8hgm0abr.js → index-pzvr1699.js} +187 -183
  65. package/dist/client/static/js/{index-dydwcp3n.js → index-r9db1gsf.js} +1 -1
  66. package/dist/client/static/js/{index-b4y5g48d.js → index-raca8tsh.js} +1 -1
  67. package/dist/client/static/js/{index-95en3p3g.js → index-rf29f3fq.js} +4 -4
  68. package/dist/client/static/js/{index-sz3mxjvy.js → index-s4gv0rpk.js} +1 -1
  69. package/dist/client/static/js/{index-a9t9gdew.js → index-v3f7we4n.js} +4 -4
  70. package/dist/client/static/js/{index-ejdnjh5c.js → index-yjmm73jm.js} +1 -1
  71. package/dist/client/static/js/{index-1rxa9zxp.js → index-ykfd2fyj.js} +1 -1
  72. package/dist/client/static/js/{index-4z4ax55k.js → index-yzda8j2d.js} +6 -6
  73. package/dist/client/static/js/{index-vcn1kcpy.js → index-z78bzryw.js} +3 -3
  74. package/dist/client/static/js/{index-tqycj126.js → index-zndbhb9w.js} +1 -1
  75. package/dist/client/static/js/{index-ka2rc2cr.js → index-zs73zwjz.js} +3 -3
  76. package/dist/client/static/js/{index-xe5cqwnf.js → index-zs7sjv6x.js} +1 -1
  77. package/dist/client/static/js/{index-hzwr5fm9.js → index-zw621xez.js} +3 -3
  78. package/dist/client/static/js/info-A6RAGUB7-n495k952.js +1 -0
  79. package/dist/client/static/js/{infoDiagram-VRGFBTTK-tqytmzp1.js → infoDiagram-VRGFBTTK-4e7ej63f.js} +2 -2
  80. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-rp77ff6m.js → ishikawaDiagram-OU5B5YK6-k3yet1ec.js} +2 -2
  81. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-c7bxrhf1.js → journeyDiagram-ZHPQQLJL-qe352kyd.js} +2 -2
  82. package/dist/client/static/js/{kanban-definition-PNTS6WVX-j2pxewqq.js → kanban-definition-PNTS6WVX-58hag75n.js} +4 -4
  83. package/dist/client/static/js/{mermaid.core-cqqe1krg.js → mermaid.core-6e89h6vm.js} +2 -2
  84. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-s03k32p9.js → mindmap-definition-NLK3R4M7-ncsam2fm.js} +1 -1
  85. package/dist/client/static/js/one-dark-pro-qmyne0tn.js +1 -0
  86. package/dist/client/static/js/one-light-dj0ecjcj.js +1 -0
  87. package/dist/client/static/js/packet-AYTQ26CC-zajj62z6.js +1 -0
  88. package/dist/client/static/js/{pegDiagram-GJSIUBJH-dfg2j0zc.js → pegDiagram-GJSIUBJH-b5ckc39d.js} +1 -1
  89. package/dist/client/static/js/{perl-5vxax0nr.js → perl-dtn1fccw.js} +1 -1
  90. package/dist/client/static/js/{php-hgrgdq63.js → php-7av78hch.js} +1 -1
  91. package/dist/client/static/js/pie-WAS4IAKB-1ve78y5f.js +1 -0
  92. package/dist/client/static/js/{pieDiagram-5QR66LMP-pshd1j79.js → pieDiagram-5QR66LMP-s4d47ve8.js} +2 -2
  93. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-cvvvmtk2.js → quadrantDiagram-O4NWA36T-zm0ekvjz.js} +1 -1
  94. package/dist/client/static/js/radar-RG4KPBEZ-8rqadb58.js +1 -0
  95. package/dist/client/static/js/railroad-74A4TZTK-v6ppm8dy.js +1 -0
  96. package/dist/client/static/js/railroad-abnf-HS5TGJTU-9j6bae14.js +1 -0
  97. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-56cpyt0g.js +1 -0
  98. package/dist/client/static/js/railroad-peg-WCYAUIDC-yfdmspf4.js +1 -0
  99. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-h53p3sha.js → railroadDiagram-XR7U4H2S-52vdqf53.js} +1 -1
  100. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-bdv2fkxd.js → requirementDiagram-PLB6GJNP-7kf8bmk9.js} +1 -1
  101. package/dist/client/static/js/{ruby-8pxcn21w.js → ruby-s2bqr910.js} +1 -1
  102. package/dist/client/static/js/{rust-j80dxgjg.js → rust-q98kssv3.js} +1 -1
  103. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-xqnnvmhy.js → sankeyDiagram-IPEJSGJF-bcb9f54a.js} +1 -1
  104. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-3p67305f.js → sequenceDiagram-PO4LG4MO-76ywvj7g.js} +3 -3
  105. package/dist/client/static/js/{sizeCapture-INFHLROL-f87525h7.js → sizeCapture-INFHLROL-p9bsf5dc.js} +1 -1
  106. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-e5st1fy3.js → stateDiagram-v2-GCMORJYK-1ecfb3fs.js} +1 -1
  107. package/dist/client/static/js/{swimlanes-2SLR337P-ceghkbez.js → swimlanes-2SLR337P-2pyjr946.js} +1 -1
  108. package/dist/client/static/js/{swimlanesDiagram-TC7HE7FX-vc8hvfya.js → swimlanesDiagram-TC7HE7FX-qr5hdxm4.js} +1 -1
  109. package/dist/client/static/js/{timeline-definition-EJHVYXUP-f7evs443.js → timeline-definition-EJHVYXUP-4csxwmn2.js} +3 -3
  110. package/dist/client/static/js/treeView-Q6P3EWNA-vwpg3wp8.js +1 -0
  111. package/dist/client/static/js/treemap-WGGIJYW6-htfxwd32.js +1 -0
  112. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-0gpn21p7.js → usecaseDiagram-POWQR4AR-0p1jnbsn.js} +7 -7
  113. package/dist/client/static/js/{vennDiagram-UO4OBE2U-4spzy428.js → vennDiagram-UO4OBE2U-y1hgdet4.js} +2 -2
  114. package/dist/client/static/js/{vue-xm1dxpmy.js → vue-cbqm4bed.js} +1 -1
  115. package/dist/client/static/js/wardley-WFR3VGLG-hapfjkzq.js +1 -0
  116. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-745xr2pa.js → wardleyDiagram-VNRHLVJA-p578yrgm.js} +2 -2
  117. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-7dr9qwx5.js → xychartDiagram-PMCCYNJV-b08b4ah0.js} +3 -3
  118. package/package.json +1 -1
  119. package/src/cli/lib/commands/session.js +12 -1
  120. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +14 -123
  121. package/src/client/components/workspace/chat-timeline/OrchestrationNotice.tsx +214 -0
  122. package/src/client/components/workspace/chat-timeline/UserTurn.test.tsx +126 -0
  123. package/src/client/components/workspace/chat-timeline/UserTurn.tsx +183 -0
  124. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +3 -3
  125. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolRowActions.tsx +45 -0
  126. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/tool-view.ts +14 -4
  127. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Card.tsx +2 -12
  128. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Compact.tsx +42 -38
  129. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +25 -21
  130. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Trace.tsx +41 -29
  131. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +47 -43
  132. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/parity.test.tsx +136 -0
  133. package/src/client/hooks/chat/timeline/composer-modes.ts +10 -7
  134. package/src/client/hooks/chat/timeline/plan-review-republish.test.ts +121 -0
  135. package/src/client/hooks/chat/timeline/plan-review.ts +12 -3
  136. package/src/server/lib/harness/acp/acp-audit.server.ts +1 -1
  137. package/src/server/lib/harness/acp/session-exit.ts +39 -5
  138. package/src/server/lib/harness/acp/session-turns.ts +67 -12
  139. package/src/server/lib/harness/acp/session.test.ts +61 -0
  140. package/src/server/lib/harness/acp/session.ts +15 -25
  141. package/src/server/lib/harness/acp/turn-outcome.server.test.ts +97 -0
  142. package/src/server/lib/harness/acp/turn-outcome.server.ts +71 -0
  143. package/src/server/lib/harness/acp/turn-silence.ts +52 -0
  144. package/src/server/lib/harness/acp/turn.test.ts +85 -3
  145. package/src/server/lib/harness/acp/turn.ts +62 -4
  146. package/src/server/lib/lifecycle/after-listen.ts +10 -0
  147. package/src/server/lib/omp/rpc/frame-fold-contract.ts +21 -0
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +4 -0
  149. package/src/server/lib/omp/rpc/frame-fold.ts +25 -2
  150. package/src/server/lib/omp/rpc/manager.ts +9 -8
  151. package/src/server/lib/omp/rpc/retry-saga.ts +54 -0
  152. package/src/server/lib/omp/rpc/run-settle.server.ts +38 -5
  153. package/src/server/lib/omp/rpc/run-settle.test.ts +5 -2
  154. package/src/server/lib/omp/rpc/session-commands-dialog.test.ts +6 -20
  155. package/src/server/lib/omp/rpc/session-commands-mapping.test.ts +131 -0
  156. package/src/server/lib/omp/rpc/session-commands.test.ts +95 -116
  157. package/src/server/lib/omp/rpc/session-commands.ts +38 -17
  158. package/src/server/lib/omp/rpc/terminal-settle.test.ts +223 -0
  159. package/src/server/lib/omp/rpc/terminal-settle.ts +127 -29
  160. package/src/server/lib/omp/session/scan.ts +15 -2
  161. package/src/server/lib/omp/session/session-discovery.test.ts +21 -0
  162. package/src/server/lib/sessions/notify.server.test.ts +11 -3
  163. package/src/server/lib/sessions/notify.server.ts +67 -42
  164. package/src/server/lib/sessions/spawn.server.test.ts +5 -1
  165. package/src/server/lib/sessions/spawn.server.ts +8 -3
  166. package/src/server/routes/sessions/answer.test.ts +62 -0
  167. package/src/server/routes/sessions/answer.ts +13 -2
  168. package/src/shared/lib/chat/composer/delegation.ts +11 -7
  169. package/src/shared/lib/chat/export-markdown.ts +19 -0
  170. package/src/shared/lib/chat/orchestration/notice.test.ts +118 -0
  171. package/src/shared/lib/chat/orchestration/notice.ts +183 -0
  172. package/src/shared/lib/chat/timeline/omp-callbacks.ts +6 -1
  173. package/src/shared/lib/chat/timeline/tool-render-mode.ts +3 -3
  174. package/src/shared/lib/icons/tint-hues.generated.ts +36 -36
  175. package/src/shared/lib/omp/session/operator-title.test.ts +21 -0
  176. package/src/shared/lib/omp/session/operator-title.ts +28 -0
  177. package/dist/client/static/js/architecture-7GRP2DOG-9q06651f.js +0 -1
  178. package/dist/client/static/js/cynefin-OW5HDTMX-w7a38g4g.js +0 -1
  179. package/dist/client/static/js/eventmodeling-NTZA5JFV-6wrjccyw.js +0 -1
  180. package/dist/client/static/js/flowDiagram-KWPJA3E3-19vjkg84.js +0 -1
  181. package/dist/client/static/js/gitGraph-4MIJSDKK-4je2p50v.js +0 -1
  182. package/dist/client/static/js/html-bwyt0ayy.js +0 -1
  183. package/dist/client/static/js/info-A6RAGUB7-k0z5qdew.js +0 -1
  184. package/dist/client/static/js/one-dark-pro-9tt0a020.js +0 -1
  185. package/dist/client/static/js/one-light-5fg4r0ra.js +0 -1
  186. package/dist/client/static/js/packet-AYTQ26CC-6cnvmb2z.js +0 -1
  187. package/dist/client/static/js/pie-WAS4IAKB-m9z1mztn.js +0 -1
  188. package/dist/client/static/js/radar-RG4KPBEZ-8m9rkex6.js +0 -1
  189. package/dist/client/static/js/railroad-74A4TZTK-wc55emj8.js +0 -1
  190. package/dist/client/static/js/railroad-abnf-HS5TGJTU-2y2rnrzq.js +0 -1
  191. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-zzcc9x0v.js +0 -1
  192. package/dist/client/static/js/railroad-peg-WCYAUIDC-z82na5nb.js +0 -1
  193. package/dist/client/static/js/treeView-Q6P3EWNA-kzh6cm3f.js +0 -1
  194. package/dist/client/static/js/treemap-WGGIJYW6-wz5ed560.js +0 -1
  195. package/dist/client/static/js/wardley-WFR3VGLG-zewbfccz.js +0 -1
@@ -1,3 +1,3 @@
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
+ 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,Z,lt,Js,_o,Zs,Xs,To,YA,ch,Mm,sl,Re,ae,Yt,T,ye,fi,df,yg}from"./index-pzvr1699.js";import{Et,hi,au,ou,su,As,bi,_d}from"./index-fb6pw9xb.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-yzda8j2d.js";import{Qa,Ra,ki}from"./index-0e9nkc0g.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,Y=Math.max(1,Math.floor((Q-60)/150));V(Y)}});if(C.current)N.observe(C.current);return()=>N.disconnect()},[]);let A=Ze(r,t.map((N)=>N.id)),G=[],X=[];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)),X=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,Y=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:Y?`${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||Y?"":" opacity-60"}${Y?" text-error":""}`}),e("span",{className:`text-xs font-mono truncate flex-1${Y?" 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})})}),X.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"}),X.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),X.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:X,onReload:N,canReload:R,refreshing:P=!1,reloadDiscardsEdits:Q,onSaveAs:Y,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:X,onReload:N,onSaveAs:Y,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(Z,{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),X=++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(X!==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(X!==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 X=g.current;if(!X?.path)return{entries:[],truncated:!1};let N=new URLSearchParams({blameHistory:"1",file:X.path,line:String(A),repo:X.repo||"."});if(X.root)N.set("root",X.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}),X=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,Y]=n(!1);o(()=>{if(p>0)Y(!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)=>{Y(!1);let le=gr(r.content,se-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>Y(!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:X,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:X,missing:N}){let R=g==="image"||g==="pdf"||g==="docx"||g==="spreadsheet",P=ms[g]===!0,Q=a(async(Y)=>{let J=await Vc(t,Y,{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((Y)=>Math.min(Xs,Y+1)),onZoomOut:()=>M((Y)=>Math.max(Zs,Y-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:X})]})}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:X,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:X,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(Z,{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(Z,{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",{}),X=nu(String(F??"")),[N,R]=S("editor.zoomLevel",_o),[P,Q]=n(!1),[Y,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)),j=Yc(L??null,{reportSaveError:!0,onFileSaved:g,missing:be}),on=Cg({path:L?.path??"",content:j.content,language:j.language}),rn=j.diskChange,Oe=tn({openedFiles:r,activeFileId:F,onSelectFile:c,onCloseFile:p,saveNow:j.saveNow}),ve=Jc({text:j.content,documentKey:`${L?.id??""}\x00${j.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,j.content,j.loaded&&!j.loadError);It({searchReveal:Ae,revealMatch:ve.revealMatch}),Xc({file:L,editor:j,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)j.reset()},[v]),o(()=>{j.retain(r.map((K)=>K.id)),Ve(r.map((K)=>K.id))},[r]),Ft({openedFiles:r,dirtyKeys:j.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:j.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=j.viewerKind,Ie=L?U[L.id]:!1,mn={activeFile:L,editor:j,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:Y,setWordWrap:J,viewerKind:cn,isPreview:Boolean(Ie),isReviewing:Boolean(Ie)&&X.active,onToggleReview:X.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:j,externalChange:rn,conflict:j.conflict,onReload:j.resolveConflictByReload,onKeepMine:j.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{t,Qs,h,Ls}from"./index-13dr1t1r.js";import{mn}from"./index-czagykbq.js";var o=mn(Ls(),1);var Wo=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),Su=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};Wo(s,r).lower()},"drawBackgroundRect"),Fg=t((s,e)=>{let r=e.text.replace(Qs," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),Jd=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Zd=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),or=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),Xd=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Pa=t(()=>{let s=h(".mermaidTooltip");if(s.empty())s=h("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
1
+ import{t,Qs,h,Ls}from"./index-cz50ha6x.js";import{mn}from"./index-pxtff3ez.js";var o=mn(Ls(),1);var Wo=t((s,e)=>{let r=s.append("rect");if(r.attr("x",e.x),r.attr("y",e.y),r.attr("fill",e.fill),r.attr("stroke",e.stroke),r.attr("width",e.width),r.attr("height",e.height),e.name)r.attr("name",e.name);if(e.rx)r.attr("rx",e.rx);if(e.ry)r.attr("ry",e.ry);if(e.attrs!==void 0)for(let a in e.attrs)r.attr(a,e.attrs[a]);if(e.class)r.attr("class",e.class);return r},"drawRect"),Su=t((s,e)=>{let r={x:e.startx,y:e.starty,width:e.stopx-e.startx,height:e.stopy-e.starty,fill:e.fill,stroke:e.stroke,class:"rect"};Wo(s,r).lower()},"drawBackgroundRect"),Fg=t((s,e)=>{let r=e.text.replace(Qs," "),a=s.append("text");if(a.attr("x",e.x),a.attr("y",e.y),a.attr("class","legend"),a.style("text-anchor",e.anchor),e.class)a.attr("class",e.class);let i=a.append("tspan");return i.attr("x",e.x+e.textMargin*2),i.text(r),a},"drawText"),Jd=t((s,e,r,a)=>{let i=s.append("image");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",n)},"drawImage"),Zd=t((s,e,r,a)=>{let i=s.append("use");i.attr("x",e),i.attr("y",r);let n=o.sanitizeUrl(a);i.attr("xlink:href",`#${n}`)},"drawEmbeddedImage"),or=t(()=>({x:0,y:0,width:100,height:100,fill:"#EDF2AE",stroke:"#666",anchor:"start",rx:0,ry:0}),"getNoteRect"),Xd=t(()=>({x:0,y:0,width:100,height:100,"text-anchor":"start",style:"#666",textMargin:0,rx:0,ry:0,tspan:!0}),"getTextObj"),Pa=t(()=>{let s=h(".mermaidTooltip");if(s.empty())s=h("body").append("div").attr("class","mermaidTooltip").style("opacity",0).style("position","absolute").style("text-align","center").style("max-width","200px").style("padding","2px").style("font-size","12px").style("background","#ffffde").style("border","1px solid #333").style("border-radius","2px").style("pointer-events","none").style("z-index","100");return s},"createTooltip");
2
2
  export{Wo,Su,Fg,Jd,Zd,or,Xd,Pa};
@@ -1,4 +1,4 @@
1
- import{t,l,jt,C,ee,te,R,p,ue}from"./index-13dr1t1r.js";var M="",O="",D="",E=[],N=new Map,S=t((e)=>ee(e,p()),"sanitizeText"),z=t((e)=>{switch(e.type){case"terminal":return{...e,value:S(e.value)};case"nonterminal":return{...e,name:S(e.name)};case"sequence":return{...e,elements:e.elements.map(z)};case"choice":return{...e,alternatives:e.alternatives.map(z)};case"optional":return{...e,element:z(e.element)};case"repetition":return{...e,element:z(e.element),separator:e.separator?z(e.separator):void 0};case"special":return{...e,text:S(e.text)}}},"sanitizeAstNode"),H=t(()=>{M="",O="",D="",E.length=0,N.clear(),R(),l.debug("[Railroad] Database cleared")},"clear"),Y=t((e)=>{M=S(e),l.debug("[Railroad] Title set:",e)},"setTitle"),P=t(()=>M,"getTitle"),q=t((e)=>{let n={...e,name:S(e.name),definition:z(e.definition),comment:e.comment?S(e.comment):void 0};if(l.debug("[Railroad] Adding rule:",n.name),N.has(n.name))l.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);E.push(n),N.set(n.name,n)},"addRule"),G=t(()=>E,"getRules"),U=t((e)=>N.get(e),"getRule"),j=t((e)=>{O=S(e).replace(/^\s+/g,""),l.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),K=t(()=>O,"getAccTitle"),J=t((e)=>{D=S(e).replace(/\n\s+/g,`
1
+ import{t,l,jt,C,ee,te,R,p,de}from"./index-cz50ha6x.js";var M="",O="",D="",E=[],N=new Map,S=t((e)=>ee(e,p()),"sanitizeText"),z=t((e)=>{switch(e.type){case"terminal":return{...e,value:S(e.value)};case"nonterminal":return{...e,name:S(e.name)};case"sequence":return{...e,elements:e.elements.map(z)};case"choice":return{...e,alternatives:e.alternatives.map(z)};case"optional":return{...e,element:z(e.element)};case"repetition":return{...e,element:z(e.element),separator:e.separator?z(e.separator):void 0};case"special":return{...e,text:S(e.text)}}},"sanitizeAstNode"),H=t(()=>{M="",O="",D="",E.length=0,N.clear(),R(),l.debug("[Railroad] Database cleared")},"clear"),Y=t((e)=>{M=S(e),l.debug("[Railroad] Title set:",e)},"setTitle"),P=t(()=>M,"getTitle"),q=t((e)=>{let n={...e,name:S(e.name),definition:z(e.definition),comment:e.comment?S(e.comment):void 0};if(l.debug("[Railroad] Adding rule:",n.name),N.has(n.name))l.warn(`[Railroad] Rule '${n.name}' is already defined. Overwriting.`);E.push(n),N.set(n.name,n)},"addRule"),G=t(()=>E,"getRules"),U=t((e)=>N.get(e),"getRule"),j=t((e)=>{O=S(e).replace(/^\s+/g,""),l.debug("[Railroad] Accessibility title set:",e)},"setAccTitle"),K=t(()=>O,"getAccTitle"),J=t((e)=>{D=S(e).replace(/\n\s+/g,`
2
2
  `),l.debug("[Railroad] Accessibility description set:",e)},"setAccDescription"),Q=t(()=>D,"getAccDescription"),Z=Y,V=P,Fe={clear:H,setTitle:Y,getTitle:P,addRule:q,getRules:G,getRule:U,setAccTitle:j,getAccTitle:K,setAccDescription:J,getAccDescription:Q,setDiagramTitle:Z,getDiagramTitle:V},T={compactMode:!1,padding:10,verticalSeparation:8,horizontalSeparation:10,arcRadius:10,fontSize:14,fontFamily:"monospace",terminalFill:"#FFFFC0",terminalStroke:"#000000",terminalTextColor:"#000000",nonTerminalFill:"#FFFFFF",nonTerminalStroke:"#000000",nonTerminalTextColor:"#000000",lineColor:"#000000",strokeWidth:2,markerFill:"#000000",commentFill:"#E8E8E8",commentStroke:"#888888",commentTextColor:"#666666",specialFill:"#F0E0FF",specialStroke:"#8800CC",ruleNameColor:"#000066",showMarkers:!0,markerRadius:5},re=/^#(?:[\da-f]{3,4}|[\da-f]{6}|[\da-f]{8})$|^(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch)\([\d\s%+,./-]+\)$|^[a-z]+$/i,ie=/^[\w "',.-]+$/,ne=new Set(["compactMode","padding","verticalSeparation","horizontalSeparation","arcRadius","fontSize","fontFamily","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","lineColor","strokeWidth","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","showMarkers","markerRadius"]),L=t((e)=>{if(!e)return!1;return Object.keys(e).every((n)=>n==="railroad"||ne.has(n))},"isRailroadStyleOptions"),ae=t((e)=>{if(!e)return{};if("railroad"in e&&e.railroad)return e.railroad;return L(e)?e:{}},"extractRailroadOverrides"),oe=t((e)=>{if(!e||L(e))return{};let{railroad:n,svgId:o,theme:i,look:r,...a}=e;return a},"extractThemeOverrides"),u=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return re.test(o)?o:n},"sanitizeColorValue"),I=t((e,n)=>{if(typeof e!=="string")return n;let o=e.trim();return ie.test(o)?o:n},"sanitizeFontFamilyValue"),y=t((e,n)=>{let o=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(o)&&o>=0?o:n},"sanitizeNumberValue"),le=t((e)=>{let n=typeof e==="number"?e:typeof e==="string"?Number.parseFloat(e):Number.NaN;return Number.isFinite(n)&&n>0?n:void 0},"parseThemeFontSize"),se=t((e)=>{let n=I(e.fontFamily,T.fontFamily),o=le(e.fontSize)??T.fontSize;return{...T,fontFamily:n,fontSize:o,terminalFill:u(e.secondBkg??e.secondaryColor,T.terminalFill),terminalStroke:u(e.secondaryBorderColor??e.lineColor,T.terminalStroke),terminalTextColor:u(e.secondaryTextColor??e.textColor,T.terminalTextColor),nonTerminalFill:u(e.mainBkg??e.background,T.nonTerminalFill),nonTerminalStroke:u(e.primaryBorderColor??e.lineColor,T.nonTerminalStroke),nonTerminalTextColor:u(e.primaryTextColor??e.textColor,T.nonTerminalTextColor),lineColor:u(e.lineColor,T.lineColor),markerFill:u(e.lineColor,T.markerFill),commentFill:u(e.labelBackground??e.tertiaryColor,T.commentFill),commentStroke:u(e.tertiaryBorderColor??e.lineColor,T.commentStroke),commentTextColor:u(e.tertiaryTextColor??e.textColor,T.commentTextColor),specialFill:u(e.tertiaryColor??e.secondaryColor,T.specialFill),specialStroke:u(e.tertiaryBorderColor??e.secondaryBorderColor,T.specialStroke),ruleNameColor:u(e.titleColor??e.textColor,T.ruleNameColor)}},"buildThemeDefaults"),W=t((e)=>{let n=C(),o={...jt(),...n.themeVariables??{},...oe(e)},i=se(o),r={...n.railroad??{},...ae(e)};return{compactMode:r.compactMode??i.compactMode,padding:y(r.padding,i.padding),verticalSeparation:y(r.verticalSeparation,i.verticalSeparation),horizontalSeparation:y(r.horizontalSeparation,i.horizontalSeparation),arcRadius:y(r.arcRadius,i.arcRadius),fontSize:y(r.fontSize,i.fontSize),fontFamily:I(r.fontFamily,i.fontFamily),terminalFill:u(r.terminalFill,i.terminalFill),terminalStroke:u(r.terminalStroke,i.terminalStroke),terminalTextColor:u(r.terminalTextColor,i.terminalTextColor),nonTerminalFill:u(r.nonTerminalFill,i.nonTerminalFill),nonTerminalStroke:u(r.nonTerminalStroke,i.nonTerminalStroke),nonTerminalTextColor:u(r.nonTerminalTextColor,i.nonTerminalTextColor),lineColor:u(r.lineColor,i.lineColor),strokeWidth:y(r.strokeWidth,i.strokeWidth),markerFill:u(r.markerFill,i.markerFill),commentFill:u(r.commentFill,i.commentFill),commentStroke:u(r.commentStroke,i.commentStroke),commentTextColor:u(r.commentTextColor,i.commentTextColor),specialFill:u(r.specialFill,i.specialFill),specialStroke:u(r.specialStroke,i.specialStroke),ruleNameColor:u(r.ruleNameColor,i.ruleNameColor),showMarkers:r.showMarkers??i.showMarkers,markerRadius:y(r.markerRadius,i.markerRadius)}},"buildRailroadStyleOptions"),Fa=t((e)=>{let{fontFamily:n,fontSize:o,terminalFill:i,terminalStroke:r,terminalTextColor:a,nonTerminalFill:g,nonTerminalStroke:c,nonTerminalTextColor:s,lineColor:f,strokeWidth:h,markerFill:m,commentFill:k,commentStroke:d,commentTextColor:x,specialFill:b,specialStroke:F,ruleNameColor:v}=W(e);return`
3
3
  .railroad-diagram {
4
4
  font-family: ${n};
@@ -84,6 +84,6 @@ import{t,l,jt,C,ee,te,R,p,ue}from"./index-13dr1t1r.js";var M="",O="",D="",E=[],N
84
84
  .railroad-group {
85
85
  /* Grouping container, no specific styles */
86
86
  }
87
- `},"getStyles"),w=class{constructor(){this.d=""}static{t(this,"PathBuilder")}moveTo(e,n){return this.d+=`M ${e} ${n} `,this}lineTo(e,n){return this.d+=`L ${e} ${n} `,this}horizontalTo(e){return this.d+=`H ${e} `,this}verticalTo(e){return this.d+=`V ${e} `,this}arcTo(e,n,o,i,r,a,g){return this.d+=`A ${e} ${n} ${o} ${i?1:0} ${r?1:0} ${a} ${g} `,this}build(){return this.d.trim()}},de=class{constructor(e,n=W()){this.textCache=new Map,this.svg=e,this.config=n}static{t(this,"RailroadRenderer")}measureText(e){if(this.textCache.has(e))return this.textCache.get(e);let n=this.svg.append("text").attr("font-family",this.config.fontFamily).attr("font-size",this.config.fontSize).text(e),o=n.node().getBBox(),i={width:o.width,height:o.height};return n.remove(),this.textCache.set(e,i),i}renderTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-terminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r).attr("rx",10).attr("ry",10),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderNonTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-nonterminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderSequence(e,n){let o=n.map((s)=>this.renderExpression(e,s)),i=0,r=0,a=0;for(let s of o)i+=s.dimensions.width,r=Math.max(r,s.dimensions.up),a=Math.max(a,s.dimensions.down);i+=(o.length-1)*this.config.horizontalSeparation;let g=e.append("g").attr("class","railroad-sequence"),c=0;for(let s=0;s<o.length;s++){let f=o[s],h=r-f.dimensions.up;if(g.node().appendChild(f.element).setAttribute("transform",`translate(${c}, ${h})`),s<o.length-1){let k=c+f.dimensions.width,d=k+this.config.horizontalSeparation,x=r;g.append("path").attr("class","railroad-line").attr("d",new w().moveTo(k,x).lineTo(d,x).build())}c+=f.dimensions.width+this.config.horizontalSeparation}return{element:g.node(),dimensions:{width:i,height:r+a,up:r,down:a}}}renderChoice(e,n){let o=n.map((m)=>this.renderExpression(e,m)),i=0,r=0;for(let m of o)i=Math.max(i,m.dimensions.width),r+=m.dimensions.height;r+=(o.length-1)*this.config.verticalSeparation;let a=this.config.arcRadius,g=a*4,c=i+g,s=e.append("g").attr("class","railroad-choice"),f=0,h=r/2;for(let m of o){let k=f,d=k+m.dimensions.up,x=a*2+(i-m.dimensions.width)/2;s.node().appendChild(m.element).setAttribute("transform",`translate(${x}, ${k})`);let F=new w,v=d>h;if(d===h)F.moveTo(0,h).lineTo(x,d);else F.moveTo(0,h).arcTo(a,a,0,!1,v,a,h+(v?a:-a)).lineTo(a,d-(v?a:-a)).arcTo(a,a,0,!1,!v,a*2,d).lineTo(x,d);s.append("path").attr("class","railroad-line").attr("d",F.build());let A=new w,_=x+m.dimensions.width,X=c-a*2;if(d===h)A.moveTo(_,d).lineTo(c,h);else A.moveTo(_,d).lineTo(X,d).arcTo(a,a,0,!1,!v,c-a,d+(v?-a:a)).lineTo(c-a,h+(v?a:-a)).arcTo(a,a,0,!1,v,c,h);s.append("path").attr("class","railroad-line").attr("d",A.build()),f+=m.dimensions.height+this.config.verticalSeparation}return{element:s.node(),dimensions:{width:c,height:r,up:h,down:r-h}}}renderOptional(e,n){let o=this.renderExpression(e,n),i=this.config.arcRadius,r=i*2,a=o.dimensions.width+i*4,g=o.dimensions.height+r,c=e.append("g").attr("class","railroad-optional"),s=i*2,f=r;c.node().appendChild(o.element).setAttribute("transform",`translate(${s}, ${f})`);let m=f+o.dimensions.up,k=new w().moveTo(0,m).lineTo(i*2,m);c.append("path").attr("class","railroad-line").attr("d",k.build());let d=new w().moveTo(s+o.dimensions.width,m).lineTo(a,m);c.append("path").attr("class","railroad-line").attr("d",d.build());let x=new w().moveTo(0,m).arcTo(i,i,0,!1,!1,i,m-i).lineTo(i,i).arcTo(i,i,0,!1,!0,i*2,0).lineTo(a-i*2,0).arcTo(i,i,0,!1,!0,a-i,i).lineTo(a-i,m-i).arcTo(i,i,0,!1,!1,a,m);return c.append("path").attr("class","railroad-line").attr("d",x.build()),{element:c.node(),dimensions:{width:a,height:g,up:m,down:g-m}}}renderRepetition(e,n,o){let i=this.renderExpression(e,n),r=this.config.arcRadius,a=r*2,g=i.dimensions.width+r*4,c=o===0,s=i.dimensions.height+a+(c?a:0),f=e.append("g").attr("class","railroad-repetition"),h=r*2,m=c?a:0;f.node().appendChild(i.element).setAttribute("transform",`translate(${h}, ${m})`);let d=m+i.dimensions.up;f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(0,d).lineTo(r*2,d).build()),f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(h+i.dimensions.width,d).lineTo(g,d).build());let x=m+i.dimensions.height+r,b=new w().moveTo(h+i.dimensions.width,d).arcTo(r,r,0,!1,!0,h+i.dimensions.width+r,d+r).lineTo(h+i.dimensions.width+r,x).arcTo(r,r,0,!1,!0,h+i.dimensions.width,x+r).lineTo(r*2,x+r).arcTo(r,r,0,!1,!0,r,x).lineTo(r,d+r).arcTo(r,r,0,!1,!0,r*2,d);if(f.append("path").attr("class","railroad-line").attr("d",b.build()),c){let F=new w().moveTo(0,d).arcTo(r,r,0,!1,!1,r,d-r).lineTo(r,r).arcTo(r,r,0,!1,!0,r*2,0).lineTo(g-r*2,0).arcTo(r,r,0,!1,!0,g-r,r).lineTo(g-r,d-r).arcTo(r,r,0,!1,!1,g,d);f.append("path").attr("class","railroad-line").attr("d",F.build())}return{element:f.node(),dimensions:{width:g,height:s,up:d,down:s-d}}}renderSpecial(e,n){let o=this.measureText("? "+n+" ?"),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-special");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text("? "+n+" ?"),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderExpression(e,n){switch(n.type){case"terminal":return this.renderTerminal(e,n.value);case"nonterminal":return this.renderNonTerminal(e,n.name);case"sequence":return this.renderSequence(e,n.elements);case"choice":return this.renderChoice(e,n.alternatives);case"optional":return this.renderOptional(e,n.element);case"repetition":return this.renderRepetition(e,n.element,n.min);case"special":return this.renderSpecial(e,n.text);default:throw Error(`Unknown node type: ${n.type}`)}}renderRule(e,n){let o=this.svg.append("g").attr("class","railroad-rule").attr("transform",`translate(0, ${n})`),i=e.name+" =",r=this.measureText(i).width+20,a=r+20,g=o.append("g"),c=this.renderExpression(g,e.definition),s=Math.max(20,c.dimensions.up),f=s-c.dimensions.up;return g.attr("transform",`translate(${a}, ${f})`),o.append("g").attr("class","railroad-rule-name-group").append("text").attr("class","railroad-rule-name").attr("x",0).attr("y",s).text(i),o.append("g").attr("class","railroad-start").append("circle").attr("cx",r).attr("cy",s).attr("r",this.config.markerRadius),o.append("g").attr("class","railroad-end").append("circle").attr("cx",a+c.dimensions.width+10).attr("cy",s).attr("r",this.config.markerRadius),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(r+this.config.markerRadius,s).lineTo(a,s).build()),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(a+c.dimensions.width,s).lineTo(a+c.dimensions.width+10-this.config.markerRadius,s).build()),{height:Math.max(40,f+c.dimensions.height+this.config.padding*2),width:a+c.dimensions.width+10+this.config.markerRadius}}renderDiagram(e){let n=this.config.padding,o=0;for(let i of e){let r=this.renderRule(i,n);n+=r.height+this.config.verticalSeparation,o=Math.max(o,r.width)}return{width:o+this.config.padding*2,height:n+this.config.padding}}},B=t((e,n,o)=>{te(e,n.height,n.width,o),e.attr("viewBox",`0 0 ${n.width} ${n.height}`)},"configureRailroadSvgSize"),ce=t((e,n,o)=>{l.debug(`[Railroad] Rendering diagram
88
- `+e);try{let i=ue(n);i.attr("class","railroad-diagram");let a=C().railroad?.useMaxWidth??!0,g=Fe.getRules();if(l.debug(`[Railroad] Rendering ${g.length} rules`),g.length===0){l.warn("[Railroad] No rules to render"),B(i,{height:100,width:200},a);return}let s=new de(i,W()).renderDiagram(g);B(i,s,a),l.debug("[Railroad] Render complete")}catch(i){throw l.error("[Railroad] Render error:",i),i}},"draw"),La={draw:ce};
87
+ `},"getStyles"),w=class{constructor(){this.d=""}static{t(this,"PathBuilder")}moveTo(e,n){return this.d+=`M ${e} ${n} `,this}lineTo(e,n){return this.d+=`L ${e} ${n} `,this}horizontalTo(e){return this.d+=`H ${e} `,this}verticalTo(e){return this.d+=`V ${e} `,this}arcTo(e,n,o,i,r,a,g){return this.d+=`A ${e} ${n} ${o} ${i?1:0} ${r?1:0} ${a} ${g} `,this}build(){return this.d.trim()}},ce=class{constructor(e,n=W()){this.textCache=new Map,this.svg=e,this.config=n}static{t(this,"RailroadRenderer")}measureText(e){if(this.textCache.has(e))return this.textCache.get(e);let n=this.svg.append("text").attr("font-family",this.config.fontFamily).attr("font-size",this.config.fontSize).text(e),o=n.node().getBBox(),i={width:o.width,height:o.height};return n.remove(),this.textCache.set(e,i),i}renderTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-terminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r).attr("rx",10).attr("ry",10),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderNonTerminal(e,n){let o=this.measureText(n),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-nonterminal");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text(n),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderSequence(e,n){let o=n.map((s)=>this.renderExpression(e,s)),i=0,r=0,a=0;for(let s of o)i+=s.dimensions.width,r=Math.max(r,s.dimensions.up),a=Math.max(a,s.dimensions.down);i+=(o.length-1)*this.config.horizontalSeparation;let g=e.append("g").attr("class","railroad-sequence"),c=0;for(let s=0;s<o.length;s++){let f=o[s],h=r-f.dimensions.up;if(g.node().appendChild(f.element).setAttribute("transform",`translate(${c}, ${h})`),s<o.length-1){let k=c+f.dimensions.width,d=k+this.config.horizontalSeparation,x=r;g.append("path").attr("class","railroad-line").attr("d",new w().moveTo(k,x).lineTo(d,x).build())}c+=f.dimensions.width+this.config.horizontalSeparation}return{element:g.node(),dimensions:{width:i,height:r+a,up:r,down:a}}}renderChoice(e,n){let o=n.map((m)=>this.renderExpression(e,m)),i=0,r=0;for(let m of o)i=Math.max(i,m.dimensions.width),r+=m.dimensions.height;r+=(o.length-1)*this.config.verticalSeparation;let a=this.config.arcRadius,g=a*4,c=i+g,s=e.append("g").attr("class","railroad-choice"),f=0,h=r/2;for(let m of o){let k=f,d=k+m.dimensions.up,x=a*2+(i-m.dimensions.width)/2;s.node().appendChild(m.element).setAttribute("transform",`translate(${x}, ${k})`);let F=new w,v=d>h;if(d===h)F.moveTo(0,h).lineTo(x,d);else F.moveTo(0,h).arcTo(a,a,0,!1,v,a,h+(v?a:-a)).lineTo(a,d-(v?a:-a)).arcTo(a,a,0,!1,!v,a*2,d).lineTo(x,d);s.append("path").attr("class","railroad-line").attr("d",F.build());let A=new w,_=x+m.dimensions.width,X=c-a*2;if(d===h)A.moveTo(_,d).lineTo(c,h);else A.moveTo(_,d).lineTo(X,d).arcTo(a,a,0,!1,!v,c-a,d+(v?-a:a)).lineTo(c-a,h+(v?a:-a)).arcTo(a,a,0,!1,v,c,h);s.append("path").attr("class","railroad-line").attr("d",A.build()),f+=m.dimensions.height+this.config.verticalSeparation}return{element:s.node(),dimensions:{width:c,height:r,up:h,down:r-h}}}renderOptional(e,n){let o=this.renderExpression(e,n),i=this.config.arcRadius,r=i*2,a=o.dimensions.width+i*4,g=o.dimensions.height+r,c=e.append("g").attr("class","railroad-optional"),s=i*2,f=r;c.node().appendChild(o.element).setAttribute("transform",`translate(${s}, ${f})`);let m=f+o.dimensions.up,k=new w().moveTo(0,m).lineTo(i*2,m);c.append("path").attr("class","railroad-line").attr("d",k.build());let d=new w().moveTo(s+o.dimensions.width,m).lineTo(a,m);c.append("path").attr("class","railroad-line").attr("d",d.build());let x=new w().moveTo(0,m).arcTo(i,i,0,!1,!1,i,m-i).lineTo(i,i).arcTo(i,i,0,!1,!0,i*2,0).lineTo(a-i*2,0).arcTo(i,i,0,!1,!0,a-i,i).lineTo(a-i,m-i).arcTo(i,i,0,!1,!1,a,m);return c.append("path").attr("class","railroad-line").attr("d",x.build()),{element:c.node(),dimensions:{width:a,height:g,up:m,down:g-m}}}renderRepetition(e,n,o){let i=this.renderExpression(e,n),r=this.config.arcRadius,a=r*2,g=i.dimensions.width+r*4,c=o===0,s=i.dimensions.height+a+(c?a:0),f=e.append("g").attr("class","railroad-repetition"),h=r*2,m=c?a:0;f.node().appendChild(i.element).setAttribute("transform",`translate(${h}, ${m})`);let d=m+i.dimensions.up;f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(0,d).lineTo(r*2,d).build()),f.append("path").attr("class","railroad-line").attr("d",new w().moveTo(h+i.dimensions.width,d).lineTo(g,d).build());let x=m+i.dimensions.height+r,b=new w().moveTo(h+i.dimensions.width,d).arcTo(r,r,0,!1,!0,h+i.dimensions.width+r,d+r).lineTo(h+i.dimensions.width+r,x).arcTo(r,r,0,!1,!0,h+i.dimensions.width,x+r).lineTo(r*2,x+r).arcTo(r,r,0,!1,!0,r,x).lineTo(r,d+r).arcTo(r,r,0,!1,!0,r*2,d);if(f.append("path").attr("class","railroad-line").attr("d",b.build()),c){let F=new w().moveTo(0,d).arcTo(r,r,0,!1,!1,r,d-r).lineTo(r,r).arcTo(r,r,0,!1,!0,r*2,0).lineTo(g-r*2,0).arcTo(r,r,0,!1,!0,g-r,r).lineTo(g-r,d-r).arcTo(r,r,0,!1,!1,g,d);f.append("path").attr("class","railroad-line").attr("d",F.build())}return{element:f.node(),dimensions:{width:g,height:s,up:d,down:s-d}}}renderSpecial(e,n){let o=this.measureText("? "+n+" ?"),i=o.width+this.config.padding*2,r=o.height+this.config.padding*2,a=e.append("g").attr("class","railroad-special");return a.append("rect").attr("x",0).attr("y",0).attr("width",i).attr("height",r),a.append("text").attr("x",i/2).attr("y",r/2).text("? "+n+" ?"),{element:a.node(),dimensions:{width:i,height:r,up:r/2,down:r/2}}}renderExpression(e,n){switch(n.type){case"terminal":return this.renderTerminal(e,n.value);case"nonterminal":return this.renderNonTerminal(e,n.name);case"sequence":return this.renderSequence(e,n.elements);case"choice":return this.renderChoice(e,n.alternatives);case"optional":return this.renderOptional(e,n.element);case"repetition":return this.renderRepetition(e,n.element,n.min);case"special":return this.renderSpecial(e,n.text);default:throw Error(`Unknown node type: ${n.type}`)}}renderRule(e,n){let o=this.svg.append("g").attr("class","railroad-rule").attr("transform",`translate(0, ${n})`),i=e.name+" =",r=this.measureText(i).width+20,a=r+20,g=o.append("g"),c=this.renderExpression(g,e.definition),s=Math.max(20,c.dimensions.up),f=s-c.dimensions.up;return g.attr("transform",`translate(${a}, ${f})`),o.append("g").attr("class","railroad-rule-name-group").append("text").attr("class","railroad-rule-name").attr("x",0).attr("y",s).text(i),o.append("g").attr("class","railroad-start").append("circle").attr("cx",r).attr("cy",s).attr("r",this.config.markerRadius),o.append("g").attr("class","railroad-end").append("circle").attr("cx",a+c.dimensions.width+10).attr("cy",s).attr("r",this.config.markerRadius),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(r+this.config.markerRadius,s).lineTo(a,s).build()),o.append("path").attr("class","railroad-line").attr("d",new w().moveTo(a+c.dimensions.width,s).lineTo(a+c.dimensions.width+10-this.config.markerRadius,s).build()),{height:Math.max(40,f+c.dimensions.height+this.config.padding*2),width:a+c.dimensions.width+10+this.config.markerRadius}}renderDiagram(e){let n=this.config.padding,o=0;for(let i of e){let r=this.renderRule(i,n);n+=r.height+this.config.verticalSeparation,o=Math.max(o,r.width)}return{width:o+this.config.padding*2,height:n+this.config.padding}}},B=t((e,n,o)=>{te(e,n.height,n.width,o),e.attr("viewBox",`0 0 ${n.width} ${n.height}`)},"configureRailroadSvgSize"),me=t((e,n,o)=>{l.debug(`[Railroad] Rendering diagram
88
+ `+e);try{let i=de(n);i.attr("class","railroad-diagram");let a=C().railroad?.useMaxWidth??!0,g=Fe.getRules();if(l.debug(`[Railroad] Rendering ${g.length} rules`),g.length===0){l.warn("[Railroad] No rules to render"),B(i,{height:100,width:200},a);return}let s=new ce(i,W()).renderDiagram(g);B(i,s,a),l.debug("[Railroad] Render complete")}catch(i){throw l.error("[Railroad] Render error:",i),i}},"draw"),La={draw:me};
89
89
  export{Fe,Fa,La};
@@ -1 +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};
1
+ import{d,n,o,i,u,a,e,tA,Ce,S,cr,ur,E,m,tn,nn,Ee,Kr,O,ht,it,Z,J}from"./index-pzvr1699.js";import{br}from"./index-7a2efrbj.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(Z,{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(J,{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 X(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 Q(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 Y(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=X({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??Y(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=Q({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};