@kabmo-labs/kabmo 0.43.1 → 0.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (385) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +337 -337
  3. package/dist/client/static/js/{CsvGrid-g67pk2zy.js → CsvGrid-1t2q46rg.js} +2 -2
  4. package/dist/client/static/js/{DocxView-pyh6p2kb.js → DocxView-301hxnwk.js} +4 -4
  5. package/dist/client/static/js/{DrawioView-g48r6y2m.js → DrawioView-47bwea5t.js} +2 -2
  6. package/dist/client/static/js/ImageView-68zdx5ex.js +1 -0
  7. package/dist/client/static/js/LayoutWrapper-vw54s8ra.js +2 -0
  8. package/dist/client/static/js/{Modal-edw446r8.js → Modal-fb9b4gq6.js} +18 -18
  9. package/dist/client/static/js/{PdfView-6z3cgj37.js → PdfView-m64ksepp.js} +1 -1
  10. package/dist/client/static/js/SessionsView-zyjwhpzm.js +1 -0
  11. package/dist/client/static/js/{SheetView-64076z1j.js → SheetView-e88sqprx.js} +13 -13
  12. package/dist/client/static/js/{SvgPreview-dmpgavgd.js → SvgPreview-hs9a713t.js} +1 -1
  13. package/dist/client/static/js/{abnfDiagram-O67JEVCF-nfz5z1vw.js → abnfDiagram-O67JEVCF-fnr5kyqk.js} +1 -1
  14. package/dist/client/static/js/architecture-7GRP2DOG-mq93vqx9.js +1 -0
  15. package/dist/client/static/js/{architectureDiagram-NJMV4G6O-jra2jyzw.js → architectureDiagram-NJMV4G6O-7v003363.js} +11 -11
  16. package/dist/client/static/js/{astro-dpfdhc5e.js → astro-t9vjc0mc.js} +1 -1
  17. package/dist/client/static/js/bash-fjzhxy10.js +1 -0
  18. package/dist/client/static/js/{blockDiagram-BEXU5L5S-3szktxam.js → blockDiagram-BEXU5L5S-k4mwbw3d.js} +5 -5
  19. package/dist/client/static/js/c-y1y6v00q.js +1 -0
  20. package/dist/client/static/js/{c4Diagram-YGBWAQC7-xe9vbppt.js → c4Diagram-YGBWAQC7-688zq6f4.js} +6 -6
  21. package/dist/client/static/js/{classDiagram-v2-NBCMYWYE-egzhj1xn.js → classDiagram-v2-NBCMYWYE-h0s16pxr.js} +5 -5
  22. package/dist/client/static/js/{cose-bilkent-JH36ORCC-dfrk1wnr.js → cose-bilkent-JH36ORCC-qb2t8qq5.js} +1 -1
  23. package/dist/client/static/js/cpp-9f6zkdd4.js +1 -0
  24. package/dist/client/static/js/css-g85rwzty.js +1 -0
  25. package/dist/client/static/js/css-y4y3qtsb.js +1 -0
  26. package/dist/client/static/js/cynefin-OW5HDTMX-qyg5rjr5.js +1 -0
  27. package/dist/client/static/js/{cynefinDiagram-VND7K2PF-xefpcmpg.js → cynefinDiagram-VND7K2PF-syhtcr7b.js} +1 -1
  28. package/dist/client/static/js/{dagre-6A5THRUB-vtzjnrt9.js → dagre-6A5THRUB-7wgbx6cm.js} +2 -2
  29. package/dist/client/static/js/{diagram-22UHCM2B-4vvn790v.js → diagram-22UHCM2B-951cmp5h.js} +21 -21
  30. package/dist/client/static/js/{diagram-3UASUU5V-tmht3bew.js → diagram-3UASUU5V-mvdbqt7b.js} +2 -2
  31. package/dist/client/static/js/{diagram-ATOU4E4O-p5wa5ztx.js → diagram-ATOU4E4O-hkvdtgdm.js} +3 -3
  32. package/dist/client/static/js/{diagram-CDSNMT55-8myesjfc.js → diagram-CDSNMT55-bkkz35ca.js} +4 -4
  33. package/dist/client/static/js/{diagram-MLGK6HIB-9t3x2d5f.js → diagram-MLGK6HIB-z6pcrkc3.js} +2 -2
  34. package/dist/client/static/js/{diagram-MPIPVDR6-8ahgnmhy.js → diagram-MPIPVDR6-mkwf8j4m.js} +1 -1
  35. package/dist/client/static/js/{dockerfile-x8aa0543.js → dockerfile-7gd570bm.js} +1 -1
  36. package/dist/client/static/js/{ebnfDiagram-ZINNZB2B-5semw111.js → ebnfDiagram-ZINNZB2B-trym26ts.js} +1 -1
  37. package/dist/client/static/js/{elixir-5ewfhvfh.js → elixir-z77c7tfn.js} +1 -1
  38. package/dist/client/static/js/{elk-276RUBZZ-jmhs58ww.js → elk-276RUBZZ-gkhz67v6.js} +1 -1
  39. package/dist/client/static/js/{erDiagram-OPXOYQCR-31wvbpdr.js → erDiagram-OPXOYQCR-gkyr5cqs.js} +7 -7
  40. package/dist/client/static/js/{erlang-jqqa3ehb.js → erlang-6vrvh2m6.js} +1 -1
  41. package/dist/client/static/js/eventmodeling-NTZA5JFV-15yz245z.js +1 -0
  42. package/dist/client/static/js/flowDiagram-KWPJA3E3-n1sapfye.js +1 -0
  43. package/dist/client/static/js/{ganttDiagram-FUAMR5RP-c2dycjrf.js → ganttDiagram-FUAMR5RP-1qpme6ks.js} +4 -4
  44. package/dist/client/static/js/gitGraph-4MIJSDKK-xtjwv160.js +1 -0
  45. package/dist/client/static/js/{gitGraphDiagram-X574FWY7-y4k4pdd8.js → gitGraphDiagram-X574FWY7-wbg3kqak.js} +10 -10
  46. package/dist/client/static/js/graphql-amk52c95.js +1 -0
  47. package/dist/client/static/js/html-2y935m7r.js +1 -0
  48. package/dist/client/static/js/index-07yh7qx0.js +1 -0
  49. package/dist/client/static/js/{index-6fpd55cq.js → index-1923aj4g.js} +2 -2
  50. package/dist/client/static/js/{index-s00j9042.js → index-19ffgf9a.js} +1 -1
  51. package/dist/client/static/js/index-204ae4vs.js +2 -0
  52. package/dist/client/static/js/{index-cqnpsw2m.js → index-22whvfdw.js} +2 -2
  53. package/dist/client/static/js/{index-2cbnjc32.js → index-232nsp2c.js} +2 -2
  54. package/dist/client/static/js/{index-aar68x31.js → index-31hntzse.js} +5 -5
  55. package/dist/client/static/js/{index-2b46dzw8.js → index-3w845q50.js} +4 -4
  56. package/dist/client/static/js/{index-gmnmnfm0.js → index-4y4hshcx.js} +2 -2
  57. package/dist/client/static/js/index-53ysgsd2.js +1 -0
  58. package/dist/client/static/js/{index-m94f4ngb.js → index-62ng8tkj.js} +3 -3
  59. package/dist/client/static/js/{index-nt7nhchn.js → index-6ah5sj5y.js} +1 -1
  60. package/dist/client/static/js/{index-kc5znr75.js → index-6gyk52ff.js} +2 -2
  61. package/dist/client/static/js/{index-m9s9rg5k.js → index-6s4mrdew.js} +2 -2
  62. package/dist/client/static/js/index-6t21c6jt.js +2 -0
  63. package/dist/client/static/js/{index-7dp90ad1.js → index-83pwa9c0.js} +2 -2
  64. package/dist/client/static/js/{index-pt8440xh.js → index-8trggh1z.js} +15 -15
  65. package/dist/client/static/js/{index-ys0xpw3q.js → index-92n96mgd.js} +2 -2
  66. package/dist/client/static/js/index-ad4x44d6.js +9 -0
  67. package/dist/client/static/js/{index-s78n0dtv.js → index-as1wptfa.js} +2 -2
  68. package/dist/client/static/js/{index-j17h4z6f.js → index-barbpakv.js} +2 -2
  69. package/dist/client/static/js/index-bjqz7swa.js +1 -0
  70. package/dist/client/static/js/{index-yvgbr7ek.js → index-c3v62nvt.js} +2 -2
  71. package/dist/client/static/js/{index-f77c3ag0.js → index-cq98p2rb.js} +200 -200
  72. package/dist/client/static/js/{index-3588r3wg.js → index-czedkbmb.js} +2 -2
  73. package/dist/client/static/js/{index-sesghshh.js → index-dmv2zasz.js} +2 -2
  74. package/dist/client/static/js/{index-ycks7gyg.js → index-e6rm5xzj.js} +2 -2
  75. package/dist/client/static/js/{index-48pb18zj.js → index-ehacfgwm.js} +2 -2
  76. package/dist/client/static/js/{index-q81rxwh7.js → index-fbpc1wx6.js} +41 -41
  77. package/dist/client/static/js/{index-qhytrsyb.js → index-fj4k07zt.js} +2 -2
  78. package/dist/client/static/js/{index-jz93j0at.js → index-gtkhz0hj.js} +2 -2
  79. package/dist/client/static/js/{index-181p91hf.js → index-hfsvwfgw.js} +2 -2
  80. package/dist/client/static/js/{index-sk9ej289.js → index-jaqjvk22.js} +2 -2
  81. package/dist/client/static/js/{index-e7yf273s.js → index-jbkkwa2q.js} +2 -2
  82. package/dist/client/static/js/{index-38v0781h.js → index-ks23y2cd.js} +2 -2
  83. package/dist/client/static/js/{index-f7djda1g.js → index-kwpaz891.js} +2 -2
  84. package/dist/client/static/js/{index-0c6vpk89.js → index-n0matkz9.js} +2 -2
  85. package/dist/client/static/js/index-n6fbd265.js +1 -0
  86. package/dist/client/static/js/{index-cjhvtzdd.js → index-nqjd3hh5.js} +2 -2
  87. package/dist/client/static/js/{index-ynaxep06.js → index-nr8s5xm9.js} +2 -2
  88. package/dist/client/static/js/index-nvevymac.js +2 -0
  89. package/dist/client/static/js/index-pxm44qfd.js +1 -0
  90. package/dist/client/static/js/{index-fg965t62.js → index-pysqpc5n.js} +2 -2
  91. package/dist/client/static/js/index-qf9x7yet.js +1 -0
  92. package/dist/client/static/js/{index-s7rfbydk.js → index-qkjx6521.js} +4 -4
  93. package/dist/client/static/js/index-qm92sf9w.js +12 -0
  94. package/dist/client/static/js/{index-fjnkzk12.js → index-qsw5edtk.js} +5 -5
  95. package/dist/client/static/js/index-rpzxrr2d.js +1 -0
  96. package/dist/client/static/js/index-s8bktzpg.js +1 -0
  97. package/dist/client/static/js/index-sc7r305t.css +1 -0
  98. package/dist/client/static/js/{index-efra065v.js → index-svmzgtcx.js} +2 -2
  99. package/dist/client/static/js/{index-vyw4tbn8.js → index-tr2pkfs6.js} +2 -2
  100. package/dist/client/static/js/{index-bvjct7sp.js → index-tzdm1y3z.js} +2 -2
  101. package/dist/client/static/js/{index-cgzw43bc.js → index-v5npdwy2.js} +65 -65
  102. package/dist/client/static/js/{index-dkwhs38j.js → index-v7bcgh77.js} +2 -2
  103. package/dist/client/static/js/index-wytdbvax.js +3 -0
  104. package/dist/client/static/js/{index-n9scbxy5.js → index-yfjvx4yf.js} +2 -2
  105. package/dist/client/static/js/info-A6RAGUB7-e31s2xvj.js +1 -0
  106. package/dist/client/static/js/{infoDiagram-VRGFBTTK-z3pqx7w8.js → infoDiagram-VRGFBTTK-yebngg8c.js} +1 -1
  107. package/dist/client/static/js/ini-kemnmt16.js +1 -0
  108. package/dist/client/static/js/{ishikawaDiagram-OU5B5YK6-f5v6z8yr.js → ishikawaDiagram-OU5B5YK6-kh4nqj6q.js} +3 -3
  109. package/dist/client/static/js/java-caqpfm88.js +1 -0
  110. package/dist/client/static/js/{journeyDiagram-ZHPQQLJL-js1yxatk.js → journeyDiagram-ZHPQQLJL-4khnf8x1.js} +5 -5
  111. package/dist/client/static/js/json-qn73s8xb.js +1 -0
  112. package/dist/client/static/js/jsx-bvterpm5.js +1 -0
  113. package/dist/client/static/js/{julia-0h9krgsd.js → julia-svwxx41e.js} +1 -1
  114. package/dist/client/static/js/{kanban-definition-PNTS6WVX-m0a6069c.js → kanban-definition-PNTS6WVX-snmq3wq4.js} +4 -4
  115. package/dist/client/static/js/lua-1hcfm8ya.js +1 -0
  116. package/dist/client/static/js/markdown-n6na4ykv.js +1 -0
  117. package/dist/client/static/js/{mermaid.core-6xvbnm63.js → mermaid.core-yctw30sk.js} +7 -7
  118. package/dist/client/static/js/{mindmap-definition-NLK3R4M7-a9f9yzc0.js → mindmap-definition-NLK3R4M7-atfv66wq.js} +3 -3
  119. package/dist/client/static/js/one-dark-pro-c1vnxka7.js +1 -0
  120. package/dist/client/static/js/one-light-mbxx52p5.js +1 -0
  121. package/dist/client/static/js/packet-AYTQ26CC-mtzmsrk4.js +1 -0
  122. package/dist/client/static/js/{pegDiagram-GJSIUBJH-4v4pf1h1.js → pegDiagram-GJSIUBJH-hpbtxjht.js} +1 -1
  123. package/dist/client/static/js/{perl-rptyx23q.js → perl-mr0ds2ex.js} +1 -1
  124. package/dist/client/static/js/{php-sagvq3wz.js → php-5h3wt6tv.js} +1 -1
  125. package/dist/client/static/js/pie-WAS4IAKB-85nwadmj.js +1 -0
  126. package/dist/client/static/js/{pieDiagram-5QR66LMP-a54yrmfm.js → pieDiagram-5QR66LMP-9zrtkdr2.js} +2 -2
  127. package/dist/client/static/js/properties-nxcks67c.js +1 -0
  128. package/dist/client/static/js/python-58p0gqn0.js +1 -0
  129. package/dist/client/static/js/{quadrantDiagram-O4NWA36T-1twhvnp2.js → quadrantDiagram-O4NWA36T-xq970vx1.js} +6 -6
  130. package/dist/client/static/js/r-eyn8en0g.js +1 -0
  131. package/dist/client/static/js/radar-RG4KPBEZ-ae3jdajx.js +1 -0
  132. package/dist/client/static/js/railroad-74A4TZTK-3m0s7cse.js +1 -0
  133. package/dist/client/static/js/railroad-abnf-HS5TGJTU-pz22c3eb.js +1 -0
  134. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-cgqgqq15.js +1 -0
  135. package/dist/client/static/js/railroad-peg-WCYAUIDC-ts0nmcxb.js +1 -0
  136. package/dist/client/static/js/{railroadDiagram-XR7U4H2S-83tqfdcy.js → railroadDiagram-XR7U4H2S-1g9jchbk.js} +1 -1
  137. package/dist/client/static/js/{requirementDiagram-PLB6GJNP-73e3pzw6.js → requirementDiagram-PLB6GJNP-ntt088y4.js} +4 -4
  138. package/dist/client/static/js/{ruby-9qyx7knh.js → ruby-nn836rtq.js} +1 -1
  139. package/dist/client/static/js/{rust-jds4e4r7.js → rust-eygk56y5.js} +1 -1
  140. package/dist/client/static/js/{sankeyDiagram-IPEJSGJF-1bzwj6sb.js → sankeyDiagram-IPEJSGJF-95k8c5v6.js} +5 -5
  141. package/dist/client/static/js/{sass-07rteya0.js → sass-c2bk03e4.js} +1 -1
  142. package/dist/client/static/js/{scss-e2dndbfa.js → scss-qycakpjn.js} +1 -1
  143. package/dist/client/static/js/{sequenceDiagram-PO4LG4MO-yh3h988k.js → sequenceDiagram-PO4LG4MO-qfvxrwfa.js} +19 -19
  144. package/dist/client/static/js/{sizeCapture-INFHLROL-1n121yp6.js → sizeCapture-INFHLROL-0m7dc5nd.js} +1 -1
  145. package/dist/client/static/js/{stateDiagram-v2-GCMORJYK-0tdrzn06.js → stateDiagram-v2-GCMORJYK-femwcn7n.js} +5 -5
  146. package/dist/client/static/js/{svelte-w365cpwa.js → svelte-bfy1rq5g.js} +1 -1
  147. package/dist/client/static/js/{swimlanes-2SLR337P-77n1ttdw.js → swimlanes-2SLR337P-5n1qq48r.js} +1 -1
  148. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-n85hawg8.js +8 -0
  149. package/dist/client/static/js/{timeline-definition-EJHVYXUP-b6r0k3e8.js → timeline-definition-EJHVYXUP-vdsj18be.js} +7 -7
  150. package/dist/client/static/js/treeView-Q6P3EWNA-fvpt3hm8.js +1 -0
  151. package/dist/client/static/js/treemap-WGGIJYW6-4z9s24je.js +1 -0
  152. package/dist/client/static/js/tsx-fnzxsv25.js +1 -0
  153. package/dist/client/static/js/typescript-0ppbqrb6.js +1 -0
  154. package/dist/client/static/js/{usecaseDiagram-POWQR4AR-efq58m3m.js → usecaseDiagram-POWQR4AR-psjbrprk.js} +43 -43
  155. package/dist/client/static/js/{vennDiagram-UO4OBE2U-ad4gvd5r.js → vennDiagram-UO4OBE2U-4yn9kac9.js} +7 -7
  156. package/dist/client/static/js/{vue-d6cesny1.js → vue-0fwtgwj4.js} +1 -1
  157. package/dist/client/static/js/wardley-WFR3VGLG-73mrhkmy.js +1 -0
  158. package/dist/client/static/js/{wardleyDiagram-VNRHLVJA-v89tys2p.js → wardleyDiagram-VNRHLVJA-js0tbpca.js} +3 -3
  159. package/dist/client/static/js/xml-v1ytr8qz.js +1 -0
  160. package/dist/client/static/js/{xychartDiagram-PMCCYNJV-xtgzmknw.js → xychartDiagram-PMCCYNJV-svr38ygh.js} +5 -5
  161. package/dist/client/static/js/yaml-txrqz62t.js +1 -0
  162. package/marketplace/plugins/stats/package.json +2 -2
  163. package/marketplace/plugins/stats/src/proc/identity.ts +4 -3
  164. package/package.json +2 -2
  165. package/src/client/App.tsx +1 -1
  166. package/src/client/borders.css +143 -0
  167. package/src/client/components/common/context-usage-button/Ring.tsx +34 -9
  168. package/src/client/components/common/context-usage-button/index.test.tsx +19 -2
  169. package/src/client/components/common/context-usage-button/index.tsx +4 -4
  170. package/src/client/components/common/header-controls/index.test.tsx +26 -59
  171. package/src/client/components/common/header-controls/index.tsx +41 -52
  172. package/src/client/components/common/header-controls/phone-row.test.tsx +265 -0
  173. package/src/client/components/common/header-controls/plugin-entry.test.tsx +25 -3
  174. package/src/client/components/common/header-controls/shell-chrome.test.tsx +2 -2
  175. package/src/client/components/layout/LeftDock.tsx +7 -0
  176. package/src/client/components/layout/desktop-layout/DesktopOverlays.tsx +51 -0
  177. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +117 -15
  178. package/src/client/components/layout/desktop-layout/RightColumn.tsx +257 -0
  179. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +23 -24
  180. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +50 -78
  181. package/src/client/components/layout/desktop-layout/index.tsx +73 -73
  182. package/src/client/components/layout/session-sidebar/Footer.test.tsx +20 -0
  183. package/src/client/components/layout/session-sidebar/Footer.tsx +24 -2
  184. package/src/client/components/layout/session-sidebar/Header.test.ts +10 -0
  185. package/src/client/components/layout/session-sidebar/Header.tsx +2 -2
  186. package/src/client/components/mobile/mobile-main-view/Header.test.tsx +2 -3
  187. package/src/client/components/mobile/mobile-main-view/Header.tsx +12 -10
  188. package/src/client/components/settings/Modal.tsx +14 -9
  189. package/src/client/components/settings/ProjectSelectorDropdown.tsx +18 -6
  190. package/src/client/components/settings/SettingsSidebarList.tsx +2 -1
  191. package/src/client/components/settings/Sidebar.tsx +6 -4
  192. package/src/client/components/settings/apply-side-effects.test.ts +17 -0
  193. package/src/client/components/settings/apply-side-effects.ts +26 -5
  194. package/src/client/components/settings/band-height.test.tsx +122 -0
  195. package/src/client/components/settings/categories/AppearanceSettings.test.tsx +144 -0
  196. package/src/client/components/settings/categories/AppearanceSettings.tsx +81 -39
  197. package/src/client/components/settings/categories/ChatSettings.tsx +9 -15
  198. package/src/client/components/settings/categories/UsageSettings.tsx +2 -1
  199. package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.test.tsx +101 -0
  200. package/src/client/components/settings/categories/appearance-settings/BorderStyleSection.tsx +134 -0
  201. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -2
  202. package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +5 -5
  203. package/src/client/components/settings/categories/appearance-settings/EditorIndentSection.tsx +2 -2
  204. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +6 -6
  205. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -2
  206. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +2 -2
  207. package/src/client/components/settings/categories/appearance-settings/PanelNavSection.tsx +167 -0
  208. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +2 -2
  209. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +2 -2
  210. package/src/client/components/settings/categories/appearance-settings/ThemeSection.tsx +42 -0
  211. package/src/client/components/settings/categories/appearance-settings/TrayIconSection.tsx +2 -2
  212. package/src/client/components/settings/categories/appearance-settings/groups.test.ts +47 -0
  213. package/src/client/components/settings/categories/appearance-settings/groups.ts +95 -0
  214. package/src/client/components/settings/categories/chat-settings/LayoutSection.tsx +31 -14
  215. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +2 -1
  216. package/src/client/components/settings/categories/project-settings/SidebarList.tsx +2 -1
  217. package/src/client/components/settings/categories/provider-settings/SidebarList.tsx +2 -1
  218. package/src/client/components/settings/categories/usage-settings/SidebarList.tsx +2 -1
  219. package/src/client/components/settings/master-detail/GroupDetail.tsx +38 -0
  220. package/src/client/components/settings/{categories/chat-settings/SidebarList.tsx → master-detail/GroupSidebar.tsx} +35 -12
  221. package/src/client/components/settings/master-detail/index.tsx +3 -1
  222. package/src/client/components/settings/pane-header.ts +25 -0
  223. package/src/client/components/workspace/browser-toolbar/index.test.tsx +39 -1
  224. package/src/client/components/workspace/browser-toolbar/index.tsx +53 -17
  225. package/src/client/components/workspace/chat-timeline/ColumnResizeHandle.tsx +107 -0
  226. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +9 -3
  227. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +35 -26
  228. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +6 -0
  229. package/src/client/components/workspace/chat-timeline/column-resize.test.tsx +292 -0
  230. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +5 -3
  231. package/src/client/components/workspace/context-panel/index.tsx +10 -4
  232. package/src/client/components/workspace/editor/EditorHideButton.tsx +41 -0
  233. package/src/client/components/workspace/editor/EmptyEditor.tsx +11 -2
  234. package/src/client/components/workspace/editor/PluginColumn.tsx +11 -1
  235. package/src/client/components/workspace/editor/Tabs.tsx +8 -0
  236. package/src/client/components/workspace/editor/editor-hide-button.test.ts +144 -0
  237. package/src/client/components/workspace/editor/index.tsx +8 -2
  238. package/src/client/components/workspace/editor/props.ts +9 -0
  239. package/src/client/components/workspace/file-explorer/RowLabel.test.tsx +90 -0
  240. package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -4
  241. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.test.ts +52 -46
  242. package/src/client/components/workspace/git-panel/commit-modal/CommitRow.tsx +41 -21
  243. package/src/client/components/workspace/git-panel/commit-modal/GraphCanvas.tsx +6 -5
  244. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +19 -22
  245. package/src/client/components/workspace/panel-header/title-policy.test.tsx +62 -0
  246. package/src/client/components/workspace/panel-header/title-policy.tsx +83 -0
  247. package/src/client/components/workspace/panel-tabs/Home.density.test.tsx +122 -0
  248. package/src/client/components/workspace/panel-tabs/Home.test.tsx +137 -0
  249. package/src/client/components/workspace/panel-tabs/Home.tsx +106 -0
  250. package/src/client/components/workspace/panel-tabs/TabStrip.test.tsx +221 -0
  251. package/src/client/components/workspace/panel-tabs/TabStrip.tsx +315 -0
  252. package/src/client/components/workspace/panel-tabs/index.tsx +97 -0
  253. package/src/client/components/workspace/panels/builtin.tsx +9 -0
  254. package/src/client/components/workspace/plan-panel/index.tsx +7 -2
  255. package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
  256. package/src/client/components/workspace/repo-picker/index.test.tsx +32 -8
  257. package/src/client/components/workspace/repo-picker/index.tsx +2 -2
  258. package/src/client/components/workspace/search-panel/Body.tsx +7 -1
  259. package/src/client/components/workspace/search-panel/index.tsx +2 -1
  260. package/src/client/components/workspace/terminal-panel/Header.tsx +10 -3
  261. package/src/client/components/workspace/terminal-panel/index.tsx +4 -1
  262. package/src/client/components/workspace/todo-panel/index.tsx +6 -1
  263. package/src/client/components/workspace/usage-panel/index.tsx +7 -2
  264. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +43 -4
  265. package/src/client/components/workspace/user-browser-panel/Frame.tsx +101 -45
  266. package/src/client/components/workspace/user-browser-panel/TabStrip.tsx +107 -0
  267. package/src/client/components/workspace/user-browser-panel/index.tsx +31 -6
  268. package/src/client/glass.test.ts +1 -1
  269. package/src/client/hooks/browser/use-annotate.ts +6 -5
  270. package/src/client/hooks/browser/use-user-browser.test.tsx +279 -0
  271. package/src/client/hooks/browser/use-user-browser.ts +190 -44
  272. package/src/client/hooks/chat/timeline/column-drag.ts +171 -0
  273. package/src/client/hooks/chat/timeline/width-mode.test.ts +112 -11
  274. package/src/client/hooks/chat/timeline/width-mode.ts +91 -18
  275. package/src/client/hooks/ui/border-style.test.ts +172 -0
  276. package/src/client/hooks/ui/border-style.ts +60 -0
  277. package/src/client/hooks/ui/navbar-controls.test.ts +27 -1
  278. package/src/client/hooks/ui/navbar-controls.ts +95 -20
  279. package/src/client/hooks/ui/style-attributes.test.ts +2 -0
  280. package/src/client/hooks/workspace/active-project.ts +46 -0
  281. package/src/client/hooks/workspace/commit-expansion.test.ts +135 -0
  282. package/src/client/hooks/workspace/commit-expansion.ts +56 -0
  283. package/src/client/hooks/workspace/panel-nav.test.ts +102 -0
  284. package/src/client/hooks/workspace/panel-nav.ts +95 -0
  285. package/src/client/hooks/workspace/panel-tabs.session.test.tsx +235 -0
  286. package/src/client/hooks/workspace/panel-tabs.ts +194 -0
  287. package/src/client/hooks/workspace/right-open-request.ts +53 -0
  288. package/src/client/hooks/workspace/right-side.test.ts +204 -0
  289. package/src/client/hooks/workspace/right-side.ts +142 -0
  290. package/src/client/main.tsx +9 -4
  291. package/src/client/tailwind.css +6 -0
  292. package/src/server/lib/assets/shell-attributes.server.ts +26 -10
  293. package/src/server/lib/assets/shell-attributes.test.ts +26 -0
  294. package/src/server/lib/harness/acp/background-replay.test.ts +16 -1
  295. package/src/server/lib/harness/acp/background-replay.ts +6 -1
  296. package/src/server/lib/harness/acp/background-work.ts +44 -31
  297. package/src/server/lib/harness/acp/session-turns.ts +4 -3
  298. package/src/server/lib/harness/acp/session-wiring.test.ts +53 -0
  299. package/src/server/lib/harness/acp/session-wiring.ts +11 -2
  300. package/src/server/lib/harness/session-lease.server.ts +3 -2
  301. package/src/server/lib/omp/session/lease-probe.server.test.ts +82 -0
  302. package/src/server/lib/omp/session/lease-probe.server.ts +180 -0
  303. package/src/server/lib/omp/session/ownership.server.test.ts +17 -6
  304. package/src/server/lib/omp/session/ownership.server.ts +7 -5
  305. package/src/server/plugins/ssr.ts +6 -3
  306. package/src/shared/lib/browser/user-tabs.test.ts +165 -0
  307. package/src/shared/lib/browser/user-tabs.ts +172 -0
  308. package/src/shared/lib/chat/timeline/width-mode.test.ts +34 -2
  309. package/src/shared/lib/chat/timeline/width-mode.ts +71 -22
  310. package/src/shared/lib/commands/catalog.ts +2 -2
  311. package/src/shared/lib/fs/git-status.test.ts +23 -0
  312. package/src/shared/lib/fs/git-status.ts +15 -0
  313. package/src/shared/lib/icons/tint-hues.generated.ts +20 -20
  314. package/src/shared/lib/settings/defaults.ts +7 -1
  315. package/src/shared/lib/theme/border-style.test.ts +83 -0
  316. package/src/shared/lib/theme/border-style.ts +122 -0
  317. package/src/shared/lib/workspace/keymap.ts +2 -1
  318. package/src/shared/lib/workspace/panel-nav.test.ts +162 -0
  319. package/src/shared/lib/workspace/panel-nav.ts +105 -0
  320. package/src/shared/lib/workspace/panel-tabs-close.test.ts +154 -0
  321. package/src/shared/lib/workspace/panel-tabs.ts +105 -0
  322. package/src/shared/lib/workspace/session-state/cache.ts +22 -0
  323. package/src/shared/lib/workspace/session-state/merge.ts +6 -0
  324. package/src/shared/lib/workspace/session-state/store.ts +23 -0
  325. package/src/shared/types/settings/state.ts +50 -3
  326. package/src/test-support/header-controls-harness.ts +22 -0
  327. package/src/test-support/peer-harness.ts +2 -2
  328. package/dist/client/static/js/ImageView-rnzf5tve.js +0 -1
  329. package/dist/client/static/js/LayoutWrapper-rekrgth6.js +0 -2
  330. package/dist/client/static/js/SessionsView-e84tjbcr.js +0 -1
  331. package/dist/client/static/js/architecture-7GRP2DOG-7j23x20s.js +0 -1
  332. package/dist/client/static/js/bash-vv2ysp0a.js +0 -1
  333. package/dist/client/static/js/c-8jf64j6h.js +0 -1
  334. package/dist/client/static/js/cpp-vh94zee0.js +0 -1
  335. package/dist/client/static/js/css-a13jmmnc.js +0 -1
  336. package/dist/client/static/js/css-p57h1fme.js +0 -1
  337. package/dist/client/static/js/cynefin-OW5HDTMX-me5xnx6a.js +0 -1
  338. package/dist/client/static/js/eventmodeling-NTZA5JFV-5zbvjj84.js +0 -1
  339. package/dist/client/static/js/flowDiagram-KWPJA3E3-36ygrbvm.js +0 -1
  340. package/dist/client/static/js/gitGraph-4MIJSDKK-tjhkv71w.js +0 -1
  341. package/dist/client/static/js/graphql-kesh8gk0.js +0 -1
  342. package/dist/client/static/js/html-sxpfydga.js +0 -1
  343. package/dist/client/static/js/index-0q2qfcjn.js +0 -1
  344. package/dist/client/static/js/index-48gh56ka.js +0 -3
  345. package/dist/client/static/js/index-4rv388z7.js +0 -2
  346. package/dist/client/static/js/index-52xmdeh2.js +0 -1
  347. package/dist/client/static/js/index-8kqepehd.js +0 -12
  348. package/dist/client/static/js/index-cje5gg45.js +0 -1
  349. package/dist/client/static/js/index-fbcg8y95.js +0 -1
  350. package/dist/client/static/js/index-g3shdymf.js +0 -1
  351. package/dist/client/static/js/index-h5n1btqy.js +0 -1
  352. package/dist/client/static/js/index-m1n4v0z7.js +0 -9
  353. package/dist/client/static/js/index-rn8w29pv.js +0 -2
  354. package/dist/client/static/js/index-sg6sz3g8.js +0 -1
  355. package/dist/client/static/js/index-vcrh95gf.css +0 -1
  356. package/dist/client/static/js/index-w5rw8f7w.js +0 -1
  357. package/dist/client/static/js/index-x6v37h3j.js +0 -1
  358. package/dist/client/static/js/info-A6RAGUB7-m6qz24p8.js +0 -1
  359. package/dist/client/static/js/ini-1x0ad976.js +0 -1
  360. package/dist/client/static/js/java-3944nq02.js +0 -1
  361. package/dist/client/static/js/json-g5ggnd94.js +0 -1
  362. package/dist/client/static/js/jsx-f6p72qpc.js +0 -1
  363. package/dist/client/static/js/lua-edn2b3wn.js +0 -1
  364. package/dist/client/static/js/markdown-9dhg1fax.js +0 -1
  365. package/dist/client/static/js/one-dark-pro-hteqzfb0.js +0 -1
  366. package/dist/client/static/js/one-light-dapnh0rs.js +0 -1
  367. package/dist/client/static/js/packet-AYTQ26CC-ng6wq5xj.js +0 -1
  368. package/dist/client/static/js/pie-WAS4IAKB-rf6jhxf6.js +0 -1
  369. package/dist/client/static/js/properties-fcmj08pv.js +0 -1
  370. package/dist/client/static/js/python-532d8ezm.js +0 -1
  371. package/dist/client/static/js/r-ptmdxs2a.js +0 -1
  372. package/dist/client/static/js/radar-RG4KPBEZ-ygp6hxq4.js +0 -1
  373. package/dist/client/static/js/railroad-74A4TZTK-rxgnrb2g.js +0 -1
  374. package/dist/client/static/js/railroad-abnf-HS5TGJTU-xkv52a2p.js +0 -1
  375. package/dist/client/static/js/railroad-ebnf-LZEXJU2U-bvcktbqh.js +0 -1
  376. package/dist/client/static/js/railroad-peg-WCYAUIDC-9c3v7jsq.js +0 -1
  377. package/dist/client/static/js/swimlanesDiagram-TC7HE7FX-akjqm31r.js +0 -8
  378. package/dist/client/static/js/treeView-Q6P3EWNA-fb58a7z1.js +0 -1
  379. package/dist/client/static/js/treemap-WGGIJYW6-ej4qhksx.js +0 -1
  380. package/dist/client/static/js/tsx-zfy727zs.js +0 -1
  381. package/dist/client/static/js/typescript-683kkkaw.js +0 -1
  382. package/dist/client/static/js/wardley-WFR3VGLG-mkp0kanv.js +0 -1
  383. package/dist/client/static/js/xml-6ct32gys.js +0 -1
  384. package/dist/client/static/js/yaml-1d5m3bfj.js +0 -1
  385. package/src/server/lib/omp/session/lease-flock.server.ts +0 -117
@@ -2,8 +2,10 @@ import type { ThemeId } from '@/shared/lib/theme/catalog';
2
2
  import type { ChatWidthMode } from '@/shared/lib/chat/timeline/width-mode';
3
3
  import type { ToolRenderMode } from '@/shared/lib/chat/timeline/tool-render-mode';
4
4
  import type { SidebarStyle } from '@/shared/lib/workspace/sidebar-style';
5
+ import type { PanelNavStyle } from '@/shared/lib/workspace/panel-nav';
5
6
  import type { ComposerStyle } from '@/shared/lib/chat/composer/style';
6
7
  import type { SurfaceStyle } from '@/shared/lib/theme/surface-style';
8
+ import type { BorderStyle } from '@/shared/lib/theme/border-style';
7
9
  import type { IconStyle } from '@/shared/lib/theme/icon-style';
8
10
  import type { TrayIconStyle } from '@/shared/lib/theme/tray-icon-style';
9
11
  import type { SettingsSection } from '@/shared/lib/settings/sections';
@@ -141,15 +143,23 @@ export interface SettingsState {
141
143
  */
142
144
  goalDefaultBudget: number | null;
143
145
  /**
144
- * How wide the chat's content column is (`compact` | `wide` | `full`). A
145
- * READING width, not a layout: no mode hides a panel. The numbers live in
146
- * `tailwind.css` (`--chat-column-max`); this field only names the choice.
146
+ * How wide the chat's content column is (`compact` | `wide` | `full` |
147
+ * `custom`). A READING width, not a layout: no mode hides a panel. The
148
+ * PRESET numbers live in `tailwind.css` (`--chat-column-max`); `custom` draws
149
+ * at `chatColumnWidth` below.
147
150
  *
148
151
  * Global, not per-session: a comfortable line length is a property of the
149
152
  * person and the display, not of one conversation, and a per-session value
150
153
  * would send every new chat back to the default.
151
154
  */
152
155
  chatWidthMode: ChatWidthMode;
156
+ /**
157
+ * Pixel width a `custom` column draws at, written by dragging the column's
158
+ * edge. Kept while a preset is active, so picking Custom again restores the
159
+ * width the user dragged instead of a placeholder. Clamped on read
160
+ * (`resolveChatColumnWidth`), because a stored value is untrusted input.
161
+ */
162
+ chatColumnWidth: number;
153
163
  /**
154
164
  * How a tool call is drawn in the transcript (`card` | `compact` | `trace` |
155
165
  * `minimal` | `tui`). A reading style: every mode renders the same call,
@@ -176,6 +186,28 @@ export interface SettingsState {
176
186
  * `classic` is the default so an upgrade rearranges nothing.
177
187
  */
178
188
  sidebarStyle: SidebarStyle;
189
+ /**
190
+ * How the DESKTOP left panel column is navigated (`rail` | `tabs`).
191
+ *
192
+ * A PRESENTATION choice over one catalog: both styles draw the same views and
193
+ * the same bodies. `rail` is the 44px vertical activity bar every install
194
+ * already has; `tabs` is a browser-style strip of opened views over a home
195
+ * page that draws the whole catalog as a card grid.
196
+ *
197
+ * **Independent of `rightPanelNav`**, and desktop-only: a phone has one drawer
198
+ * per side and keeps its chip strip, so `mobile/**` never reads either value.
199
+ * `rail` is the default so an upgrade rearranges nothing.
200
+ */
201
+ leftPanelNav: PanelNavStyle;
202
+ /**
203
+ * How the DESKTOP right panel column is navigated (`rail` | `tabs`).
204
+ *
205
+ * Independent of `leftPanelNav`: the two columns answer different questions
206
+ * (the left is the session list plus placed panels, the right is a working set
207
+ * the user opens and closes), so a user may want tabs on one and the rail on
208
+ * the other. Desktop-only, like its left counterpart.
209
+ */
210
+ rightPanelNav: PanelNavStyle;
179
211
  /**
180
212
  * How the chat composer is drawn (`classic` | `calm` | `console` | `stage`).
181
213
  * A PRESENTATION choice over one composer: every style renders the same
@@ -199,6 +231,21 @@ export interface SettingsState {
199
231
  * call site each. `classic` is the default so an upgrade restyles nothing.
200
232
  */
201
233
  surfaceStyle: SurfaceStyle;
234
+ /**
235
+ * How the app's HAIRLINES are drawn (`hairline` | `borderless`). A
236
+ * presentation choice over one shell: both styles draw the same panels, rows
237
+ * and controls, and `borderless` removes only the 1px rules between them —
238
+ * never a control's own edge, a validation colour, a drop zone or a focus
239
+ * ring, because those are facts and affordances rather than decoration. The
240
+ * table lives in `shared/lib/theme/border-style.ts`; the pixels are the
241
+ * `[data-borders="borderless"]` block in `src/client/borders.css`.
242
+ *
243
+ * It reaches the document as `data-borders` on `<html>`, for the same reason
244
+ * as the surface material: the sidebar, navbar, composer and every modal are
245
+ * separate subtrees. `hairline` is what CSS paints with no attribute, so an
246
+ * upgrade removes nothing.
247
+ */
248
+ borderStyle: BorderStyle;
202
249
  /**
203
250
  * How EVERY icon is painted (`monochrome` | `color`): functional Lucide
204
251
  * glyphs, provider/model marks and file-type marks. `color` gives each glyph
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `HeaderControls` with the plugin entries its surface resolves.
8
+ *
9
+ * The cluster takes `entries` from its caller (the row and the visibility menu
10
+ * are two halves of one `useHeaderEntries` answer), so a suite that mounts the
11
+ * cluster on its own has to stand in for that caller. This harness is the
12
+ * caller, not a second contract: it renders the real component with the real
13
+ * hook against the suite's realtime server and plugin registry.
14
+ */
15
+
16
+ import { h } from 'preact';
17
+ import { HeaderControls, type HeaderControlsProps } from '@/client/components/common/header-controls';
18
+ import { useHeaderEntries } from '@/client/components/common/header-panel-buttons/entries';
19
+
20
+ export function HeaderControlsHarness(props: Omit<HeaderControlsProps, 'entries'>) {
21
+ return h(HeaderControls, { ...props, entries: useHeaderEntries(props.layout) });
22
+ }
@@ -23,7 +23,7 @@ import { join } from 'node:path';
23
23
 
24
24
  import type { RealtimeConnection } from '@/server/lib/realtime/hub.server';
25
25
  import { sessionLeasePath } from '@/server/lib/omp/session/ownership.server';
26
- import { leaseHeldByAnother } from '@/server/lib/omp/session/lease-flock.server';
26
+ import { leaseHeldByAnother } from '@/server/lib/omp/session/lease-probe.server';
27
27
  import { isProcessAlive, processParentPid } from '@/server/lib/lifecycle/identity';
28
28
  import type { RealtimeServerFrame } from '@/shared/lib/realtime/protocol';
29
29
 
@@ -207,7 +207,7 @@ export async function holdLeaseInForeignProcess(sessionId: string): Promise<Fore
207
207
  const lease = sessionLeasePath(sessionId);
208
208
  writeFileSync(lease, '');
209
209
  const script = `
210
- const { holdLeaseForTest } = await import(${JSON.stringify(join(import.meta.dir, '..', 'server/lib/omp/session/lease-flock.server.ts'))});
210
+ const { holdLeaseForTest } = await import(${JSON.stringify(join(import.meta.dir, '..', 'server/lib/omp/session/lease-probe.server.ts'))});
211
211
  holdLeaseForTest(process.argv[1]);
212
212
  await Promise.withResolvers().promise;
213
213
  `;
@@ -1 +0,0 @@
1
- import{e,m,Dr}from"./index-f77c3ag0.js";import{gi,Hc}from"./index-8kqepehd.js";function g({source:t,name:r,revision:s=0}){let{url:i,loading:n,error:o}=Hc(t,s);if(o)return e(Dr,{name:r,message:o});if(n||!i)return e("div",{className:"flex flex-1 items-center justify-center gap-2 text-xs text-ink/40",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading image…"})]});return e(gi,{src:i,name:r,className:"flex-1 min-h-0"})}export{g as ImageView};
@@ -1,2 +0,0 @@
1
- import{d,n,o,K,i,u,a,Ve,le,gn,Xl,e,Kn,$s,tt,Te,Xt,Yg,$a,Fp,s,Qe,Ie,m,en,_,nt,tn,f,B,se,rt,re,ge,St,qe,ln,pe,Ge,ce,ka,Kr,cn,xa,W,D,O,Gs,b,dn,js,Pe,Tt,Co,me,Z,st,Yi,Ji,qu,tc,xe,je,Xi,wA,ac,Ct,Nt,Qt,ic,Js,Bo,Zs,Xs,Ju,_o,He,Ze,na,We,nl,rl,Cc,_a,Ec,Xu,is,Sa,To,Do,No,Bt,Xn,us,Qo,Ro,Fo,ol,Ka,il,sl,ll,cl,Br,Dm,Nm,Lo,Tc,Rm,Fm,Lm,Dc,er,Ir,Mo,Po,Mm,Pm,Nc,Va,Om,$m,zm,sh,ad,lh,ut,od,Um,Gm,jm,ul,fg,af,Rc,hl,df,pf,gd,mf,Eh}from"./index-f77c3ag0.js";import{Oc,$c,zc,Uc,Gc,jc,qc,yd,ms,$o,fs,gi,Wc,bl,Kc,Vc,Yc,Jc,Zc,Xc,eu,tu,nu}from"./index-8kqepehd.js";import{Mu,Pu,Yo,Ou,$u}from"./index-m94f4ngb.js";import{pt,Ai,au,ou,su}from"./index-rn8w29pv.js";import{hs,Da,Nr,lu,cu,zo,uu,bs,Sd,Eg,ys,vs,ks,Qr,xs,ws,Uo,Cs,Es,Bs,Is,bi,Go,_s,Ss,du,Td,pu,mu,fu,gu,Au,hu}from"./index-s7rfbydk.js";import{Na,Qa}from"./index-48pb18zj.js";function to(t){let{editorOpen:r,diffOpen:c,settingsOpen:p,offMainScreen:h,onCloseEditor:g,onCloseDiff:v,onCloseSettings:S,onReturnToMain:k}=t;o(()=>Eh(()=>{if(r)return g(),!0;if(c)return v(),!0;if(p)return S(),!0;if(h)return k(),!0;return!1}),[r,c,p,h,g,v,S,k])}var gt={name:"menu",size:24,node:[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]},no=s(gt);function ze(){let t=Xi(),[r,c]=n(null),p=a((v,S)=>{c({top:S,bottom:S,left:v,right:v})},[]),h=Mu({enabled:t,onLongPress:p}),g=a(()=>c(null),[]);return{anchor:r,close:g,surfaceProps:{onContextMenu:(v)=>{v.preventDefault();let S=v.currentTarget.getBoundingClientRect();c({top:S.top,bottom:S.bottom,left:S.left,right:S.right})},onTouchStart:h.onTouchStart,onTouchMove:h.onTouchMove,onTouchEnd:h.onTouchEnd,onTouchCancel:h.onTouchCancel,onClickCapture:(v)=>{if(!h.consume())return;v.preventDefault(),v.stopPropagation()}}}}var vt=10,io=600000;function ro({activeSessionTitle:t,activeSessionId:r,onOpenSessionSidebar:c,onOpenRightSidebar:p,onNewSession:h,onSelectSession:g}){let{folders:v}=We(),S=gd(),k=Sa(r),[l,x]=n(null),{hidden:N,setHidden:R}=Um(),y=ze(),E=u(()=>{let w=Date.now(),C=[];for(let A of v)for(let T of A.sessions??[]){if(T.is_archived===1)continue;let F=Yg(String(T.id)),I=T.updated_at?Date.parse(T.updated_at):0,j=F!==void 0&&w-F<=io?F:I;if(F!==void 0&&w-F>io)continue;C.push({id:T.id,title:T.title,folderName:A.name,modified:j})}return C.sort((A,T)=>T.modified-A.modified).slice(0,vt)},[v]),P=t?t.charAt(0).toUpperCase()+t.slice(1):"New session";return e("header",{className:`flex-shrink-0 bg-canvas border-b border-ink/10 flex items-center justify-between ${ol} px-3 z-20 titlebar-drag-region select-none`,...Mo(),...y.surfaceProps,style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingLeft:Po(er("0.75rem",!0)),paddingRight:Ir("0.75rem",!0),paddingTop:"env(safe-area-inset-top, 0px)"},children:[e("div",{className:"flex items-center space-x-2 flex-1 min-w-0 titlebar-no-drag",children:[e("button",{type:"button",onClick:c,className:"w-9 h-9 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0 inline-flex items-center justify-center",title:"Open Sessions","aria-label":"Open Sessions",children:e(no,{size:20,strokeWidth:2})}),e("span",{className:"relative font-bold text-sm tracking-tight flex items-center flex-shrink-0",children:[e(_a,{glow:!0}),e("span",{className:"absolute -top-0.5 -right-1.5 flex",children:e(Dc,{status:S})})]}),e("span",{className:"text-ink/25 font-light text-xs flex-shrink-0 select-none",children:"/"}),e("div",{className:"relative min-w-0 flex-1 max-w-[150px]","data-testid":"session-picker",children:[e("button",{type:"button",onClick:(w)=>{x((C)=>C?null:Ct(w.currentTarget))},className:"tap-chip flex w-full items-center space-x-1 text-xs font-semibold text-ink hover:text-ink/80 transition-colors py-1 min-w-0",title:P,"aria-haspopup":"menu","aria-expanded":l!==null,children:[e("span",{className:"truncate",children:P}),k&&e(m,{size:12,className:"animate-spin text-ink/50 flex-shrink-0",role:"status","aria-label":"Generating a session name…"}),e(B,{size:13,className:"text-ink/50 flex-shrink-0"})]}),l&&e(Nt,{anchor:l,align:"start",className:"w-72 bg-paper border border-ink/15 rounded-xl shadow-lg p-2 text-xs",onClose:()=>x(null),children:[e("button",{type:"button",onClick:()=>{x(null),h()},className:"w-full text-left px-3 py-2 rounded-lg bg-ink text-canvas flex items-center space-x-2 font-medium mb-1.5 active:scale-98",children:[e(W,{size:14}),e("span",{children:"Start New Session"})]}),e("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40",children:"Recent Sessions"}),e("div",{className:"max-h-64 scrollbar-overlay-container space-y-0.5",children:E.length===0?e("div",{className:"px-2.5 py-2 text-ink/40 italic",children:"No sessions yet"}):E.map((w)=>e("button",{type:"button",onClick:()=>{x(null),g(w.id)},className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between space-x-2 transition-colors ${String(r)===String(w.id)?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[e("span",{className:"min-w-0 flex flex-col",children:[e("span",{className:"truncate",children:w.title?w.title.charAt(0).toUpperCase()+w.title.slice(1):"Untitled"}),e("span",{className:"truncate text-[10px] text-ink/40 font-mono",children:w.folderName})]}),String(r)===String(w.id)&&e(f,{size:12,className:"flex-shrink-0"})]},w.id))})]})]})]}),e(Gm,{layout:"mobile",sessionId:r==null?null:String(r),showRightPanel:!1,onToggleRightPanel:p,hidden:N}),y.anchor?e(Lo,{anchor:y.anchor,title:"Navbar",align:"right",items:od.filter((w)=>w.id!==ut.install&&w.id!==ut.editor&&w.id!==ut.mobile).map((w)=>({...w,removable:!0})),hidden:N,onToggle:R,onClose:y.close}):null]})}function so({activeSessionId:t,onSelectSession:r,onNewSession:c,onOpenSessionSidebar:p,onOpenRightSidebar:h,appSettings:g={}}){let{folders:v}=We(),[S,k]=n(null),l=u(()=>{if(!t)return"New session";for(let N of v){let R=N.sessions?.find((y)=>String(y.id)===String(t));if(R)return R.title}return null},[t,v]);return e("div",{className:"flex flex-col h-full w-full bg-canvas text-ink relative",children:[e(ro,{activeSessionTitle:S||l||"New session",activeSessionId:t,onOpenSessionSidebar:p,onOpenRightSidebar:h,onNewSession:c,onSelectSession:r}),e("main",{className:"flex-1 min-h-0",children:e(af,{appSettings:g,onSessionTitle:k,variant:"mobile"})})]})}function ao({onClose:t,viewLabel:r="Sessions",menuProps:c}){return e("div",{className:"border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0 bg-canvas titlebar-drag-region select-none",...Mo(),...c,style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingLeft:Po(er("0.75rem",!0)),paddingRight:Ir("0.75rem",!0),paddingTop:"env(safe-area-inset-top, 0px)"},children:[e("div",{className:"flex items-center space-x-2.5 titlebar-no-drag min-w-0",children:[e("span",{className:"font-bold text-sm tracking-tight flex items-center flex-shrink-0",children:e(_a,{className:"text-[16px]",glow:!0})}),e("span",{className:"text-ink/25 text-xs select-none flex-shrink-0",children:"/"}),e("span",{className:"text-[11px] font-semibold text-ink/60 uppercase tracking-wider font-mono truncate",children:r})]}),e("div",{className:"flex items-center gap-1 titlebar-no-drag flex-shrink-0",children:[e(jm,{variant:"chip"}),e("button",{type:"button",onClick:t,className:"w-9 h-9 rounded-xl hover:bg-ink/5 active:bg-ink/10 text-ink flex items-center justify-center transition-colors cursor-pointer",title:"Close sidebar","aria-label":"Close sidebar",children:e(b,{size:19,strokeWidth:2})})]})]})}var Me="w-9.5 h-9.5 rounded-xl border active:scale-95 flex items-center justify-center transition-all flex-shrink-0 cursor-pointer shadow-xs",Re="border-ink/15 bg-paper hover:bg-ink/5 text-ink/80 hover:text-ink",lo="bg-ink/10 text-ink border-ink/30";function co({searchQuery:t,sortOption:r,optionsOpen:c,showArchived:p,optionsRef:h,onNewSession:g,onNewWorkspace:v,onScheduler:S,scheduledCount:k,onRefresh:l,refreshing:x,onToggleOptions:N,onSortChange:R,onResetSort:y,onToggleArchived:E,onHideArchived:P,onSearchChange:w,onClearSearch:C,onSelectWorkspaces:A,selecting:T}){let{ref:F,width:I}=bs(0),j=Eg(I),G={};for(let J of Sd.slice(0,j))G[J]=!0;let U=Sd.slice(j),M=p?"Hide archived sessions":"Show archived sessions",ee=k>0?`Scheduled tasks (${k} armed)`:"Scheduled tasks",Y=[];if(U.includes("new-workspace"))Y.push({id:"new-workspace",label:"New Workspace",icon:ln,onSelect:v});if(U.includes("refresh"))Y.push({id:"refresh",label:"Refresh sessions",icon:D,onSelect:l});if(U.includes("scheduler"))Y.push({id:"scheduler",label:ee,icon:Da,onSelect:S});if(U.includes("archive"))Y.push({id:"archive",label:M,icon:nt,onSelect:E,active:p});if(U.includes("select"))Y.push({id:"select",label:T?"Cancel selection":"Select workspaces",icon:Nr,onSelect:A,active:T});return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-2.5 flex-shrink-0 bg-canvas",children:[e("div",{ref:F,className:"flex items-center space-x-2",children:[e("button",{type:"button",onClick:g,"aria-label":"New Session",title:"New Session",className:"flex-1 min-w-0 h-9.5 flex items-center justify-center space-x-2 px-3.5 rounded-xl bg-ink text-canvas hover:bg-ink/90 active:scale-[0.98] text-xs font-semibold transition-all shadow-xs",children:[e(W,{size:15,strokeWidth:2.4,className:"shrink-0"}),e("span",{className:"min-w-0 truncate",children:"New Session"})]}),G["new-workspace"]&&e("button",{type:"button",onClick:v,className:`${Me} ${Re}`,title:"New Workspace","aria-label":"New Workspace",children:e(ln,{size:16,strokeWidth:1.8})}),G.scheduler&&e("button",{type:"button",onClick:S,className:`relative ${Me} ${Re}`,title:ee,"aria-label":k>0?`Scheduled tasks, ${k} armed`:"Scheduled tasks",children:[e(Da,{size:16,strokeWidth:1.8}),k>0&&e("span",{className:"absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-[3px] rounded-full bg-ink text-canvas text-[10px] leading-[13px] text-center font-semibold",children:k>9?"9+":k})]}),G.archive&&e("button",{type:"button",onClick:E,"aria-pressed":p,className:`${Me} ${p?"bg-warning/15 border-warning/40 text-warning":Re}`,title:M,"aria-label":M,children:e(nt,{size:16,strokeWidth:1.8})}),G.select&&e("button",{type:"button",onClick:A,"aria-pressed":T,className:`${Me} ${T?lo:Re}`,title:T?"Cancel selection":"Select workspaces","aria-label":T?"Cancel selection":"Select workspaces",children:e(Nr,{size:16,strokeWidth:1.8})}),G.refresh&&e("button",{type:"button",onClick:l,className:`${Me} ${Re}`,title:"Refresh sessions","aria-label":"Refresh sessions","aria-busy":x,children:e(D,{size:15,strokeWidth:1.8,className:x?"animate-spin":void 0})}),G.sort&&e("div",{className:"relative flex-shrink-0",ref:h,children:[e("button",{type:"button",onClick:N,className:`${Me} ${c||r!=="A-Z"?lo:Re}`,title:"Sort workspaces","aria-label":"Sort workspaces",children:e(hs,{size:15,strokeWidth:1.8})}),c&&e("div",{className:"glass-popover absolute right-0 top-full mt-2 w-52 bg-paper border border-ink/15 rounded-xl shadow-xl z-50 p-2 text-xs",children:e(zo,{variant:"mobile",sortOption:r,onSortChange:R})})]}),U.length>0&&e(uu,{actions:Y,sortHidden:U.includes("sort"),sortOption:r,onSortChange:R,layout:"mobile"})]}),e("div",{className:"relative flex items-center",children:[e(O,{size:14,className:"absolute left-3 text-ink/40"}),e("input",{type:"text",value:t,onChange:(J)=>w(J.currentTarget.value),placeholder:"Search workspaces & sessions...",className:"w-full bg-paper border border-ink/15 rounded-xl pl-8 pr-8 py-2 text-xs text-ink placeholder-ink/40 focus:outline-none focus:border-ink/40 transition-colors font-mono"}),t&&e("button",{type:"button",onClick:C,className:"absolute right-2.5 text-ink/40 hover:text-ink p-1","aria-label":"Clear search",children:e(b,{size:13})})]}),(p||r!=="A-Z")&&e("div",{className:"flex items-center space-x-1.5 flex-wrap gap-y-1 pt-0.5",children:[r!=="A-Z"&&e("span",{className:"inline-flex items-center space-x-1 bg-ink/5 border border-ink/10 text-ink/80 rounded-lg px-2 py-0.5 text-[10px] font-mono",children:[e("span",{children:["Sort: ",r.replace("_"," ")]}),e("button",{type:"button",onClick:y,className:"hover:text-ink ml-0.5",title:"Reset sort",children:e(b,{size:10})})]}),p&&e("span",{className:"inline-flex items-center space-x-1 bg-warning/15 border border-warning/25 text-warning rounded-lg px-2 py-0.5 text-[10px] font-mono",children:[e(nt,{size:10}),e("span",{children:"Archived"}),e("button",{type:"button",onClick:P,className:"hover:text-warning-hover ml-0.5",title:"Hide archived",children:e(b,{size:10})})]})]})]})}var xt="p-1.5 rounded-lg hover:bg-ink/10 active:bg-ink/15 text-ink/60 hover:text-ink";function po({folder:t,canWorktree:r,onOpenFolder:c,onNewWorktree:p,onSelectSessions:h,confirmDelete:g,onPin:v,onDelete:S,onRequestDelete:k,onCancelDelete:l}){let[x,N]=n(!1),R=i(null),[y,E]=n(null),P=(w)=>()=>{N(!1),w()};return e("div",{className:"relative flex items-center",onClick:(w)=>w.stopPropagation(),children:[e("button",{ref:R,type:"button",onClick:(w)=>{if(w.stopPropagation(),R.current)E(Ct(R.current));N((C)=>!C)},className:xt,title:"Workspace options","aria-label":`Options for ${t.name}`,"aria-haspopup":"menu","aria-expanded":x,children:e(Ie,{size:15})}),e(Nt,{anchor:x?y:null,align:"end",ariaLabel:`Options for ${t.name}`,className:"w-48 rounded-lg border border-ink/15 bg-paper py-1 text-xs shadow-lg",onClose:()=>{N(!1),l()},children:e(Bs,{variant:"mobile",isPinned:t.isPinned,onOpenFolder:c?P(c):void 0,onNewWorktree:r&&p?P(p):void 0,onSelectSessions:h?P(h):void 0,confirmDelete:g,onPin:P(v),onDelete:P(S),onRequestDelete:k,onCancelDelete:l})})]})}var mo={inset:"",insetPx:0,slotWidth:16,markGap:8,padding:"py-2",glyph:Ze.touch};function uo({session:t,harness:r,isActive:c,status:p,awaitingInput:h=!1,timeAgo:g,timeTitle:v,runStartedAt:S,expandable:k=!1,isExpanded:l=!1,onToggleExpand:x,isChild:N=!1,folderId:R,onSelect:y,onArchive:E,onDelete:P,onRename:w,onRenameWithAi:C,waitingFor:A,onCancelWait:T,selectable:F=!1,selected:I=!1,onToggleSelect:j}){let{isEditing:G,draft:U,setDraft:M,inputRef:ee,startRename:Y,handleKeyDown:J,handleBlur:ue}=No(t.title,w),de=Sa(t.id),oe=Qo(),te=oe.anchor!==null,q=Boolean(w||E||P||T),Q=Boolean(A),ae=k&&Boolean(x),ne=t.title.charAt(0).toUpperCase()+t.title.slice(1);if(G)return e("div",{className:"w-full rounded-lg flex items-center bg-ink/10",children:e("input",{ref:ee,autoFocus:!0,value:U,onChange:(X)=>M(X.currentTarget.value),onKeyDown:J,onBlur:ue,className:"flex-1 min-w-0 mx-2 my-1.5 bg-paper border border-ink/25 rounded px-2 py-1 text-xs text-ink outline-none focus:border-ink/50"})});return e(d,{children:[e("div",{"data-testid":"session-item","data-session-id":String(t.id),"data-menu-open":te?"true":void 0,onContextMenu:q&&!F?oe.openAtCursor:void 0,className:`w-full rounded-lg flex items-center transition-colors ${F&&I||te?Es:c?"bg-ink/10 font-medium text-ink":"hover:bg-ink/5 text-ink/85"}`,children:[e("button",{type:"button",onClick:F?j:y,className:"flex-1 text-left py-2 flex items-center justify-between min-w-0",children:[e("div",{className:"flex items-center min-w-0 pr-2",children:[F?e(Qr,{checked:I,label:`Select ${t.title}`,onChange:()=>j?.()}):e("span",{className:"w-4 flex-shrink-0 flex items-center justify-center",children:de?e("span",{role:"status","aria-label":"Generating a name…",children:e(m,{size:13,className:"text-ink/50 animate-spin"})}):h?e(Qe,{size:13,className:"text-ink/70 animate-pulse"}):Q?e("span",{role:"status","aria-label":`Waiting for ${A?.title??"another session"}`,children:e(Ge,{size:13,className:"text-ink/60 animate-pulse"})}):p==="stream"?e("span",{role:"status","aria-label":"Running",children:e(m,{size:13,className:"text-ink/50 animate-spin"})}):p?e(f,{size:13,className:"text-ink/50"}):N?e("span",{"data-testid":"child-indicator",className:"text-ink/35","aria-hidden":"true",children:e(pe,{size:13})}):null}),e("span",{className:"flex flex-col min-w-0 ml-2 leading-snug",children:[e("span",{className:"flex min-w-0 items-center",children:[r&&e("span",{className:"mr-1.5 flex shrink-0 items-center",children:e(He,{harness:r,size:Ze.touch})}),e("span",{className:"min-w-0 truncate text-xs",children:ne})]}),Q&&e("span",{className:"text-[10px] text-ink/40 truncate",children:["waiting for ",A?.title??"another session"]}),t.worktree?e(xs,{worktree:t.worktree}):null]})]}),e(Cs,{timeAgo:g,timeTitle:v,runStartedAt:S,className:"text-[11px] font-mono flex-shrink-0 ml-2",restingClassName:"text-ink/45"})]}),q&&!F&&e("button",{type:"button",onClick:oe.openBelow,title:"Session actions","aria-label":"Session actions","aria-haspopup":"menu","aria-expanded":te,className:"flex-shrink-0 py-1.5 pl-1.5 pr-1 text-ink/35 hover:text-ink rounded-lg cursor-pointer",children:e(Ie,{size:16})}),ae&&!F&&e("button",{type:"button",onClick:x,title:l?"Collapse sessions and subagents":"Expand sessions and subagents","aria-expanded":l,"aria-label":l?"Collapse sessions and subagents":"Expand sessions and subagents",className:"flex-shrink-0 py-1.5 pl-1.5 pr-1 flex items-center justify-center text-ink/50 hover:text-ink rounded-lg cursor-pointer",children:l?e(B,{size:14}):e(se,{size:14})})]}),oe.anchor&&e(Ro,{anchor:oe.anchor,sessionId:t.id,...r?{harness:r}:{},...R!==void 0?{folderId:R}:{},isArchived:t.is_archived===1,onRename:w?Y:void 0,onRenameWithAi:C,onArchive:E,onDelete:P,onCancelWait:T,onClose:oe.close})]})}function fo(t,r){let[c,p]=n(!1);return{open:()=>p(!0),dialog:c?e(Fo,{isOpen:!0,onClose:()=>p(!1),root:t.project_path??null,folderId:t.id,folderName:t.name,onCreated:(h)=>{p(!1),r(h.path)}}):null}}function ho({hiddenCount:t,canShowLess:r,onShowMore:c,onShowLess:p}){if(t<=0&&!r)return null;return e("div",{className:"flex items-center gap-1",children:[t>0&&e("button",{type:"button",onClick:c,className:"flex items-center min-w-0 text-left py-2 pr-3 text-xs text-ink/60 hover:text-ink",children:[e("span",{className:"w-4 h-4 flex-shrink-0 flex items-center justify-center",children:e(B,{size:12})}),e("span",{className:"w-2 shrink-0"}),e("span",{className:"truncate",children:["Show more sessions (",t,")"]})]}),r&&e("button",{type:"button",onClick:p,className:"ml-auto shrink-0 flex items-center gap-1 text-xs text-ink/60 hover:text-ink pl-3 py-2",children:[e(rt,{size:12}),e("span",{className:"truncate",children:"Show less"})]})]})}function bo(t){return t?"mb-4":"mb-1"}function go({folder:t,activeSessionId:r,onSelectSession:c,onNewSessionForFolder:p,onNewWorktreeSession:h,isExpanded:g,onToggleExpand:v,showArchived:S=!1,sessionStatus:k={},onToast:l,batch:x,onStartSessionSelection:N,onCancelWait:R}){let{visibleCount:y,showMore:E,showLess:P,canShowLess:w}=vs(),C=fo(t,(H)=>h?.(t.id,H)),{refresh:A,runStartedAtMap:T}=We(),{expandedSessionIds:F,toggleSession:I}=us(),[j]=le(),G=j.get("subagent"),U=j.get("sessionId"),{confirmDelete:M,requestDelete:ee,cancelDelete:Y,handlePin:J,handleDelete:ue,handleArchive:de,handleRename:oe,handleRenameWithAi:te,handleOpenFolder:q}=ks(t,A,l),Q=To(),ae=J,ne=ue,X=q??void 0,ve=(t.sessions||[]).filter((H)=>S?H.is_archived===1:H.is_archived!==1),we=na(t.icon),{folderCheckbox:ke,sessionCheckboxes:he,folderSummary:z,toggleFolderSelection:L,rendered:V,hiddenCount:fe}=_s({batch:x,folder:t,sessions:ve,showArchived:S,visibleCount:y,activeSessionId:r,sessionStatus:k}),Ee=Go(V),Ce=g||he,Le=(H,ye)=>{let ie=String(H.id),Se=String(r)===ie,Be=Se&&U===ie&&Boolean(G),Ne=Bt(ie);return e(uo,{session:H,harness:H.harness,folderId:H.folder_id,isActive:Se&&!Be,status:k[ie],awaitingInput:Boolean(H.awaitingInput),timeAgo:ws(H.updated_at??H.created_at),timeTitle:Uo(H.updated_at??H.created_at),runStartedAt:k[ie]==="stream"?T[ie]:void 0,expandable:ye.expandable,isChild:ye.isChild,isExpanded:ye.isExpanded,onToggleExpand:ye.onToggleExpand,onSelect:()=>c(H.id),onArchive:()=>de(H),onDelete:Ne?void 0:()=>Q.requestDelete(H),onRename:Ne?void 0:($e)=>void oe(H,$e),onRenameWithAi:Ne?void 0:()=>void te(H),waitingFor:H.waitingFor?{title:H.waitingFor.title}:void 0,onCancelWait:H.waitingFor?()=>R?.(H.waitingFor.waitId):void 0,selectable:he,selected:Boolean(x?.selected.includes(ie)),onToggleSelect:x?()=>x.toggle(ie):void 0})},Oe=(H)=>Is(H,Ee.childrenOf,F,I);return e("div",{className:bo(Ce),"data-testid":"session-folder",children:[e("div",{onClick:x?void 0:v,className:"flex items-center justify-between gap-2 py-1 cursor-pointer hover:bg-ink/5 rounded-lg select-none transition-colors",children:[e("div",{className:"flex items-center space-x-2 min-w-0",children:[ke&&z?e(Qr,{size:"md",checked:z.all,indeterminate:z.some,label:`Select ${t.name}`,onChange:L}):e(d,{children:e("span",{className:"w-4 h-4 flex items-center justify-center flex-shrink-0",children:t.customIconUrl?e("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain",referrerPolicy:"no-referrer"}):t.iconType==="chat"?e(cn,{size:15,className:"text-ink/80"}):e(we,{size:15,className:"text-ink/80",style:{color:t.accentColor||void 0}})})}),e("span",{className:"text-sm font-semibold text-ink truncate",children:t.name})]}),e("div",{className:"flex items-center space-x-2 text-xs text-ink/60",children:[e("span",{className:"font-mono text-[11px] text-ink/70",children:ve.length}),t.project_path&&e(pe,{size:13,className:"text-ink/50 ml-1"}),!x&&e(d,{children:[e("button",{type:"button",onClick:(H)=>{H.stopPropagation(),p(t.id)},className:"p-1.5 rounded-lg hover:bg-ink/10 active:bg-ink/15 text-ink/60 hover:text-ink",title:"New Session","aria-label":`New session in ${t.name}`,children:e(W,{size:15})}),e(po,{folder:t,canWorktree:Boolean(h&&t.project_path),onOpenFolder:X,onNewWorktree:h?()=>C.open():void 0,onSelectSessions:N?()=>N(t.id):void 0,confirmDelete:M,onPin:ae,onDelete:ne,onRequestDelete:ee,onCancelDelete:Y}),e("span",{className:"flex items-center justify-center pr-1",children:g?e(B,{size:14}):e(se,{size:14})})]})]})]}),Ce&&e("div",{className:"mt-0.5 space-y-0.5",children:[Ee.roots.map((H)=>{let ye=String(H.id),ie=Oe(H);return e("div",{className:"space-y-0.5",children:[Le(H,ie),ie.isExpanded&&e(bi,{parentId:ye,hasSubagents:Boolean(H.hasSubagents),childrenOf:Ee.childrenOf,expandedIds:F,onToggle:I,activeSessionId:r===null?null:String(r),renderSession:Le,style:mo})]},H.id)}),e(ho,{hiddenCount:he?0:fe,canShowLess:!he&&w,onShowMore:E,onShowLess:P})]}),e(Do,{session:Q.pending,isDeleting:Q.isDeleting,error:Q.error,onClose:Q.cancelDelete,onConfirm:()=>void Q.confirmDelete()}),C.dialog]})}function vo({folders:t,activeSessionId:r,expandedFolders:c,showArchived:p,sessionStatus:h,onSelectSession:g,onNewSessionForFolder:v,onNewWorktreeSession:S,onToggleFolder:k,onToast:l,batch:x,onStartSessionSelection:N,onCancelWait:R}){return e("div",{className:"flex-1 scrollbar-overlay-container pl-3 pr-2 py-3",children:t.length===0?e("div",{className:"text-center py-12 text-xs text-ink/50 italic",children:"No matching sessions found"}):t.map((y)=>e(go,{folder:y,activeSessionId:r,onSelectSession:g,onNewSessionForFolder:v,onNewWorktreeSession:S,isExpanded:c[y.id]??!0,onToggleExpand:()=>k(y.id),showArchived:p,sessionStatus:h,onToast:l,batch:x,onStartSessionSelection:N,onCancelWait:R},y.id))})}var kt=[3,2];function xo(){return e("div",{className:"flex-1 p-3 space-y-4","aria-hidden":"true",children:kt.map((t,r)=>e("div",{className:"space-y-2",children:[e("div",{className:"flex items-center gap-2 py-2",children:[e("span",{className:"w-4 h-4 rounded-sm animate-pulse bg-ink/10"}),e("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:t},(c,p)=>e("div",{className:"flex items-center gap-2 rounded py-2",children:[e("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),e("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-p%3*12}%`}})]},p))]},r))})}function So({folders:t,initializing:r,failed:c,activeSessionId:p,expandedFolders:h,sessionStatus:g,searchQuery:v,sortOption:S,optionsOpen:k,showArchived:l,harnessFilter:x,onHarnessFilterChange:N,harnessOptions:R,optionsRef:y,scheduledCount:E,refreshing:P,selecting:w,batch:C,onNewSession:A,onNewWorkspace:T,onScheduler:F,onRefresh:I,onToggleOptions:j,onSortChange:G,onResetSort:U,onToggleArchived:M,onHideArchived:ee,onSearchChange:Y,onClearSearch:J,onSelectWorkspaces:ue,onSelectSession:de,onNewSessionForFolder:oe,onNewWorktreeSession:te,onToggleFolder:q,onToast:Q,onStartSessionSelection:ae,onCancelWait:ne}){return e(d,{children:[e(co,{searchQuery:v,sortOption:S,optionsOpen:k,showArchived:l,optionsRef:y,onNewSession:A,onNewWorkspace:T,onScheduler:F,scheduledCount:E,onRefresh:I,refreshing:P,onToggleOptions:j,onSortChange:G,onResetSort:U,onToggleArchived:M,onHideArchived:ee,onSearchChange:Y,onClearSearch:J,onSelectWorkspaces:ue,selecting:w}),e("div",{className:"px-3 pt-2 pb-1",children:e(ys,{options:R,value:x,onChange:N,touch:!0})}),c?e(Ss,{touch:!0,onRetry:I,refreshing:P}):r?e(xo,{}):e(vo,{folders:t,activeSessionId:p,expandedFolders:h,showArchived:l,sessionStatus:g,onSelectSession:de,onNewSessionForFolder:oe,onNewWorktreeSession:te,onToggleFolder:q,onToast:Q,batch:C,onStartSessionSelection:ae,onCancelWait:ne})]})}function ko({onSettings:t,onKeyBindings:r,onAbout:c,updateAvailable:p,onUpdateClick:h,onDesktopToggle:g,shellDownload:v}){return e("div",{className:"px-3 pt-3 border-t border-ink/10 flex items-center justify-between flex-shrink-0 bg-canvas text-xs text-ink/60",style:{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"},children:[e("div",{className:"flex items-center space-x-3",children:[e("button",{type:"button",onClick:t,className:"flex items-center space-x-1 hover:text-ink transition-colors",children:[e(Gs,{size:14}),e("span",{children:"Settings"})]}),e("button",{type:"button",onClick:r,className:"flex items-center space-x-1 hover:text-ink transition-colors",children:[e(ka,{size:14}),e("span",{children:"Keys"})]}),e("button",{type:"button",onClick:c,className:"flex items-center space-x-1 hover:text-ink transition-colors",children:[e(ce,{size:14}),e("span",{children:"About"})]}),v&&e(Lm,{download:v,variant:"label"}),g&&e("button",{type:"button",onClick:g,className:"flex items-center space-x-1 hover:text-ink transition-colors",title:"Switch to desktop view",children:[e(xa,{size:14}),e("span",{children:"Desktop"})]})]}),e("div",{className:"flex items-center gap-2",children:[e("span",{className:"font-mono text-[10px] text-ink/40",children:["v",Cc.version]}),p&&e("button",{type:"button",onClick:h,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})]})}function wo(t){let r=Mm(),c=Fm();return xe(Ec,()=>{t.onClose(),t.openAbout(),r.apply("kabmo").then((p)=>{if(!p)return;t.pushToast(p.message,tc(p))})}),Pm(r,t.pushToast),{updates:r,shellDownload:c}}function yo(t,r,c){return t.filter((p)=>p.id!==r&&!(c&&p.side==="left"))}function Eo(t){return t}function Oo(t,r=0){let{scrollLeft:c,clientWidth:p,scrollWidth:h,start:g,size:v}=t,S=Math.max(0,h-p),k=g-r,l=g+v+r;if(v+r*2>=p)return Math.max(0,Math.min(S,k));let x=c;if(k<c)x=k;else if(l>c+p)x=l-p;return Math.max(0,Math.min(S,x))}var wt=8;function _e({panels:t,activeId:r,onSelect:c,hasGitChanges:p=!1}){let h=i(null),g=i(new Map),v=i({activeId:r,panels:t});v.current={activeId:r,panels:t};let S=i({signature:"",width:0}),k=a(()=>{let l=h.current,x=g.current.get(v.current.activeId);if(!l||!x||l.clientWidth<=0)return;let N=`${v.current.activeId}\x00${v.current.panels.map((w)=>w.id).join("\x00")}`,R=S.current;if(R.signature===N&&R.width===l.clientWidth)return;S.current={signature:N,width:l.clientWidth};let y=l.getBoundingClientRect(),E=x.getBoundingClientRect(),P=Oo({scrollLeft:l.scrollLeft,clientWidth:l.clientWidth,scrollWidth:l.scrollWidth,start:E.left-y.left+l.scrollLeft,size:E.width},wt);if(P!==l.scrollLeft)l.scrollLeft=P},[]);return K(k,[r,t,k]),o(()=>{let l=h.current;if(!l||typeof ResizeObserver>"u")return;let x=new ResizeObserver(k);return x.observe(l),()=>x.disconnect()},[k]),e("div",{ref:h,className:"flex items-center space-x-1.5 overflow-x-auto no-scrollbar py-1",children:t.map((l)=>{let x=l.id===r;return e("button",{ref:(N)=>{if(N)g.current.set(l.id,N);else g.current.delete(l.id)},type:"button",onClick:()=>c(l.id),"aria-pressed":x,"aria-label":l.title,className:`relative flex shrink-0 items-center transition-all cursor-pointer ${x?"space-x-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold bg-ink text-canvas shadow-sm":"p-2 rounded-lg text-ink/70 hover:bg-ink/5"}`,title:l.title,children:[e(nl,{panelId:l.id,builtin:l.builtin,icon:l.builtin?l.icon:void 0,name:l.builtin?l.label:l.name,...l.iconUrl?{iconUrl:l.iconUrl}:{},...l.color?{color:l.color}:{},size:gn}),x&&e("span",{className:`shrink-0 whitespace-nowrap ${l.id==="git"?"tracking-wide":""}`,children:l.label}),l.id==="git"&&p&&e("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-info",title:"Uncommitted changes"})]},l.id)})})}function Ao({panels:t,activeId:r,onSelect:c,menuProps:p}){return e("div",{className:"px-3 py-1.5 border-b border-ink/10 bg-canvas flex-shrink-0",...p,children:e(_e,{panels:t,activeId:r,onSelect:c})})}function Io({panelKey:t,panel:r,body:c}){if(!r)return e("div",{className:"flex-1 min-h-0",children:e(Tc,{panelKey:t})});return e("div",{className:"flex-1 min-h-0 overflow-hidden relative",children:e(Ve,{fallback:e("div",{className:"h-full flex items-center justify-center text-ink/40",children:e("span",{className:"text-xs font-mono",children:"Loading…"})}),children:e(Co,{value:c,children:r.render(c)})})})}function Wo({activeSessionId:t,newWorkspaceOpen:r,onCloseNewWorkspace:c,schedulerOpen:p,onCloseScheduler:h,aboutOpen:g,onCloseAbout:v,updates:S,pushToast:k,batchDelete:l,batchMode:x,onEndBatch:N,scopeLabel:R}){return e(d,{children:[e(is,{isOpen:r,onClose:c,onCreate:ll,onClone:cl}),e(cu,{isOpen:p,onClose:h,activeSessionId:t===null?null:String(t),onToast:k}),e(Xu,{isOpen:g,onClose:v,updates:S,onToast:k}),e(Rm,{updates:S}),e(hu,{mode:x??"session",count:l.pending.length,scopeLabel:R,isDeleting:l.isDeleting,progress:l.progress,outcome:l.outcome,onClose:()=>{let y=l.outcome?.refused.length??0;if(l.cancel(),l.outcome&&y===0)N()},onConfirm:()=>{let y=x??"session";l.confirm(y).then((E)=>{if(E&&E.refused.length===0)N()})}})]})}function Ho(){let t=Tt(),r=Br("left"),[c,p]=$a("layout.mobileLeftPanel",Pe),h=Dm(c,t.enabled);return{catalog:r,activeView:h,setActiveView:p,showingSessions:h===Pe,activePanel:r.find((g)=>g.id===h),enabled:t.enabled}}function Vo(t){return{className:"w-full h-full",sessionId:t.sessionId===null?null:String(t.sessionId),enabled:t.requiresWorkspace?t.hasActiveContext===!0:!0,active:!0,refreshKey:t.refreshKey,...t.rootPath?{rootPath:t.rootPath}:{},...t.onRefresh?{onRefresh:t.onRefresh}:{},...t.onOpenFile?{onOpenFile:t.onOpenFile}:{},onClose:t.onClose,showHeader:!1,layout:"phone"}}function Ko({appSettings:t,onSelectSession:r,onClose:c,rootPath:p,refreshKey:h,onRefresh:g,onOpenFile:v}){let S=pu(t,{onSelectSession:r,onAfterSelect:c}),{folders:k,processedFolders:l,refreshNow:x,showArchived:N,activeSessionId:R}=S,y=gu(l,N,x),[E,P]=n({1:!0,2:!0,3:!0}),w=i(null);me(w,()=>S.setOptionsOpen(!1));let C=(I)=>{P((U)=>({...U,[I]:!U[I]}));let j=k.find((U)=>U.id===I),G=!(E[I]??j?.isExpanded??!0);Td(I,G)},A=l.map((I)=>`${I.id}:${I.isExpanded}`).join("|");o(()=>{P(Object.fromEntries(l.map((I)=>[I.id,I.isExpanded])))},[A]);let T=Ho(),F=Vo({sessionId:R,refreshKey:h,rootPath:p,onRefresh:g,onOpenFile:v,onClose:c,requiresWorkspace:T.activePanel?.requiresWorkspace??!1,hasActiveContext:Boolean(p)});return{controller:S,batch:y,expandedFolders:E,toggleFolder:C,optionsRef:w,dock:T,dockBody:F}}function Ke(t){let{disabledPanels:r}=dn(),{setEnabled:c}=js(),p=ze(),h=Nm(t),g=a((v,S)=>{c(v,S)},[c]);return{...p,items:h,hidden:r,toggle:g}}function jo({activeSessionId:t,onSelectSession:r,onNewSession:c,onNewSessionForFolder:p,onNewWorktreeSession:h,onClose:g,onDesktopToggle:v,appSettings:S={},rootPath:k,refreshKey:l=0,onRefresh:x,onOpenFile:N}){let{controller:R,batch:y,expandedFolders:E,toggleFolder:P,optionsRef:w,dock:C,dockBody:A}=Ko({appSettings:S,onSelectSession:r,onClose:g,rootPath:k,refreshKey:l,onRefresh:x,onOpenFile:N}),{initializing:T,failed:F,refreshNow:I,isRefreshing:j,searchQuery:G,setSearchQuery:U,showArchived:M,setShowArchived:ee,optionsOpen:Y,setOptionsOpen:J,sortOption:ue,handleSortChange:de,harnessFilter:oe,setHarnessFilter:te,harnessOptions:q,processedFolders:Q,sessionStatus:ae,handleSelectSession:ne}=R,{selection:X,deleteRun:ve,archiveRun:we,binding:ke,scopeFolder:he,available:z,selected:L}=y,V=Ju(),fe=Ke("left"),[Ee,Ce]=n(!1),[Le,Oe]=n(!1),H=lu(),[ye,ie]=n(!1),{pushToast:Se}=je(),Be=sl(Se);mu({onNotice:Se});let{updates:Ne,shellDownload:$e}=wo({onClose:g,openAbout:()=>ie(!0),pushToast:Se}),Ye=()=>{c(),g()},ht=()=>{we.archive(L).then((be)=>{if(!be)return;let De=fu(be);if(De)Se(De.message,De.tone);if(!be.error)X.end()})},Je=(be)=>{p(be),g()},eo=()=>{ee(!M)},oo=h?(be,De)=>{h(be,De),g()}:void 0,bt={className:"flex-1 min-h-0 w-full",folders:Q,initializing:T,failed:F,activeSessionId:t,sessionStatus:ae,searchQuery:G,onSearchChange:U,showArchived:M,onToggleArchived:eo,sortOption:ue,optionsOpen:Y,onToggleOptions:()=>J(!Y),onCloseOptions:()=>J(!1),onSortChange:de,harnessFilter:oe,onHarnessFilterChange:te,harnessOptions:q,onRefresh:I,refreshing:j,scheduledCount:H,onNewSession:Ye,onNewWorkspace:()=>Ce(!0),onScheduler:()=>Oe(!0),onSelectSession:ne,onNewSessionForFolder:Je,onNewWorktreeSession:oo,onToast:Se,onCancelWait:Be,batch:ke,onSelectWorkspaces:y.toggleWorkspaceSelection,onStartSessionSelection:(be)=>X.begin("session",be)};return e("div",{className:"flex flex-col h-full w-full bg-canvas text-ink relative select-none",children:[e(ao,{onClose:g,viewLabel:C.showingSessions?"Sessions":C.activePanel?.label??"Panel",menuProps:fe.surfaceProps}),Eo(C.enabled)?e(Ao,{panels:C.catalog,activeId:C.activeView,onSelect:C.setActiveView,menuProps:fe.surfaceProps}):null,fe.anchor?e(Lo,{anchor:fe.anchor,items:fe.items,hidden:fe.hidden,onToggle:fe.toggle,onClose:fe.close}):null,e("div",{className:C.showingSessions?"contents":"hidden",children:[V==="modern"?e(du,{...bt,touch:!0}):e(So,{folders:Q,initializing:T,failed:F,activeSessionId:t,expandedFolders:E,sessionStatus:ae,searchQuery:G,sortOption:ue,optionsOpen:Y,showArchived:M,harnessFilter:oe,onHarnessFilterChange:te,harnessOptions:q,optionsRef:w,scheduledCount:H,refreshing:j,selecting:X.mode!==null,batch:ke,onNewSession:Ye,onNewWorkspace:()=>Ce(!0),onScheduler:()=>Oe(!0),onRefresh:I,onToggleOptions:()=>J(!Y),onSortChange:de,onResetSort:()=>de("A-Z"),onToggleArchived:eo,onHideArchived:()=>ee(!1),onSearchChange:U,onClearSearch:()=>U(""),onSelectWorkspaces:y.toggleWorkspaceSelection,onSelectSession:ne,onNewSessionForFolder:Je,onNewWorktreeSession:oo,onToggleFolder:P,onToast:Se,onStartSessionSelection:(be)=>X.begin("session",be),onCancelWait:Be}),X.mode&&e(Au,{drawer:!0,mode:X.mode,count:L.length,total:z.length,busy:ve.isDeleting,archiving:we.isArchiving,scopeLabel:he?.name,onSelectAll:()=>X.selectAllOf(z),onUnselectAll:()=>X.unselectAllOf(z),onDelete:()=>ve.request(L),onArchive:ht,onCancel:X.end})]}),C.showingSessions?null:e(Io,{panelKey:C.activeView,panel:C.activePanel,body:A}),e(ko,{onSettings:()=>window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{}})),onKeyBindings:Nc,onAbout:()=>ie(!0),shellDownload:$e,onDesktopToggle:v,updateAvailable:Ne.hasUpdate,onUpdateClick:()=>{ie(!0),Ne.check()}}),e(Wo,{activeSessionId:t,newWorkspaceOpen:Ee,onCloseNewWorkspace:()=>Ce(!1),schedulerOpen:Le,onCloseScheduler:()=>Oe(!1),aboutOpen:ye,onCloseAbout:()=>ie(!1),updates:Ne,pushToast:Se,batchDelete:ve,batchMode:X.mode,onEndBatch:X.end,scopeLabel:he?.name})]})}var yt="terminal";function Ue(t){return t===yt}function Fe(t){if(Ue(t))wA()}function qo({enabled:t=!0,rootPath:r,refreshKey:c=0,onRefresh:p,onOpenFile:h,onClose:g}){let[v,S]=$a("layout.mobileRightPanel",Xl),k=Tt(),l=yo(Br("all"),Pe,k.enabled),x=l.find((A)=>A.id===v)??l[0],N=Fp(r,t),{changes:R}=$s(r,N,t),y=R.length>0,E=a((A)=>{if(A!==x?.id)Fe(A);S(A)},[x?.id,S]);o(()=>{if(!Ue(x?.id))ac()},[x?.id]);let P=Ke(k.enabled?"right":"all"),w=k.enabled?P.items:P.items.filter((A)=>A.id!==Pe),C={className:"h-full w-full",enabled:t||!x?.requiresWorkspace,active:!0,refreshKey:c,...r?{rootPath:r}:{},onRefresh:p,onOpenFile:h,onClose:g,showHeader:!1,layout:"phone"};return e("div",{className:"flex flex-col h-full w-full bg-paper text-ink relative select-none",children:[e("div",{className:"border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0 bg-canvas titlebar-drag-region select-none",...Mo(),...P.surfaceProps,style:{height:"calc(3.5rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:Po(er("0.75rem",!0)),paddingRight:Ir("0.75rem",!0)},children:[e("div",{className:"flex items-center min-w-0 titlebar-no-drag",children:e(_e,{panels:l,activeId:x?.id??v,onSelect:E,hasGitChanges:y})}),e("button",{type:"button",onClick:g,className:"p-1.5 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0 ml-2 titlebar-no-drag",title:"Close right sidebar","aria-label":"Close right sidebar",children:e(b,{size:20,strokeWidth:1.8})})]}),P.anchor?e(Lo,{anchor:P.anchor,align:"right",items:w,hidden:P.hidden,onToggle:P.toggle,onClose:P.close}):null,e("div",{className:"flex-1 min-h-0 overflow-hidden relative",style:{paddingBottom:"env(safe-area-inset-bottom, 0px)"},children:x?e(Ve,{fallback:e("div",{className:"h-full flex items-center justify-center text-ink/40",children:e("span",{className:"text-xs font-mono",children:"Loading…"})}),children:e(Co,{value:C,children:x.render(C)})}):e("div",{className:"h-full flex items-center justify-center text-ink/40",children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})})})]})}function Zo({fileName:t,hasPreview:r,isPreview:c,hasReview:p,isReviewing:h,onToggleReview:g,wordWrap:v,copied:S,byteViewer:k=!1,missing:l=!1,onSave:x,onClose:N,onTogglePreview:R,onToggleFind:y,findOpen:E,onToggleWrap:P,onZoomOut:w,onZoomIn:C,onCopy:A,onDownload:T}){return e("header",{className:"bg-canvas border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0",style:{height:"calc(3rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:er("0.75rem",!0),paddingRight:Ir("0.75rem",!0)},children:[e("div",{className:"flex items-center space-x-2 min-w-0 pr-2",children:[e("button",{type:"button",onClick:N,className:"p-1.5 rounded-lg hover:bg-ink/10 text-ink transition-colors active:scale-90 flex-shrink-0 cursor-pointer",title:"Close editor","aria-label":"Close editor",children:e(tn,{size:18,strokeWidth:2})}),e("div",{className:"flex items-center space-x-1.5 truncate",children:[e(st,{name:t,size:15,className:`flex-shrink-0${l?" text-error":""}`}),e("span",{className:`font-semibold text-xs truncate${l?" text-error line-through":" text-ink"}`,children:t})]})]}),e("div",{className:"flex items-center space-x-1 text-ink/70 flex-shrink-0",children:[l&&x&&e("button",{type:"button",onClick:x,className:"p-1.5 rounded bg-error text-canvas hover:bg-error/90 transition-colors cursor-pointer",title:"Save and recreate the file","aria-label":"Save and recreate the file",children:e(pt,{size:15})}),!k&&e("button",{type:"button",onClick:y,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${E?"bg-ink text-canvas":""}`,title:E?"Close find":"Find in file","aria-label":E?"Close find":"Find in file","aria-pressed":E,children:e(O,{size:15})}),p&&e("button",{type:"button",onClick:g,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${h?"bg-ink text-canvas":""}`,title:h?"Exit review mode":"Review this document","aria-label":h?"Exit review mode":"Review this document","aria-pressed":h,children:e(cn,{size:15})}),r&&e("button",{type:"button",onClick:R,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${c?"bg-ink text-canvas":""}`,title:c?"View source":"Show preview","aria-label":c?"View source":"Show preview",children:c?e(St,{size:15}):e(qe,{size:15})}),!k&&e(d,{children:[e("button",{type:"button",onClick:P,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${v?"text-ink":""}`,title:"Toggle word wrap",children:e(en,{size:15})}),e("button",{type:"button",onClick:w,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Decrease font size",children:e(Qa,{size:15})}),e("button",{type:"button",onClick:C,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Increase font size",children:e(Na,{size:15})})]}),e("button",{type:"button",onClick:A,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Copy content",children:S?e(f,{size:15,className:"text-success"}):e(re,{size:15})}),e("button",{type:"button",onClick:T,className:"p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer",title:"Download file",children:e(ge,{size:15})})]})]})}function Xo({fileName:t,content:r,path:c,root:p,repo:h,fontSize:g,scrollRef:v,onScroll:S,isLoading:k,unsupported:l,loadError:x,reviewActive:N,onExitReview:R}){return e("div",{ref:v,onScroll:S,"data-testid":"editor-scroller",className:"flex-1 min-h-0 overflow-auto relative bg-paper text-ink select-text",children:k?e("div",{className:"flex items-center justify-center h-full text-ink/40 text-xs gap-2",children:[e(m,{size:14,className:"animate-spin"}),e("span",{children:"Loading file content..."})]}):l?e("div",{className:"flex flex-col items-center justify-center h-full 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," cannot be opened here"]}),e("span",{className:"text-[11px] text-ink/50 font-sans max-w-[42ch]",children:l})]}):x?e("div",{className:"flex flex-col items-center justify-center h-full 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]}),e("span",{className:"text-[11px] text-ink/50 font-mono break-all",children:x})]}):e("div",{className:"p-4 bg-paper text-ink min-h-full font-sans",style:{fontSize:`${g}px`},children:e(zc,{content:r,file:{name:t,path:c,root:p,repo:h},active:N,onExit:R})})})}function Jo({file:t,editor:r,viewerKind:c,byteViewer:p,isPreview:h,isMd:g,content:v,language:S,wordWrap:k,fileKey:l,revealMarks:x,currentMark:N,surfaceRef:R,setCodeScroller:y,previewRef:E,scroll:P,fontSize:w,reviewActive:C,onExitReview:A,editorTheme:T,editorFontFamily:F,indentUnitText:I,typing:j}){let G=a(async(U)=>{let M=await Vc(t,U,{interactive:!0,baseMtimeMs:r.baseMtimeMs});if(M.status==="written")return{ok:!0};if(M.status==="conflict")return{ok:!1,error:"This file changed on disk since it was opened."};if(M.status==="needs-permission")return{ok:!1,error:"Tap Save again to grant write access."};return{ok:!1,error:M.error}},[t,r.baseMtimeMs]);if(r.isImage&&r.imageUrl)return e(gi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"});if(r.isImage||Wc(c)&&(p||h))return e(bl,{kind:c,path:t.path??t.name,name:t.name,source:r.byteSource,content:r.content,revision:r.revision,onContentChange:r.onChange,onSaveBytes:r.deviceBacked?void 0:G,onDirtyChange:r.setBinaryDirty});if(r.isLoading||r.unsupported||r.loadError||g&&h)return e(Xo,{fileName:t.name,content:v,path:t.path??t.name,root:t.root,repo:t.repo,fontSize:w,scrollRef:E,onScroll:P.onScroll,isLoading:r.isLoading,unsupported:r.unsupported,loadError:r.loadError,reviewActive:C,onExitReview:A});return e(Gc,{ref:R,value:v,onValueChange:r.onChange,language:S,wordWrap:k,documentKey:l,marks:x,currentMark:N,onScroller:y,scrollTestId:"editor-scroller",className:"flex-1 min-h-0 text-ink select-text",themeVars:T.vars,themes:T.themes,indentUnitText:I,typing:j,padding:12,placeholder:"This file is empty",style:{fontFamily:F,fontSize:`${w}px`,lineHeight:Js}})}function et(){return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-error/30 bg-error/10 text-error shrink-0",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."})]})]})}function ot({isImage:t,byteViewer:r,viewerKind:c,lineCount:p,charCount:h,language:g,saveStatus:v,path:S,conflicts:k=0}){return e("footer",{className:"bg-canvas border-t border-ink/10 px-3 flex items-center justify-between text-[10px] text-ink/60 flex-shrink-0 font-mono",style:{height:"calc(1.75rem + env(safe-area-inset-bottom, 0px))",paddingBottom:"env(safe-area-inset-bottom, 0px)",paddingLeft:"max(0.75rem, env(safe-area-inset-left, 0px))",paddingRight:"max(0.75rem, env(safe-area-inset-right, 0px))"},children:[e("div",{className:"flex items-center space-x-3",children:t?e("span",{className:"uppercase",children:"Image"}):r?e("span",{className:"uppercase",children:$o[c]}):e(d,{children:[k>0&&e("span",{className:"text-error font-semibold tabular-nums",children:["⚠ ",k]}),e("span",{children:[p," lines"]}),e("span",{children:[h," chars"]}),e("span",{className:"uppercase",children:g})]})}),e("div",{className:"flex items-center space-x-2",children:[v==="saving"&&e(d,{children:[e(m,{size:10,className:"animate-spin"}),e("span",{children:"Saving…"})]}),v==="saved"&&e(d,{children:[e("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),e("span",{children:"Saved"})]}),v==="error"&&e(d,{children:[e("span",{className:"w-1.5 h-1.5 rounded-full bg-error"}),e("span",{className:"text-error",children:"Save failed"})]}),v==="idle"&&S&&e("span",{className:"truncate max-w-[140px]",children:S})]})]})}function it({path:t,content:r,ready:c,surfaceRef:p}){let h=Zc(t,r,c),g=i(null);return o(()=>{if(!h||g.current===h.request)return;g.current=h.request;let v=h.matches[h.currentIndex];if(!v)return;p.current?.select(v.start,v.end,!1),p.current?.revealOffset(v.start)},[h,p]),{matches:h?.matches??[],currentIndex:h?.currentIndex??-1}}function at({path:t,content:r,documentKey:c,ready:p,surfaceRef:h,toggleWordWrap:g}){let v=it({path:t,content:r,ready:p,surfaceRef:h}),S=Jc({text:r,documentKey:c,readSelection:()=>h.current?.getSelection()??null,select:(k,l,x=!0)=>h.current?.select(k,l,x),reveal:(k)=>h.current?.revealOffset(k),applyDocument:(k,l,x)=>h.current?.applyDocument(k,l,x),toggleWordWrap:g});if(S.open&&S.matches.length>0)return{find:S,revealMarks:S.matches,currentMark:S.currentIndex};return{find:S,revealMarks:v.matches.length>0?v.matches:void 0,currentMark:v.currentIndex}}function lt({path:t,symbols:r,total:c,truncated:p,emptyNotice:h,preview:g=!1}){let[v,S]=n(!1);if(!t)return null;let k=(l,x)=>{if(S(!1),g){let N=qu(r,x);if(N)Ji({path:t,...N});return}Yi({path:t,line:l.line,column:l.column,length:l.name.length})};return e(d,{children:[e("div",{className:"absolute bottom-14 right-3 z-20",children:e("button",{type:"button",onClick:()=>S(!0),"aria-label":`Outline (${c} symbols)`,title:"Outline",className:"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})})}),v&&e(Z,{onClose:()=>S(!1),maxWidthClass:"max-w-sm",zClass:"z-[70]",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:"Outline"}),e("span",{className:"font-mono text-[11px] text-ink/40",children:p?`${r.length}/${c}`:c})]}),children:e("div",{className:"max-h-[60vh] overflow-y-auto scrollbar-overlay-container py-1",children:[r.length===0?e("div",{className:"px-4 py-3 text-[11px] italic text-ink/40",children:h}):r.map((l,x)=>e("button",{type:"button",onClick:()=>k(l,x),"aria-label":g?`${Yo(l.kind)} ${l.name}`:`${Yo(l.kind)} ${l.name}, line ${l.line}`,className:"flex w-full min-w-0 items-center gap-2 px-4 py-2 text-left transition-colors hover:bg-ink/5 active:bg-ink/10",style:{paddingLeft:`${16+l.depth*12}px`},children:[e(Pu,{kind:l.kind,size:13}),e("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-ink",children:l.name}),!g&&e("span",{className:"flex-shrink-0 font-mono text-[10px] text-ink/40",children:l.line})]},`${l.line}:${l.kind}:${l.name}`)),p&&e("div",{className:"px-4 py-2 text-[11px] italic text-ink/40",children:Ou(c)})]})})]})}function ct({file:t,missing:r=!1,onClose:c,onFileSaved:p,onDropResult:h}){let g=fs(t.path??t.name),[v,S]=n({}),[k,l]=n(Bo),[x,N]=n(!0),R=_o(),y=Ai(),E=ou(),P=su(),w=g==="markdown",C=yd[g]===!0,A=ms[g]===!0,T=t.path??t.name,F=v[T]??A,I=nu(String(T)),j=w&&F,G=()=>S((V)=>({...V,[T]:!F})),U=Rc({enabled:Boolean(t.root),onResult:h}),M=Yc(t,{flushOnUnmount:!0,reportSaveError:!0,downloadMimeType:"text/plain;charset=utf-8",onFileSaved:p,missing:r}),[ee,Y]=n(null),J=ul({tabKey:T,surface:w&&F?"rendered":"code",ready:M.loaded,slot:sh,element:w&&F?void 0:ee}),[ue,de]=n(null),oe=a((V)=>{J.ref(V),de(V)},[J.ref]);qc({path:t.path??null,scroller:ue,preview:w&&F});let te=i(null),{find:q,revealMarks:Q,currentMark:ae}=at({path:t.path??null,content:M.content,documentKey:`${T}\x00${M.language}`,ready:M.loaded&&!M.loadError,surfaceRef:te,toggleWordWrap:()=>N((V)=>!V)}),{content:ne,language:X}=M,ve=ne.split(`
2
- `).length,we=Uc(ne);Xc({file:{id:T,name:t.name,path:t.path??T},editor:M,surfaceRef:te,isPreview:F,exitPreview:()=>S((V)=>({...V,[T]:!1})),publish:!1});let{symbols:ke,total:he,truncated:z,notice:L}=$u({content:ne,language:X,path:t.path??null,state:C?"not-a-document":M.loadError?"error":M.loaded?"ready":"loading",note:C?`${$o[g]} files have no text outline.`:M.loadError});return e("div",{className:"fixed inset-x-0 top-0 h-dvh z-[60] bg-paper flex flex-col font-mono text-xs select-none",...U.dropProps,...U.captureDropProps,children:[e(hl,{visible:U.isDragging}),e(Zo,{fileName:t.name,hasPreview:A,isPreview:F,wordWrap:x,copied:M.copied,byteViewer:C,missing:r,onSave:M.saveNow,onClose:c,onTogglePreview:G,hasReview:j,isReviewing:j&&I.active,onToggleReview:I.toggle,onToggleFind:()=>q.open?q.close():q.openFind(),findOpen:q.open,onToggleWrap:()=>N(!x),onZoomOut:()=>l((V)=>Math.max(Zs,V-1)),onZoomIn:()=>l((V)=>Math.min(Xs,V+1)),onCopy:M.copy,onDownload:M.download}),r&&e(et,{}),M.diskChange&&e(eu,{fileName:t.name,onReload:M.reloadFromDisk,onKeepMine:M.keepMineAgainstDisk}),q.open&&!C&&e("div",{className:"relative shrink-0 h-9 border-b border-ink/10 bg-paper",children:e(jc,{find:q})}),e(Jo,{file:t,editor:M,viewerKind:g,byteViewer:C,isPreview:F,isMd:w,content:ne,language:X,wordWrap:x,fileKey:T,revealMarks:Q,currentMark:ae,surfaceRef:te,setCodeScroller:Y,previewRef:oe,scroll:J,fontSize:k,reviewActive:j&&I.active,onExitReview:I.toggle,editorTheme:y,editorFontFamily:R,indentUnitText:au(E),typing:P}),!C&&e(lt,{path:t.path??null,symbols:ke,total:he,truncated:z,emptyNotice:L,preview:w&&F}),e(ot,{isImage:M.isImage,byteViewer:C,viewerKind:g,lineCount:ve,charCount:ne.length,language:X,saveStatus:M.saveStatus,path:t.path,conflicts:we}),M.saveMissingConfirm&&t.path&&e(tu,{fileName:t.name,filePath:t.path,onClose:M.cancelSaveMissing,onConfirm:M.confirmSaveMissing})]})}function dt({diff:t,onClose:r,onFileSaved:c}){let p=t.path.split("/").pop()||t.path,h=Boolean(t.staged),g=t.status||"M",v=Kn(g,h);return e("div",{className:"fixed inset-x-0 top-0 h-dvh z-[60] bg-paper flex flex-col",children:[e("header",{className:"bg-canvas border-b border-ink/10 flex items-center justify-between px-3 flex-shrink-0",style:{height:"calc(3rem + env(safe-area-inset-top, 0px))",paddingTop:"env(safe-area-inset-top, 0px)",paddingLeft:er("0.75rem",!0),paddingRight:Ir("0.75rem",!0)},children:[e("div",{className:"flex items-center space-x-2 min-w-0 pr-2",children:[e("button",{type:"button",onClick:r,className:"p-1.5 -ml-1 rounded-lg hover:bg-ink/5 active:bg-ink/10 text-ink transition-colors flex-shrink-0",title:"Back","aria-label":"Close diff",children:e(tn,{size:18,strokeWidth:1.9})}),e(st,{name:p,size:14,className:"flex-shrink-0"}),e("span",{className:"font-mono text-xs text-ink font-medium truncate",title:t.path,children:p})]}),e("span",{className:`px-1.5 py-0.5 text-[10px] font-mono font-semibold rounded border flex-shrink-0 ${v.badgeBgClass}`,children:[v.charStatus," ",v.label]})]}),e("div",{className:"flex-1 min-h-0",children:e($c,{className:"h-full",viewModeButtons:!1,filePath:t.path,status:g,isStaged:h,root:t.root,repo:t.repo||".",journalDiff:t.journal,readOnly:Boolean(t.journal),onFileSaved:c,tabKey:t.journal?zm(t.journal.path,t.journal.from,t.journal.to):$m(t.path,h)})})]})}function Ae(t,r){let c=t[r];return typeof c==="string"&&c.length>0?c:void 0}function Mt(t){let r=t.content;return typeof r==="string"?r:void 0}function Xe(t,r){let c=typeof t==="object"&&t!==null?t:{},p=(Ae(c,"path")??"").replace(/^\/+/,"");if(!p)return null;return{name:Ae(c,"name")??p.split("/").pop()??"file",path:p,content:Mt(c),root:Ae(c,"root")??r??void 0,repo:Ae(c,"repo"),handleId:Ae(c,"handleId"),deviceFile:c.deviceFile===!0?!0:void 0}}function mt(t){if(!t)return[];return[{id:"mobile-editor",path:t.path,root:t.root,repo:t.repo,content:t.content,handleId:t.handleId,deviceFile:t.deviceFile}]}function ft(t,r,c){Ka(c);let p=Xn(r);return Xt(p,fg,{folderId:r,worktreePath:c}),t.setSearchParams((h)=>{let g=Qt(h);return g.set("sessionId",p),g.set("folderId",r.toString()),g},{replace:!0}),t.afterNavigate?.(),p}function sd({onDesktopToggle:t,appSettings:r={}}){let{folders:c,isMock:p}=We(),h=Tt(),{sessionId:g}=tt(),[v,S]=le(),k=v.get("sessionId"),l=k?Number.isNaN(Number(k))?k:Number(k):null,x=v.get("folderId"),N=x?Number.isNaN(Number(x))?x:Number(x):null,[R,y]=n("main"),[E,P]=n(null),[w,C]=n(null),[A,T]=n(0),[F,I]=n(!1),[j,G]=n("appearance"),[U,M]=n(!1),ee=a(()=>T((z)=>z+1),[]),Y=Kc(mt(E),A),{pushToast:J}=je(),ue=a((z)=>J(z.message,z.ok?"success":"error"),[J]),de=Y.size>0;to({editorOpen:E!==null,diffOpen:w!==null,settingsOpen:F,offMainScreen:R!=="main",onCloseEditor:()=>P(null),onCloseDiff:()=>C(null),onCloseSettings:()=>{I(!1),M(!1)},onReturnToMain:()=>y("main")});let{folder:oe}=Va(c,l),te=oe??(N?c.find((z)=>String(z.id)===String(N))??null:null),q=Om(c,l)??te?.project_path??null,Q=!!te,ae=Rc({enabled:Q,onResult:ue});xe("omp:open-file",(z)=>{let V=Xe(z.detail,q);if(V)P(V)}),xe("omp:open-diff",(z)=>{let L=z.detail;if(!L?.file)return;C({path:L.file.replace(/^\/+/,""),status:L.status,staged:L.staged,repo:L.repo,root:L.root??q??void 0,...L.source==="journal"&&L.journal?{journal:L.journal}:{}})}),xe("omp:view-subagent",()=>y("main")),xe(ad,(z)=>{let L=z.detail?.panelKey;if(!L)return;let V=lh(L,h);if(!V)return;let fe=Te(g,"layout.mobileRightPanel");if(V==="right"&&(R!=="right"||fe!==L))Fe(L);Xt(g,V==="left"?"layout.mobileLeftPanel":"layout.mobileRightPanel",L),y(V==="left"?"session":"right")}),xe("omp:open-settings",(z)=>{let L=z.detail;G(L?.category??"appearance"),M(Boolean(L?.autoOpenAdd)),I(!0)});let ne=(z)=>{S((L)=>{let V=Qt(L);if(V.set("sessionId",z.toString()),V.has("subagent"))V.delete("subagent");return V},{replace:!0}),y("main")},X=()=>{S(new URLSearchParams,{replace:!0}),y("main")},ve=(z)=>{let L=il(c,k,z);if(L)Ka(L);S((V)=>ic(V,Xn(z),z),{replace:!0}),y("main")},we=(z,L)=>ft({setSearchParams:S,afterNavigate:()=>y("main")},z,L),ke=a((z)=>{let L=Xe(z,q);if(L)P(L)},[q]),he=a(()=>{let z=Te(g,"layout.mobileRightPanel")??Xl;Fe(z),y("right")},[g]);return e("div",{"data-testid":"app-root",className:"app-window flex flex-col h-dvh w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas relative",children:[e(df,{}),e(pf,{isMock:p}),e(mf,{workspacePath:q}),e("div",{className:`flex-1 min-h-0 w-full relative ${R==="main"?"block":"hidden"}`,...ae.dropProps,...ae.captureDropProps,children:[e(hl,{visible:ae.isDragging}),e(so,{activeSessionId:l,onSelectSession:ne,onNewSession:X,onOpenSessionSidebar:()=>y("session"),onOpenRightSidebar:he,appSettings:r})]}),e("div",{className:`flex-1 min-h-0 w-full ${R==="session"?"block":"hidden"}`,children:e(jo,{activeSessionId:l,onSelectSession:ne,onNewSession:X,onNewSessionForFolder:ve,onNewWorktreeSession:we,onClose:()=>y("main"),onDesktopToggle:t,appSettings:r,rootPath:q??void 0,refreshKey:A,onRefresh:ee,onOpenFile:ke})}),R==="right"&&e("div",{className:"flex-1 min-h-0 w-full",children:e(qo,{enabled:Q,rootPath:q??void 0,refreshKey:A,onRefresh:ee,onOpenFile:ke,onClose:()=>y("main")})}),E&&e(ct,{file:E,missing:de,onClose:()=>P(null),onFileSaved:ee}),w&&e(dt,{diff:w,onClose:()=>C(null),onFileSaved:ee}),e(rl,{isOpen:F,onClose:()=>{I(!1),M(!1)},initialCategory:j,autoOpenAddProvider:U,appSettings:r})]})}export{sd as MobileLayoutWrapper};
@@ -1 +0,0 @@
1
- import{d,n,o,i,le,e,Xt,Qe,Ie,m,nt,f,B,se,rt,ln,pe,Ge,wr,W,D,O,b,lt,je,Ct,Nt,ic,em,ea,Ju,He,Ze,na,tl,We,is,Sa,To,Do,No,Bt,Xn,us,Qo,Ro,Fo,Ka,il,sl,ll,cl}from"./index-f77c3ag0.js";import{hs,Da,Nr,lu,cu,zo,uu,bs,_d,wg,Cg,ys,vs,ks,Qr,xs,ws,Uo,Cs,Es,Bs,Is,bi,Go,_s,Ss,du,pu,mu,fu,gu,Au,hu}from"./index-s7rfbydk.js";var re="shrink-0 w-7 h-7 inline-flex items-center justify-center rounded border transition-colors cursor-pointer",ae="border-ink/15 bg-paper text-ink/70 hover:bg-ink/5 hover:text-ink",fe="border-ink/30 bg-ink/10 text-ink";function ye({isSearchVisible:t,searchQuery:c,showArchived:p,optionsOpen:u,sortOption:y,onToggleSearch:w,onSearchChange:S,onToggleArchived:C,onHideArchived:P,onToggleOptions:v,onCloseOptions:M,onSortChange:A,onNewSession:I,onNewWorkspace:k,onScheduler:E,scheduledCount:l,onRefresh:z,refreshing:_,onSelectWorkspaces:H,selecting:g}){let{ref:F,width:L}=bs(wg),j=Cg(L),r=new Set(_d.slice(0,j)),a=_d.slice(j),U=p?"Hide Archive":"Show Archive",V=l>0?`Scheduled tasks (${l} armed)`:"Scheduled tasks",x=[];if(a.includes("new-workspace"))x.push({id:"new-workspace",label:"New Workspace",icon:ln,onSelect:k});if(a.includes("refresh"))x.push({id:"refresh",label:"Refresh sessions",icon:D,onSelect:z});if(a.includes("search"))x.push({id:"search",label:"Search sessions",icon:O,onSelect:w,active:t});if(a.includes("archive"))x.push({id:"archive",label:U,icon:nt,onSelect:C,active:p});if(a.includes("select"))x.push({id:"select",label:g?"Cancel selection":"Select workspaces",icon:Nr,onSelect:H,active:g});if(a.includes("scheduler"))x.push({id:"scheduler",label:V,icon:Da,onSelect:E});return e("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[e("div",{ref:F,className:"flex items-center justify-between gap-2 px-1 text-ink/60",children:[e("div",{className:"flex flex-1 min-w-0 items-center gap-1.5",children:[e("button",{type:"button",title:"New Session","aria-label":"New Session",onClick:I,className:"flex-1 min-w-[52px] h-7 flex items-center justify-center space-x-1.5 px-2 rounded bg-ink text-canvas text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[e(W,{size:14,className:"shrink-0"}),e("span",{className:"truncate",children:"New Session"})]}),r.has("new-workspace")&&e("button",{type:"button",title:"New Workspace","aria-label":"New Workspace",onClick:k,className:`${re} ${ae}`,children:e(ln,{size:14})}),r.has("scheduler")&&e("button",{type:"button",title:V,"aria-label":l>0?`Scheduled tasks, ${l} armed`:"Scheduled tasks",onClick:E,className:`relative ${re} ${ae}`,children:[e(Da,{size:14}),l>0&&e("span",{className:"absolute -top-1 -right-1 min-w-[10px] h-[10px] px-[2px] rounded-full bg-ink text-canvas text-[7px] leading-[10px] text-center font-semibold",children:l>9?"9+":l})]}),r.has("refresh")&&e("button",{type:"button",title:"Refresh sessions",onClick:z,className:`${re} ${ae}`,"aria-label":"Refresh sessions","aria-busy":_,children:e(D,{size:14,className:_?"animate-spin":""})})]}),e("div",{className:"ml-auto flex items-center gap-1.5 shrink-0",children:[r.has("search")&&e("button",{type:"button",title:t?"Hide search":"Search sessions","aria-label":t?"Hide search":"Search sessions","aria-pressed":t,onClick:w,className:`${re} ${t?fe:ae}`,children:e(O,{size:14})}),r.has("select")&&e("button",{type:"button",title:g?"Cancel selection":"Select workspaces","aria-label":g?"Cancel selection":"Select workspaces","aria-pressed":g,onClick:H,className:`${re} ${g?fe:ae}`,children:e(Nr,{size:14})}),r.has("archive")&&e("button",{type:"button",title:U,"aria-label":U,"aria-pressed":p,onClick:C,className:`${re} ${p?fe:ae}`,children:e(nt,{size:14})}),r.has("sort")&&e("div",{className:"relative",children:[e("button",{type:"button",title:"Sort workspaces","aria-label":"Sort workspaces","aria-haspopup":"menu","aria-expanded":u,onClick:v,className:`${re} ${u||y!=="A-Z"?fe:ae}`,children:e(hs,{size:14})}),u&&e("div",{className:"glass-popover absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/15 rounded-lg shadow-lg z-50 py-1",onMouseLeave:M,children:e(zo,{variant:"desktop",sortOption:y,onSortChange:A})})]}),x.length>0&&e(uu,{actions:x,sortHidden:a.includes("sort"),sortOption:y,onSortChange:A})]})]}),t&&e("div",{className:"pt-1",children:e("input",{type:"text",placeholder:"Search workspaces & sessions...",value:c,onChange:(K)=>S(K.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),p&&e("div",{className:"flex items-center justify-between bg-warning/10 border border-warning/25 text-warning rounded px-2.5 py-1.5 text-[10px] font-medium",children:[e("div",{className:"flex items-center space-x-1.5",children:[e(nt,{size:10}),e("span",{children:"Showing Archived"})]}),e("button",{className:"hover:text-warning-hover",onClick:P,children:e(b,{size:10})})]})]})}var Ce={inset:"px-2",insetPx:8,slotWidth:16,markGap:8,padding:"py-1.5",glyph:Ze.compact};function Ae({sessionId:t,title:c,harness:p,isActive:u=!1,isArchived:y=!1,status:w,awaitingInput:S=!1,timeAgo:C,timeTitle:P,runStartedAt:v,onClick:M,onArchive:A,onDelete:I,onRename:k,onRenameWithAi:E,expandable:l=!1,isExpanded:z=!1,onToggleExpand:_,isChild:H=!1,folderId:g,waitingFor:F,onCancelWait:L,worktree:j,selectable:r=!1,selected:a=!1,onToggleSelect:U}){let V=Sa(t),x=Boolean(l&&_),K=Boolean(F),q=x&&!(S||w==="stream"||K)&&!V,J=Boolean(V||S||w)&&!q,{isEditing:G,draft:N,setDraft:T,inputRef:ee,startRename:ce,handleKeyDown:Y,handleBlur:ne}=No(c,k),Q=Qo(),te=Q.anchor!==null,ie=Boolean(k||A||I||L);return e(d,{children:[e("div",{"data-testid":"session-item","data-session-id":String(t),"data-selected":r&&a?"true":void 0,"data-menu-open":te?"true":void 0,onClick:G?void 0:r?U:M,onContextMenu:ie&&!G&&!r?Q.openAtCursor:void 0,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${r&&a||te?Es:u?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[r?e(d,{children:[e(Qr,{checked:a,label:`Select ${c}`,onChange:()=>U?.()}),e("span",{className:"w-2 shrink-0"})]}):e(d,{children:[e("span",{className:"relative w-4 h-4 shrink-0",children:[x&&_&&e("button",{type:"button",onClick:(Z)=>{Z.stopPropagation(),_(Z)},title:z?"Collapse sessions and subagents":"Expand sessions and subagents","aria-expanded":z,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${q?"text-ink/60 hover:text-ink":"text-ink/40 hover:text-ink pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:z?e(B,{size:13}):e(se,{size:13})}),J&&e("span",{className:`pointer-events-none absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${x?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:V?e("span",{role:"status","aria-label":"Generating a name…",children:e(m,{size:12,className:"animate-spin"})}):S?e(Qe,{size:12,className:"animate-pulse text-ink/80"}):K?e("span",{role:"status","aria-label":`Waiting for ${F?.title??"another session"}`,children:e(Ge,{size:12,className:"animate-pulse text-ink/60"})}):w==="stream"?e("span",{role:"status","aria-label":"Running",children:e(m,{size:12,className:"animate-spin"})}):e(f,{size:12})}),H&&!x&&!J&&e("span",{"data-testid":"child-indicator","aria-hidden":"true",className:"pointer-events-none absolute inset-0 flex items-center justify-center text-ink/35",children:e(pe,{size:12,"aria-hidden":"true"})})]}),e("span",{className:"w-2 shrink-0"})]}),p&&e("span",{className:"mr-1.5 flex shrink-0 items-center",children:e(He,{harness:p,size:Ze.compact})}),G?e("input",{ref:ee,autoFocus:!0,value:N,onChange:(Z)=>T(Z.currentTarget.value),onClick:(Z)=>Z.stopPropagation(),onKeyDown:Y,onBlur:ne,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):e("span",{className:"flex-1 min-w-0 flex flex-col leading-snug",children:[e("span",{className:"min-w-0 truncate",children:c.charAt(0).toUpperCase()+c.slice(1)}),K&&e("span",{className:"truncate text-[10px] text-ink/40 font-normal",children:["waiting for ",F?.title??"another session"]}),j&&!G&&e(xs,{worktree:j})]}),!G&&e(Cs,{timeAgo:C,timeTitle:P,runStartedAt:v,className:"shrink-0 ml-2 font-mono text-[10px]"}),!G&&ie&&!r&&e("button",{type:"button",onClick:Q.openBelow,title:"Session actions","aria-label":"Session actions","aria-haspopup":"menu","aria-expanded":te,className:"shrink-0 ml-1 p-1 text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer",children:e(Ie,{size:14})})]}),Q.anchor&&e(Ro,{anchor:Q.anchor,sessionId:t,...p?{harness:p}:{},...g!==void 0?{folderId:g}:{},isArchived:y,onRename:k?ce:void 0,onRenameWithAi:E,onArchive:A,onDelete:I,onCancelWait:L,onClose:Q.close})]})}function Oe({folder:t,isOpen:c,onToggleFolder:p,checkbox:u,batchActive:y,showMenu:w,onToggleMenu:S,onCloseMenu:C,onNewSession:P,onNewWorktreeSession:v,onOpenFolder:M,onSelectSessions:A,confirmDelete:I,onPin:k,onDelete:E,onRequestDelete:l,onCancelDelete:z}){let _=na(t.icon),[H,g]=n(!1),F=Boolean(v&&t.project_path),L=i(null),[j,r]=n(null);return e("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[e("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:y?void 0:p,children:[u?e(d,{children:[e(Qr,{size:"md",checked:u.checked,indeterminate:u.indeterminate,label:u.label,onChange:u.onChange}),e("span",{className:"w-2 shrink-0"})]}):e(d,{children:[e("span",{className:"relative w-4 h-4 flex items-center justify-center shrink-0",children:[e("span",{className:"absolute inset-0 flex items-center justify-center transition-opacity group-hover:opacity-0 touch-hidden",children:t.customIconUrl?e("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):e(_,{size:15,className:"project-accent-mark text-ink/75",style:tl(t.accentColor)})}),e("span",{className:"absolute inset-0 flex items-center justify-center text-ink/60 opacity-0 transition-opacity group-hover:opacity-100 touch-visible",children:c?e(B,{size:13}):e(se,{size:13})})]}),e("span",{className:"w-2 shrink-0"})]}),t.isPinned&&e(wr,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),e("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),!y&&e("div",{className:"flex items-center space-x-0.5 pl-1",children:[e("button",{type:"button",title:"New Session","aria-label":`New session in ${t.name}`,className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:(a)=>{a.stopPropagation(),P()},children:e(W,{size:12})}),e("div",{className:"relative flex items-center",children:[e("button",{ref:L,type:"button",title:`Options for ${t.name}`,"aria-label":`Options for ${t.name}`,"aria-haspopup":"menu","aria-expanded":w,className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:(a)=>{if(a.stopPropagation(),L.current)r(Ct(L.current));S()},children:e(Ie,{size:12})}),e(Nt,{anchor:w?j:null,align:"end",ariaLabel:`Options for ${t.name}`,className:"glass-popover w-44 rounded-md border border-ink/15 bg-paper py-1 text-xs shadow-lg",onClose:C,children:e(Bs,{variant:"desktop",isPinned:t.isPinned,onOpenFolder:M,onSelectSessions:A,onNewWorktree:F?()=>{S(),g(!0)}:void 0,confirmDelete:I,onPin:k,onDelete:E,onRequestDelete:l,onCancelDelete:z})})]})]}),F&&e(Fo,{isOpen:H,onClose:()=>g(!1),root:t.project_path??null,folderId:t.id,folderName:t.name,onCreated:(a)=>{g(!1),v?.(t.id,a.path)}})]})}function Te({folder:t,activeSessionId:c,onSelectSession:p,onNewSessionForFolder:u,onNewWorktreeSession:y,forceExpanded:w=!1,showArchived:S=!1,sessionStatus:C={},onToast:P,batch:v,onStartSessionSelection:M,onCancelWait:A}){let[I,k]=n(t.isExpanded||!1),[E,l]=n(!1),{visibleCount:z,showMore:_,showLess:H,canShowLess:g}=vs(),[F]=le(),L=F.get("subagent"),j=F.get("sessionId"),{expandedSessionIds:r,toggleSession:a}=us();o(()=>{if(typeof t.isExpanded==="boolean")k(t.isExpanded)},[t.isExpanded]);let{refresh:U,runStartedAtMap:V}=We(),x=lt(),{confirmDelete:K,requestDelete:oe,cancelDelete:q,handlePin:J,handleDelete:G,handleArchive:N,handleRename:T,handleRenameWithAi:ee,handleOpenFolder:ce}=ks(t,U,P),Y=To(),ne=()=>{l(!1),q()},Q=t.sessions,te=()=>{let s=!I;if(k(s),typeof t.id!=="number")return;x.submit({isExpanded:String(s)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},ie=()=>{J(),l(!1)},Z=()=>{G(),l(!1)},ge=ce?()=>{ce(),l(!1)}:void 0,he=w||I,ue=(Q||[]).filter((s)=>S?s.is_archived===1:s.is_archived!==1),{folderCheckbox:h,sessionCheckboxes:R,folderSummary:de,toggleFolderSelection:be,rendered:Fe,hiddenCount:ke}=_s({batch:v,folder:t,sessions:ue,showArchived:S,visibleCount:z,activeSessionId:c,sessionStatus:C}),Se=Go(Fe),Be=he||R,xe=ke>0,we=(s,me)=>{let X=String(s.id),Ne=c!==null?String(c)===X:s.is_active===1,Ee=Ne&&j===X&&Boolean(L),ve=Bt(X);return e(Ae,{sessionId:s.id,title:s.title,harness:s.harness,folderId:s.folder_id,isActive:Ne&&!Ee,isArchived:s.is_archived===1,status:C[X],awaitingInput:Boolean(s.awaitingInput),worktree:s.worktree,timeAgo:ws(s.updated_at??s.created_at),timeTitle:Uo(s.updated_at??s.created_at),runStartedAt:C[X]==="stream"?V[X]:void 0,onClick:()=>p(s.id),onArchive:()=>N(s),onDelete:ve?void 0:()=>Y.requestDelete(s),onRename:ve?void 0:(ze)=>void T(s,ze),onRenameWithAi:ve?void 0:()=>void ee(s),expandable:me.expandable,isChild:me.isChild,isExpanded:me.isExpanded,onToggleExpand:me.onToggleExpand,waitingFor:s.waitingFor?{title:s.waitingFor.title}:void 0,onCancelWait:s.waitingFor?()=>A?.(s.waitingFor.waitId):void 0,selectable:R,selected:Boolean(v?.selected.includes(X)),onToggleSelect:v?()=>v.toggle(X):void 0})},Me=(s)=>Is(s,Se.childrenOf,r,a);return e("div",{className:"space-y-1",children:[e(Oe,{folder:t,isOpen:he,onToggleFolder:te,checkbox:h&&de?{checked:de.all,indeterminate:de.some,label:`Select ${t.name}`,onChange:be}:null,batchActive:Boolean(v),showMenu:E,onToggleMenu:()=>l(!E),onCloseMenu:ne,onNewSession:()=>u(t.id),onNewWorktreeSession:y,onOpenFolder:ge,onSelectSessions:M?()=>{l(!1),M(t.id)}:void 0,confirmDelete:K,onPin:ie,onDelete:Z,onRequestDelete:oe,onCancelDelete:q}),Be&&e("div",{className:"space-y-0.5",children:[Se.roots.map((s)=>{let me=String(s.id),X=Me(s);return e("div",{className:"space-y-0.5",children:[we(s,X),X.isExpanded&&e(bi,{parentId:me,hasSubagents:Boolean(s.hasSubagents),childrenOf:Se.childrenOf,expandedIds:r,onToggle:a,activeSessionId:c===null?null:String(c),renderSession:we,style:Ce})]},s.id)}),(xe||g)&&!R&&e("div",{className:"flex items-center gap-1",children:[xe&&e("button",{type:"button",onClick:_,className:"flex items-center min-w-0 text-xs text-ink/45 hover:text-ink/80 py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[e("span",{className:"w-4 h-4 shrink-0 flex items-center justify-center",children:e(B,{size:12})}),e("span",{className:"w-2 shrink-0"}),e("span",{className:"truncate leading-snug",children:["Show more sessions (",ke,")"]})]}),g&&e("button",{type:"button",onClick:H,className:"ml-auto shrink-0 flex items-center gap-1 text-xs text-ink/45 hover:text-ink/80 py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[e(rt,{size:12}),e("span",{className:"truncate leading-snug",children:"Show less"})]})]}),ue.length===0&&e("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:S?"No archived sessions.":"No sessions."})]}),e(Do,{session:Y.pending,isDeleting:Y.isDeleting,error:Y.error,onClose:Y.cancelDelete,onConfirm:()=>void Y.confirmDelete()})]})}function De({folders:t,activeSessionId:c,searchQuery:p,showArchived:u,harnessFilter:y,sessionStatus:w,onSelectSession:S,onNewSessionForFolder:C,onNewWorktreeSession:P,onToast:v,batch:M,onStartSessionSelection:A,onCancelWait:I}){return e("div",{className:"flex-1 scrollbar-overlay-container p-2 space-y-4",children:t.length===0?e("div",{className:"text-center py-8 text-xs text-muted",children:p?"No results found.":y?`No chats on ${ea(y)}.`:"No workspaces available."}):t.map((k)=>e(Te,{folder:k,activeSessionId:c,onSelectSession:S,onNewSessionForFolder:C,onNewWorktreeSession:P,forceExpanded:p.trim().length>0,showArchived:u,sessionStatus:w,onToast:v,batch:M,onStartSessionSelection:A,onCancelWait:I},k.id))})}var _e=[3,2];function Re(){return e("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:_e.map((t,c)=>e("div",{className:"space-y-1.5",children:[e("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[e("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),e("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:t},(p,u)=>e("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[e("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),e("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-u%3*12}%`}})]},u))]},c))})}function Pe({className:t="",folders:c,initializing:p,failed:u,activeSessionId:y,sessionStatus:w,searchQuery:S,onSearchChange:C,showArchived:P,onToggleArchived:v,sortOption:M,optionsOpen:A,onToggleOptions:I,onCloseOptions:k,onSortChange:E,harnessFilter:l,onHarnessFilterChange:z,harnessOptions:_,onRefresh:H,refreshing:g,scheduledCount:F,onNewSession:L,onNewWorkspace:j,onScheduler:r,onSelectSession:a,onNewSessionForFolder:U,onNewWorktreeSession:V,onToast:x,onCancelWait:K,batch:oe,onSelectWorkspaces:q,onStartSessionSelection:J}){let[G,N]=n(!1),T=G||S.length>0,ee=Boolean(oe);return e("div",{className:`flex flex-col ${t}`,children:[e(ye,{isSearchVisible:T,searchQuery:S,showArchived:P,optionsOpen:A,sortOption:M,onToggleSearch:()=>{if(T)N(!1),C("");else N(!0)},onSearchChange:C,onToggleArchived:v,onHideArchived:v,onToggleOptions:I,onCloseOptions:k,onSortChange:E,onNewSession:L,onNewWorkspace:j,onScheduler:r,scheduledCount:F,onRefresh:H,refreshing:g,onSelectWorkspaces:q,selecting:ee}),e("div",{className:"px-3 pt-2 pb-1",children:e(ys,{options:_,value:l,onChange:z})}),u?e(Ss,{onRetry:H,refreshing:g}):p?e(Re,{}):e(De,{folders:c,activeSessionId:y,searchQuery:S,showArchived:P,harnessFilter:l,sessionStatus:w,onSelectSession:a,onNewSessionForFolder:U,onNewWorktreeSession:V,onToast:x,batch:oe,onStartSessionSelection:J,onCancelWait:K})]})}function Fn({className:t="",appSettings:c={}}){let{folders:p,initializing:u,failed:y,refreshNow:w,isRefreshing:S,activeSessionId:C,sessionParam:P,searchQuery:v,setSearchQuery:M,showArchived:A,setShowArchived:I,optionsOpen:k,setOptionsOpen:E,sortOption:l,handleSortChange:z,harnessFilter:_,setHarnessFilter:H,harnessOptions:g,processedFolders:F,sessionStatus:L,handleSelectSession:j}=pu(c,{expandSearchMatches:!0}),[,r]=le(),a=Ju(),[U,V]=n(!1),[x,K]=n(!1),oe=lu(),{pushToast:q}=je(),J=sl(q);mu({onNotice:q});let G=gu(F,A,w),{selection:N,deleteRun:T,archiveRun:ee,binding:ce,scopeFolder:Y,available:ne,selected:Q}=G,te=()=>{ee.archive(Q).then((h)=>{if(!h)return;let R=fu(h);if(R)q(R.message,R.tone);if(!h.error)N.end()})},ie=(h)=>{let R=il(p,P,h);if(R)Ka(R)},Z=()=>{em({replace:!0})},ge=(h,R)=>{ie(h);let de=Xn(h);Xt(de,"chat.spawnTarget",{folderId:h,worktreePath:R}),r((be)=>ic(be,de,h),{replace:!0})},he=(h)=>{ie(h),r((R)=>ic(R,Xn(h),h),{replace:!0})},ue={className:`flex-1 min-h-0 w-full ${t}`,folders:F,initializing:u,failed:y,activeSessionId:C,sessionStatus:L,searchQuery:v,onSearchChange:M,showArchived:A,onToggleArchived:()=>I(!A),sortOption:l,optionsOpen:k,onToggleOptions:()=>E(!k),onCloseOptions:()=>E(!1),onSortChange:z,harnessFilter:_,onHarnessFilterChange:H,harnessOptions:g,onRefresh:w,refreshing:S,scheduledCount:oe,onNewSession:Z,onNewWorkspace:()=>V(!0),onScheduler:()=>K(!0),onSelectSession:j,onNewSessionForFolder:he,onNewWorktreeSession:ge,onToast:q,onCancelWait:J,batch:ce,onSelectWorkspaces:G.toggleWorkspaceSelection,onStartSessionSelection:(h)=>N.begin("session",h)};return e(d,{children:[e("div",{className:"flex flex-col h-full",children:[a==="modern"?e(du,{...ue}):e(Pe,{...ue}),N.mode&&e(Au,{mode:N.mode,count:Q.length,total:ne.length,busy:T.isDeleting,archiving:ee.isArchiving,scopeLabel:Y?.name,onSelectAll:()=>N.selectAllOf(ne),onUnselectAll:()=>N.unselectAllOf(ne),onDelete:()=>T.request(Q),onArchive:te,onCancel:N.end})]}),e(hu,{mode:N.mode??"session",count:T.pending.length,scopeLabel:Y?.name,isDeleting:T.isDeleting,progress:T.progress,outcome:T.outcome,onClose:()=>{let h=T.outcome?.refused.length??0;if(T.cancel(),T.outcome&&h===0)N.end()},onConfirm:()=>{let h=N.mode??"session";T.confirm(h).then((R)=>{if(R&&R.refused.length===0)N.end()})}}),e(is,{isOpen:U,onClose:()=>V(!1),onCreate:ll,onClone:cl}),e(cu,{isOpen:x,onClose:()=>K(!1),activeSessionId:typeof P==="string"?P:null,onToast:q})]})}export{Fn as SessionsView};
@@ -1 +0,0 @@
1
- import{Bf}from"./index-q81rxwh7.js";export{Bf as createArchitectureServices};
@@ -1 +0,0 @@
1
- import{Tp}from"./index-fg965t62.js";export{Tp as default};
@@ -1 +0,0 @@
1
- import{Jo}from"./index-sesghshh.js";export{Jo as default};
@@ -1 +0,0 @@
1
- import{Zl}from"./index-181p91hf.js";import"./index-sesghshh.js";export{Zl as default};
@@ -1 +0,0 @@
1
- import{yt}from"./index-sk9ej289.js";export{yt as default};
@@ -1 +0,0 @@
1
- import{kd,gs,Ih,_h,Sh,Th}from"./index-m9s9rg5k.js";export{Ih as css,Th as gss,gs as keywords,Sh as less,kd as mkCSS,_h as sCSS};
@@ -1 +0,0 @@
1
- import{vf}from"./index-q81rxwh7.js";export{vf as createCynefinServices};
@@ -1 +0,0 @@
1
- import{If}from"./index-q81rxwh7.js";export{If as createEventModelingServices};
@@ -1 +0,0 @@
1
- import"./index-cgzw43bc.js";import"./index-cjhvtzdd.js";import{Bh}from"./index-pt8440xh.js";export{Bh as diagram};
@@ -1 +0,0 @@
1
- import{kf}from"./index-q81rxwh7.js";export{kf as createGitGraphServices};
@@ -1 +0,0 @@
1
- import{Hf}from"./index-ys0xpw3q.js";import"./index-jz93j0at.js";import"./index-j17h4z6f.js";import"./index-xf36nmbm.js";import"./index-e7yf273s.js";export{Hf as default};
@@ -1 +0,0 @@
1
- import{Nn}from"./index-ycks7gyg.js";import"./index-xf36nmbm.js";import"./index-sk9ej289.js";export{Nn as default};
@@ -1 +0,0 @@
1
- import{d,n,o,i,u,a,le,e,Dp,Ce,S,s,f,B,se,va,re,ce,b,ht,ot,me,it,nA,ci}from"./index-f77c3ag0.js";var ae={name:"chevrons-up-down",size:24,node:[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]},H=s(ae);function O(l,r,c=1e6){return{sessionId:l,sessionTitle:r,modelId:"",modelName:"",timestamp:"",contextUsed:0,contextLimit:c,contextPercent:0,messagesCount:0,userCount:0,assistantCount:0,totalCost:0,costFormatted:"$0.00",cacheHitAverage:0,costBreakdown:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0},lastMessage:{input:0,output:0,reasoning:0,cacheRead:0,cacheWrite:0,cacheHitPercent:0},distribution:{userTokens:0,userPercent:0,assistantTokens:0,assistantPercent:0,toolTokens:0,toolPercent:0,otherTokens:0,otherPercent:100},rawMessages:[]}}function J({used:l,limit:r,percent:c}){let x=l.toLocaleString(),m=r.toLocaleString(),t=Math.min(100,Math.max(0,c));return e("div",{className:"bg-canvas border border-ink/10 rounded-xl p-4 transition-all",children:[e("div",{className:"flex items-center justify-between text-xs mb-2",children:[e("span",{className:"font-semibold text-ink/80",children:"Context"}),e("span",{className:"font-mono text-ink/70 text-[11px]",children:[x," / ",m]})]}),e("div",{className:"w-full h-1.5 bg-ink/10 rounded-full overflow-hidden mb-2",children:e("div",{className:"h-full bg-ink/70 rounded-full transition-all duration-500 ease-out",style:{width:`${t}%`}})}),e("div",{className:"text-[11px] font-mono text-ink/50 text-left",children:[t.toFixed(1),"% used"]})]})}function L(l){return l<0.01?"$0.01":`$${l.toFixed(6).replace(/0+$/,"").replace(/\.$/,"")}`}function Z({open:l,onClose:r,breakdown:c,costFormatted:x}){let m=i(null);if(me(m,r),!l)return null;let t=c?[{label:"Total Cost",value:L(c.total),strong:!0},{label:"Input (cache miss)",value:L(c.input)},{label:"Output",value:L(c.output)},{label:"Cache Read (cache hit)",value:L(c.cacheRead)},{label:"Cache Write",value:L(c.cacheWrite)}]:[{label:"Total Cost",value:x??"$0.01",strong:!0}];return e("div",{ref:m,className:"glass-popover absolute top-full right-0 mt-1.5 z-50 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg p-3",role:"dialog","aria-modal":"false",children:[e("div",{className:"flex items-center justify-between mb-2.5",children:[e("span",{className:"text-xs font-semibold text-ink tracking-tight",children:"Cost Breakdown"}),e("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-ink/5 text-ink/60 hover:text-ink transition-colors","aria-label":"Close cost breakdown",children:e(b,{size:14})})]}),e("div",{className:"space-y-1.5",children:t.map((h)=>e("div",{className:"flex items-center justify-between text-[11px] font-mono border-b border-ink/5 last:border-0 pb-1.5 last:pb-0",children:[e("span",{className:"text-ink/60",children:h.label}),e("span",{className:`${h.strong?"font-semibold text-ink":"text-ink/80"}`,children:h.value})]},h.label))})]})}function V({messagesCount:l,userCount:r,assistantCount:c,costFormatted:x,cacheHitAverage:m,costBreakdown:t}){let[h,g]=n(!1);return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Session Stats"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"Messages",value:l}),e(it,{variant:"compact",label:"User",value:r}),e(it,{variant:"compact",label:"Assistant",value:c}),e(it,{variant:"compact",label:"Cache Hit",value:m!==void 0?`${m.toFixed(1)}%`:"–"}),e("div",{className:"relative bg-canvas border border-ink/10 rounded-lg px-2.5 py-1.5 flex flex-col gap-0.5 flex-1 min-w-0",children:[e("span",{className:"text-[10px] font-medium text-ink/50 flex items-center gap-1",children:["Cost",e("button",{type:"button",onClick:()=>g(!0),className:"p-0.5 rounded text-ink/40 hover:text-ink hover:bg-ink/5 transition-colors","aria-label":"Show cost breakdown",title:"Cost breakdown",children:e(ce,{size:11})})]}),e("span",{className:"text-xs font-semibold font-mono text-ink truncate",children:x}),e(Z,{open:h,onClose:()=>g(!1),breakdown:t,costFormatted:x})]})]})]})}function z({input:l,output:r,reasoning:c,cacheRead:x,cacheWrite:m,cacheHitPercent:t}){return e(d,{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Last Assistant Message"})}),e("div",{className:"flex gap-2 flex-wrap",children:[e(it,{variant:"compact",label:"In",value:l.toLocaleString()}),e(it,{variant:"compact",label:"Out",value:r.toLocaleString()}),e(it,{variant:"compact",label:"Reason",value:c.toLocaleString()}),e(it,{variant:"compact",label:"Cache",value:`${x.toLocaleString()}/${m.toLocaleString()}`}),e(it,{variant:"compact",label:"Hit",value:`${t.toFixed(1)}%`})]})]})}function Q({userPercent:l,assistantPercent:r,toolPercent:c,otherPercent:x}){return e("div",{className:"space-y-2.5",children:[e("div",{className:"w-full h-1.5 rounded-full overflow-hidden flex bg-ink/10",children:[e("div",{className:"h-full bg-emerald-500 transition-all duration-300",style:{width:`${l}%`},title:`User: ${l}%`}),e("div",{className:"h-full bg-sky-500 transition-all duration-300",style:{width:`${r}%`},title:`Assistant: ${r}%`}),e("div",{className:"h-full bg-amber-500 transition-all duration-300",style:{width:`${c}%`},title:`Tool Calls: ${c}%`}),e("div",{className:"h-full bg-slate-400 transition-all duration-300",style:{width:`${x}%`},title:`Other: ${x}%`})]}),e("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[11px] text-ink/70",children:[e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-emerald-500 flex-shrink-0"}),e("span",{children:["User ",l,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-sky-500 flex-shrink-0"}),e("span",{children:["Assistant ",r,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-amber-500 flex-shrink-0"}),e("span",{children:["Tool Calls ",c,"%"]})]}),e("div",{className:"flex items-center space-x-1.5",children:[e("span",{className:"w-2 h-2 rounded-full bg-slate-400 flex-shrink-0"}),e("span",{children:["Other ",x,"%"]})]})]})]})}function G({data:l}){ci();let[r,c]=n(!1),x=i(null),m=i(null),t=JSON.stringify(l,null,2),h=nA(t),g=a((y)=>{let v=m.current;if(!v)return;v.scrollLeft=y.currentTarget.scrollLeft,v.scrollTop=y.currentTarget.scrollTop},[]),w=a(async(y)=>{y.stopPropagation();try{await navigator.clipboard.writeText(t)}catch{let v=document.createElement("textarea");v.value=t,v.style.position="fixed",v.style.opacity="0",document.body.appendChild(v),v.select(),document.execCommand("copy"),document.body.removeChild(v)}c(!0),setTimeout(()=>c(!1),2000)},[t]);return e("div",{className:"relative my-1.5 rounded-lg bg-paper/80 border border-ink/10 overflow-hidden",children:[e("div",{className:"flex items-center justify-between px-2.5 py-1.5 bg-ink/[0.04] border-b border-ink/10",children:[e("span",{className:"text-[10px] font-mono text-ink/50 select-none",children:[Object.keys(l).length," keys · ",t.length," chars"]}),e("button",{type:"button",onClick:w,className:"flex items-center space-x-1 px-2 py-1 rounded bg-canvas hover:bg-paper text-ink/70 hover:text-ink border border-ink/10 text-[10px] transition-colors shadow-xs",title:"Copy Pretty JSON",children:r?e(d,{children:[e(f,{size:11,className:"text-success"}),e("span",{className:"text-success font-sans font-medium",children:"Copied"})]}):e(d,{children:[e(re,{size:11}),e("span",{className:"font-sans",children:"Copy JSON"})]})})]}),e("div",{className:"relative",children:[e("pre",{ref:m,"aria-hidden":!0,className:"absolute inset-0 p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre pointer-events-none",dangerouslySetInnerHTML:{__html:h}}),e("pre",{ref:x,onScroll:g,className:"relative p-2.5 m-0 font-mono text-[11px] leading-5 overflow-x-auto overflow-y-auto whitespace-pre select-text selection:bg-ink selection:text-canvas",children:e("code",{className:"text-transparent",children:t})})]})]})}var D=["bg-emerald-500","bg-sky-500","bg-amber-500","bg-violet-500","bg-rose-500","bg-teal-500","bg-indigo-500","bg-fuchsia-500","bg-lime-500","bg-cyan-500","bg-orange-500","bg-pink-500","bg-yellow-500","bg-purple-500","bg-red-500","bg-blue-500","bg-green-500","bg-cyan-600","bg-violet-600","bg-amber-600"],_=20;function K(l){let r=0;for(let c=0;c<l.length;c++)r=r*31+l.charCodeAt(c)|0;return Math.abs(r)}function q(l){let r=l.indexOf("/"),c=r>0?l.slice(0,r):l,x=r>0?l.slice(r+1):"";return x?`${c} · ${x}`:c}function Y(l,r){if(r<=7)return Array.from({length:r},(h,g)=>g+1);let c=new Set([1,r,l,l-1,l+1]);if(l<=3)[2,3,4].forEach((h)=>c.add(h));if(l>=r-2)[r-3,r-2,r-1].forEach((h)=>c.add(h));let x=[...c].filter((h)=>h>=1&&h<=r).sort((h,g)=>h-g),m=[],t=0;for(let h of x){if(h-t>1)m.push("…");m.push(h),t=h}return m}function X({sessionId:l,refreshKey:r=0}){let[c,x]=S("context.rawExpandedIds",{}),[m,t]=S("context.rawFilterRole","all"),[h,g]=n(1),[w,y]=n([]),[v,I]=n(0),[R,C]=n(!1),W=i(0),E=i(!1),j=a((p)=>{if(typeof window>"u")return;let k=++W.current;if(!p?.silent)C(!0);let P=new URLSearchParams({page:String(h),pageSize:String(_),role:m});if(l)P.set("sessionId",l);fetch(`/api/telemetry/raw-messages?${P.toString()}`).then((N)=>N.ok?N.json():null).then((N)=>{if(E.current||k!==W.current)return;y(N&&Array.isArray(N.items)?N.items:[]),I(N&&Number.isFinite(N.filteredTotal)?N.filteredTotal:0)}).catch(()=>{if(E.current||k!==W.current)return;y([]),I(0)}).finally(()=>{if(!p?.silent&&k===W.current)C(!1)})},[l,h,m]);o(()=>(E.current=!1,j(),()=>{E.current=!0}),[j,r]);let T=Math.max(1,Math.ceil(v/_)),M=Math.min(h,T),U=(p)=>g(Math.min(Math.max(1,p),T)),ee=(p)=>{x((k)=>({...k,[p]:!k[p]}))},te=()=>{if(w.every((k)=>c[k.id]))x({});else{let k={};w.forEach((P)=>{k[P.id]=!0}),x(k)}},A=u(()=>{let p=[];for(let k of w){let P=k.info.modelID;if(!P||p.includes(P))continue;p.push(P)}return p},[w]),F=(p)=>p?D[K(p)%D.length]:"bg-ink/20";return e("div",{className:"space-y-3",children:[A.length>0&&e("div",{children:[e("div",{className:"mb-1.5",children:e("span",{className:"text-xs font-semibold text-ink/80",children:"Legend"})}),e("div",{className:"bg-canvas border border-ink/10 rounded-xl px-3 py-2",children:e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[10px] font-mono text-ink/60",children:A.map((p)=>e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p)}`}),e("span",{children:q(p)})]},p))})})]}),e("div",{className:"flex items-center justify-between",children:[e("div",{className:"flex items-center space-x-2",children:[e("span",{className:"text-xs font-semibold text-ink/80",children:"Raw Messages"}),e("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded-full border border-ink/10",children:v})]}),e("div",{className:"flex items-center space-x-1",children:[e("div",{className:"flex items-center bg-canvas border border-ink/10 rounded-lg p-0.5 text-[10px]",children:[e("button",{type:"button",onClick:()=>{t("all"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="all"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"All"}),e("button",{type:"button",onClick:()=>{t("assistant"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="assistant"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"AI"}),e("button",{type:"button",onClick:()=>{t("user"),g(1)},className:`px-1.5 py-0.5 rounded ${m==="user"?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink"}`,children:"User"})]}),e("button",{type:"button",onClick:te,className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 transition-colors text-[10px] flex items-center",title:"Expand / Collapse All",children:e(H,{size:14})})]})]}),e("div",{className:"space-y-1.5",children:!R&&w.length===0?e("div",{className:"p-4 text-center text-xs text-ink/40 italic bg-canvas rounded-xl border border-ink/10",children:"No raw messages recorded yet."}):w.map((p)=>{let k=Boolean(c[p.id]);return e("div",{className:`bg-canvas border border-ink/10 rounded-xl overflow-hidden transition-all duration-200 ${R?"opacity-50":""}`,children:[e("button",{type:"button",onClick:()=>ee(p.id),className:"w-full text-left px-3.5 py-2.5 flex items-center justify-between hover:bg-ink/5 transition-colors cursor-pointer",children:[e("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[e("span",{className:"text-ink/40 flex-shrink-0",children:k?e(B,{size:14}):e(se,{size:14})}),e("span",{className:"text-xs font-mono text-ink/90 truncate",children:p.badgeLabel})]}),e("div",{className:"flex items-center space-x-3 text-[11px] font-mono text-ink/50 flex-shrink-0",children:[p.tokenSummary&&e("span",{className:"text-ink/60",children:p.tokenSummary}),e("span",{className:"flex items-center gap-1.5",children:[e("span",{className:`w-2 h-2 rounded-full ${F(p.info.modelID)}`}),e("span",{children:p.timestamp})]})]})]}),k&&e("div",{className:"px-3.5 pb-3 pt-1 border-t border-ink/5 bg-canvas/60",children:e(G,{data:p.rawPayload})})]},p.id)})}),T>1&&e("div",{className:"flex items-center justify-between pt-1",children:[e("span",{className:"text-[10px] font-mono text-ink/50",children:[(M-1)*_+1,"–",Math.min(M*_,v)," of ",v]}),e("div",{className:"flex items-center gap-0.5",children:[e("button",{type:"button",disabled:M<=1,onClick:()=>U(M-1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Previous page",children:e(va,{size:14})}),Y(M,T).map((p,k)=>p==="…"?e("span",{className:"px-1 text-[10px] font-mono text-ink/40 select-none",children:"…"},`gap-${k}`):e("button",{type:"button",onClick:()=>U(p),className:`min-w-[22px] h-[22px] px-1 rounded text-[10px] font-mono transition-colors ${p===M?"bg-ink text-canvas font-medium":"text-ink/60 hover:text-ink hover:bg-ink/5"}`,children:p},p)),e("button",{type:"button",disabled:M>=T,onClick:()=>U(M+1),className:"p-1 rounded text-ink/60 hover:text-ink hover:bg-ink/5 disabled:opacity-30 disabled:hover:bg-transparent transition-colors",title:"Next page",children:e(se,{size:14})})]})]})]})}function pt({className:l="",enabled:r=!0,refreshKey:c=0}){let[x]=le(),m=x.get("sessionId"),[t,h]=n(()=>O(m||"default","Session not started")),g=i(!1),w=a(()=>{if(typeof window>"u")return;let R=m?`?sessionId=${encodeURIComponent(m)}`:"";fetch(`/api/telemetry/context${R}`).then((C)=>C.ok?C.json():null).then((C)=>{if(!g.current&&C&&C.telemetry)h(C.telemetry)}).catch((C)=>{if(!g.current)console.warn("Failed to fetch context telemetry:",C)})},[m]);o(()=>{if(g.current=!1,!r)return;return w(),()=>{g.current=!0}},[r,c,w]);let y=Ce(m?Dp(m):null,{enabled:r}),[v,I]=n(0);if(o(()=>{if(y.data)h(y.data),I((R)=>R+1)},[y.data]),!r)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono text-muted",children:"No session selected"})});if(t.messagesCount===0)return e("div",{className:`flex flex-col h-full bg-paper items-center justify-center text-ink/40 ${l}`,children:e("span",{className:"text-xs font-mono",children:"Session not started"})});return e("div",{className:`flex flex-col h-full bg-paper text-ink overflow-hidden select-none ${l}`,children:[e(ht,{left:e(d,{children:[e("h2",{className:"text-xs font-medium text-ink tracking-tight truncate",children:t.sessionTitle}),e("span",{className:"text-[11px] text-ink/50 truncate font-mono",children:t.timestamp})]}),right:e(ot,{label:"Refresh context telemetry",onClick:()=>{y.refresh(),w()},busy:y.refreshing,disabled:!r})}),e("div",{className:"flex-1 scrollbar-overlay-container p-4 space-y-4",children:[e(J,{used:t.contextUsed,limit:t.contextLimit,percent:t.contextPercent}),e(V,{messagesCount:t.messagesCount,userCount:t.userCount,assistantCount:t.assistantCount,costFormatted:t.costFormatted,cacheHitAverage:t.cacheHitAverage,costBreakdown:t.costBreakdown}),e(z,{input:t.lastMessage.input,output:t.lastMessage.output,reasoning:t.lastMessage.reasoning,cacheRead:t.lastMessage.cacheRead,cacheWrite:t.lastMessage.cacheWrite,cacheHitPercent:t.lastMessage.cacheHitPercent}),e(Q,{userPercent:t.distribution.userPercent,assistantPercent:t.distribution.assistantPercent,toolPercent:t.distribution.toolPercent,otherPercent:t.distribution.otherPercent}),e(X,{sessionId:m,refreshKey:c+v})]})]})}export{pt as ContextPanel};
@@ -1,3 +0,0 @@
1
- import{d,n,o,K,i,u,a,Ue,oe,e,Kn,tt,Te,S,s,E,m,en,_,f,B,re,At,ge,St,qe,ri,cn,Yr,D,O,b,Zr,Je,me,fr,Z,st,Js,Bo,Zs,Xs,_o,WA,ih,Qm,ul,Fe,ae,Yt,T,ye,mi,sf,Ag}from"./index-f77c3ag0.js";import{pt,Ai,au,ou,su,As,hi,Id}from"./index-rn8w29pv.js";import{Oc,hd,bd,kg,xg,$c,nr,ps,zc,Uc,Gc,jc,qc,ms,$o,fs,gi,Wc,bl,yl,Kc,Vc,Yc,Jc,Zc,Xc,eu,tu,nu}from"./index-8kqepehd.js";import{Na,Qa,yi}from"./index-48pb18zj.js";var fn={name:"git-commit-vertical",size:24,node:[["path",{d:"M12 3v6",key:"1holv5"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M12 15v6",key:"a9ows0"}]]},Le=s(fn);var bn={name:"maximize",size:24,node:[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]]},xe=s(bn);var gn={name:"minimize",size:24,node:[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]]},we=s(gn);var hn={name:"save-all",size:24,node:[["path",{d:"M10 2v3a1 1 0 0 0 1 1h5",key:"1xspal"}],["path",{d:"M18 18v-6a1 1 0 0 0-1-1h-6a1 1 0 0 0-1 1v6",key:"1ra60u"}],["path",{d:"M18 22H4a2 2 0 0 1-2-2V6",key:"pblm9e"}],["path",{d:"M8 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9.172a2 2 0 0 1 1.414.586l2.828 2.828A2 2 0 0 1 22 6.828V16a2 2 0 0 1-2.01 2z",key:"1yve0x"}]]},ke=s(hn);var ie=new Set,Be=new Set,ze=new Set;function He(){ze=new Set(ie);for(let t of[...Be])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 Be.add(t),()=>{Be.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 K(()=>{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 be={rightFileId:null,fraction:0.5};function Se(t,r,l){if(t===null)return!1;if(t===r)return!1;return l.includes(t)}function 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 pe(t){if(!Number.isFinite(t))return be.fraction;return Math.max(0.2,Math.min(0.8,t))}function Ye(t,r){if(typeof t!=="object"||t===null)return be;let l=t,c=typeof l.fraction==="number"?pe(l.fraction):be.fraction,p=typeof l.rightFileId==="string"||typeof l.rightFileId==="number"?l.rightFileId:null;if(p===null||!r.includes(p))return{rightFileId:null,fraction:c};return{rightFileId:p,fraction:c}}function 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:Se(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 et({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);me(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(ri,{size:14,className:R?"text-info flex-shrink-0":"text-info/70 flex-shrink-0"}):e(st,{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(ri,{size:14,className:"text-info/80"}):e(st,{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 Ce({diskMtimeMs:t,fileName:r,onReload:l,onKeepMine:c}){let p=xn(t);return e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-[11px] text-ink flex-shrink-0",role:"alert","data-conflict-strip":"",children:[e(_,{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:cn,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(cn,{size:14})})}]}function rt(t){if(!t.hasPreview)return[];return[{id:"preview",actions:[{label:t.previewLabel,icon:t.isPreview?St:qe,onSelect:t.onTogglePreview,active:t.isPreview}],children:e(ps,{label:t.previewLabel,pressed:t.isPreview,onClick:t.onTogglePreview,children:t.isPreview?e(St,{size:14}):e(qe,{size:14})})}]}function it(t){let r=[];if(r.push(...nt(t),...ot(t),...rt(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:Le,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(Le,{size:14})})}),r.push({id:"zoom",actions:[{label:"Decrease font size",icon:Qa,onSelect:t.onZoomOut},{label:"Increase font size",icon:Na,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(Qa,{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(Na,{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:ge,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(ge,{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 at({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(pt,{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(pt,{size:14,className:"text-warning"}):e(pt,{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})}),ue=Id(),se=hd(),le=it({byteViewer:y,hasPreview:c,isPreview:p,wordWrap:l,hasReview:h,isReviewing:v,blameInline:ue.inline,findOpen:M,copied:g,isMaximized:C,saveDisabled:w,canReload:R,refreshing:P,reloadDiscardsEdits:Q,saveButton:ce,maximizeButton:te,viewModeButtons:e(bd,{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 fe={...hi(),inline:!ue.inline};Zr({editorBlameInline:fe.inline}),window.dispatchEvent(new CustomEvent(As,{detail:fe}))},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(yi,{clusters:le,className:"text-ink/40 ml-auto"})]})}function lt({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 dt({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:$o[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 ct(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 mt(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 ut({lineCount:t,onGo:r,onClose:l}){let[c,p]=n(""),h=i(null);o(()=>{h.current?.focus(),h.current?.select()},[]);let v=()=>{let w=mt(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=mt(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(At,{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 Ee(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(Ee(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 Ct(t,r,l){let c=q("div",wt);c.setAttribute("role","dialog"),c.setAttribute("aria-label","Line blame"),c.addEventListener("mousedown",(x)=>x.stopPropagation());let p=null,h=!1,v=!1,g=()=>{let x=r.snapshot();return{line:t,status:x.status,payload:x.payload,message:x.message,stale:r.stale(),history:p,historyOpen:h,historyLoading:v}},y=()=>{On(c,g());let x=c.querySelector('[aria-label="Read the blame again"]');if(x)x.addEventListener("click",(k)=>{k.stopPropagation(),l()});c.querySelector("button[aria-expanded]")?.addEventListener("click",(k)=>{if(k.stopPropagation(),h=!h,y(),!h||p||v)return;v=!0,y(),r.history(t).then((I)=>{p=I,v=!1,y()})})};y();let w=r.subscribe(y);return{element:c,place(x){let k=c.ownerDocument.defaultView,I=k?.innerWidth??1024,C=k?.innerHeight??768,M=c.offsetWidth||340,z=c.offsetHeight||120,V=8,H=Math.max(8,Math.min(x.left,I-M-8)),F=x.bottom+6,L=x.top-z-6,U=F+z>C-8&&L>8?L:F;c.style.left=`${H}px`,c.style.top=`${Math.max(8,U)}px`},destroy(){w(),c.remove()}}}function Et(t){return ye.define((r)=>{let l=null,c=0,p,h=()=>{clearTimeout(p),p=void 0,l?.destroy(),l=null,c=0},v=(C,M)=>{let z=C.getBoundingClientRect();if(z.width>0)return{left:z.left,top:z.top,bottom:z.bottom};let V=r.state.doc.line(Math.min(M,r.state.doc.lines)),H=null;try{H=r.coordsAtPos(V.from)}catch{H=null}if(H)return H;let F=r.scrollDOM.getBoundingClientRect();return{left:F.left,top:F.top+24,bottom:F.top+24}},g=(C,M)=>{if(c===C&&l)return;h(),c=C,l=Ct(C,t,()=>{t.reload(),h()}),document.body.append(l.element),l.place(M)},y=(C)=>{let M=C.target,z=M?.closest?.(".cm-blame-label");if(z){let F=Number(z.dataset.blameLine);return Number.isInteger(F)&&F>0?{line:F,anchor:z}:null}let V=M?.closest?.(".cm-lineNumbers .cm-gutterElement");if(!V)return null;let H=Number((V.textContent??"").trim());return Number.isInteger(H)&&H>0?{line:H,anchor:V}:null},w=(C)=>{let M=y(C);if(!M)return;g(M.line,v(M.anchor,M.line))},x=(C)=>{let M=y(C);if(M){C.preventDefault(),g(M.line,v(M.anchor,M.line));return}if(l&&!l.element.contains(C.target))h()},k=(C)=>{if(C.key==="Escape"&&l)h(),C.stopPropagation()},I=(C)=>{if(!l)return;let M=C.relatedTarget;if(M&&(l.element.contains(M)||r.scrollDOM.contains(M)))return;p=setTimeout(h,200)};return r.scrollDOM.addEventListener("mouseover",w),r.scrollDOM.addEventListener("mouseleave",I),r.scrollDOM.addEventListener("mousedown",x),document.addEventListener("mousedown",x),document.addEventListener("keydown",k,!0),{update(C){if(C.docChanged&&l)h()},destroy(){h(),r.scrollDOM.removeEventListener("mouseover",w),r.scrollDOM.removeEventListener("mouseleave",I),r.scrollDOM.removeEventListener("mousedown",x),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",k,!0)}}})}var Tt=40,Nt=ae.define();function An(t){return Fe.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||Ee(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):[],Et(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=Id(),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);ct(J,x);let te=ul({tabKey:String(t.id),surface:F&&M?"rendered":"code",ready:r.loaded,element:F&&M?void 0:J}),ue=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(ut,{lineCount:r.content?r.content.split(`
2
- `).length:1,onGo:(se)=>{Y(!1);let le=fr(r.content,se-1);c.current?.select(le,le,!0),c.current?.revealOffset(le)},onClose:()=>Y(!1)}):null,F&&M?e(lt,{content:r.content,file:{name:t.name,path:t.path,root:t.root,repo:t.repo},zoomLevel:w,reviewActive:z,onExitReview:V,scrollRef:ue,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(dt,{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(at,{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:yl(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(Ce,{diskMtimeMs:r.conflict.diskMtimeMs,fileName:t.name,onReload:r.resolveConflictByReload,onKeepMine:r.resolveConflictByKeepingMine}),r.handleMissing&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-warning/30 bg-warning/10 text-warning",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:"This file was opened by the system, not from a workspace."}),e("div",{className:"text-[11px] font-sans text-warning/80",children:"Its write permission ended with the last page load. Reopen the file from the OS to edit it again."})]})]}),r.deviceBacked&&e("div",{className:"flex items-start gap-2 px-3 py-2 border-b border-ink/20 bg-ink/5 text-ink/70",children:[e(_,{size:14,className:"shrink-0 mt-0.5"}),e("div",{className:"min-w-0",children:[e("div",{className:"text-[11.5px] font-sans",children:r.deviceMissing?"The bytes for this file did not survive the reload.":"Opened from this device, so it is read-only here."}),e("div",{className:"text-[11px] font-sans text-ink/50",children:r.deviceMissing?"A phone's file lives only on the phone, so it cannot be re-read. Open it again from the app that shared it.":"The console cannot reach a file on your phone. Copy it into a workspace to edit it."})]})]}),r.isImage&&r.imageUrl?e(gi,{src:r.imageUrl,name:t.name,className:"flex-1 min-h-0"}):r.isImage?e(bl,{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(xg,{view:p}):Wc(g)&&(R||y)?e(bl,{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(Je,{pluginId:t,children:e(r,{sessionId:l,workspacePath:null})})})}function It({className:t=""}){return e("div",{className:`flex flex-col h-full bg-canvas items-center justify-center text-muted ${t}`,children:[e(st,{name:"placeholder.txt",size:48,className:"mb-4 opacity-20"}),e("p",{className:"font-mono text-sm",children:"Select a file to open"})]})}function Ft({searchReveal:t,revealMatch:r}){let l=i(r);l.current=r;let c=i(null);o(()=>{if(!t||c.current===t.request)return;c.current=t.request,l.current({query:t.request.query,options:t.request.options,line:t.request.line})},[t])}function zt({openedFiles:t,dirtyKeys:r,activeFile:l,previewReady:c,setPreviewMode:p,sessionId:h}){o(()=>{let v=new Set(t.filter((g)=>!g.isDiff&&g.content===void 0).map((g)=>g.id));$e([...r].filter((g)=>v.has(g)))},[r,t]),o(()=>{if(!c)return;let v=l?.id;if(!l||v===void 0||v===null)return;if(!ms[fs(l.name)])return;let g=Te(h,"editor.previewMode");if(g&&g[v]!==void 0)return;p((y)=>y[v]===void 0?{...y,[v]:!0}:y)},[c,l])}function Ht({activeFile:t,externalChange:r,conflict:l,onReload:c,onKeepMine:p}){if(!t)return null;if(l)return e(Ce,{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 $t(t){let r=t.name.trim();if(!r)return{status:"failed",reason:"Enter a file name."};let l=new FormData;if(l.append("actionType","saveAs"),l.append("path",t.parent),l.append("name",r),l.append("content",t.content),l.append("eol",t.eol),t.root)l.append("root",t.root);if(t.repo&&t.repo!==".")l.append("repo",t.repo);try{let c=await fetch("/api/fs/action",{method:"POST",body:l}),p=await c.json().catch(()=>null),h=typeof p?.error==="string"?p.error:null;if(c.status===409)return{status:"exists",reason:h??`${r} already exists.`};if(c.ok&&p?.success&&typeof p.path==="string")return{status:"written",path:p.path};return{status:"failed",reason:h??"The file could not be written."}}catch{return{status:"failed",reason:"The file could not be written."}}}function Vt(t){let r=t.lastIndexOf(".");if(r<=0)return`${t} copy`;return`${t.slice(0,r)} copy${t.slice(r)}`}function Wt(t){let r=t.trim();if(!r)return!1;if(r==="."||r==="..")return!1;return!r.includes("/")&&!r.includes("\\")}function Hn(t){let r=t.lastIndexOf("/");return r===-1?"":t.slice(0,r)}function Kt({fileName:t,filePath:r,content:l,eol:c,root:p,repo:h,onSaved:v,onClose:g}){let[y,w]=n(()=>Hn(r)),[x,k]=n(()=>Vt(t)),[I,C]=n(!1),[M,z]=n(null),V=i(null);o(()=>{V.current?.focus(),V.current?.select()},[]);let H=Wt(x),F=async()=>{if(!H||I)return;C(!0),z(null);let U=await $t({parent:y,name:x,content:l,eol:c,root:p,repo:h});if(C(!1),U.status==="written"){v({path:U.path});return}z(U.reason)},L=(U)=>{if(U.key==="Enter"){U.preventDefault(),F();return}if(U.key==="Escape")U.preventDefault(),g()};return e(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(At,{size:12}),"Save"]})]}),children:e("div",{className:"px-4 py-3 space-y-2 text-xs",children:[e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Folder"}),e("input",{value:y,onInput:(U)=>w(U.target.value),onKeyDown:L,placeholder:"(workspace root)","aria-label":"Destination folder",className:"w-full bg-paper border border-ink/20 rounded px-2 py-1 font-mono text-ink outline-none focus:border-ink/40"})]}),e("label",{className:"block",children:[e("span",{className:"block text-[10px] uppercase tracking-wide text-ink/50 mb-1",children:"Name"}),e("input",{ref:V,value:x,onInput:(U)=>k(U.target.value),onKeyDown:L,"aria-label":"File name","aria-invalid":!H,className:`w-full bg-paper border rounded px-2 py-1 font-mono text-ink outline-none ${H?"border-ink/20 focus:border-ink/40":"border-error text-error"}`})]}),!H?e("div",{className:"text-[10px] text-error font-mono",children:"Enter a file name without a path separator"}):null,M?e("div",{className:"text-[10px] text-error font-mono",children:M}):null,e("div",{className:"text-[10px] text-ink/40",children:"The original file stays where it is, and its tab stays open."})]})})}function Ut(){o(()=>{let t=(r)=>{if(!Ke())return;r.preventDefault(),r.returnValue=""};return window.addEventListener("beforeunload",t),()=>window.removeEventListener("beforeunload",t)},[])}function _t({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(_t,{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(Ht,{activeFile:v,externalChange:y,conflict:w,onReload:x,onKeepMine:k}),I,C&&v?e(Kt,{fileName:v.name,filePath:v.path,content:g.content,eol:g.eol,root:v.root,repo:v.repo,onSaved:({path:F})=>z(F),onClose:M}):null,e(Gt,{closeGuard:V,activeFile:v,saveMissingConfirm:g.saveMissingConfirm,onCancelSaveMissing:g.cancelSaveMissing,onConfirmSaveMissing:g.confirmSaveMissing})]})}function Zt({fileName:t,onClose:r,children:l}){return e("div",{className:"flex flex-col h-full min-w-0","data-split-pane":"",children:[e("div",{className:"flex items-center justify-between gap-2 px-3 py-1 border-b border-ink/10 bg-canvas flex-shrink-0",children:[e("span",{className:"text-[11px] font-mono text-ink/60 truncate",title:t,children:t}),e("button",{type:"button",onClick:r,className:"p-0.5 rounded hover:bg-ink/10 text-ink/50 hover:text-ink transition-colors cursor-pointer flex-shrink-0",title:"Close this pane (the tab stays open)","aria-label":"Close split pane",children:e(b,{size:12})})]}),e("div",{className:"flex-1 min-h-0",children:l})]})}function Xt({fraction:t,onFraction:r,rightPaneName:l,onClosePane:c,rightPane:p,children:h}){let v=i(null),g=i(null),y=Qm(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(pe((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(pe(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",be),h=t.map((k)=>k.id),v=Xe(Ye(c,h),r),g=l&&v.rightFileId!==null?t.find((k)=>k.id===v.rightFileId)??null:null,y=a((k)=>{if(k!==null&&!Se(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:pe(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=WA(mi,g);if(!w||!sf(w))return;g.preventDefault(),g.stopPropagation(),p.current(w)},[])}}function Qt(t){let r=i(t);r.current=t;let l=i(null);if(!l.current)l.current={saveNow:()=>r.current.saveNow(),runCommand:(p)=>r.current.runCommand(p)};return o(()=>{let p=l.current;if(!p)return;return Ag(p)},[]),{onFocusCapture:a(()=>{if(l.current)Ag(l.current)},[])}}function tn({openedFiles:t,activeFileId:r,onSelectFile:l,onCloseFile:c,saveNow:p}){let[h,v]=n(null);Ut();let g=a((w)=>{let x=t.find((k)=>k.id===w);if(x&&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((W)=>W.id===F),[U,A,G]=S("editor.previewMode",{}),X=nu(String(F??"")),[N,R]=S("editor.zoomLevel",Bo),[P,Q]=n(!1),[Y,J]=S("editor.wordWrap",!0),ne=nn(),{sessionId:ce}=tt(),ee=jt({openedFiles:r,activeFileId:F,enabled:!H}),te=i(null),ue=_o(),se=Ai(),le=Kc(r,v),fe=Boolean(L&&le.has(L.id)),j=Yc(L??null,{reportSaveError:!0,onFileSaved:g,missing:fe}),on=kg({path:L?.path??"",content:j.content,language:j.language}),rn=j.diskChange,De=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:(W,de,Pe=!0)=>te.current?.select(W,de,Pe),reveal:(W)=>te.current?.revealOffset(W),applyDocument:(W,de,Pe)=>te.current?.applyDocument(W,de,Pe),toggleWordWrap:()=>J((W)=>!W)}),Oe=Zc(L?.path??null,j.content,j.loaded&&!j.loadError);Ft({searchReveal:Oe,revealMatch:ve.revealMatch}),Xc({file:L,editor:j,surfaceRef:te,isPreview:L?U[L.id]===!0:!1,exitPreview:()=>{let W=L?.id;if(W===void 0||W===null)return;A((de)=>({...de,[W]:!1}))}}),o(()=>{if(v>0)j.reset()},[v]),o(()=>{j.retain(r.map((W)=>W.id)),Ve(r.map((W)=>W.id))},[r]),zt({openedFiles:r,dirtyKeys:j.dirtyKeys,activeFile:L,previewReady:G,setPreviewMode:A,sessionId:ce});let an=()=>{if(!L)return;A((W)=>({...W,[L.id]:!W[L.id]}))},Ne=(W)=>{if(sf(W)){ve.runCommand(W);return}if(W==="toggleWordWrap"){J((de)=>!de);return}if(W==="goToLine"){ne.openGoToLine();return}te.current?.runCommand(W)},sn=Jt({find:ve,runCommand:Ne,reopenClosed:w}),ln=Qt({saveNow:j.saveNow,runCommand:Ne}),Re=ih(z);if(Re)return e(Ot,{pluginId:Re.pluginId,Component:Re.Component,sessionId:ce,className:t});if(r.length===0)return e(It,{className:t});let dn=j.viewerKind,Ae=L?U[L.id]:!1,mn={activeFile:L,editor:j,find:ve,surfaceRef:te,pluginFileView:on,wordWrap:Y,setWordWrap:J,viewerKind:dn,isPreview:Boolean(Ae),isReviewing:Boolean(Ae)&&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:ue,editorTheme:se,togglePreview:an,revealActive:Boolean(Oe),missing:fe,onConvertDiffToEditor:h,onFileSaved:g},un=(W)=>({openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:p,onConvertDiffToEditor:h,refreshKey:v,onFileSaved:g,onOpenPath:y,rootPath:C,repoPath:M,forcedActiveFileId:W,asSplitPane:!0}),pn=e(et,{openedFiles:r,activeFileId:l,onSelectFile:c,onCloseFile:De.requestClose,missingIds:le,onCopyPath:k,onRevealInFiles:I,onReopenClosed:w,reopenableCount:x,onSplitTo:ee.splitTo,onUnsplit:ee.close,splitRightFileId:ee.rightFile?.id??null}),Ie=e(qt,{className:t,isMaximized:P,onKeyDownCapture:sn.onKeyDownCapture,onFocusCapture:ln.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:(W)=>{ne.setSaveAsOpen(!1),y?.(W)},closeGuard:De});if(!ee.rightFile)return Ie;return e(Xt,{fraction:ee.fraction,onFraction:ee.setFraction,rightPaneName:ee.rightFile.name,onClosePane:ee.close,rightPane:e($n,{...un(ee.rightFile.id)}),children:Ie})}export{$n as Editor};