wiki-viewer 2.8.1 → 2.9.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 (282) hide show
  1. package/.next/standalone/.next/BUILD_ID +1 -1
  2. package/.next/standalone/.next/build-manifest.json +3 -3
  3. package/.next/standalone/.next/prerender-manifest.json +3 -3
  4. package/.next/standalone/.next/required-server-files.json +1 -1
  5. package/.next/standalone/.next/server/app/_global-error.html +1 -1
  6. package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/standalone/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/.next/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/standalone/.next/server/app/api/agent/activity/route.js +7 -7
  13. package/.next/standalone/.next/server/app/api/agent/activity/route.js.nft.json +1 -1
  14. package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js +6 -6
  15. package/.next/standalone/.next/server/app/api/agent/admin/agents/[agentId]/revoke/route.js.nft.json +1 -1
  16. package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js +6 -6
  17. package/.next/standalone/.next/server/app/api/agent/admin/agents/route.js.nft.json +1 -1
  18. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js +7 -7
  19. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/approve/route.js.nft.json +1 -1
  20. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js +7 -7
  21. package/.next/standalone/.next/server/app/api/agent/admin/registrations/[regId]/deny/route.js.nft.json +1 -1
  22. package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js +7 -7
  23. package/.next/standalone/.next/server/app/api/agent/admin/registrations/route.js.nft.json +1 -1
  24. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js +7 -7
  25. package/.next/standalone/.next/server/app/api/agent/events/[...path]/route.js.nft.json +1 -1
  26. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js +8 -8
  27. package/.next/standalone/.next/server/app/api/agent/files/[...path]/route.js.nft.json +1 -1
  28. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js +8 -8
  29. package/.next/standalone/.next/server/app/api/agent/fs/file/[...path]/route.js.nft.json +1 -1
  30. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js +8 -8
  31. package/.next/standalone/.next/server/app/api/agent/fs/ls/[[...path]]/route.js.nft.json +1 -1
  32. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js +5 -5
  33. package/.next/standalone/.next/server/app/api/agent/fs/move/route.js.nft.json +1 -1
  34. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js +7 -7
  35. package/.next/standalone/.next/server/app/api/agent/fs/search/route.js.nft.json +1 -1
  36. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js +6 -6
  37. package/.next/standalone/.next/server/app/api/agent/internal/span/route.js.nft.json +1 -1
  38. package/.next/standalone/.next/server/app/api/agent/settings/route.js +7 -7
  39. package/.next/standalone/.next/server/app/api/agent/settings/route.js.nft.json +1 -1
  40. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js +8 -8
  41. package/.next/standalone/.next/server/app/api/agent/sidecar/[...path]/route.js.nft.json +1 -1
  42. package/.next/standalone/.next/server/app/api/app-proxy/[...path]/route.js.nft.json +1 -1
  43. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js +6 -6
  44. package/.next/standalone/.next/server/app/api/assets/[...path]/route.js.nft.json +1 -1
  45. package/.next/standalone/.next/server/app/api/auth/[...all]/route.js +2 -2
  46. package/.next/standalone/.next/server/app/api/auth/[...all]/route.js.nft.json +1 -1
  47. package/.next/standalone/.next/server/app/api/pdf/save/route.js +6 -6
  48. package/.next/standalone/.next/server/app/api/pdf/save/route.js.nft.json +1 -1
  49. package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js +2 -2
  50. package/.next/standalone/.next/server/app/api/share/[token]/asset/route.js.nft.json +1 -1
  51. package/.next/standalone/.next/server/app/api/share/[token]/route.js +5 -5
  52. package/.next/standalone/.next/server/app/api/share/[token]/route.js.nft.json +1 -1
  53. package/.next/standalone/.next/server/app/api/share/route.js +6 -6
  54. package/.next/standalone/.next/server/app/api/share/route.js.nft.json +1 -1
  55. package/.next/standalone/.next/server/app/api/system/admins/route.js +4 -4
  56. package/.next/standalone/.next/server/app/api/system/admins/route.js.nft.json +1 -1
  57. package/.next/standalone/.next/server/app/api/system/api-key/route.js +4 -4
  58. package/.next/standalone/.next/server/app/api/system/api-key/route.js.nft.json +1 -1
  59. package/.next/standalone/.next/server/app/api/system/auth-config/route.js +4 -4
  60. package/.next/standalone/.next/server/app/api/system/auth-config/route.js.nft.json +1 -1
  61. package/.next/standalone/.next/server/app/api/system/auth-settings/route.js +4 -4
  62. package/.next/standalone/.next/server/app/api/system/auth-settings/route.js.nft.json +1 -1
  63. package/.next/standalone/.next/server/app/api/system/browse/route.js +5 -5
  64. package/.next/standalone/.next/server/app/api/system/browse/route.js.nft.json +1 -1
  65. package/.next/standalone/.next/server/app/api/system/clear-root/route.js +5 -5
  66. package/.next/standalone/.next/server/app/api/system/clear-root/route.js.nft.json +1 -1
  67. package/.next/standalone/.next/server/app/api/system/config/route.js +4 -4
  68. package/.next/standalone/.next/server/app/api/system/config/route.js.nft.json +1 -1
  69. package/.next/standalone/.next/server/app/api/system/pins/route.js +6 -6
  70. package/.next/standalone/.next/server/app/api/system/pins/route.js.nft.json +1 -1
  71. package/.next/standalone/.next/server/app/api/system/reveal/route.js +7 -7
  72. package/.next/standalone/.next/server/app/api/system/reveal/route.js.nft.json +1 -1
  73. package/.next/standalone/.next/server/app/api/system/root-status/route.js +7 -7
  74. package/.next/standalone/.next/server/app/api/system/root-status/route.js.nft.json +1 -1
  75. package/.next/standalone/.next/server/app/api/system/set-root/route.js +6 -6
  76. package/.next/standalone/.next/server/app/api/system/set-root/route.js.nft.json +1 -1
  77. package/.next/standalone/.next/server/app/api/system/users/route.js +3 -3
  78. package/.next/standalone/.next/server/app/api/system/users/route.js.nft.json +1 -1
  79. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js +3 -3
  80. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/branch/route.js.nft.json +1 -1
  81. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js +5 -5
  82. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/open/route.js.nft.json +1 -1
  83. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js +3 -3
  84. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/refresh/route.js.nft.json +1 -1
  85. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js +5 -5
  86. package/.next/standalone/.next/server/app/api/system/workspaces/[id]/route.js.nft.json +1 -1
  87. package/.next/standalone/.next/server/app/api/system/workspaces/route.js +5 -5
  88. package/.next/standalone/.next/server/app/api/system/workspaces/route.js.nft.json +1 -1
  89. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js +6 -6
  90. package/.next/standalone/.next/server/app/api/upload/[...path]/route.js.nft.json +1 -1
  91. package/.next/standalone/.next/server/app/api/wiki/app/route.js +4 -4
  92. package/.next/standalone/.next/server/app/api/wiki/app/route.js.nft.json +1 -1
  93. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js +7 -7
  94. package/.next/standalone/.next/server/app/api/wiki/backlinks/route.js.nft.json +1 -1
  95. package/.next/standalone/.next/server/app/api/wiki/content/route.js +6 -6
  96. package/.next/standalone/.next/server/app/api/wiki/content/route.js.nft.json +1 -1
  97. package/.next/standalone/.next/server/app/api/wiki/download/route.js +7 -7
  98. package/.next/standalone/.next/server/app/api/wiki/download/route.js.nft.json +1 -1
  99. package/.next/standalone/.next/server/app/api/wiki/file/route.js +6 -6
  100. package/.next/standalone/.next/server/app/api/wiki/file/route.js.nft.json +1 -1
  101. package/.next/standalone/.next/server/app/api/wiki/folder/route.js +6 -6
  102. package/.next/standalone/.next/server/app/api/wiki/folder/route.js.nft.json +1 -1
  103. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js +7 -7
  104. package/.next/standalone/.next/server/app/api/wiki/git-branches/route.js.nft.json +1 -1
  105. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js +4 -4
  106. package/.next/standalone/.next/server/app/api/wiki/git-checkout/route.js.nft.json +1 -1
  107. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js +7 -7
  108. package/.next/standalone/.next/server/app/api/wiki/git-diff/route.js.nft.json +1 -1
  109. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js +7 -7
  110. package/.next/standalone/.next/server/app/api/wiki/git-file-info/route.js.nft.json +1 -1
  111. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js +7 -7
  112. package/.next/standalone/.next/server/app/api/wiki/git-history/route.js.nft.json +1 -1
  113. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js +6 -6
  114. package/.next/standalone/.next/server/app/api/wiki/git-pull/route.js.nft.json +1 -1
  115. package/.next/standalone/.next/server/app/api/wiki/move/route.js +6 -6
  116. package/.next/standalone/.next/server/app/api/wiki/move/route.js.nft.json +1 -1
  117. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js +6 -6
  118. package/.next/standalone/.next/server/app/api/wiki/new-file/route.js.nft.json +1 -1
  119. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js +6 -6
  120. package/.next/standalone/.next/server/app/api/wiki/outlinks/route.js.nft.json +1 -1
  121. package/.next/standalone/.next/server/app/api/wiki/page/route.js +6 -6
  122. package/.next/standalone/.next/server/app/api/wiki/page/route.js.nft.json +1 -1
  123. package/.next/standalone/.next/server/app/api/wiki/presence/route.js +6 -6
  124. package/.next/standalone/.next/server/app/api/wiki/presence/route.js.nft.json +1 -1
  125. package/.next/standalone/.next/server/app/api/wiki/route.js +6 -6
  126. package/.next/standalone/.next/server/app/api/wiki/route.js.nft.json +1 -1
  127. package/.next/standalone/.next/server/app/api/wiki/search/route.js +7 -7
  128. package/.next/standalone/.next/server/app/api/wiki/search/route.js.nft.json +1 -1
  129. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js +6 -6
  130. package/.next/standalone/.next/server/app/api/wiki/slugs/route.js.nft.json +1 -1
  131. package/.next/standalone/.next/server/app/api/wiki/upload/route.js +6 -6
  132. package/.next/standalone/.next/server/app/api/wiki/upload/route.js.nft.json +1 -1
  133. package/.next/standalone/.next/server/app/api/wiki/watch/route.js +5 -5
  134. package/.next/standalone/.next/server/app/api/wiki/watch/route.js.nft.json +1 -1
  135. package/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  136. package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  137. package/.next/standalone/.next/server/app/signin/page.js +1 -1
  138. package/.next/standalone/.next/server/app/signin/page.js.nft.json +1 -1
  139. package/.next/standalone/.next/server/chunks/032z_better-auth_dist_adapters_kysely-adapter_index_mjs_0.uqexi._.js +3 -0
  140. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0qh1ixf._.js → [root-of-the-server]__0-3eby~._.js} +2 -2
  141. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0-qz_3c._.js → [root-of-the-server]__0-bd36s._.js} +2 -2
  142. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0a2xlp5._.js → [root-of-the-server]__0._o62m._.js} +2 -2
  143. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0d620xp._.js → [root-of-the-server]__0.f~mr1._.js} +2 -2
  144. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0pigocu._.js → [root-of-the-server]__0.xsx4e._.js} +2 -2
  145. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0.uhsjk._.js → [root-of-the-server]__0002pqj._.js} +2 -2
  146. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0epcyks._.js → [root-of-the-server]__01w5s-4._.js} +2 -2
  147. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0202z9f._.js → [root-of-the-server]__020sc-x._.js} +2 -2
  148. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0y0kxa~._.js → [root-of-the-server]__02hiw0n._.js} +2 -2
  149. package/.next/standalone/.next/server/chunks/[root-of-the-server]__037g~yp._.js +20 -0
  150. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0d8xqo8._.js → [root-of-the-server]__04mie79._.js} +2 -2
  151. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0_7vimt._.js → [root-of-the-server]__04yzrn9._.js} +2 -2
  152. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__138gjuw._.js → [root-of-the-server]__05dk_5q._.js} +2 -2
  153. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__11t.sry._.js → [root-of-the-server]__05wicn_._.js} +2 -2
  154. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__08_y49c._.js → [root-of-the-server]__086~~78._.js} +2 -2
  155. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__02wzxsf._.js → [root-of-the-server]__08h0txl._.js} +2 -2
  156. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0o1k3fi._.js → [root-of-the-server]__08xiuca._.js} +2 -2
  157. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__07lzlrr._.js → [root-of-the-server]__0915i_~._.js} +2 -2
  158. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0g3udh8._.js → [root-of-the-server]__09ezcba._.js} +2 -2
  159. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__05i.wh.._.js → [root-of-the-server]__0_h4.il._.js} +3 -3
  160. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0qe859g._.js → [root-of-the-server]__0a7c~hj._.js} +2 -2
  161. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__01e574b._.js → [root-of-the-server]__0au~ncj._.js} +2 -2
  162. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0cdtp8a._.js → [root-of-the-server]__0c-49tx._.js} +2 -2
  163. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0c1~r8t._.js +2 -2
  164. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__12d.iws._.js → [root-of-the-server]__0d8j9pv._.js} +2 -2
  165. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0vijyiu._.js → [root-of-the-server]__0di13ue._.js} +2 -2
  166. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0bjzl0a._.js → [root-of-the-server]__0dkxp4y._.js} +2 -2
  167. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0r91ni0._.js → [root-of-the-server]__0e_irm6._.js} +2 -2
  168. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0egcl8n._.js +12 -0
  169. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0ij7xum._.js → [root-of-the-server]__0imefb9._.js} +2 -2
  170. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0t.n7ho._.js → [root-of-the-server]__0jhwupj._.js} +2 -2
  171. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__006okq3._.js → [root-of-the-server]__0ker6~l._.js} +2 -2
  172. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0zryblt._.js → [root-of-the-server]__0l6bj_u._.js} +2 -2
  173. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0mjux2y._.js +3 -0
  174. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__07sj3y5._.js → [root-of-the-server]__0mkrdf0._.js} +2 -2
  175. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0s6nb4u._.js → [root-of-the-server]__0mw1brk._.js} +2 -2
  176. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0j~yfb8._.js → [root-of-the-server]__0n7uto3._.js} +2 -2
  177. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0mvpu2b._.js → [root-of-the-server]__0nzjsw9._.js} +2 -2
  178. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0_g14o1._.js → [root-of-the-server]__0o0lsmx._.js} +2 -2
  179. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0x0z_oi._.js → [root-of-the-server]__0omc1-s._.js} +4 -4
  180. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0os3ej1._.js +16 -0
  181. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0s7-nm1._.js → [root-of-the-server]__0px8._m._.js} +2 -2
  182. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0~w23al._.js → [root-of-the-server]__0qe7kxb._.js} +2 -2
  183. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0t-buqi._.js → [root-of-the-server]__0qe8lje._.js} +2 -2
  184. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__06ag0hv._.js → [root-of-the-server]__0qox302._.js} +2 -2
  185. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0zireda._.js → [root-of-the-server]__0s5ns33._.js} +2 -2
  186. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__07twyrn._.js → [root-of-the-server]__0s6kt0y._.js} +2 -2
  187. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__13g7bwf._.js → [root-of-the-server]__0sl86.1._.js} +2 -2
  188. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0ro.26e._.js → [root-of-the-server]__0t_s2dg._.js} +4 -4
  189. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__02b3m59._.js → [root-of-the-server]__0tchvup._.js} +2 -2
  190. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__020jdr7._.js → [root-of-the-server]__0tw6h_5._.js} +2 -2
  191. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0v4g9el._.js → [root-of-the-server]__0ujzwde._.js} +2 -2
  192. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0jigd36._.js → [root-of-the-server]__0uxn5_c._.js} +2 -2
  193. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__12aful9._.js → [root-of-the-server]__0vxdtn~._.js} +2 -2
  194. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0ofr1kg._.js → [root-of-the-server]__0wmp13_._.js} +2 -2
  195. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0cbr5tn._.js → [root-of-the-server]__0z8qb~s._.js} +2 -2
  196. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__10ui429._.js → [root-of-the-server]__0zy2f8y._.js} +3 -3
  197. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__11wskj0._.js → [root-of-the-server]__0~p29-i._.js} +2 -2
  198. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0~s~szv._.js +16 -0
  199. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__08gf7vl._.js → [root-of-the-server]__1024gkd._.js} +2 -2
  200. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04atpe0._.js → [root-of-the-server]__10c4_fo._.js} +2 -2
  201. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__08ayj9k._.js → [root-of-the-server]__11mhei8._.js} +2 -2
  202. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__04_l24g._.js → [root-of-the-server]__12abg.4._.js} +2 -2
  203. package/.next/standalone/.next/server/chunks/{[root-of-the-server]__0pjnlq6._.js → [root-of-the-server]__12jdw86._.js} +2 -2
  204. package/.next/standalone/.next/server/chunks/src_lib_auth_server_ts_00f4e0h._.js +3 -3
  205. package/.next/standalone/.next/server/chunks/ssr/032z_better-auth_dist_adapters_kysely-adapter_index_mjs_0z7xdrs._.js +3 -0
  206. package/.next/standalone/.next/server/chunks/ssr/0p91_next_0f40gy0._.js +2 -2
  207. package/.next/standalone/.next/server/chunks/ssr/{0~w0_katex_dist_katex_mjs_0ad8sxj._.js → 0~w0_katex_dist_katex_mjs_0p7ph25._.js} +1 -1
  208. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__09ut-wj._.js +12 -0
  209. package/.next/standalone/.next/server/chunks/ssr/{[root-of-the-server]__00m334i._.js → [root-of-the-server]__13k6~ax._.js} +2 -2
  210. package/.next/standalone/.next/server/chunks/ssr/_03xt0rl._.js +1 -1
  211. package/.next/standalone/.next/server/chunks/ssr/_0i3r51-._.js +1 -1
  212. package/.next/standalone/.next/server/chunks/ssr/_0v4uz-4._.js +1 -1
  213. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0w.8oky._.js → node_modules__pnpm_03ciu.l._.js} +1 -1
  214. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0gjtsn.._.js → node_modules__pnpm_03jchtd._.js} +1 -1
  215. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0_147lg._.js → node_modules__pnpm_04qqrjr._.js} +2 -2
  216. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_10e6442._.js → node_modules__pnpm_04xh4re._.js} +1 -1
  217. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0x0g0os._.js → node_modules__pnpm_06usij4._.js} +1 -1
  218. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0d7vbro._.js → node_modules__pnpm_0819uyi._.js} +2 -2
  219. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_05e0bk~._.js → node_modules__pnpm_09c3lg3._.js} +1 -1
  220. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_01t3sq6._.js → node_modules__pnpm_09k0q18._.js} +1 -1
  221. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_05t9ax3._.js → node_modules__pnpm_09ybwhl._.js} +1 -1
  222. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0v2okl2._.js → node_modules__pnpm_0a-f4gi._.js} +1 -1
  223. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_04wum0.._.js → node_modules__pnpm_0b3l3b4._.js} +1 -1
  224. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0-1ss1p._.js → node_modules__pnpm_0c.b4rt._.js} +1 -1
  225. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0dl2oqy._.js → node_modules__pnpm_0dsnv76._.js} +1 -1
  226. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_10teun9._.js → node_modules__pnpm_0eiz-8_._.js} +1 -1
  227. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_13ldydj._.js → node_modules__pnpm_0gnc95r._.js} +2 -2
  228. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_03xabl9._.js → node_modules__pnpm_0iuzd3o._.js} +1 -1
  229. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0--p4nj._.js → node_modules__pnpm_0kli5~f._.js} +1 -1
  230. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0vr89s3._.js → node_modules__pnpm_0ldft78._.js} +1 -1
  231. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0.9b4fh._.js → node_modules__pnpm_0m2hb6k._.js} +1 -1
  232. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0u3x9vb._.js → node_modules__pnpm_0ov9ih8._.js} +1 -1
  233. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0.57ebn._.js → node_modules__pnpm_0qhs4r2._.js} +1 -1
  234. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0kn.dtv._.js → node_modules__pnpm_0umkew~._.js} +2 -2
  235. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0nrgzso._.js → node_modules__pnpm_0wjizot._.js} +2 -2
  236. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0b.~9qt._.js → node_modules__pnpm_0yfe2s1._.js} +1 -1
  237. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_006-aus._.js → node_modules__pnpm_0ypcps.._.js} +2 -2
  238. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_00r.2o_._.js → node_modules__pnpm_0~ovwm1._.js} +1 -1
  239. package/.next/standalone/.next/server/chunks/ssr/{node_modules__pnpm_0ilobyl._.js → node_modules__pnpm_12dmj0l._.js} +2 -2
  240. package/.next/standalone/.next/server/chunks/ssr/src_app_signin_00yk0vm._.js +3 -3
  241. package/.next/standalone/.next/server/middleware-build-manifest.js +3 -3
  242. package/.next/standalone/.next/server/pages/500.html +1 -1
  243. package/.next/standalone/.next/server/server-reference-manifest.js +1 -1
  244. package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  245. package/.next/standalone/.next/static/chunks/{0geo.l55~q1t..js → 0-lsw0io13aha.js} +1 -1
  246. package/.next/standalone/.next/static/chunks/{0lhpfri5g83ie.js → 08yt220_vis~5.js} +1 -1
  247. package/.next/standalone/.next/static/chunks/0mn.-bl.si~im.js +1 -0
  248. package/.next/standalone/package.json +129 -131
  249. package/.next/standalone/server.js +1 -1
  250. package/bin/postbuild.js +3 -3
  251. package/package.json +129 -131
  252. package/.next/standalone/.next/server/chunks/0dhv_better-auth_dist_adapters_kysely-adapter_index_mjs_0t4t4z8._.js +0 -3
  253. package/.next/standalone/.next/server/chunks/[root-of-the-server]__00vbqtx._.js +0 -12
  254. package/.next/standalone/.next/server/chunks/[root-of-the-server]__024xlhl._.js +0 -3
  255. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0i.8g~9._.js +0 -20
  256. package/.next/standalone/.next/server/chunks/[root-of-the-server]__0ll9j_l._.js +0 -16
  257. package/.next/standalone/.next/server/chunks/[root-of-the-server]__13.6kr3._.js +0 -16
  258. package/.next/standalone/.next/server/chunks/ssr/0dhv_better-auth_dist_adapters_kysely-adapter_index_mjs_08ymlcb._.js +0 -3
  259. package/.next/standalone/.next/server/chunks/ssr/[root-of-the-server]__0~~1h_p._.js +0 -12
  260. package/.next/standalone/.next/static/chunks/0g5dv59skfo1z.js +0 -1
  261. package/.next/standalone/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
  262. package/.next/standalone/node_modules/better-sqlite3/lib/database.js +0 -90
  263. package/.next/standalone/node_modules/better-sqlite3/lib/index.js +0 -3
  264. package/.next/standalone/node_modules/better-sqlite3/lib/methods/aggregate.js +0 -43
  265. package/.next/standalone/node_modules/better-sqlite3/lib/methods/backup.js +0 -67
  266. package/.next/standalone/node_modules/better-sqlite3/lib/methods/function.js +0 -31
  267. package/.next/standalone/node_modules/better-sqlite3/lib/methods/inspect.js +0 -7
  268. package/.next/standalone/node_modules/better-sqlite3/lib/methods/pragma.js +0 -12
  269. package/.next/standalone/node_modules/better-sqlite3/lib/methods/serialize.js +0 -16
  270. package/.next/standalone/node_modules/better-sqlite3/lib/methods/table.js +0 -189
  271. package/.next/standalone/node_modules/better-sqlite3/lib/methods/transaction.js +0 -78
  272. package/.next/standalone/node_modules/better-sqlite3/lib/methods/wrappers.js +0 -54
  273. package/.next/standalone/node_modules/better-sqlite3/lib/sqlite-error.js +0 -20
  274. package/.next/standalone/node_modules/better-sqlite3/lib/util.js +0 -12
  275. package/.next/standalone/node_modules/better-sqlite3/package.json +0 -59
  276. package/.next/standalone/node_modules/bindings/bindings.js +0 -221
  277. package/.next/standalone/node_modules/bindings/package.json +0 -28
  278. package/.next/standalone/node_modules/file-uri-to-path/index.js +0 -66
  279. package/.next/standalone/node_modules/file-uri-to-path/package.json +0 -32
  280. /package/.next/standalone/.next/static/{WtKQEaB8ro8SFVwVGO-6x → 014EirzgOgUjO57zMiZrA}/_buildManifest.js +0 -0
  281. /package/.next/standalone/.next/static/{WtKQEaB8ro8SFVwVGO-6x → 014EirzgOgUjO57zMiZrA}/_clientMiddlewareManifest.js +0 -0
  282. /package/.next/standalone/.next/static/{WtKQEaB8ro8SFVwVGO-6x → 014EirzgOgUjO57zMiZrA}/_ssgManifest.js +0 -0
@@ -14,4 +14,4 @@ TOKEN=<paste token here>
14
14
  # 3. Read snapshot
15
15
  curl -s -H "Authorization: Bearer $TOKEN" \\
16
16
  -H "X-Agent-Id: ai:claude" \\
17
- ${t}/api/agent/files/${e??"<path/to/file.md>"}`;await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),1500)},[e])}}(e??null),[m,p]=(0,W.useState)(""),h=(0,W.useRef)(null),x=window.location.origin,f=(0,W.useCallback)(()=>nu,[]),g=(0,W.useCallback)(()=>m.replace(/\$WIKI_URL/g,x),[m,x]),b=(0,W.useCallback)(()=>`npx wiki-viewer-mcp register --url ${x} --id ai:myagent --name "My Agent"`,[x]),w=(0,W.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:x,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[x]),y=nm(f),v=nm(g),N=nm(b),j=nm(w);return((0,W.useEffect)(()=>{if(a)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&n()}},[a,n]),(0,W.useEffect)(()=>{a&&h.current?.focus()},[a]),(0,W.useEffect)(()=>{if(!a)return;c();let e=setInterval(()=>void c(),1e4);return()=>clearInterval(e)},[a,c]),(0,W.useEffect)(()=>{a&&fetch((0,tU.apiUrl)("/api/agents/install")).then(e=>e.json()).then(e=>{e.bootstrapPrompt&&p(e.bootstrapPrompt)}).catch(()=>void 0)},[a]),a)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:n,"aria-hidden":!0}),(0,t.jsxs)("aside",{ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(r,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:n,title:"Close panel (Esc)",children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,t.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,t.jsx)(H.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,t.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:nu}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,t.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,t.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:b()}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void N.copy(),children:N.copied?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,t.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,t.jsx)(H.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void j.copy(),children:j.copied?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,t.jsxs)("button",{type:"button",onClick:()=>void u(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[d?(0,t.jsx)(s.Check,{className:"h-3 w-3 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3 w-3"})," curl example"]}),(0,t.jsxs)("a",{href:(0,tU.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,t.jsx)(en.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,t.jsxs)("a",{href:(0,tU.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,t.jsx)(en.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,t.jsx)(nr,{}),(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,t.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,t.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===l.length?(0,t.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,t.jsx)(a4,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,t.jsx)("ul",{className:"space-y-1.5",children:l.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,t.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:e.by}),(0,t.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[e.opCount," op",1!==e.opCount?"s":""]})]},e.by))})})]}),(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,t.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,t.jsx)(nd,{activity:i})})]}),(0,t.jsx)("section",{children:(0,t.jsx)("a",{href:(0,tU.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var nh=e.i(580330),nx=e.i(877031),nf=/[\\\/_+.#"@\[\(\{&]/,ng=/[\\\/_+.#"@\[\(\{&]/g,nb=/[\s-]/,nw=/[\s-]/g;function ny(e){return e.toLowerCase().replace(nw," ")}var nv=e.i(750110),nN=e.i(433616),nj='[cmdk-group=""]',nk='[cmdk-group-items=""]',n_='[cmdk-item=""]',nC=`${n_}:not([aria-disabled="true"])`,nE="cmdk-item-select",nS="data-value",nM=(e,t,a)=>{var n;return n=e,function e(t,a,n,r,s,i,l){if(i===a.length)return s===t.length?1:.99;var o=`${s},${i}`;if(void 0!==l[o])return l[o];for(var c,d,u,m,p=r.charAt(i),h=n.indexOf(p,s),x=0;h>=0;)(c=e(t,a,n,r,h+1,i+1,l))>x&&(h===s?c*=1:nf.test(t.charAt(h-1))?(c*=.8,(u=t.slice(s,h-1).match(ng))&&s>0&&(c*=Math.pow(.999,u.length))):nb.test(t.charAt(h-1))?(c*=.9,(m=t.slice(s,h-1).match(nw))&&s>0&&(c*=Math.pow(.999,m.length))):(c*=.17,s>0&&(c*=Math.pow(.999,h-s))),t.charAt(h)!==a.charAt(i)&&(c*=.9999)),(c<.1&&n.charAt(h-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(h-1)!==r.charAt(i))&&.1*(d=e(t,a,n,r,h+1,i+2,l))>c&&(c=.1*d),c>x&&(x=c),h=n.indexOf(p,h+1);return l[o]=x,x}(n=a&&a.length>0?`${n+" "+a.join(" ")}`:n,t,ny(n),ny(t),0,0,{})},nA=W.createContext(void 0),nD=W.createContext(void 0),nT=W.createContext(void 0),nO=W.forwardRef((e,t)=>{let a=nq(()=>{var t,a;return{search:"",value:null!=(a=null!=(t=e.value)?t:e.defaultValue)?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=nq(()=>new Set),r=nq(()=>new Map),s=nq(()=>new Map),i=nq(()=>new Set),l=nz(e),{label:o,children:c,value:d,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:x=!1,vimBindings:f=!0,...g}=e,b=(0,nN.useId)(),w=(0,nN.useId)(),y=(0,nN.useId)(),v=W.useRef(null),N=nH();nU(()=>{if(void 0!==d){let e=d.trim();a.current.value=e,j.emit()}},[d]),nU(()=>{N(6,M)},[]);let j=W.useMemo(()=>({subscribe:e=>(i.current.add(e),()=>i.current.delete(e)),snapshot:()=>a.current,setState:(e,t,n)=>{var r,s,i,o;if(!Object.is(a.current[e],t)){if(a.current[e]=t,"search"===e)S(),C(),N(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(y);e?e.focus():null==(r=document.getElementById(b))||r.focus()}if(N(7,()=>{var e;a.current.selectedItemId=null==(e=A())?void 0:e.id,j.emit()}),n||N(5,M),(null==(s=l.current)?void 0:s.value)!==void 0){null==(o=(i=l.current).onValueChange)||o.call(i,null!=t?t:"");return}}j.emit()}},emit:()=>{i.current.forEach(e=>e())}}),[]),k=W.useMemo(()=>({value:(e,t,n)=>{var r;t!==(null==(r=s.current.get(e))?void 0:r.value)&&(s.current.set(e,{value:t,keywords:n}),a.current.filtered.items.set(e,_(t,n)),N(2,()=>{C(),j.emit()}))},item:(e,t)=>(n.current.add(e),t&&(r.current.has(t)?r.current.get(t).add(e):r.current.set(t,new Set([e]))),N(3,()=>{S(),C(),a.current.value||E(),j.emit()}),()=>{s.current.delete(e),n.current.delete(e),a.current.filtered.items.delete(e);let t=A();N(4,()=>{S(),(null==t?void 0:t.getAttribute("id"))===e&&E(),j.emit()})}),group:e=>(r.current.has(e)||r.current.set(e,new Set),()=>{s.current.delete(e),r.current.delete(e)}),filter:()=>l.current.shouldFilter,label:o||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:y,labelId:w,listInnerRef:v}),[]);function _(e,t){var n,r;let s=null!=(r=null==(n=l.current)?void 0:n.filter)?r:nM;return e?s(e,a.current.search,t):0}function C(){if(!a.current.search||!1===l.current.shouldFilter)return;let e=a.current.filtered.items,t=[];a.current.filtered.groups.forEach(a=>{let n=r.current.get(a),s=0;n.forEach(t=>{s=Math.max(e.get(t),s)}),t.push([a,s])});let n=v.current;D().sort((t,a)=>{var n,r;let s=t.getAttribute("id"),i=a.getAttribute("id");return(null!=(n=e.get(i))?n:0)-(null!=(r=e.get(s))?r:0)}).forEach(e=>{let t=e.closest(nk);t?t.appendChild(e.parentElement===t?e:e.closest(`${nk} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${nk} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let a=null==(t=v.current)?void 0:t.querySelector(`${nj}[${nS}="${encodeURIComponent(e[0])}"]`);null==a||a.parentElement.appendChild(a)})}function E(){let e=D().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(nS);j.setState("value",t||void 0)}function S(){var e,t,i,o;if(!a.current.search||!1===l.current.shouldFilter){a.current.filtered.count=n.current.size;return}a.current.filtered.groups=new Set;let c=0;for(let r of n.current){let n=_(null!=(t=null==(e=s.current.get(r))?void 0:e.value)?t:"",null!=(o=null==(i=s.current.get(r))?void 0:i.keywords)?o:[]);a.current.filtered.items.set(r,n),n>0&&c++}for(let[e,t]of r.current)for(let n of t)if(a.current.filtered.items.get(n)>0){a.current.filtered.groups.add(e);break}a.current.filtered.count=c}function M(){var e,t,a;let n=A();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(a=null==(t=n.closest(nj))?void 0:t.querySelector('[cmdk-group-heading=""]'))||a.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function A(){var e;return null==(e=v.current)?void 0:e.querySelector(`${n_}[aria-selected="true"]`)}function D(){var e;return Array.from((null==(e=v.current)?void 0:e.querySelectorAll(nC))||[])}function T(e){let t=D()[e];t&&j.setState("value",t.getAttribute(nS))}function O(e){var t;let a=A(),n=D(),r=n.findIndex(e=>e===a),s=n[r+e];null!=(t=l.current)&&t.loop&&(s=r+e<0?n[n.length-1]:r+e===n.length?n[0]:n[r+e]),s&&j.setState("value",s.getAttribute(nS))}function I(e){let t=A(),a=null==t?void 0:t.closest(nj),n;for(;a&&!n;)n=null==(a=e>0?function(e,t){let a=e.nextElementSibling;for(;a;){if(a.matches(t))return a;a=a.nextElementSibling}}(a,nj):function(e,t){let a=e.previousElementSibling;for(;a;){if(a.matches(t))return a;a=a.previousElementSibling}}(a,nj))?void 0:a.querySelector(nC);n?j.setState("value",n.getAttribute(nS)):O(e)}let R=()=>T(D().length-1),F=e=>{e.preventDefault(),e.metaKey?R():e.altKey?I(1):O(1)},L=e=>{e.preventDefault(),e.metaKey?T(0):e.altKey?I(-1):O(-1)};return W.createElement(nv.Primitive.div,{ref:t,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=g.onKeyDown)||t.call(g,e);let a=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||a))switch(e.key){case"n":case"j":f&&e.ctrlKey&&F(e);break;case"ArrowDown":F(e);break;case"p":case"k":f&&e.ctrlKey&&L(e);break;case"ArrowUp":L(e);break;case"Home":e.preventDefault(),T(0);break;case"End":e.preventDefault(),R();break;case"Enter":{e.preventDefault();let t=A();if(t){let e=new Event(nE);t.dispatchEvent(e)}}}}},W.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:nV},o),nG(e,e=>W.createElement(nD.Provider,{value:j},W.createElement(nA.Provider,{value:k},e))))}),nI=W.forwardRef((e,t)=>{var a,n;let r=(0,nN.useId)(),s=W.useRef(null),i=W.useContext(nT),l=W.useContext(nA),o=nz(e),c=null!=(n=null==(a=o.current)?void 0:a.forceMount)?n:null==i?void 0:i.forceMount;nU(()=>{if(!c)return l.item(r,null==i?void 0:i.id)},[c]);let d=nW(r,s,[e.value,e.children,s],e.keywords),u=W.useContext(nD),m=nK(e=>e.value&&e.value===d.current),p=nK(e=>!!c||!1===l.filter()||!e.search||e.filtered.items.get(r)>0);function h(){var e,t;x(),null==(t=(e=o.current).onSelect)||t.call(e,d.current)}function x(){u.setState("value",d.current,!0)}if(W.useEffect(()=>{let t=s.current;if(!(!t||e.disabled))return t.addEventListener(nE,h),()=>t.removeEventListener(nE,h)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:g,onSelect:b,forceMount:w,keywords:y,...v}=e;return W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(s,t),...v,id:r,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!m,"data-disabled":!!f,"data-selected":!!m,onPointerMove:f||l.getDisablePointerSelection()?void 0:x,onClick:f?void 0:h},e.children)}),nR=W.forwardRef((e,t)=>{let{heading:a,children:n,forceMount:r,...s}=e,i=(0,nN.useId)(),l=W.useRef(null),o=W.useRef(null),c=(0,nN.useId)(),d=W.useContext(nA),u=nK(e=>!!r||!1===d.filter()||!e.search||e.filtered.groups.has(i));nU(()=>d.group(i),[]),nW(i,l,[e.value,e.heading,o]);let m=W.useMemo(()=>({id:i,forceMount:r}),[r]);return W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(l,t),...s,"cmdk-group":"",role:"presentation",hidden:!u||void 0},a&&W.createElement("div",{ref:o,"cmdk-group-heading":"","aria-hidden":!0,id:c},a),nG(e,e=>W.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?c:void 0},W.createElement(nT.Provider,{value:m},e))))}),nF=W.forwardRef((e,t)=>{let{alwaysRender:a,...n}=e,r=W.useRef(null),s=nK(e=>!e.search);return a||s?W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(r,t),...n,"cmdk-separator":"",role:"separator"}):null}),nL=W.forwardRef((e,t)=>{let{onValueChange:a,...n}=e,r=null!=e.value,s=W.useContext(nD),i=nK(e=>e.search),l=nK(e=>e.selectedItemId),o=W.useContext(nA);return W.useEffect(()=>{null!=e.value&&s.setState("search",e.value)},[e.value]),W.createElement(nv.Primitive.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":o.listId,"aria-labelledby":o.labelId,"aria-activedescendant":l,id:o.inputId,type:"text",value:r?e.value:i,onChange:e=>{r||s.setState("search",e.target.value),null==a||a(e.target.value)}})}),nP=W.forwardRef((e,t)=>{let{children:a,label:n="Suggestions",...r}=e,s=W.useRef(null),i=W.useRef(null),l=nK(e=>e.selectedItemId),o=W.useContext(nA);return W.useEffect(()=>{if(i.current&&s.current){let e=i.current,t=s.current,a,n=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{let a=e.offsetHeight;t.style.setProperty("--cmdk-list-height",a.toFixed(1)+"px")})});return n.observe(e),()=>{cancelAnimationFrame(a),n.unobserve(e)}}},[]),W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(s,t),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":n,id:o.listId},nG(e,e=>W.createElement("div",{ref:(0,al.composeRefs)(i,o.listInnerRef),"cmdk-list-sizer":""},e)))}),nB=W.forwardRef((e,t)=>{let{open:a,onOpenChange:n,overlayClassName:r,contentClassName:s,container:i,...l}=e;return W.createElement(tV.Root,{open:a,onOpenChange:n},W.createElement(tV.Portal,{container:i},W.createElement(tV.Overlay,{"cmdk-overlay":"",className:r}),W.createElement(tV.Content,{"aria-label":e.label,"cmdk-dialog":"",className:s},W.createElement(nO,{ref:t,...l}))))}),n$=Object.assign(nO,{List:nP,Item:nI,Input:nL,Group:nR,Separator:nF,Dialog:nB,Empty:W.forwardRef((e,t)=>nK(e=>0===e.filtered.count)?W.createElement(nv.Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:W.forwardRef((e,t)=>{let{progress:a,children:n,label:r="Loading...",...s}=e;return W.createElement(nv.Primitive.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},nG(e,e=>W.createElement("div",{"aria-hidden":!0},e)))})});function nz(e){let t=W.useRef(e);return nU(()=>{t.current=e}),t}var nU="u"<typeof window?W.useEffect:W.useLayoutEffect;function nq(e){let t=W.useRef();return void 0===t.current&&(t.current=e()),t}function nK(e){let t=W.useContext(nD),a=()=>e(t.snapshot());return W.useSyncExternalStore(t.subscribe,a,a)}function nW(e,t,a,n=[]){let r=W.useRef(),s=W.useContext(nA);return nU(()=>{var i;let l=(()=>{var e;for(let t of a){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():r.current}})(),o=n.map(e=>e.trim());s.value(e,l,o),null==(i=t.current)||i.setAttribute(nS,l),r.current=l}),r}var nH=()=>{let[e,t]=W.useState(),a=nq(()=>new Map);return nU(()=>{a.current.forEach(e=>e()),a.current=new Map},[e]),(e,n)=>{a.current.set(e,n),t({})}};function nG({asChild:e,children:t},a){let n;return e&&W.isValidElement(t)?W.cloneElement("function"==typeof(n=t.type)?n(t.props):"render"in n?n.render(t.props):t,{ref:t.ref},a(t.props.children)):a(t)}var nV={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let nZ=(0,n.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),nX=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$,{ref:n,className:(0,tf.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",e),...a}));function nJ({children:e,shouldFilter:a,...n}){return(0,t.jsx)(G.Dialog,{...n,children:(0,t.jsxs)(G.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,t.jsx)(G.DialogTitle,{className:"sr-only",children:"Search"}),(0,t.jsx)(nX,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})})}nX.displayName=n$.displayName;let nQ=W.forwardRef(({className:e,...a},n)=>(0,t.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,t.jsx)(nZ,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,t.jsx)(n$.Input,{ref:n,className:(0,tf.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...a})]}));nQ.displayName=n$.Input.displayName;let nY=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.List,{ref:n,className:(0,tf.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));nY.displayName=n$.List.displayName;let n0=W.forwardRef((e,a)=>(0,t.jsx)(n$.Empty,{ref:a,className:"py-6 text-center text-sm text-muted-foreground",...e}));n0.displayName=n$.Empty.displayName;let n1=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Group,{ref:n,className:(0,tf.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",e),...a}));n1.displayName=n$.Group.displayName;let n2=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Separator,{ref:n,className:(0,tf.cn)("-mx-1 h-px bg-border",e),...a}));n2.displayName=n$.Separator.displayName;let n5=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Item,{ref:n,className:(0,tf.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a}));n5.displayName=n$.Item.displayName;let n3=null,n4=null,n9=(0,t5.create)(e=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:t=>e({query:t}),setOpen:t=>e({open:t}),clear:()=>{n4&&clearTimeout(n4),n3?.abort(),e({query:"",results:[],loading:!1,truncated:!1})},search:t=>(n4&&clearTimeout(n4),t.trim())?(e({loading:!0}),new Promise(a=>{n4=setTimeout(()=>{n7(e,t).finally(a)},150)})):(n3?.abort(),e({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function n7(e,t){n3?.abort();let a=new AbortController;n3=a;try{let n=await (0,X.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,limit:30}),signal:a.signal});if(!n.ok)return void e({results:[],loading:!1,truncated:!1});let r=await n.json();if(a.signal.aborted)return;e({results:r.matches??[],truncated:!!r.truncated,loading:!1})}catch(t){"AbortError"!==t.name&&e({loading:!1})}}var n6=e.i(395624);function n8({html:e}){let a=function(e){let t,a=[],n=/<mark>([\s\S]*?)<\/mark>/g,r=0;for(;null!==(t=n.exec(e));)t.index>r&&a.push({text:e.slice(r,t.index),mark:!1}),a.push({text:t[1]??"",mark:!0}),r=t.index+t[0].length;return r<e.length&&a.push({text:e.slice(r),mark:!1}),a}(e);return(0,t.jsx)(t.Fragment,{children:a.map((e,a)=>e.mark?(0,t.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:e.text},a):(0,t.jsx)("span",{children:e.text},a))})}function re({onOpenFile:e,recents:a=[],onToggleSidebar:n=()=>void 0,onNewFile:s=()=>void 0,onCopyPath:i=()=>void 0}){let l=n9(e=>e.open),c=n9(e=>e.setOpen),d=n9(e=>e.query),u=n9(e=>e.setQuery),p=n9(e=>e.results),h=n9(e=>e.loading),x=n9(e=>e.truncated),f=n9(e=>e.search),{resolvedTheme:g,setTheme:b}=(0,tH.useTheme)(),w=(0,a9.useAIPanelStore)(e=>e.toggle),y=(0,n6.useViewWidthStore)(e=>e.width),v=(0,n6.useViewWidthStore)(e=>e.cycle),N=d.trimStart(),j=""===N||N.startsWith(">"),k=""===N&&a.length>0,_=j?"":d;function C(e){e(),c(!1),u("")}(0,W.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()&&(e.preventDefault(),c(!l))}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,c]),(0,W.useEffect)(()=>{if(!l||j)return;let e=setTimeout(()=>{f(_)},120);return()=>clearTimeout(e)},[_,j,l,f]);let E=(n6.VIEW_WIDTH_ORDER.indexOf(y)+1)%n6.VIEW_WIDTH_ORDER.length,M=n6.VIEW_WIDTH_LABEL[n6.VIEW_WIDTH_ORDER[E]];return(0,t.jsxs)(nJ,{open:l,onOpenChange:e=>{c(e),e||u("")},shouldFilter:!1,children:[(0,t.jsx)(nQ,{placeholder:"Search files… ( > for actions )",value:d,onValueChange:u}),(0,t.jsxs)(nY,{children:[k&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n1,{heading:"Recent",children:a.map(a=>(0,t.jsxs)(n5,{value:`recent:${a.path}`,onSelect:()=>{e(a.path),c(!1),u("")},children:[(0,t.jsx)(ar,{className:"mr-2 h-4 w-4"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.path})]})]},a.path))}),(0,t.jsx)(n2,{})]}),j&&(0,t.jsxs)(n1,{heading:"Actions",children:[(0,t.jsxs)(n5,{value:"toggle-dark-mode",onSelect:()=>C(()=>b("dark"===g?"light":"dark")),children:["dark"===g?(0,t.jsx)(B.Sun,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(S.Moon,{className:"mr-2 h-4 w-4"}),"dark"===g?"Switch to light mode":"Switch to dark mode"]}),(0,t.jsxs)(n5,{value:"toggle-ai-panel",onSelect:()=>C(w),children:[(0,t.jsx)(r,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,t.jsxs)(n5,{value:"toggle-sidebar",onSelect:()=>C(n),children:[(0,t.jsx)(nx.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,t.jsxs)(n5,{value:"new-file",onSelect:()=>C(s),children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,t.jsxs)(n5,{value:"copy-path",onSelect:()=>C(i),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,t.jsxs)(n5,{value:"cycle-view-width",onSelect:()=>C(v),children:[(0,t.jsx)(nh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,t.jsxs)("span",{children:["Change view width"," ",(0,t.jsxs)("span",{className:"text-muted-foreground",children:["(",n6.VIEW_WIDTH_LABEL[y]," → ",M,")"]})]})]})]}),!j&&(0,t.jsxs)(t.Fragment,{children:[h&&(0,t.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!h&&""!==_.trim()&&0===p.length&&(0,t.jsx)(n0,{children:"No matches."}),p.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n2,{}),(0,t.jsx)(n1,{heading:x?"Top results (refine query for more)":"Results",children:p.map(a=>(0,t.jsx)(n5,{value:a.path,onSelect:()=>{e(a.path),c(!1),u("")},children:(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,t.jsx)(n8,{html:a.snippet})})]})},a.path))})]})]})]})]})}function rt({onOpenFile:e}){let a=n9(e=>e.query),n=n9(e=>e.setQuery),r=n9(e=>e.results),s=n9(e=>e.loading),i=n9(e=>e.search),l=n9(e=>e.clear),[o,c]=(0,W.useState)(0),d=(0,W.useRef)(null);function u(t){let a=r[t];a&&(e(a.path),l())}return(0,W.useEffect)(()=>{c(0)},[r]),(0,W.useEffect)(()=>{let e=d.current?.querySelector(`[data-idx="${o}"]`);e?.scrollIntoView({block:"nearest"})},[o]),(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(nZ,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,t.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:a,onChange:e=>{n(e.target.value),i(e.target.value)},onKeyDown:e=>{"Escape"===e.key?l():0!==r.length&&("ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%r.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+r.length)%r.length)):"Enter"===e.key&&(e.preventDefault(),u(o)))}})]}),""!==a.trim()&&(0,t.jsxs)("div",{ref:d,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[s&&(0,t.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!s&&0===r.length&&(0,t.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),r.map((e,a)=>(0,t.jsxs)("button",{type:"button","data-idx":a,onClick:()=>u(a),onMouseEnter:()=>c(a),className:`block w-full px-2 py-1 text-left ${a===o?"bg-accent":"hover:bg-accent"}`,children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs",children:e.path}),e.snippet&&(0,t.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,t.jsx)(n8,{html:e.snippet})})]},e.path))]})]})}let ra="wiki-sidebar-width";function rn(e){return Number.isNaN(e)?288:Math.min(600,Math.max(200,Math.round(e)))}let rr=(0,t5.create)(e=>({width:function(){let e=localStorage.getItem(ra);if(e){let t=Number.parseInt(e,10);if(!Number.isNaN(t))return rn(t)}return 288}(),setWidth:t=>{let a=rn(t);localStorage.setItem(ra,String(a)),e({width:a})}}));var rs=e.i(246542),ri=e.i(50808);let rl="wiki-show-hidden",ro=(0,t5.create)((e,t)=>({showHidden:"1"===localStorage.getItem(rl),toggle:()=>{let a=!t().showHidden;a?localStorage.setItem(rl,"1"):localStorage.removeItem(rl),e({showHidden:a})}})),rc="wiki-humanize-names",rd=(0,t5.create)((e,t)=>({humanize:"1"===localStorage.getItem(rc),toggle:()=>{let a=!t().humanize;a?localStorage.setItem(rc,"1"):localStorage.removeItem(rc),e({humanize:a})}}));function ru(e){let t=e.lastIndexOf("."),a=t>0&&t<e.length-1,n=a?e.slice(0,t):e,r=a?e.slice(t):"",s=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(e=>/^[A-Z0-9]+$/.test(e)?e:e[0].toUpperCase()+e.slice(1));return s.length?s.join(" ")+r:e}let rm=(0,tb.default)(()=>e.A(810497).then(e=>e.PdfViewer),{loadableGenerated:{modules:[904378]},ssr:!1});function rp(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return"";let a=Math.floor(Math.max(0,Date.now()-t)/1e3);if(a<60)return"just now";let n=Math.floor(a/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}let rh=new Set(["image","media","pdf","fallback","app","node-app","html"]);function rx(e){return e.split(".").pop()?.toLowerCase()??""}function rf(e,t){if("node-app"===t)return"node-app";if("app"===t)return"app";if("dir"===t)return"fallback";let a=e.split("/").pop()??e;if(a.startsWith(".")&&-1===a.indexOf(".",1))return"source";let n=rx(e);return n?["md","markdown"].includes(n)?"editor":"txt"===n?"text":["csv","tsv"].includes(n)?"csv":"pdf"===n?"pdf":["mmd","mermaid"].includes(n)?"mermaid":"ipynb"===n?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(n)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(n)?"media":"docx"===n?"docx":["xlsx","xlsm"].includes(n)?"xlsx":"pptx"===n?"pptx":"html"===n?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(n),"source"):"source"}let rg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function rb(e){let t=rf(e,"file");return"editor"===t||"text"===t||rg.has(rx(e))}function rw(e){return["md","markdown"].includes(rx(e))}function ry(e){return"image"===rf(e,"file")}function rv(e){return"html"===rf(e,"file")}async function rN(e){let t=await (0,X.wsFetch)(`/api/wiki?dir=${encodeURIComponent(e)}`);return t.ok?(await t.json()).entries.map(t=>({name:t.name,path:e?`${e}/${t.name}`:t.name,type:t.type,size:t.size,modifiedAt:t.modifiedAt,expanded:!1,git:t.git})):[]}let rj=new Map,rk=new Map;async function r_(e){let t=rj.get(e);if(t)return rj.delete(e),t;let a=rk.get(e);if(a){let t=await a;return rj.delete(e),t}return null}function rC(e,t,a){return e.map(e=>e.path===t?a(e):e.children?{...e,children:rC(e.children,t,a)}:e)}let rE={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function rS({node:e,ctx:a,isPinned:n,activeWorkspaceId:r}){return(0,t.jsxs)(aX,{className:"w-48",children:[(0,t.jsxs)(aJ,{onSelect:()=>a.copyPath(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(aJ,{onSelect:()=>a.copyWikiLink(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.copyUrl(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(aJ,{onSelect:()=>a.copyRawContent(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.copyFormattedContent(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,t.jsx)(aQ,{}),"dir"===e.type&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(aJ,{onSelect:()=>{e.expanded||a.toggleFolder(e),a.setNewFileParent(e.path),a.setNewFileName(""),a.setFileCreateError(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.triggerUpload(e.path),children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,t.jsxs)(aJ,{onSelect:()=>{a.setNewFolderParent(e.path),a.setNewFolderName(""),a.setFolderError(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,t.jsx)(aQ,{})]}),(0,t.jsxs)(aJ,{onSelect:()=>a.handleDownload(e),children:[(0,t.jsx)(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.togglePin(e,r),children:[(0,t.jsx)(I,{className:(0,tf.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Unpin":"Pin to top"]}),(0,t.jsx)(aQ,{}),(0,t.jsxs)(aJ,{className:"text-destructive focus:text-destructive",onSelect:()=>{a.setDeletingPath(e.path),a.setDeletingIsDir("file"!==e.type)},children:[(0,t.jsx)(U.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function rM({name:e,type:a}){let n="h-3.5 w-3.5 shrink-0";return"dir"===a?(0,t.jsx)(h.Folder,{className:(0,tf.cn)(n,"text-warning")}):"app"===a?(0,t.jsx)(y.Globe,{className:(0,tf.cn)(n,"text-foreground/70")}):"node-app"===a?(0,t.jsx)($,{className:(0,tf.cn)(n,"text-emerald-500")}):rv(e)?(0,t.jsx)(y.Globe,{className:(0,tf.cn)(n,"text-foreground/60")}):ry(e)?(0,t.jsx)(j.Image,{className:(0,tf.cn)(n,"text-sunshine-700")}):rb(e)?(0,t.jsx)(p.FileText,{className:(0,tf.cn)(n,"text-foreground/70")}):(0,t.jsx)(u.File,{className:(0,tf.cn)(n,"text-foreground/60")})}let rA=(0,W.memo)(function({node:e,depth:a,ctx:n,isMobile:r,activeWorkspaceId:s,sidebarScrollRef:i,isActive:d,isDragOver:b,isPinned:w,isAgentActive:v,isPulling:N,branchOpen:C,branchPos:S,branches:M,branchLoading:A,checkingOut:D,onHoverEnter:T,onHoverLeave:O}){let R=rd(e=>e.humanize);return(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!r,onKeyDown:t=>{if("Enter"===t.key||" "===t.key)t.preventDefault(),"dir"===e.type?n.toggleFolder(e):"app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e);else if("ArrowDown"===t.key){t.preventDefault();let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n+1]?.focus()}else if("ArrowUp"===t.key){t.preventDefault();let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n-1]?.focus()}else if("ArrowRight"===t.key){if(t.preventDefault(),"dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded){let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n+1]?.focus()}else n.toggleFolder(e)}else if("ArrowLeft"===t.key){if(t.preventDefault(),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded)n.toggleFolder(e);else if(a>0){let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=t.currentTarget,r=a.indexOf(n),s=Number.parseInt(n.style.paddingLeft??"0",10);for(let e=r-1;e>=0;e--)if(Number.parseInt(a[e].style.paddingLeft??"0",10)<s){a[e].focus();break}}}},onDragStart:t=>n.handleDragStart(t,e),onDragOver:t=>"dir"===e.type?n.handleDragOver(t,e.path,"dir"):t.preventDefault(),onDragLeave:()=>n.setDragOverPath(null),onDrop:t=>"dir"===e.type?n.handleDropOnFolder(t,e.path):t.preventDefault(),onMouseEnter:()=>T(e),onMouseLeave:O,className:(0,tf.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",d?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",b&&"ring-2 ring-primary bg-primary-soft",e.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*a+8}px`,...rE},onClick:()=>{"dir"===e.type?n.toggleFolder(e):("app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e),r&&n.setSidebarCollapsed(!0))},children:["dir"===e.type||"app"===e.type||"node-app"===e.type?e.loading?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,t.jsx)(l.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:e.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===e.type?e.expanded?(0,t.jsx)(x,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-warning")}):(0,t.jsx)(h.Folder,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-warning")}):"app"===e.type?(0,t.jsx)(y.Globe,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/70")}):"node-app"===e.type?(0,t.jsx)($,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-emerald-500")}):rv(e.name)?(0,t.jsx)(y.Globe,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/60")}):ry(e.name)?(0,t.jsx)(j.Image,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-sunshine-700")}):rb(e.name)?(0,t.jsx)(p.FileText,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/70")}):(0,t.jsx)(u.File,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/60")})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",title:R?e.name:void 0,children:R?ru(e.name):e.name}),e.git&&(0,t.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,t.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:t=>{if(t.stopPropagation(),C){n.setBranchDropdownNode(null),n.setBranchDropdownPos(null);return}let a=t.currentTarget.getBoundingClientRect();n.setBranchDropdownPos({top:a.bottom+4,left:a.left}),n.setBranchDropdownNode(e.path),n.loadBranches(e.path)},children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"}),e.git.branch,e.git.dirty&&(0,t.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),N?(0,t.jsx)(_.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation();let a=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleGitPull(e.path,a)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,t.jsx)(F,{className:"h-2.5 w-2.5"})}),C&&S&&(0,t.jsx)(tW,{pos:S,branches:M,loading:A,busyName:D,disabled:null!==D,onPick:t=>{let a=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleCheckout(e.path,t,a)},onClose:()=>{n.setBranchDropdownNode(null),n.setBranchDropdownPos(null)}})]}),v&&(0,t.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,t.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyPath(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyWikiLink(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyUrl(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyRawContent(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyFormattedContent(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),"dir"===e.type&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:async()=>{e.expanded||n.toggleFolder(e),n.setNewFileParent(e.path),n.setNewFileName(""),n.setFileCreateError(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.triggerUpload(e.path),children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{n.setNewFolderParent(e.path),n.setNewFolderName(""),n.setFolderError(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{})]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.handleDownload(e),children:[(0,t.jsx)(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.togglePin(e,s),children:[(0,t.jsx)(I,{className:(0,tf.cn)("mr-2 h-3.5 w-3.5",w&&"fill-current text-amber-400")}),w?"Unpin":"Pin to top"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{n.setDeletingPath(e.path),n.setDeletingIsDir("file"!==e.type)},children:[(0,t.jsx)(U.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,t.jsx)(rS,{node:e,ctx:n,isPinned:w,activeWorkspaceId:s})]})}),rD=(0,W.memo)(function(e){let{ctx:a,openPath:n,dragOverPath:r,branchDropdownNode:i,branchDropdownPos:l,nodeBranches:o,branchesLoading:c,checkingOutBranch:d,pullingRepo:u,activePaths:m,pins:x,isMobile:f,activeWorkspaceId:g,newFileParent:b,newFileName:w,fileCreateError:y,newFolderParent:v,newFolderName:N,folderError:j,sidebarScrollRef:k}=e,_=ro(e=>e.showHidden),C=(0,W.useRef)(null),E=(0,W.useCallback)(e=>{let t=("dir"===e.type||"app"===e.type||"node-app"===e.type)&&!e.expanded&&void 0===e.children;("file"===e.type||t)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>a.prefetch(e),120))},[a]),S=(0,W.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),M=(0,W.useMemo)(()=>{let t=[],a=(e,n)=>{for(let r of e)!(!_&&r.name.startsWith("."))&&(t.push({kind:"row",node:r,depth:n}),"dir"===r.type&&(v===r.path&&t.push({kind:"newfolder",node:r,depth:n}),b===r.path&&t.push({kind:"newfile",node:r,depth:n})),("dir"===r.type||"app"===r.type||"node-app"===r.type)&&r.expanded&&(r.children&&r.children.length>0?a(r.children,n+1):r.children?.length===0&&t.push({kind:"empty",node:r,depth:n})))};return a(e.nodes,0),t},[e.nodes,b,v,_]);return(0,t.jsx)(t.Fragment,{children:M.map(e=>{let{node:b,depth:v}=e;if("row"===e.kind){let e=i===b.path;return(0,t.jsx)(rA,{node:b,depth:v,ctx:a,isMobile:f,activeWorkspaceId:g,sidebarScrollRef:k,isActive:n===b.path,isDragOver:r===b.path,isPinned:x.some(e=>e.path===b.path),isAgentActive:m.has(b.path),isPulling:u===b.path,branchOpen:e,branchPos:e?l:null,branches:b.git?o[b.path]??[]:[],branchLoading:!!b.git&&!!c[b.path],checkingOut:e?d:null,onHoverEnter:E,onHoverLeave:S},b.path)}return"newfolder"===e.kind?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...rE},children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)(h.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,t.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>a.setNewFolderName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&a.handleCreateFolder(),"Escape"===e.key&&(a.setNewFolderParent(null),a.setNewFolderName(""))}}),j&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:j}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:a.handleCreateFolder,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a.setNewFolderParent(null),a.setNewFolderName("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]},`nf-${b.path}`):"newfile"===e.kind?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...rE},children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,t.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:w,onChange:e=>a.setNewFileName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&a.handleCreateFile(),"Escape"===e.key&&(a.setNewFileParent(null),a.setNewFileName(""))}}),y&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:y}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:a.handleCreateFile,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a.setNewFileParent(null),a.setNewFileName("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]},`ff-${b.path}`):(0,t.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...rE},children:"Empty"},`empty-${b.path}`)})})});e.s(["default",0,function(){let e;(0,rs.useWikiSlugsStore)(e=>e.loadedAt),(0,W.useEffect)(()=>{rs.useWikiSlugsStore.getState().load()},[]);let[n,c]=(0,W.useState)(null),[x,$]=(0,W.useState)(null),[G,Z]=(0,W.useState)(()=>(0,X.getActiveWorkspaceId)()),[J,Q]=(0,W.useState)([]),[Y,en]=(0,W.useState)(!1),[er,eo]=(0,W.useState)(!1),[ed,eu]=(0,W.useState)(null),[em,ep]=(0,W.useState)(null),[eh,ex]=(0,W.useState)({}),[ef,eg]=(0,W.useState)(null),[eb,ew]=(0,W.useState)(null),[ey,ev]=(0,W.useState)(null),[eN,ej]=(0,W.useState)(null),ek=(0,W.useCallback)(async()=>{let e=(0,X.getEphemeralRoot)();if(e){Q([]),en(!1),c(!0),$(e),Z(`root:${e}`);return}try{let e=await fetch((0,tU.apiUrl)("/api/system/workspaces"));if(!e.ok)throw Error("Failed");let t=await e.json();if(Q(t.workspaces),en(t.isAdmin),t.workspaces.length>0){c(!0);let e=new URLSearchParams(window.location.search).get("ws"),a=e?t.workspaces.find(t=>t.id===e):null,n=a??[...t.workspaces].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];if(Z(n.id),$(n.rootDir),!a){let e=new URL(location.href);e.searchParams.set("ws",n.id),history.replaceState(null,"",e.toString())}}else c(!1)}catch{c(!1)}},[]);(0,W.useEffect)(()=>{ek()},[ek]);let e_=(0,ns.useEditorStore)(e=>e.currentPath),eC=a1(e=>e.recents),[eE,eS]=(0,W.useState)(!1),[eM,eA]=(0,W.useState)(!0),eD=a3(e=>e.pins),eT=(0,W.useRef)(null),eO=(0,a9.useAIPanelStore)(e=>e.activity),eI=(0,W.useMemo)(()=>{let e=new Date(Date.now()-6e4).toISOString(),t=new Set;for(let a of eO)a.at>=e&&a.path&&a.by?.startsWith("ai:")&&t.add(a.path);return t},[eO]);(0,W.useEffect)(()=>{let e=()=>{a9.useAIPanelStore.getState().loadActivity()};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[]),(0,W.useEffect)(()=>{a1.getState().loadForWorkspace(G),a3.getState().loadForWorkspace(G)},[G]),(0,W.useEffect)(()=>{let e=[...eD.map(e=>e.path),...eC.slice(0,8).map(e=>e.path)].filter((e,t,a)=>rw(e)&&a.indexOf(e)===t).slice(0,12);if(0===e.length)return;let t=("requestIdleCallback"in window?e=>window.requestIdleCallback(e):e=>window.setTimeout(e,400))(()=>{for(let t of e)(0,ns.prefetchPage)(t)});return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(t):clearTimeout(t)}},[eD,eC]);let eR=(0,W.useRef)(new URLSearchParams(window.location.search).get("path")??new URLSearchParams(window.location.search).get("file")),eF=(0,W.useRef)(!1),[eL,eP]=(0,W.useState)(!1),[eB,e$]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t="1"===e.get("embed");eP(t),e$(t&&"1"!==e.get("chrome"))},[]);let[ez,eU]=(0,W.useState)([]),[eq,eK]=(0,W.useState)(!1),[eW,eH]=(0,W.useState)(!1),eG=(0,W.useRef)(!1),[eV,eZ]=(0,W.useState)(!1),[eX,eJ]=(0,W.useState)(!1),[eQ,eY]=(0,W.useState)(null),e0=(0,W.useRef)(null),e1=(0,W.useRef)(""),[e2,e5]=(0,W.useState)(null),[e3,e4]=(0,W.useState)(""),[e9,e7]=(0,W.useState)(null),[e6,e8]=(0,W.useState)(null),[te,tt]=(0,W.useState)(""),[ta,tr]=(0,W.useState)(null),[ts,ti]=(0,W.useState)(null),[tl,to]=(0,W.useState)(!1),[tc,td]=(0,W.useState)(null),[tu,tp]=(0,W.useState)(null),[tb,tw]=(0,W.useState)(!1),[ty,tv]=(0,W.useState)(0),[tN,tj]=(0,W.useState)(0),tk=function(e="(max-width: 767px)"){let[t,a]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{let t=window.matchMedia(e),n=()=>a(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e]),t}(),[t_,tC]=(0,W.useState)(!1),tE=rr(e=>e.width),tS=ro(e=>e.showHidden),tM=rd(e=>e.humanize),{resolvedTheme:tD,setTheme:tO}=(0,tH.useTheme)(),tI=rr(e=>e.setWidth);(0,W.useEffect)(()=>{tk&&tC(!0)},[tk]);let[tF,tP]=(0,W.useState)(!1),[tB,t$]=(0,W.useState)(!1),[tz,tK]=(0,W.useState)(!1),[tG,tV]=(0,W.useState)(null),[tZ,tX]=(0,W.useState)(0),[tJ,tQ]=(0,W.useState)(!1),[tY,t0]=(0,W.useState)(!1),[t2,t5]=(0,W.useState)(""),[t3,t4]=(0,W.useState)(!1),[t9,t7]=(0,W.useState)(!1),[t6,t8]=(0,W.useState)(null),ae=(0,W.useRef)(null),[at,an]=(0,W.useState)(null),ar=(0,W.useRef)(null),as=(0,W.useRef)(!1),ai=(0,W.useRef)(async()=>{});(0,W.useEffect)(()=>{!G||eq||eG.current||(eG.current=!0,eH(!0),rN("").then(e=>{eU(e),eK(!0),eH(!1)}).catch(()=>{eG.current=!1,eH(!1)}))},[eq,G]);let al=(0,W.useCallback)(async e=>{let t=e.split("/");if(t.length<=1)return;let a=[],n="";for(let e=0;e<t.length-1;e++)n=n?`${n}/${t[e]}`:t[e],a.push({prefix:n,children:await rN(n)});eU(e=>{let t=e;for(let{prefix:e,children:n}of a)t=rC(t,e,e=>({...e,children:n,expanded:!0}));return t})},[]),ao=(0,W.useCallback)(async e=>{let t=await rN(e);""===e?eU(e=>{let a=new Map(e.map(e=>[e.path,e]));return t.map(e=>{let t=a.get(e.path);return t&&("dir"===t.type||"app"===t.type)?{...e,expanded:t.expanded,children:t.children}:e})}):eU(a=>rC(a,e,e=>({...e,children:t,expanded:!0})))},[]),[ac,ad]=(0,W.useState)(null),[au,am]=(0,W.useState)(null),[ap,ah]=(0,W.useState)(!1),[ax,af]=(0,W.useState)([]),[ag,ab]=(0,W.useState)(!1),[aw,ay]=(0,W.useState)(null),[av,aN]=(0,W.useState)(null),[aj,aC]=(0,W.useState)(!1),[aE,aS]=(0,W.useState)({}),[aM,aA]=(0,W.useState)({}),[aD,aT]=(0,W.useState)(null),[aO,aR]=(0,W.useState)(null),[aL,aP]=(0,W.useState)(null),aB=(0,W.useCallback)(async(e,t)=>{if(!ac){ad(e);try{let a=await (0,X.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:e})});if(!a.ok){let e=await a.json();(0,t1.showError)(e.message??e.error??"Pull failed");return}let n=await a.json();(0,t1.showSuccess)(`Pulled ${e} (${n.branch} @ ${n.sha.slice(0,7)})`),await ao(t)}catch{(0,t1.showError)("Pull failed")}finally{ad(null)}}},[ac,ao]);(0,W.useEffect)(()=>{ah(!1),af([]),ay(null),aN(null)},[tc?.path]);let a$=tc?.path;(0,W.useEffect)(()=>{if(!a$)return void am(null);let e=!1,t=setTimeout(()=>{(async()=>{try{let t=await (0,X.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(a$)}`);if(e)return;if(!t.ok)return void am(null);let a=await t.json();e||am(a.info)}catch{e||am(null)}})()},200);return()=>{e=!0,clearTimeout(t)}},[a$]);let az=(0,W.useCallback)(async()=>{if(!tc)return;let e=tc.path;ah(!0),ab(!0),af([]),ay(null),aN(null);try{let t=await (0,X.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(e)}`);if(!t.ok)return void(0,t1.showError)("Could not load history");let a=await t.json();tc.path===e&&af(a.commits)}catch{(0,t1.showError)("Could not load history")}finally{ab(!1)}},[tc]),aU=(0,W.useCallback)(async e=>{if(!tc)return;if(aw===e){ay(null),aN(null);return}let t=tc.path;ay(e),aC(!0),aN(null);try{let a=await (0,X.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(t)}&sha=${encodeURIComponent(e)}`);if(!a.ok)return void(0,t1.showError)("Could not load diff");let n=await a.json();tc.path===t&&aw===e&&aN(n.diff)}catch{(0,t1.showError)("Could not load diff")}finally{aC(!1)}},[tc,aw]),aq=(0,W.useCallback)(async e=>{if(aE[e]||aM[e])return;let t=!1;aA(t=>({...t,[e]:!0}));try{let a=await (0,X.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(e)}`);if(t)return;if(!a.ok)return void(0,t1.showError)("Could not load branches");let n=await a.json();t||aS(t=>({...t,[e]:n.branches}))}catch{t||(0,t1.showError)("Could not load branches")}finally{t||aA(t=>({...t,[e]:!1}))}return()=>{t=!0}},[aE,aM]),aK=(0,W.useCallback)(async(e,t,a)=>{if(!aD){aT(t);try{let n=await (0,X.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:e,branch:t})});if(409===n.status)return void(0,t1.showError)("Repository has uncommitted changes");if(!n.ok){let e=await n.json();(0,t1.showError)(e.error??"Checkout failed");return}let r=await n.json();(0,t1.showSuccess)(`Switched to ${r.branch}`),aS(t=>{let a={...t};return delete a[e],a}),aR(null),aP(null),await ao(a)}catch{(0,t1.showError)("Checkout failed")}finally{aT(null)}}},[aD,ao]),aW=(0,W.useCallback)(e=>{let t=[];for(let a of e)("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded&&a.children&&(t.push(a.path),t.push(...aW(a.children)));return t},[]),aH=(0,W.useRef)([]);(0,W.useEffect)(()=>{aH.current=aW(ez)},[ez,aW]);let aG=(0,W.useMemo)(()=>aW(ez).filter(e=>""!==e).slice(0,24).join("\n"),[ez,aW]),[aV,aZ]=(0,W.useState)("");(0,W.useEffect)(()=>{let e=setTimeout(()=>aZ(aG),300);return()=>clearTimeout(e)},[aG]);let aX=(0,W.useCallback)(async()=>{eZ(!0);try{let e=aW(ez),t=await rN("");for(let a of(eU(t),e)){let e=await rN(a);eU(t=>rC(t,a,t=>({...t,children:e,expanded:!0})))}}finally{eZ(!1)}},[ez,aW]),aJ=(0,W.useCallback)(async()=>{if(tc){if(rw(tc.name)){tQ(!0);try{await ns.useEditorStore.getState().loadPage(tc.path)}finally{tQ(!1)}return}if(["editor","text"].includes(rf(tc.name,tc.nodeType))||rb(tc.name)){tQ(!0);try{let e=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(tc.path)}`);if(e.ok){let t=await e.json();tV(t.content),tX(Number(e.headers.get("X-Wiki-Revision")??0))}}catch{}tQ(!1)}}},[tc]),aQ=(0,W.useCallback)(()=>{tj(e=>e+1),aJ()},[aJ]);async function aY(e){if("dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded)eU(t=>rC(t,e.path,e=>({...e,expanded:!1})));else if(void 0===e.children){let t=await r_(e.path);if(t)return void eU(a=>rC(a,e.path,e=>({...e,loading:!1,children:t,expanded:!0})));eU(t=>rC(t,e.path,e=>({...e,loading:!0})));let a=await rN(e.path);eU(t=>rC(t,e.path,e=>({...e,loading:!1,children:a,expanded:!0})))}else eU(t=>rC(t,e.path,e=>({...e,expanded:!0})))}async function a0(e){if("file"===e.type&&a1.getState().push({path:e.path,name:e.name},G),td({path:e.path,name:e.name,size:e.size,nodeType:"app"===e.type?"app":"node-app"===e.type?"node-app":"file"}),t0(!1),t4(!1),t8(null),tV(null),tX(0),"file"===e.type&&rw(e.name)){tQ(!0);try{await ns.useEditorStore.getState().loadPage(e.path)}finally{tQ(!1)}return}if(["editor","text"].includes(rf(e.name,e.type))||rb(e.name)){tQ(!0);try{let t=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e.path)}`);if(t.ok){let e=await t.json();tV(e.content),tX(Number(t.headers.get("X-Wiki-Revision")??0))}}catch{}tQ(!1)}}(0,W.useEffect)(()=>{tc&&rw(tc.name)&&ns.useEditorStore.getState().currentPath!==tc.path&&ns.useEditorStore.getState().loadPage(tc.path)},[tc]),(0,W.useEffect)(()=>{ar.current=tc},[tc]),(0,W.useEffect)(()=>{as.current=tY},[tY]),(0,W.useEffect)(()=>{ai.current=aJ},[aJ]),(0,W.useEffect)(()=>{if(!n||(0,tU.isLite)()||!G)return;let e=new Map;function t(t){e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),ao(t)},300))}let a=(aV?aV.split("\n"):[]).map(e=>`dir=${encodeURIComponent(e)}`).join("&"),r=new EventSource((0,X.withWs)(a?`/api/wiki/watch?${a}`:"/api/wiki/watch"));return r.onmessage=a=>{let n;try{n=JSON.parse(a.data)}catch{return}let{type:r,path:s}=n;if("rescan"===r){for(let e of(ri.useBacklinksStore.getState().invalidateAll(),t(""),aH.current))t(e);return}("add"===r||"change"===r||"unlink"===r)&&ri.useBacklinksStore.getState().invalidateAll();let i=s.split("/");if(t(i.length>1?i.slice(0,-1).join("/"):""),"change"===r&&ar.current?.path===s&&!as.current){let t=`__file__${s}`;e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),ai.current()},400))}},()=>{for(let t of(r.close(),e.values()))clearTimeout(t)}},[n,ao,G,aV]),(0,W.useEffect)(()=>{tw(!1)},[]);let a2=(0,W.useCallback)(e=>{let t=e.split("/").pop()??e;al(e),a0({path:e,name:t,type:"file"})},[al]),a5=(0,W.useCallback)(async e=>{let t=e.path.split("/").slice(0,-1).join("/"),a=(await rN(t)).find(t=>t.path===e.path);if(a){if("dir"===a.type){await al(e.path),await aY(a);return}if("app"===a.type||"node-app"===a.type){await al(a.path),a0({path:a.path,name:a.name,type:a.type,modifiedAt:a.modifiedAt}),await aY(a),tk&&tC(!0);return}a0({path:a.path,name:a.name,type:a.type,modifiedAt:a.modifiedAt}),tk&&tC(!0)}},[tk,a0,al,aY]);(0,W.useEffect)(()=>{if(!e_||tc&&tc.path===e_)return;let e=e_.split("/").pop()??e_;a0({path:e_,name:e,type:"file"})},[e_]);let a4=(0,W.useCallback)(async e=>{if(!e)return void td(null);let t=(0,X.toRootRelative)(e,(0,X.getEphemeralRoot)()??x);if(null===t||!(e=t))return;let a=e.split("/"),n=a[a.length-1],r=a.slice(0,-1).join("/"),s=(await rN(r)).find(t=>t.path===e);s&&(await al(e),a0({path:e,name:n,type:s.type,modifiedAt:s.modifiedAt}))},[al,x]);(0,W.useEffect)(()=>{let e=new URL(window.location.href);tc?e.searchParams.set("path",tc.path):e.searchParams.delete("path");let t=e.toString();t!==window.location.href&&window.history.pushState(null,"",t)},[tc]),(0,W.useEffect)(()=>{let e=()=>{a4(new URLSearchParams(window.location.search).get("path"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[a4]),(0,W.useEffect)(()=>{if(!eL)return;let e=e=>{e.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${e.origin}.`):e.data&&"open-file"===e.data.type&&"string"==typeof e.data.path&&a4(e.data.path)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[a4,eL]),(0,W.useEffect)(()=>{eF.current||eq&&(eF.current=!0,a4(eR.current))},[eq,a4]);let a7=(0,W.useCallback)(async e=>{if(e===G)return;try{await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/open`),{method:"POST"})}catch{}let t=new URL(location.href);t.searchParams.set("ws",e),t.searchParams.delete("path"),history.pushState(null,"",t.toString()),td(null),tV(null),t0(!1),eU([]),eK(!1),eG.current=!1,rs.useWikiSlugsStore.getState().invalidate(),ri.useBacklinksStore.getState().invalidateAll();let a=J.find(t=>t.id===e);a&&$(a.rootDir),Z(e)},[G,J]),a6=(0,W.useCallback)(async()=>{if(ed)try{if(!(await fetch((0,tU.apiUrl)(`/api/system/workspaces/${ed}`),{method:"DELETE"})).ok)throw Error("Failed");if(ed===G){let e=J.filter(e=>e.id!==ed);if(e.length>0){let t=[...e].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];await a7(t.id)}else c(!1)}await ek()}catch{}finally{eu(null)}},[ed,G,J,a7,ek]),a8=(0,W.useCallback)(async e=>{if(!em){ep(e);try{let t=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/refresh`),{method:"POST"});if(!t.ok){let e=await t.json();(0,t1.showError)(e.error??"Refresh failed")}await ek()}catch{(0,t1.showError)("Refresh failed")}finally{ep(null)}}},[em,ek]),ne=(0,W.useCallback)(async e=>{if(!eh[e])try{let t=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/branch`));if(!t.ok)return;let a=await t.json();ex(t=>({...t,[e]:a.branches??[]}))}catch{}},[eh]),nt=(0,W.useCallback)(async(e,t)=>{if(!ef){eg(e),ew(t);try{let a=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!a.ok){let e=await a.json();(0,t1.showError)(e.error??"Branch switch failed");return}(0,t1.showSuccess)(`Switched to ${t}`),ev(null),ej(null),await ek()}catch{(0,t1.showError)("Branch switch failed")}finally{eg(null),ew(null)}}},[ef,ek]);async function na(){if(!tc)return;t7(!0),t8(null);let e=await (0,X.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:tc.path,content:t2,baseRevision:tZ})});if(e.ok){let t=await e.json();"number"==typeof t.revision&&tX(t.revision),tV(t2),t0(!1)}else t8((await e.json()).error??"Save failed");t7(!1)}let nn=(0,W.useCallback)(async(e,t)=>{let a=Array.from(e);if(a.length){eJ(!0),eY(null);try{for(let e of a){let a=new FormData;a.append("file",e),a.append("dir",t);let n=await (0,X.wsFetch)("/api/wiki/upload",{method:"POST",body:a});if(!n.ok){let e=await n.json();eY(e.error??"Upload failed"),(0,t1.showError)(e.error??"Upload failed");break}}await ao(t)}catch{eY("Upload failed.")}finally{eJ(!1),e0.current&&(e0.current.value="")}}},[ao]);function nr(e){e1.current=e,e0.current?.click()}async function ni(){let e=e3.trim();if(!e||null===e2)return;e7(null);let t=e2?`${e2}/${e}`:e,a=await (0,X.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});a.ok?(e5(null),e4(""),await ao(e2),""!==e2&&eU(e=>rC(e,e2,e=>({...e,expanded:!0})))):e7((await a.json()).error??"Failed")}async function nl(){let e=te.trim();if(!e||null===e6)return;tr(null);let t=e.includes(".")?e:`${e}.md`,a=e6?`${e6}/${t}`:t,n=await (0,X.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})});n.ok?(e8(null),tt(""),await ao(e6),""!==e6&&eU(e=>rC(e,e6,e=>({...e,expanded:!0}))),a0({path:a,name:t,type:"file",modifiedAt:new Date().toISOString()})):tr((await n.json()).error??"Failed")}function no(e){navigator.clipboard.writeText(e),(0,t1.showSuccess)("Path copied")}function nc(e){let t=e.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${t}]]`),(0,t1.showSuccess)("Wiki link copied")}function nd(e){let t=new URL(location.href);t.searchParams.set("path",e),G&&t.searchParams.set("ws",G),navigator.clipboard.writeText(t.toString()),(0,t1.showSuccess)("URL copied")}async function nu(e){if(tc?.path===e&&null!==tG)return tG;if(ns.useEditorStore.getState().currentPath===e)return ns.useEditorStore.getState().content;let t=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`);if(!t.ok)throw Error("Cannot copy content");return(await t.json()).content}async function nm(e){try{let t=await nu(e);await navigator.clipboard.writeText(t),(0,t1.showSuccess)("Raw content copied")}catch{(0,t1.showError)("Could not copy file content")}}async function nh(e,t){try{let a=await nu(e);if(!rw(t)){await navigator.clipboard.writeText(a),(0,t1.showSuccess)("Content copied");return}let n=await (0,tn.markdownToHtml)(a,{pagePath:e,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([n],{type:"text/html"}),"text/plain":new Blob([a],{type:"text/plain"})})]):await navigator.clipboard.writeText(a),(0,t1.showSuccess)("Formatted content copied")}catch{(0,t1.showError)("Could not copy formatted content")}}function nx(e,a){return(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>no(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nc(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nd(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void nm(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void nh(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),a&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),a]})]})]})}async function nf(){ts&&(await (0,X.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ts})}),(tc?.path===ts||tc?.path.startsWith(`${ts}/`))&&(td(null),tV(null)),eU(e=>(function e(t,a){return t.filter(e=>e.path!==a).map(t=>t.children?{...t,children:e(t.children,a)}:t)})(e,ts)),ti(null))}function ng(e,t,a){e.preventDefault(),e.stopPropagation();let n=ae.current;if(!n){Array.from(e.dataTransfer.types).includes("Files")&&(e.dataTransfer.dropEffect="copy",an("root"===a?"":t));return}n.path===t||t.startsWith(`${n.path}/`)||(e.dataTransfer.dropEffect="move",an("root"===a?"":t))}async function nb(e,t){e.preventDefault(),e.stopPropagation(),an(null);let a=ae.current;if(ae.current=null,!a){e.dataTransfer.files.length>0&&await nn(e.dataTransfer.files,t);return}if(a.path===t||t.startsWith(`${a.path}/`))return;let n=t?`${t}/${a.name}`:a.name;if(n!==a.path&&(await (0,X.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a.path,to:n})})).ok){let e=a.path.includes("/")?a.path.split("/").slice(0,-1).join("/"):"";await ao(e),t!==e&&await ao(t),tc?.path===a.path&&td({path:n,name:a.name,nodeType:tc.nodeType,size:tc.size})}}let nw=tc?rf(tc.name,tc.nodeType):null,ny=!!tc&&null!==nw&&!rh.has(nw)&&(tc.size??0)>5242880&&tu!==tc.path,nv=(0,n6.useViewWidthStore)(e=>e.width),nN=(0,n6.useViewWidthStore)(e=>e.align),nj=(0,n6.useViewWidthStore)(e=>e.setWidth),nk=(0,n6.useViewWidthStore)(e=>e.setAlign),n_=null===nw||"editor"===nw||"text"===nw||"source"===nw||"notebook"===nw||"fallback"===nw,nC=n_?n6.VIEW_WIDTH_CLASS[nv]:"",nE=n_?n6.VIEW_ALIGN_CLASS[nN]:"",nS=(0,W.useRef)(null);nS.current={toggleFolder:e=>void aY(e),openViewer:e=>void a0(e),copyPath:no,copyWikiLink:nc,copyUrl:nd,copyRawContent:e=>void nm(e),copyFormattedContent:(e,t)=>void nh(e,t),handleDownload:function(e){let t=(0,X.withWs)(`/api/wiki/download?path=${encodeURIComponent(e.path)}`),a=document.createElement("a");a.href=t,a.download="file"===e.type?e.name:`${e.name}.zip`,document.body.appendChild(a),a.click(),a.remove()},triggerUpload:nr,handleCreateFile:()=>void nl(),handleCreateFolder:()=>void ni(),handleDragStart:function(e,t){ae.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.path)},handleDragOver:ng,handleDropOnFolder:(e,t)=>void nb(e,t),handleGitPull:(e,t)=>void aB(e,t),handleCheckout:(e,t,a)=>void aK(e,t,a),loadBranches:e=>void aq(e),prefetch:e=>{"file"===e.type?rw(e.name)&&(0,ns.prefetchPage)(e.path):function(e){if(rj.has(e)||rk.has(e))return;let t=rN(e).then(t=>(rj.set(e,t),t)).finally(()=>rk.delete(e));rk.set(e,t),t.catch(()=>{})}(e.path)},togglePin:(e,t)=>a3.getState().toggle({path:e.path,name:e.name,type:e.type},t),setDragOverPath:an,setSidebarCollapsed:tC,setBranchDropdownNode:aR,setBranchDropdownPos:aP,setNewFileParent:e8,setNewFileName:tt,setFileCreateError:tr,setNewFolderParent:e5,setNewFolderName:e4,setFolderError:e7,setDeletingPath:ti,setDeletingIsDir:to};let nM=(0,W.useMemo)(()=>({toggleFolder:e=>nS.current.toggleFolder(e),openViewer:e=>nS.current.openViewer(e),copyPath:e=>nS.current.copyPath(e),copyWikiLink:e=>nS.current.copyWikiLink(e),copyUrl:e=>nS.current.copyUrl(e),copyRawContent:e=>nS.current.copyRawContent(e),copyFormattedContent:(e,t)=>nS.current.copyFormattedContent(e,t),handleDownload:e=>nS.current.handleDownload(e),triggerUpload:e=>nS.current.triggerUpload(e),handleCreateFile:()=>nS.current.handleCreateFile(),handleCreateFolder:()=>nS.current.handleCreateFolder(),handleDragStart:(e,t)=>nS.current.handleDragStart(e,t),handleDragOver:(e,t,a)=>nS.current.handleDragOver(e,t,a),handleDropOnFolder:(e,t)=>nS.current.handleDropOnFolder(e,t),handleGitPull:(e,t)=>nS.current.handleGitPull(e,t),handleCheckout:(e,t,a)=>nS.current.handleCheckout(e,t,a),loadBranches:e=>nS.current.loadBranches(e),prefetch:e=>nS.current.prefetch(e),togglePin:(e,t)=>nS.current.togglePin(e,t),setDragOverPath:e=>nS.current.setDragOverPath(e),setSidebarCollapsed:e=>nS.current.setSidebarCollapsed(e),setBranchDropdownNode:e=>nS.current.setBranchDropdownNode(e),setBranchDropdownPos:e=>nS.current.setBranchDropdownPos(e),setNewFileParent:e=>nS.current.setNewFileParent(e),setNewFileName:e=>nS.current.setNewFileName(e),setFileCreateError:e=>nS.current.setFileCreateError(e),setNewFolderParent:e=>nS.current.setNewFolderParent(e),setNewFolderName:e=>nS.current.setNewFolderName(e),setFolderError:e=>nS.current.setFolderError(e),setDeletingPath:e=>nS.current.setDeletingPath(e),setDeletingIsDir:e=>nS.current.setDeletingIsDir(e)}),[]);return(0,t.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===n&&(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===n&&(0,t.jsx)(tq,{onSelect:e=>{let t=new URL(location.href);t.searchParams.set("ws",e),t.searchParams.delete("path"),history.replaceState(null,"",t.toString()),eK(!1),eG.current=!1,Z(e),c(!0),ek()}}),!0===n&&er&&(0,t.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>eo(!1),children:[(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,t.jsx)(tq,{onSelect:e=>{eo(!1),ek(),a7(e)}})]}),!0===n&&!er&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(re,{onOpenFile:a2,recents:eC,onToggleSidebar:()=>tC(e=>{let t=!e;return tk&&!1===t&&a9.useAIPanelStore.getState().close(),t}),onNewFile:()=>e8(""),onCopyPath:()=>{tc&&navigator.clipboard.writeText(tc.path)}}),!eB&&!t_&&tk&&(0,t.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>tC(!0),"aria-hidden":!0}),!eB&&!t_&&(0,t.jsxs)(a_.Card,{style:tk?void 0:{width:tE},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.8.1",children:[(0,t.jsx)("img",{src:(0,tU.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,t.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>tC(!0),children:(0,t.jsx)(M,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:eX,children:[eX?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(R,{className:"h-3.5 w-3.5"}),"New",(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{e8(""),tt(""),tr(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{e5(""),e4(""),e7(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nr(""),disabled:eX,children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:aX,disabled:eV,children:eV?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{a9.useAIPanelStore.getState().toggle(),tk&&tC(!0)},children:(0,t.jsx)(r,{className:"h-3.5 w-3.5"})}),(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-48",children:[Y&&J.find(e=>e.id===G)?.git&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{G&&a8(G)},disabled:em===G,children:[em===G?(0,t.jsx)(_.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(d,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>ro.getState().toggle(),children:[tS?(0,t.jsx)(O,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(T.Eye,{className:"mr-2 h-3.5 w-3.5"}),tS?"Hide hidden files":"Show hidden files"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>rd.getState().toggle(),children:[(0,t.jsx)(z.Type,{className:"mr-2 h-3.5 w-3.5"}),tM?"Raw file names":"Humanize names"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tO("dark"===tD?"light":"dark"),children:["dark"===tD?(0,t.jsx)(B.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(S.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===tD?"Light mode":"Dark mode"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>t$(!0),children:[(0,t.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),eQ&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,t.jsx)(a.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),eQ]}),""===e2&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,t.jsx)(h.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,t.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:e3,onChange:e=>e4(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ni(),"Escape"===e.key&&(e5(null),e4(""))}}),e9&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:e9}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:ni,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{e5(null),e4("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]}),""===e6&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,t.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:te,onChange:e=>tt(e.target.value),onKeyDown:e=>{"Enter"===e.key&&nl(),"Escape"===e.key&&(e8(null),tt(""))}}),ta&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:ta}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:nl,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{e8(null),tt("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]}),(0,t.jsx)("div",{className:"border-b",children:(0,t.jsx)(rt,{onOpenFile:a2})}),(0,t.jsxs)("div",{ref:eT,className:(0,tf.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===at&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:e=>ng(e,"","root"),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||an(null)},onDrop:e=>nb(e,""),children:[eD.length>0&&(0,t.jsxs)("div",{className:"border-b mb-1",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>eS(e=>!e),children:[eE?(0,t.jsx)(l.ChevronRight,{className:"h-3 w-3"}):(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3"}),(0,t.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,t.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:eD.length})]}),!eE&&eD.map(e=>(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"button",tabIndex:0,className:(0,tf.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",tc?.path===e.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{a5(e)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a5(e))},children:[(0,t.jsx)(rM,{name:e.name,type:e.type??"file"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:tM?e.name:void 0,children:tM?ru(e.name):e.name}),(0,t.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:e.path.split("/").slice(0,-1).join("/")}),(0,t.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:t=>{t.stopPropagation(),a3.getState().toggle({path:e.path,name:e.name},G)},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]})}),(0,t.jsx)(rS,{node:{path:e.path,name:e.name,type:e.type??"file"},ctx:nM,isPinned:!0,activeWorkspaceId:G})]},e.path))]}),eC.length>0&&(0,t.jsxs)("div",{className:"border-b mb-1",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>eA(e=>!e),children:[eM?(0,t.jsx)(l.ChevronRight,{className:"h-3 w-3"}):(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3"}),(0,t.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,t.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:eC.length})]}),!eM&&eC.slice(0,8).map(e=>(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"button",tabIndex:0,className:(0,tf.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",tc?.path===e.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{a0({path:e.path,name:e.name,type:e.type??"file",modifiedAt:""}),tk&&tC(!0)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a0({path:e.path,name:e.name,type:e.type??"file",modifiedAt:""}))},children:[(0,t.jsx)(rM,{name:e.name,type:e.type??"file"}),(0,t.jsx)("span",{className:"flex-1 truncate text-xs",title:tM?e.name:void 0,children:tM?ru(e.name):e.name}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:e.path.split("/").slice(0,-1).join("/")})]})}),(0,t.jsx)(rS,{node:{path:e.path,name:e.name,type:e.type??"file"},ctx:nM,isPinned:eD.some(t=>t.path===e.path),activeWorkspaceId:G})]},e.path))]}),eW?(0,t.jsx)("div",{className:"flex justify-center py-6",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===ez.length?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,t.jsx)(p.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,t.jsxs)(H.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>nr(""),disabled:eX,children:[eX?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(q.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,t.jsx)(rD,{ctx:nM,nodes:ez,openPath:tc?.path??null,dragOverPath:at,branchDropdownNode:aO,branchDropdownPos:aL,nodeBranches:aE,branchesLoading:aM,checkingOutBranch:aD,pullingRepo:ac,activePaths:eI,pins:eD,isMobile:tk,activeWorkspaceId:G,newFileParent:e6,newFileName:te,fileCreateError:ta,newFolderParent:e2,newFolderName:e3,folderError:e9,sidebarScrollRef:eT})]}),(0,t.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,t.jsxs)(tR.DropdownMenu,{modal:!1,onOpenChange:e=>{e||(ev(null),ej(null))},children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:x??"",children:[(0,t.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,t.jsx)("span",{className:"truncate text-xs font-medium",children:J.find(e=>e.id===G)?.name??"Workspace"}),(0,t.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:x??""})]}),(0,t.jsx)(i.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:e=>{e.target?.closest?.("[data-branch-portal]")&&e.preventDefault()},children:[J.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void a7(e.id),onPointerMove:e=>e.preventDefault(),onPointerLeave:e=>e.preventDefault(),className:(0,tf.cn)("gap-2",e.id===G&&"font-medium"),children:[e.id===G?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,t.jsx)("span",{className:"truncate",children:e.name}),e.git?Y?(0,t.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ef===e.id,onClick:t=>{if(t.stopPropagation(),t.preventDefault(),ey===e.id){ev(null),ej(null);return}let a=t.currentTarget.getBoundingClientRect();ej({top:a.bottom+4,left:a.left}),ev(e.id),ne(e.id)},children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," ",e.git.branch??"branch"]}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," ",e.git.branch??"read-only"]}):e.ssh?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(b,{className:"h-2.5 w-2.5"})," ",e.ssh.host]}):e.readOnly?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,t.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:e.rootDir}),e.git?.lastPulledAt&&rp(e.git.lastPulledAt)&&(0,t.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",rp(e.git.lastPulledAt)]})]}),Y&&e.git&&(0,t.jsx)("button",{className:(0,tf.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",e.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:e.git.lastError?`Last refresh failed: ${e.git.lastError}`:"Refresh",disabled:em===e.id,onClick:t=>{t.stopPropagation(),t.preventDefault(),a8(e.id)},children:(0,t.jsx)(F,{className:(0,tf.cn)("h-3.5 w-3.5",em===e.id&&"animate-spin")})}),Y&&(0,t.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:t=>{t.stopPropagation(),eu(e.id)},children:(0,t.jsx)(U.Trash2,{className:"h-3.5 w-3.5"})})]},e.id)),Y&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>eo(!0),children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!ey||!eN)return null;let e=J.find(e=>e.id===ey);return e?(0,t.jsx)(tW,{pos:eN,branches:(eh[e.id]??[]).map(t=>({name:t,current:t===e.git?.branch})),loading:!eh[e.id],busyName:ef===e.id?eb:null,disabled:ef===e.id,onPick:t=>{nt(e.id,t)},onClose:()=>{ev(null),ej(null)}}):null})()]}),(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:e=>{e.preventDefault();let t=e.clientX;tP(!0);let a=document.body.style.cursor,n=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let r=e=>{tI(tE+(e.clientX-t))},s=()=>{tP(!1),document.body.style.cursor=a,document.body.style.userSelect=n,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},onDoubleClick:()=>tI(288),onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),tI(tE-16)):"ArrowRight"===e.key&&(e.preventDefault(),tI(tE+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":tE,className:(0,tf.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",tF&&"bg-primary/60")})]}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!eB&&t_&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>tC(!1),children:(0,t.jsx)(A,{className:"h-3.5 w-3.5"})}),!eB&&(0,t.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{tC(!1),a9.useAIPanelStore.getState().close()},children:(0,t.jsx)(A,{className:"h-4 w-4"})}),(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:tc?.path,children:[tc&&(0,t.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===nw||"html"===nw?(0,t.jsx)(y.Globe,{className:"h-4 w-4 text-foreground/70"}):ry(tc.name)?(0,t.jsx)(j.Image,{className:"h-4 w-4 text-sunshine-700"}):rb(tc.name)?(0,t.jsx)(p.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,t.jsx)(u.File,{className:"h-4 w-4 text-foreground/60"})}),(0,t.jsx)("span",{className:"truncate",children:tc?tc.name:"Wiki Viewer"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{a9.useAIPanelStore.getState().open(),tC(!0)},children:(0,t.jsx)(r,{className:"h-4 w-4"})})]}),tc?"node-app"===nw?(0,t.jsx)(tL,{path:tc.path,title:tc.name}):"app"===nw||"html"===nw?(e="html"===nw?(0,X.withWs)(`/api/assets/${tc.path}`):void 0,tb?(0,t.jsx)(tT,{path:tc.path,title:tc.name,src:e,fullscreen:!0,onExit:()=>tw(!1)}):(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,t.jsxs)("div",{className:(0,tf.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!tk&&t_&&"pl-11"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"hidden md:inline-flex",children:(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:(0,t.jsx)(y.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,t.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:tc.path,children:tc.path})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[nx(tc,(0,t.jsxs)(t.Fragment,{children:["html"===nw&&!tY&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>t4(e=>!e),children:[t3?(0,t.jsx)(y.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(w.Code2,{className:"mr-2 h-3.5 w-3.5"}),t3?"Show preview":"Show source"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tv(e=>e+1),children:[(0,t.jsx)(F,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tw(!0),children:[(0,t.jsx)(C,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tK(!0),children:[(0,t.jsx)(P,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===nw&&!tY&&null!==tG&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{t0(!0),t5(tG),t8(null)},children:(0,t.jsx)(D,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{td(null),t0(!1)},children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]})]}),tY&&"html"===nw?(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,t.jsx)("textarea",{value:t2,onChange:e=>t5(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,t.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[t6&&(0,t.jsx)("span",{className:"text-xs text-destructive mr-auto",children:t6}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",onClick:()=>{t0(!1),t8(null)},children:"Cancel"}),(0,t.jsxs)(H.Button,{size:"sm",className:"gap-1",onClick:na,disabled:t9,children:[t9&&(0,t.jsx)(_.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):t3&&"html"===nw?(0,t.jsx)(tA,{path:tc.path,title:tc.name}):(0,t.jsx)(tT,{path:tc.path,title:tc.name,src:e},ty)]})):(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,t.jsxs)("div",{className:(0,tf.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!tk&&t_&&"pl-11"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"hidden md:inline-flex",children:(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:ry(tc.name)?(0,t.jsx)(j.Image,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):rb(tc.name)?(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,t.jsx)(u.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,t.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:tc.path,children:tc.path}),au&&(0,t.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,t.jsx)(N,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-[100px]",children:au.author}),(0,t.jsx)("span",{title:new Date(au.date).toLocaleString(),className:"shrink-0",children:rp(au.date)})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[nx(tc,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{ap?ah(!1):az()},children:[(0,t.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ap?"Hide history":"File history"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tK(!0),children:[(0,t.jsx)(P,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!tY&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:aQ,disabled:tJ,children:[tJ?(0,t.jsx)(_.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(F,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),n_&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsx)(tR.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),n6.VIEW_WIDTH_ORDER.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nj(e),className:"flex items-center justify-between text-xs",children:[n6.VIEW_WIDTH_LABEL[e],e===nv&&(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5"})]},e)),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsx)(tR.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),n6.VIEW_ALIGN_ORDER.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nk(e),className:"flex items-center justify-between text-xs",children:[n6.VIEW_ALIGN_LABEL[e],e===nN&&(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5"})]},e))]})]})),rb(tc.name)&&!tY&&(null!==tG||rw(tc.name))&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{t0(!0),t5(tG??""),t8(null),rw(tc.name)&&ns.useEditorStore.getState().loadPage(tc.path)},children:(0,t.jsx)(D,{className:"h-3.5 w-3.5"})}),rb(tc.name)&&tY&&rw(tc.name)&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{t0(!1),t8(null)},children:(0,t.jsx)(T.Eye,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{td(null),tV(null),t0(!1)},children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]})]}),ap&&(0,t.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,t.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>ah(!1),children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]}),ag?(0,t.jsx)("div",{className:"flex justify-center py-4",children:(0,t.jsx)(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ax.length?(0,t.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,t.jsx)("div",{children:ax.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{type:"button",className:(0,tf.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",aw===e.sha&&"bg-muted"),onClick:()=>void aU(e.sha),children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:e.shortSha}),(0,t.jsx)("span",{className:"flex-1 truncate text-xs",children:e.message}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e.author}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(e.date).toLocaleString(),children:rp(e.date)})]})}),aw===e.sha&&(0,t.jsx)("div",{className:"border-t",children:aj?(0,t.jsx)("div",{className:"flex justify-center py-3",children:(0,t.jsx)(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==av?(0,t.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:av}):null})]},e.sha))})]}),ny?(0,t.jsx)(es,{path:tc.path,size:tc.size??0,onOpen:()=>tp(tc.path)}):tY?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:rw(tc.name)?(0,t.jsx)(et.KBEditor,{}):(0,t.jsx)("textarea",{value:t2,onChange:e=>t5(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):rw(tc.name)?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,t.jsx)(et.KBEditor,{mode:"viewing"})}):"csv"===nw||"pdf"===nw||"mermaid"===nw||"notebook"===nw||"image"===nw||"media"===nw||"docx"===nw||"xlsx"===nw||"pptx"===nw||"source"===nw||"fallback"===nw?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===nw?(0,t.jsx)(ee,{path:tc.path,title:tc.name}):"pdf"===nw?(0,t.jsx)(rm,{path:tc.path,title:tc.name}):"mermaid"===nw?(0,t.jsx)(ec,{path:tc.path,title:tc.name}):"notebook"===nw?(0,t.jsx)(tm,{path:tc.path,title:tc.name}):"image"===nw?(0,t.jsx)(ei,{path:tc.path,title:tc.name}):"media"===nw?(0,t.jsx)(el,{path:tc.path,title:tc.name,type:["mp4","webm","mov","m4v"].includes(rx(tc.name))?"video":"audio"}):"docx"===nw?(0,t.jsx)(th,{path:tc.path,title:tc.name}):"xlsx"===nw?(0,t.jsx)(tg,{path:tc.path,title:tc.name}):"pptx"===nw?(0,t.jsx)(tx,{path:tc.path,title:tc.name}):"source"===nw?(0,t.jsx)(tA,{path:tc.path,title:tc.name}):(0,t.jsx)(ea,{path:tc.path,title:tc.name})},tN):(0,t.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,t.jsx)("div",{className:(0,tf.cn)("w-full",nE,nC),children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==tG?(0,t.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:tG}):rb(tc.name)?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),tY&&!rw(tc.name)&&(0,t.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[t6&&(0,t.jsx)("span",{className:"text-xs text-destructive mr-auto",children:t6}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",onClick:()=>{t0(!1),t8(null)},children:"Cancel"}),(0,t.jsxs)(H.Button,{size:"sm",className:"gap-1",onClick:na,disabled:t9,children:[t9&&(0,t.jsx)(_.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,t.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,t.jsx)(p.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,t.jsx)(ak,{open:tz,onOpenChange:tK,filePath:tc?.path??""}),!(0,tU.isLite)()&&(0,t.jsx)(aa,{open:tB,onOpenChange:t$}),(0,t.jsx)(np,{currentPath:tc?.path}),(0,t.jsx)("input",{ref:e0,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&nn(e.target.files,e1.current)}}),(0,t.jsx)(V,{open:!!ts,onOpenChange:e=>{e||ti(null)},title:tl?"Delete folder?":"Delete file?",description:tl?`"${ts?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${ts?.split("/").pop()}" will be permanently removed.`,onConfirm:nf}),(0,t.jsx)(V,{open:!!ed,onOpenChange:e=>{e||eu(null)},title:"Delete workspace?",description:`"${J.find(e=>e.id===ed)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:a6})]})]},G??"none")}],952683)}]);
17
+ ${t}/api/agent/files/${e??"<path/to/file.md>"}`;await navigator.clipboard.writeText(n),a(!0),setTimeout(()=>a(!1),1500)},[e])}}(e??null),[m,p]=(0,W.useState)(""),h=(0,W.useRef)(null),x=window.location.origin,f=(0,W.useCallback)(()=>nu,[]),g=(0,W.useCallback)(()=>m.replace(/\$WIKI_URL/g,x),[m,x]),b=(0,W.useCallback)(()=>`npx wiki-viewer-mcp register --url ${x} --id ai:myagent --name "My Agent"`,[x]),w=(0,W.useCallback)(()=>JSON.stringify({servers:{"wiki-viewer":{command:"npx",args:["wiki-viewer-mcp"],env:{WIKI_VIEWER_URL:x,WIKI_VIEWER_TOKEN:"<token from register>",WIKI_VIEWER_AGENT_ID:"ai:myagent"}}}},null,2),[x]),y=nm(f),v=nm(g),N=nm(b),j=nm(w);return((0,W.useEffect)(()=>{if(a)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e);function e(e){"Escape"===e.key&&n()}},[a,n]),(0,W.useEffect)(()=>{a&&h.current?.focus()},[a]),(0,W.useEffect)(()=>{if(!a)return;c();let e=setInterval(()=>void c(),1e4);return()=>clearInterval(e)},[a,c]),(0,W.useEffect)(()=>{a&&fetch((0,tU.apiUrl)("/api/agents/install")).then(e=>e.json()).then(e=>{e.bootstrapPrompt&&p(e.bootstrapPrompt)}).catch(()=>void 0)},[a]),a)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px]",onClick:n,"aria-hidden":!0}),(0,t.jsxs)("aside",{ref:h,tabIndex:-1,role:"dialog","aria-modal":"true","aria-label":"AI Agent Panel",className:"fixed right-0 top-0 bottom-0 z-50 flex w-[90vw] max-w-sm md:w-80 flex-col border-l border-border bg-background shadow-xl outline-none",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between border-b border-border px-4 py-3 shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(r,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("span",{className:"text-sm font-semibold",children:"AI Agent"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:n,title:"Close panel (Esc)",children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto space-y-5 px-4 py-4",children:[(0,t.jsxs)("section",{className:"rounded-md border border-border bg-muted/30 p-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Work with this wiki using AI"}),(0,t.jsxs)("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:["Connect Claude, Cursor, ChatGPT, and more. Pick by what you want — each option gives a copy-paste setup. You approve every assistant in ",(0,t.jsx)("span",{className:"font-medium text-foreground/80",children:"Agents"})," below before it gets access."]})]}),(0,t.jsxs)("section",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,t.jsx)("p",{className:"text-xs font-semibold text-foreground",children:"Co-write docs with you"}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Edits arrive as suggestions with comments you accept or revert. No MCP needed."}),(0,t.jsx)(H.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void v.copy(),disabled:!m,children:v.copied?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})," Paste into any chatbot"]})}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/50 pt-1",children:["Or install once so it sticks"," ",(0,t.jsx)("span",{className:"text-muted-foreground/40",children:"· Claude, OpenCode"}),":"]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:nu}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void y.copy(),children:y.copied?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})})]})]}),(0,t.jsxs)("div",{className:"rounded-md border border-border bg-muted/40 p-3 space-y-1.5",children:[(0,t.jsxs)("p",{className:"text-xs font-semibold text-foreground",children:["Edit files directly"," ",(0,t.jsx)("span",{className:"font-normal text-muted-foreground/60",children:"· Claude Code, Cursor, Codex"})]}),(0,t.jsx)("p",{className:"text-[10px] text-muted-foreground/70",children:"Native read / search / edit tools over MCP. Run to request access:"}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"flex-1 text-[10px] font-mono text-foreground/80 truncate bg-muted rounded px-1 py-0.5",children:b()}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 shrink-0",title:"Copy this command",onClick:()=>void N.copy(),children:N.copied?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("p",{className:"text-[10px] text-muted-foreground/50",children:["Approve in ",(0,t.jsx)("span",{className:"font-medium text-foreground/70",children:"Agents"}),", then add to your tool:"]}),(0,t.jsx)(H.Button,{size:"sm",variant:"outline",className:"h-7 w-full text-xs gap-1.5",onClick:()=>void j.copy(),children:j.copied?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 text-green-500"})," Copied!"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(o.Copy,{className:"h-3.5 w-3.5"})," Copy config (mcp.json)"]})})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/50",children:"For developers:"}),(0,t.jsxs)("button",{type:"button",onClick:()=>void u(),className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[d?(0,t.jsx)(s.Check,{className:"h-3 w-3 text-green-500"}):(0,t.jsx)(o.Copy,{className:"h-3 w-3"})," curl example"]}),(0,t.jsxs)("a",{href:(0,tU.apiUrl)("/api/agents/skill"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,t.jsx)(en.ExternalLink,{className:"h-3 w-3"})," skill"]}),(0,t.jsxs)("a",{href:(0,tU.apiUrl)("/api/agents/install"),target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-[10px] text-primary hover:underline",children:[(0,t.jsx)(en.ExternalLink,{className:"h-3 w-3"})," install JSON"]})]})]}),(0,t.jsx)(nr,{}),(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsxs)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:["Active Connections"," ",(0,t.jsx)("span",{className:"normal-case font-normal text-muted-foreground/50",children:"(last 5 min)"})]}),(0,t.jsx)("div",{className:"rounded-md border border-border bg-muted/40 p-3",children:0===l.length?(0,t.jsxs)("p",{className:"text-xs text-muted-foreground/60 flex items-center gap-1.5",children:[(0,t.jsx)(a4,{className:"h-3.5 w-3.5"}),"No recent activity"]}):(0,t.jsx)("ul",{className:"space-y-1.5",children:l.map(e=>(0,t.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,t.jsx)("span",{className:"font-mono text-foreground/80 truncate",children:e.by}),(0,t.jsxs)("span",{className:"text-muted-foreground shrink-0",children:[e.opCount," op",1!==e.opCount?"s":""]})]},e.by))})})]}),(0,t.jsxs)("section",{className:"space-y-2",children:[(0,t.jsx)("h3",{className:"text-xs font-semibold uppercase tracking-widest text-muted-foreground",children:"Recent Activity"}),(0,t.jsx)("div",{className:"rounded-md border border-border bg-muted/40 px-3 py-2 max-h-72 overflow-y-auto",children:(0,t.jsx)(nd,{activity:i})})]}),(0,t.jsx)("section",{children:(0,t.jsx)("a",{href:(0,tU.apiUrl)("/docs/agent-collab-plan.md"),target:"_blank",rel:"noreferrer",className:"text-xs text-primary underline hover:no-underline",children:"Agent collaboration docs →"})})]})]})]}):null}var nh=e.i(580330),nx=e.i(877031),nf=/[\\\/_+.#"@\[\(\{&]/,ng=/[\\\/_+.#"@\[\(\{&]/g,nb=/[\s-]/,nw=/[\s-]/g;function ny(e){return e.toLowerCase().replace(nw," ")}var nv=e.i(750110),nN=e.i(433616),nj='[cmdk-group=""]',nk='[cmdk-group-items=""]',n_='[cmdk-item=""]',nC=`${n_}:not([aria-disabled="true"])`,nE="cmdk-item-select",nS="data-value",nM=(e,t,a)=>{var n;return n=e,function e(t,a,n,r,s,i,l){if(i===a.length)return s===t.length?1:.99;var o=`${s},${i}`;if(void 0!==l[o])return l[o];for(var c,d,u,m,p=r.charAt(i),h=n.indexOf(p,s),x=0;h>=0;)(c=e(t,a,n,r,h+1,i+1,l))>x&&(h===s?c*=1:nf.test(t.charAt(h-1))?(c*=.8,(u=t.slice(s,h-1).match(ng))&&s>0&&(c*=Math.pow(.999,u.length))):nb.test(t.charAt(h-1))?(c*=.9,(m=t.slice(s,h-1).match(nw))&&s>0&&(c*=Math.pow(.999,m.length))):(c*=.17,s>0&&(c*=Math.pow(.999,h-s))),t.charAt(h)!==a.charAt(i)&&(c*=.9999)),(c<.1&&n.charAt(h-1)===r.charAt(i+1)||r.charAt(i+1)===r.charAt(i)&&n.charAt(h-1)!==r.charAt(i))&&.1*(d=e(t,a,n,r,h+1,i+2,l))>c&&(c=.1*d),c>x&&(x=c),h=n.indexOf(p,h+1);return l[o]=x,x}(n=a&&a.length>0?`${n+" "+a.join(" ")}`:n,t,ny(n),ny(t),0,0,{})},nA=W.createContext(void 0),nD=W.createContext(void 0),nT=W.createContext(void 0),nO=W.forwardRef((e,t)=>{let a=nq(()=>{var t,a;return{search:"",value:null!=(a=null!=(t=e.value)?t:e.defaultValue)?a:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),n=nq(()=>new Set),r=nq(()=>new Map),s=nq(()=>new Map),i=nq(()=>new Set),l=nz(e),{label:o,children:c,value:d,onValueChange:u,filter:m,shouldFilter:p,loop:h,disablePointerSelection:x=!1,vimBindings:f=!0,...g}=e,b=(0,nN.useId)(),w=(0,nN.useId)(),y=(0,nN.useId)(),v=W.useRef(null),N=nH();nU(()=>{if(void 0!==d){let e=d.trim();a.current.value=e,j.emit()}},[d]),nU(()=>{N(6,M)},[]);let j=W.useMemo(()=>({subscribe:e=>(i.current.add(e),()=>i.current.delete(e)),snapshot:()=>a.current,setState:(e,t,n)=>{var r,s,i,o;if(!Object.is(a.current[e],t)){if(a.current[e]=t,"search"===e)S(),C(),N(1,E);else if("value"===e){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let e=document.getElementById(y);e?e.focus():null==(r=document.getElementById(b))||r.focus()}if(N(7,()=>{var e;a.current.selectedItemId=null==(e=A())?void 0:e.id,j.emit()}),n||N(5,M),(null==(s=l.current)?void 0:s.value)!==void 0){null==(o=(i=l.current).onValueChange)||o.call(i,null!=t?t:"");return}}j.emit()}},emit:()=>{i.current.forEach(e=>e())}}),[]),k=W.useMemo(()=>({value:(e,t,n)=>{var r;t!==(null==(r=s.current.get(e))?void 0:r.value)&&(s.current.set(e,{value:t,keywords:n}),a.current.filtered.items.set(e,_(t,n)),N(2,()=>{C(),j.emit()}))},item:(e,t)=>(n.current.add(e),t&&(r.current.has(t)?r.current.get(t).add(e):r.current.set(t,new Set([e]))),N(3,()=>{S(),C(),a.current.value||E(),j.emit()}),()=>{s.current.delete(e),n.current.delete(e),a.current.filtered.items.delete(e);let t=A();N(4,()=>{S(),(null==t?void 0:t.getAttribute("id"))===e&&E(),j.emit()})}),group:e=>(r.current.has(e)||r.current.set(e,new Set),()=>{s.current.delete(e),r.current.delete(e)}),filter:()=>l.current.shouldFilter,label:o||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:b,inputId:y,labelId:w,listInnerRef:v}),[]);function _(e,t){var n,r;let s=null!=(r=null==(n=l.current)?void 0:n.filter)?r:nM;return e?s(e,a.current.search,t):0}function C(){if(!a.current.search||!1===l.current.shouldFilter)return;let e=a.current.filtered.items,t=[];a.current.filtered.groups.forEach(a=>{let n=r.current.get(a),s=0;n.forEach(t=>{s=Math.max(e.get(t),s)}),t.push([a,s])});let n=v.current;D().sort((t,a)=>{var n,r;let s=t.getAttribute("id"),i=a.getAttribute("id");return(null!=(n=e.get(i))?n:0)-(null!=(r=e.get(s))?r:0)}).forEach(e=>{let t=e.closest(nk);t?t.appendChild(e.parentElement===t?e:e.closest(`${nk} > *`)):n.appendChild(e.parentElement===n?e:e.closest(`${nk} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{var t;let a=null==(t=v.current)?void 0:t.querySelector(`${nj}[${nS}="${encodeURIComponent(e[0])}"]`);null==a||a.parentElement.appendChild(a)})}function E(){let e=D().find(e=>"true"!==e.getAttribute("aria-disabled")),t=null==e?void 0:e.getAttribute(nS);j.setState("value",t||void 0)}function S(){var e,t,i,o;if(!a.current.search||!1===l.current.shouldFilter){a.current.filtered.count=n.current.size;return}a.current.filtered.groups=new Set;let c=0;for(let r of n.current){let n=_(null!=(t=null==(e=s.current.get(r))?void 0:e.value)?t:"",null!=(o=null==(i=s.current.get(r))?void 0:i.keywords)?o:[]);a.current.filtered.items.set(r,n),n>0&&c++}for(let[e,t]of r.current)for(let n of t)if(a.current.filtered.items.get(n)>0){a.current.filtered.groups.add(e);break}a.current.filtered.count=c}function M(){var e,t,a;let n=A();n&&((null==(e=n.parentElement)?void 0:e.firstChild)===n&&(null==(a=null==(t=n.closest(nj))?void 0:t.querySelector('[cmdk-group-heading=""]'))||a.scrollIntoView({block:"nearest"})),n.scrollIntoView({block:"nearest"}))}function A(){var e;return null==(e=v.current)?void 0:e.querySelector(`${n_}[aria-selected="true"]`)}function D(){var e;return Array.from((null==(e=v.current)?void 0:e.querySelectorAll(nC))||[])}function T(e){let t=D()[e];t&&j.setState("value",t.getAttribute(nS))}function O(e){var t;let a=A(),n=D(),r=n.findIndex(e=>e===a),s=n[r+e];null!=(t=l.current)&&t.loop&&(s=r+e<0?n[n.length-1]:r+e===n.length?n[0]:n[r+e]),s&&j.setState("value",s.getAttribute(nS))}function I(e){let t=A(),a=null==t?void 0:t.closest(nj),n;for(;a&&!n;)n=null==(a=e>0?function(e,t){let a=e.nextElementSibling;for(;a;){if(a.matches(t))return a;a=a.nextElementSibling}}(a,nj):function(e,t){let a=e.previousElementSibling;for(;a;){if(a.matches(t))return a;a=a.previousElementSibling}}(a,nj))?void 0:a.querySelector(nC);n?j.setState("value",n.getAttribute(nS)):O(e)}let R=()=>T(D().length-1),F=e=>{e.preventDefault(),e.metaKey?R():e.altKey?I(1):O(1)},L=e=>{e.preventDefault(),e.metaKey?T(0):e.altKey?I(-1):O(-1)};return W.createElement(nv.Primitive.div,{ref:t,tabIndex:-1,...g,"cmdk-root":"",onKeyDown:e=>{var t;null==(t=g.onKeyDown)||t.call(g,e);let a=e.nativeEvent.isComposing||229===e.keyCode;if(!(e.defaultPrevented||a))switch(e.key){case"n":case"j":f&&e.ctrlKey&&F(e);break;case"ArrowDown":F(e);break;case"p":case"k":f&&e.ctrlKey&&L(e);break;case"ArrowUp":L(e);break;case"Home":e.preventDefault(),T(0);break;case"End":e.preventDefault(),R();break;case"Enter":{e.preventDefault();let t=A();if(t){let e=new Event(nE);t.dispatchEvent(e)}}}}},W.createElement("label",{"cmdk-label":"",htmlFor:k.inputId,id:k.labelId,style:nV},o),nG(e,e=>W.createElement(nD.Provider,{value:j},W.createElement(nA.Provider,{value:k},e))))}),nI=W.forwardRef((e,t)=>{var a,n;let r=(0,nN.useId)(),s=W.useRef(null),i=W.useContext(nT),l=W.useContext(nA),o=nz(e),c=null!=(n=null==(a=o.current)?void 0:a.forceMount)?n:null==i?void 0:i.forceMount;nU(()=>{if(!c)return l.item(r,null==i?void 0:i.id)},[c]);let d=nW(r,s,[e.value,e.children,s],e.keywords),u=W.useContext(nD),m=nK(e=>e.value&&e.value===d.current),p=nK(e=>!!c||!1===l.filter()||!e.search||e.filtered.items.get(r)>0);function h(){var e,t;x(),null==(t=(e=o.current).onSelect)||t.call(e,d.current)}function x(){u.setState("value",d.current,!0)}if(W.useEffect(()=>{let t=s.current;if(!(!t||e.disabled))return t.addEventListener(nE,h),()=>t.removeEventListener(nE,h)},[p,e.onSelect,e.disabled]),!p)return null;let{disabled:f,value:g,onSelect:b,forceMount:w,keywords:y,...v}=e;return W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(s,t),...v,id:r,"cmdk-item":"",role:"option","aria-disabled":!!f,"aria-selected":!!m,"data-disabled":!!f,"data-selected":!!m,onPointerMove:f||l.getDisablePointerSelection()?void 0:x,onClick:f?void 0:h},e.children)}),nR=W.forwardRef((e,t)=>{let{heading:a,children:n,forceMount:r,...s}=e,i=(0,nN.useId)(),l=W.useRef(null),o=W.useRef(null),c=(0,nN.useId)(),d=W.useContext(nA),u=nK(e=>!!r||!1===d.filter()||!e.search||e.filtered.groups.has(i));nU(()=>d.group(i),[]),nW(i,l,[e.value,e.heading,o]);let m=W.useMemo(()=>({id:i,forceMount:r}),[r]);return W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(l,t),...s,"cmdk-group":"",role:"presentation",hidden:!u||void 0},a&&W.createElement("div",{ref:o,"cmdk-group-heading":"","aria-hidden":!0,id:c},a),nG(e,e=>W.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":a?c:void 0},W.createElement(nT.Provider,{value:m},e))))}),nF=W.forwardRef((e,t)=>{let{alwaysRender:a,...n}=e,r=W.useRef(null),s=nK(e=>!e.search);return a||s?W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(r,t),...n,"cmdk-separator":"",role:"separator"}):null}),nL=W.forwardRef((e,t)=>{let{onValueChange:a,...n}=e,r=null!=e.value,s=W.useContext(nD),i=nK(e=>e.search),l=nK(e=>e.selectedItemId),o=W.useContext(nA);return W.useEffect(()=>{null!=e.value&&s.setState("search",e.value)},[e.value]),W.createElement(nv.Primitive.input,{ref:t,...n,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":o.listId,"aria-labelledby":o.labelId,"aria-activedescendant":l,id:o.inputId,type:"text",value:r?e.value:i,onChange:e=>{r||s.setState("search",e.target.value),null==a||a(e.target.value)}})}),nP=W.forwardRef((e,t)=>{let{children:a,label:n="Suggestions",...r}=e,s=W.useRef(null),i=W.useRef(null),l=nK(e=>e.selectedItemId),o=W.useContext(nA);return W.useEffect(()=>{if(i.current&&s.current){let e=i.current,t=s.current,a,n=new ResizeObserver(()=>{a=requestAnimationFrame(()=>{let a=e.offsetHeight;t.style.setProperty("--cmdk-list-height",a.toFixed(1)+"px")})});return n.observe(e),()=>{cancelAnimationFrame(a),n.unobserve(e)}}},[]),W.createElement(nv.Primitive.div,{ref:(0,al.composeRefs)(s,t),...r,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":n,id:o.listId},nG(e,e=>W.createElement("div",{ref:(0,al.composeRefs)(i,o.listInnerRef),"cmdk-list-sizer":""},e)))}),nB=W.forwardRef((e,t)=>{let{open:a,onOpenChange:n,overlayClassName:r,contentClassName:s,container:i,...l}=e;return W.createElement(tV.Root,{open:a,onOpenChange:n},W.createElement(tV.Portal,{container:i},W.createElement(tV.Overlay,{"cmdk-overlay":"",className:r}),W.createElement(tV.Content,{"aria-label":e.label,"cmdk-dialog":"",className:s},W.createElement(nO,{ref:t,...l}))))}),n$=Object.assign(nO,{List:nP,Item:nI,Input:nL,Group:nR,Separator:nF,Dialog:nB,Empty:W.forwardRef((e,t)=>nK(e=>0===e.filtered.count)?W.createElement(nv.Primitive.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),Loading:W.forwardRef((e,t)=>{let{progress:a,children:n,label:r="Loading...",...s}=e;return W.createElement(nv.Primitive.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,"aria-label":r},nG(e,e=>W.createElement("div",{"aria-hidden":!0},e)))})});function nz(e){let t=W.useRef(e);return nU(()=>{t.current=e}),t}var nU="u"<typeof window?W.useEffect:W.useLayoutEffect;function nq(e){let t=W.useRef();return void 0===t.current&&(t.current=e()),t}function nK(e){let t=W.useContext(nD),a=()=>e(t.snapshot());return W.useSyncExternalStore(t.subscribe,a,a)}function nW(e,t,a,n=[]){let r=W.useRef(),s=W.useContext(nA);return nU(()=>{var i;let l=(()=>{var e;for(let t of a){if("string"==typeof t)return t.trim();if("object"==typeof t&&"current"in t)return t.current?null==(e=t.current.textContent)?void 0:e.trim():r.current}})(),o=n.map(e=>e.trim());s.value(e,l,o),null==(i=t.current)||i.setAttribute(nS,l),r.current=l}),r}var nH=()=>{let[e,t]=W.useState(),a=nq(()=>new Map);return nU(()=>{a.current.forEach(e=>e()),a.current=new Map},[e]),(e,n)=>{a.current.set(e,n),t({})}};function nG({asChild:e,children:t},a){let n;return e&&W.isValidElement(t)?W.cloneElement("function"==typeof(n=t.type)?n(t.props):"render"in n?n.render(t.props):t,{ref:t.ref},a(t.props.children)):a(t)}var nV={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};let nZ=(0,n.default)("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]),nX=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$,{ref:n,className:(0,tf.cn)("flex h-full w-full flex-col overflow-hidden rounded-sm bg-popover text-popover-foreground",e),...a}));function nJ({children:e,shouldFilter:a,...n}){return(0,t.jsx)(G.Dialog,{...n,children:(0,t.jsxs)(G.DialogContent,{className:"overflow-hidden p-0 shadow-golden max-w-lg",children:[(0,t.jsx)(G.DialogTitle,{className:"sr-only",children:"Search"}),(0,t.jsx)(nX,{shouldFilter:a,className:"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5",children:e})]})})}nX.displayName=n$.displayName;let nQ=W.forwardRef(({className:e,...a},n)=>(0,t.jsxs)("div",{className:"flex items-center border-b px-3","cmdk-input-wrapper":"",children:[(0,t.jsx)(nZ,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),(0,t.jsx)(n$.Input,{ref:n,className:(0,tf.cn)("flex h-11 w-full rounded-sm bg-transparent py-3 text-sm outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50",e),...a})]}));nQ.displayName=n$.Input.displayName;let nY=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.List,{ref:n,className:(0,tf.cn)("max-h-[300px] overflow-y-auto overflow-x-hidden",e),...a}));nY.displayName=n$.List.displayName;let n0=W.forwardRef((e,a)=>(0,t.jsx)(n$.Empty,{ref:a,className:"py-6 text-center text-sm text-muted-foreground",...e}));n0.displayName=n$.Empty.displayName;let n1=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Group,{ref:n,className:(0,tf.cn)("overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-muted-foreground",e),...a}));n1.displayName=n$.Group.displayName;let n2=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Separator,{ref:n,className:(0,tf.cn)("-mx-1 h-px bg-border",e),...a}));n2.displayName=n$.Separator.displayName;let n5=W.forwardRef(({className:e,...a},n)=>(0,t.jsx)(n$.Item,{ref:n,className:(0,tf.cn)("relative flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",e),...a}));n5.displayName=n$.Item.displayName;let n3=null,n4=null,n9=(0,t5.create)(e=>({query:"",results:[],loading:!1,truncated:!1,open:!1,setQuery:t=>e({query:t}),setOpen:t=>e({open:t}),clear:()=>{n4&&clearTimeout(n4),n3?.abort(),e({query:"",results:[],loading:!1,truncated:!1})},search:t=>(n4&&clearTimeout(n4),t.trim())?(e({loading:!0}),new Promise(a=>{n4=setTimeout(()=>{n7(e,t).finally(a)},150)})):(n3?.abort(),e({results:[],loading:!1,truncated:!1}),Promise.resolve())}));async function n7(e,t){n3?.abort();let a=new AbortController;n3=a;try{let n=await (0,X.wsFetch)("/api/wiki/search",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:t,limit:30}),signal:a.signal});if(!n.ok)return void e({results:[],loading:!1,truncated:!1});let r=await n.json();if(a.signal.aborted)return;e({results:r.matches??[],truncated:!!r.truncated,loading:!1})}catch(t){"AbortError"!==t.name&&e({loading:!1})}}var n6=e.i(395624);function n8({html:e}){let a=function(e){let t,a=[],n=/<mark>([\s\S]*?)<\/mark>/g,r=0;for(;null!==(t=n.exec(e));)t.index>r&&a.push({text:e.slice(r,t.index),mark:!1}),a.push({text:t[1]??"",mark:!0}),r=t.index+t[0].length;return r<e.length&&a.push({text:e.slice(r),mark:!1}),a}(e);return(0,t.jsx)(t.Fragment,{children:a.map((e,a)=>e.mark?(0,t.jsx)("mark",{className:"bg-yellow-200 dark:bg-yellow-700 rounded-[2px] px-[1px]",children:e.text},a):(0,t.jsx)("span",{children:e.text},a))})}function re({onOpenFile:e,recents:a=[],onToggleSidebar:n=()=>void 0,onNewFile:s=()=>void 0,onCopyPath:i=()=>void 0}){let l=n9(e=>e.open),c=n9(e=>e.setOpen),d=n9(e=>e.query),u=n9(e=>e.setQuery),p=n9(e=>e.results),h=n9(e=>e.loading),x=n9(e=>e.truncated),f=n9(e=>e.search),{resolvedTheme:g,setTheme:b}=(0,tH.useTheme)(),w=(0,a9.useAIPanelStore)(e=>e.toggle),y=(0,n6.useViewWidthStore)(e=>e.width),v=(0,n6.useViewWidthStore)(e=>e.cycle),N=d.trimStart(),j=""===N||N.startsWith(">"),k=""===N&&a.length>0,_=j?"":d;function C(e){e(),c(!1),u("")}(0,W.useEffect)(()=>{function e(e){(e.metaKey||e.ctrlKey)&&"k"===e.key.toLowerCase()&&(e.preventDefault(),c(!l))}return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[l,c]),(0,W.useEffect)(()=>{if(!l||j)return;let e=setTimeout(()=>{f(_)},120);return()=>clearTimeout(e)},[_,j,l,f]);let E=(n6.VIEW_WIDTH_ORDER.indexOf(y)+1)%n6.VIEW_WIDTH_ORDER.length,M=n6.VIEW_WIDTH_LABEL[n6.VIEW_WIDTH_ORDER[E]];return(0,t.jsxs)(nJ,{open:l,onOpenChange:e=>{c(e),e||u("")},shouldFilter:!1,children:[(0,t.jsx)(nQ,{placeholder:"Search files… ( > for actions )",value:d,onValueChange:u}),(0,t.jsxs)(nY,{children:[k&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n1,{heading:"Recent",children:a.map(a=>(0,t.jsxs)(n5,{value:`recent:${a.path}`,onSelect:()=>{e(a.path),c(!1),u("")},children:[(0,t.jsx)(ar,{className:"mr-2 h-4 w-4"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"truncate font-medium",children:a.name}),(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:a.path})]})]},a.path))}),(0,t.jsx)(n2,{})]}),j&&(0,t.jsxs)(n1,{heading:"Actions",children:[(0,t.jsxs)(n5,{value:"toggle-dark-mode",onSelect:()=>C(()=>b("dark"===g?"light":"dark")),children:["dark"===g?(0,t.jsx)(B.Sun,{className:"mr-2 h-4 w-4"}):(0,t.jsx)(S.Moon,{className:"mr-2 h-4 w-4"}),"dark"===g?"Switch to light mode":"Switch to dark mode"]}),(0,t.jsxs)(n5,{value:"toggle-ai-panel",onSelect:()=>C(w),children:[(0,t.jsx)(r,{className:"mr-2 h-4 w-4"}),"Toggle AI panel"]}),(0,t.jsxs)(n5,{value:"toggle-sidebar",onSelect:()=>C(n),children:[(0,t.jsx)(nx.PanelLeft,{className:"mr-2 h-4 w-4"}),"Toggle sidebar"]}),(0,t.jsxs)(n5,{value:"new-file",onSelect:()=>C(s),children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-4 w-4"}),"New file"]}),(0,t.jsxs)(n5,{value:"copy-path",onSelect:()=>C(i),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-4 w-4"}),"Copy current file path"]}),(0,t.jsxs)(n5,{value:"cycle-view-width",onSelect:()=>C(v),children:[(0,t.jsx)(nh.AlignCenter,{className:"mr-2 h-4 w-4"}),(0,t.jsxs)("span",{children:["Change view width"," ",(0,t.jsxs)("span",{className:"text-muted-foreground",children:["(",n6.VIEW_WIDTH_LABEL[y]," → ",M,")"]})]})]})]}),!j&&(0,t.jsxs)(t.Fragment,{children:[h&&(0,t.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Searching…"}),!h&&""!==_.trim()&&0===p.length&&(0,t.jsx)(n0,{children:"No matches."}),p.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(n2,{}),(0,t.jsx)(n1,{heading:x?"Top results (refine query for more)":"Results",children:p.map(a=>(0,t.jsx)(n5,{value:a.path,onSelect:()=>{e(a.path),c(!1),u("")},children:(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-0.5",children:[(0,t.jsx)("span",{className:"truncate font-mono text-xs",children:a.path}),a.snippet&&(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:(0,t.jsx)(n8,{html:a.snippet})})]})},a.path))})]})]})]})]})}function rt({onOpenFile:e}){let a=n9(e=>e.query),n=n9(e=>e.setQuery),r=n9(e=>e.results),s=n9(e=>e.loading),i=n9(e=>e.search),l=n9(e=>e.clear),[o,c]=(0,W.useState)(0),d=(0,W.useRef)(null);function u(t){let a=r[t];a&&(e(a.path),l())}return(0,W.useEffect)(()=>{c(0)},[r]),(0,W.useEffect)(()=>{let e=d.current?.querySelector(`[data-idx="${o}"]`);e?.scrollIntoView({block:"nearest"})},[o]),(0,t.jsxs)("div",{className:"flex flex-col gap-1 px-2 py-1.5",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)(nZ,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 opacity-50"}),(0,t.jsx)("input",{type:"text",className:"w-full rounded-sm border bg-transparent py-1 pl-7 pr-2 text-xs outline-none focus:ring-1 focus:ring-ring",placeholder:"Search… (⌘K)",value:a,onChange:e=>{n(e.target.value),i(e.target.value)},onKeyDown:e=>{"Escape"===e.key?l():0!==r.length&&("ArrowDown"===e.key?(e.preventDefault(),c(e=>(e+1)%r.length)):"ArrowUp"===e.key?(e.preventDefault(),c(e=>(e-1+r.length)%r.length)):"Enter"===e.key&&(e.preventDefault(),u(o)))}})]}),""!==a.trim()&&(0,t.jsxs)("div",{ref:d,className:"max-h-64 overflow-y-auto rounded-sm border bg-popover",children:[s&&(0,t.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"Searching…"}),!s&&0===r.length&&(0,t.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:"No matches"}),r.map((e,a)=>(0,t.jsxs)("button",{type:"button","data-idx":a,onClick:()=>u(a),onMouseEnter:()=>c(a),className:`block w-full px-2 py-1 text-left ${a===o?"bg-accent":"hover:bg-accent"}`,children:[(0,t.jsx)("div",{className:"truncate font-mono text-xs",children:e.path}),e.snippet&&(0,t.jsx)("div",{className:"truncate text-[10px] text-muted-foreground",children:(0,t.jsx)(n8,{html:e.snippet})})]},e.path))]})]})}let ra="wiki-sidebar-width";function rn(e){return Number.isNaN(e)?288:Math.min(600,Math.max(200,Math.round(e)))}let rr=(0,t5.create)(e=>({width:function(){let e=localStorage.getItem(ra);if(e){let t=Number.parseInt(e,10);if(!Number.isNaN(t))return rn(t)}return 288}(),setWidth:t=>{let a=rn(t);localStorage.setItem(ra,String(a)),e({width:a})}}));var rs=e.i(246542),ri=e.i(50808);let rl="wiki-show-hidden",ro=(0,t5.create)((e,t)=>({showHidden:"1"===localStorage.getItem(rl),toggle:()=>{let a=!t().showHidden;a?localStorage.setItem(rl,"1"):localStorage.removeItem(rl),e({showHidden:a})}})),rc="wiki-humanize-names",rd=(0,t5.create)((e,t)=>({humanize:"1"===localStorage.getItem(rc),toggle:()=>{let a=!t().humanize;a?localStorage.setItem(rc,"1"):localStorage.removeItem(rc),e({humanize:a})}}));function ru(e){let t=e.lastIndexOf("."),a=t>0&&t<e.length-1,n=a?e.slice(0,t):e,r=a?e.slice(t):"",s=n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").split(/[\s_-]+/).filter(Boolean).map(e=>/^[A-Z0-9]+$/.test(e)?e:e[0].toUpperCase()+e.slice(1));return s.length?s.join(" ")+r:e}let rm=(0,tb.default)(()=>e.A(810497).then(e=>e.PdfViewer),{loadableGenerated:{modules:[904378]},ssr:!1});function rp(e){let t=new Date(e).getTime();if(!Number.isFinite(t))return"";let a=Math.floor(Math.max(0,Date.now()-t)/1e3);if(a<60)return"just now";let n=Math.floor(a/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}let rh=new Set(["image","media","pdf","fallback","app","node-app","html"]);function rx(e){return e.split(".").pop()?.toLowerCase()??""}function rf(e,t){if("node-app"===t)return"node-app";if("app"===t)return"app";if("dir"===t)return"fallback";let a=e.split("/").pop()??e;if(a.startsWith(".")&&-1===a.indexOf(".",1))return"source";let n=rx(e);return n?["md","markdown"].includes(n)?"editor":"txt"===n?"text":["csv","tsv"].includes(n)?"csv":"pdf"===n?"pdf":["mmd","mermaid"].includes(n)?"mermaid":"ipynb"===n?"notebook":["png","jpg","jpeg","gif","webp","svg","avif","ico","bmp"].includes(n)?"image":["mp4","webm","mov","m4v","mp3","wav","ogg","m4a","aac"].includes(n)?"media":"docx"===n?"docx":["xlsx","xlsm"].includes(n)?"xlsx":"pptx"===n?"pptx":"html"===n?"html":(["py","js","ts","tsx","jsx","go","rs","java","c","cpp","h","sh","bash","zsh","rb","php","swift","kt","lua","sql","yaml","yml","toml","json","xml","css","scss"].includes(n),"source"):"source"}let rg=new Set(["txt","md","markdown","json","yaml","yml","toml","csv","tsv","xml","html","css","js","ts","tsx","jsx","sh","bash","zsh","rb","py","go","rs","java","c","cpp","h","php","swift","kt","lua","sql","scss","mmd","mermaid","ini","env","log","conf"]);function rb(e){let t=rf(e,"file");return"editor"===t||"text"===t||rg.has(rx(e))}function rw(e){return["md","markdown"].includes(rx(e))}function ry(e){return"image"===rf(e,"file")}function rv(e){return"html"===rf(e,"file")}async function rN(e){let t=await (0,X.wsFetch)(`/api/wiki?dir=${encodeURIComponent(e)}`);return t.ok?(await t.json()).entries.map(t=>({name:t.name,path:e?`${e}/${t.name}`:t.name,type:t.type,size:t.size,modifiedAt:t.modifiedAt,expanded:!1,git:t.git})):[]}let rj=new Map,rk=new Map;async function r_(e){let t=rj.get(e);if(t)return rj.delete(e),t;let a=rk.get(e);if(a){let t=await a;return rj.delete(e),t}return null}function rC(e,t,a){return e.map(e=>e.path===t?a(e):e.children?{...e,children:rC(e.children,t,a)}:e)}let rE={contentVisibility:"auto",containIntrinsicSize:"auto 32px"};function rS({node:e,ctx:a,isPinned:n,activeWorkspaceId:r}){return(0,t.jsxs)(aX,{className:"w-48",children:[(0,t.jsxs)(aJ,{onSelect:()=>a.copyPath(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(aJ,{onSelect:()=>a.copyWikiLink(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.copyUrl(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(aJ,{onSelect:()=>a.copyRawContent(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.copyFormattedContent(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,t.jsx)(aQ,{}),"dir"===e.type&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(aJ,{onSelect:()=>{e.expanded||a.toggleFolder(e),a.setNewFileParent(e.path),a.setNewFileName(""),a.setFileCreateError(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.triggerUpload(e.path),children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,t.jsxs)(aJ,{onSelect:()=>{a.setNewFolderParent(e.path),a.setNewFolderName(""),a.setFolderError(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,t.jsx)(aQ,{})]}),(0,t.jsxs)(aJ,{onSelect:()=>a.handleDownload(e),children:[(0,t.jsx)(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,t.jsxs)(aJ,{onSelect:()=>a.togglePin(e,r),children:[(0,t.jsx)(I,{className:(0,tf.cn)("mr-2 h-3.5 w-3.5",n&&"fill-current text-amber-400")}),n?"Unpin":"Pin to top"]}),(0,t.jsx)(aQ,{}),(0,t.jsxs)(aJ,{className:"text-destructive focus:text-destructive",onSelect:()=>{a.setDeletingPath(e.path),a.setDeletingIsDir("file"!==e.type)},children:[(0,t.jsx)(U.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})}function rM({name:e,type:a}){let n="h-3.5 w-3.5 shrink-0";return"dir"===a?(0,t.jsx)(h.Folder,{className:(0,tf.cn)(n,"text-warning")}):"app"===a?(0,t.jsx)(y.Globe,{className:(0,tf.cn)(n,"text-foreground/70")}):"node-app"===a?(0,t.jsx)($,{className:(0,tf.cn)(n,"text-emerald-500")}):rv(e)?(0,t.jsx)(y.Globe,{className:(0,tf.cn)(n,"text-foreground/60")}):ry(e)?(0,t.jsx)(j.Image,{className:(0,tf.cn)(n,"text-sunshine-700")}):rb(e)?(0,t.jsx)(p.FileText,{className:(0,tf.cn)(n,"text-foreground/70")}):(0,t.jsx)(u.File,{className:(0,tf.cn)(n,"text-foreground/60")})}let rA=(0,W.memo)(function({node:e,depth:a,ctx:n,isMobile:r,activeWorkspaceId:s,sidebarScrollRef:i,isActive:d,isDragOver:b,isPinned:w,isAgentActive:v,isPulling:N,branchOpen:C,branchPos:S,branches:M,branchLoading:A,checkingOut:D,onHoverEnter:T,onHoverLeave:O}){let R=rd(e=>e.humanize);return(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"treeitem",tabIndex:0,draggable:!r,onKeyDown:t=>{if("Enter"===t.key||" "===t.key)t.preventDefault(),"dir"===e.type?n.toggleFolder(e):"app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e);else if("ArrowDown"===t.key){t.preventDefault();let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n+1]?.focus()}else if("ArrowUp"===t.key){t.preventDefault();let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n-1]?.focus()}else if("ArrowRight"===t.key){if(t.preventDefault(),"dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded){let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=a.indexOf(t.currentTarget);a[n+1]?.focus()}else n.toggleFolder(e)}else if("ArrowLeft"===t.key){if(t.preventDefault(),("dir"===e.type||"app"===e.type||"node-app"===e.type)&&e.expanded)n.toggleFolder(e);else if(a>0){let e=i.current;if(!e)return;let a=Array.from(e.querySelectorAll('[role="treeitem"]')),n=t.currentTarget,r=a.indexOf(n),s=Number.parseInt(n.style.paddingLeft??"0",10);for(let e=r-1;e>=0;e--)if(Number.parseInt(a[e].style.paddingLeft??"0",10)<s){a[e].focus();break}}}},onDragStart:t=>n.handleDragStart(t,e),onDragOver:t=>"dir"===e.type?n.handleDragOver(t,e.path,"dir"):t.preventDefault(),onDragLeave:()=>n.setDragOverPath(null),onDrop:t=>"dir"===e.type?n.handleDropOnFolder(t,e.path):t.preventDefault(),onMouseEnter:()=>T(e),onMouseLeave:O,className:(0,tf.cn)("tree-row-reveal flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer group transition-colors select-none touch-target",d?"bg-accent-soft text-foreground font-medium":"hover:bg-muted",b&&"ring-2 ring-primary bg-primary-soft",e.name.startsWith(".")&&"opacity-40"),style:{paddingLeft:`${14*a+8}px`,...rE},onClick:()=>{"dir"===e.type?n.toggleFolder(e):("app"===e.type||"node-app"===e.type?(n.openViewer(e),n.toggleFolder(e)):n.openViewer(e),r&&n.setSidebarCollapsed(!0))},children:["dir"===e.type||"app"===e.type||"node-app"===e.type?e.loading?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground"}):(0,t.jsx)(l.ChevronRight,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200 ease-out",style:{transform:e.expanded?"rotate(90deg)":"rotate(0deg)"}}):(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:"dir"===e.type?e.expanded?(0,t.jsx)(x,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-warning")}):(0,t.jsx)(h.Folder,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-warning")}):"app"===e.type?(0,t.jsx)(y.Globe,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/70")}):"node-app"===e.type?(0,t.jsx)($,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-emerald-500")}):rv(e.name)?(0,t.jsx)(y.Globe,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/60")}):ry(e.name)?(0,t.jsx)(j.Image,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-sunshine-700")}):rb(e.name)?(0,t.jsx)(p.FileText,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/70")}):(0,t.jsx)(u.File,{className:(0,tf.cn)("h-4 w-4 shrink-0",!d&&"text-foreground/60")})}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate",title:R?e.name:void 0,children:R?ru(e.name):e.name}),e.git&&(0,t.jsxs)("span",{className:"relative flex shrink-0 items-center gap-0.5 rounded-sm bg-muted px-1 py-0.5 text-[10px] text-muted-foreground",children:[(0,t.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"flex items-center gap-0.5 hover:text-foreground",title:"Switch branch",onClick:t=>{if(t.stopPropagation(),C){n.setBranchDropdownNode(null),n.setBranchDropdownPos(null);return}let a=t.currentTarget.getBoundingClientRect();n.setBranchDropdownPos({top:a.bottom+4,left:a.left}),n.setBranchDropdownNode(e.path),n.loadBranches(e.path)},children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"}),e.git.branch,e.git.dirty&&(0,t.jsx)("span",{className:"ml-0.5 text-warning",children:"*"})]}),N?(0,t.jsx)(_.Loader2,{className:"ml-0.5 h-2.5 w-2.5 animate-spin"}):(0,t.jsx)("button",{type:"button",onClick:t=>{t.stopPropagation();let a=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleGitPull(e.path,a)},className:"ml-0.5 text-muted-foreground hover:text-foreground",title:"Pull latest",children:(0,t.jsx)(F,{className:"h-2.5 w-2.5"})}),C&&S&&(0,t.jsx)(tW,{pos:S,branches:M,loading:A,busyName:D,disabled:null!==D,onPick:t=>{let a=e.path.includes("/")?e.path.substring(0,e.path.lastIndexOf("/")):"";n.handleCheckout(e.path,t,a)},onClose:()=>{n.setBranchDropdownNode(null),n.setBranchDropdownPos(null)}})]}),v&&(0,t.jsx)("span",{className:"ml-0.5 h-1.5 w-1.5 rounded-full bg-emerald-400 shrink-0 animate-pulse",title:"Agent recently active"}),(0,t.jsx)("div",{className:"hover-reveal flex max-w-0 shrink-0 items-center overflow-hidden opacity-0 transition-all duration-150 group-hover:max-w-7 group-hover:opacity-100 focus-within:max-w-7 focus-within:opacity-100",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0 text-muted-foreground hover:text-foreground",title:"File actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-48",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyPath(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyWikiLink(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyUrl(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),"file"===e.type&&rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyRawContent(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.copyFormattedContent(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),"dir"===e.type&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:async()=>{e.expanded||n.toggleFolder(e),n.setNewFileParent(e.path),n.setNewFileName(""),n.setFileCreateError(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file here"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.triggerUpload(e.path),children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload here"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{n.setNewFolderParent(e.path),n.setNewFolderName(""),n.setFolderError(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New subfolder"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{})]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.handleDownload(e),children:[(0,t.jsx)(c.Download,{className:"mr-2 h-3.5 w-3.5"}),"file"===e.type?"Download":"Download as zip"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>n.togglePin(e,s),children:[(0,t.jsx)(I,{className:(0,tf.cn)("mr-2 h-3.5 w-3.5",w&&"fill-current text-amber-400")}),w?"Unpin":"Pin to top"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{className:"text-destructive focus:text-destructive",onClick:()=>{n.setDeletingPath(e.path),n.setDeletingIsDir("file"!==e.type)},children:[(0,t.jsx)(U.Trash2,{className:"mr-2 h-3.5 w-3.5"}),"Delete"]})]})]})})]})}),(0,t.jsx)(rS,{node:e,ctx:n,isPinned:w,activeWorkspaceId:s})]})}),rD=(0,W.memo)(function(e){let{ctx:a,openPath:n,dragOverPath:r,branchDropdownNode:i,branchDropdownPos:l,nodeBranches:o,branchesLoading:c,checkingOutBranch:d,pullingRepo:u,activePaths:m,pins:x,isMobile:f,activeWorkspaceId:g,newFileParent:b,newFileName:w,fileCreateError:y,newFolderParent:v,newFolderName:N,folderError:j,sidebarScrollRef:k}=e,_=ro(e=>e.showHidden),C=(0,W.useRef)(null),E=(0,W.useCallback)(e=>{let t=("dir"===e.type||"app"===e.type||"node-app"===e.type)&&!e.expanded&&void 0===e.children;("file"===e.type||t)&&(C.current&&clearTimeout(C.current),C.current=setTimeout(()=>a.prefetch(e),120))},[a]),S=(0,W.useCallback)(()=>{C.current&&(clearTimeout(C.current),C.current=null)},[]),M=(0,W.useMemo)(()=>{let t=[],a=(e,n)=>{for(let r of e)!(!_&&r.name.startsWith("."))&&(t.push({kind:"row",node:r,depth:n}),"dir"===r.type&&(v===r.path&&t.push({kind:"newfolder",node:r,depth:n}),b===r.path&&t.push({kind:"newfile",node:r,depth:n})),("dir"===r.type||"app"===r.type||"node-app"===r.type)&&r.expanded&&(r.children&&r.children.length>0?a(r.children,n+1):r.children?.length===0&&t.push({kind:"empty",node:r,depth:n})))};return a(e.nodes,0),t},[e.nodes,b,v,_]);return(0,t.jsx)(t.Fragment,{children:M.map(e=>{let{node:b,depth:v}=e;if("row"===e.kind){let e=i===b.path;return(0,t.jsx)(rA,{node:b,depth:v,ctx:a,isMobile:f,activeWorkspaceId:g,sidebarScrollRef:k,isActive:n===b.path,isDragOver:r===b.path,isPinned:x.some(e=>e.path===b.path),isAgentActive:m.has(b.path),isPulling:u===b.path,branchOpen:e,branchPos:e?l:null,branches:b.git?o[b.path]??[]:[],branchLoading:!!b.git&&!!c[b.path],checkingOut:e?d:null,onHoverEnter:E,onHoverLeave:S},b.path)}return"newfolder"===e.kind?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...rE},children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)(h.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,t.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:N,onChange:e=>a.setNewFolderName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&a.handleCreateFolder(),"Escape"===e.key&&(a.setNewFolderParent(null),a.setNewFolderName(""))}}),j&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:j}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:a.handleCreateFolder,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a.setNewFolderParent(null),a.setNewFolderName("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]},`nf-${b.path}`):"newfile"===e.kind?(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1",style:{paddingLeft:`${(v+1)*14+8}px`,...rE},children:[(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,t.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:w,onChange:e=>a.setNewFileName(e.target.value),onKeyDown:e=>{"Enter"===e.key&&a.handleCreateFile(),"Escape"===e.key&&(a.setNewFileParent(null),a.setNewFileName(""))}}),y&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:y}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:a.handleCreateFile,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{a.setNewFileParent(null),a.setNewFileName("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]},`ff-${b.path}`):(0,t.jsx)("div",{className:"text-xs text-muted-foreground/50 py-0.5",style:{paddingLeft:`${(v+1)*14+8+14+6+16+6}px`,...rE},children:"Empty"},`empty-${b.path}`)})})});e.s(["default",0,function(){let e;(0,rs.useWikiSlugsStore)(e=>e.loadedAt),(0,W.useEffect)(()=>{rs.useWikiSlugsStore.getState().load()},[]);let[n,c]=(0,W.useState)(null),[x,$]=(0,W.useState)(null),[G,Z]=(0,W.useState)(()=>(0,X.getActiveWorkspaceId)()),[J,Q]=(0,W.useState)([]),[Y,en]=(0,W.useState)(!1),[er,eo]=(0,W.useState)(!1),[ed,eu]=(0,W.useState)(null),[em,ep]=(0,W.useState)(null),[eh,ex]=(0,W.useState)({}),[ef,eg]=(0,W.useState)(null),[eb,ew]=(0,W.useState)(null),[ey,ev]=(0,W.useState)(null),[eN,ej]=(0,W.useState)(null),ek=(0,W.useCallback)(async()=>{let e=(0,X.getEphemeralRoot)();if(e){Q([]),en(!1),c(!0),$(e),Z(`root:${e}`);return}try{let e=await fetch((0,tU.apiUrl)("/api/system/workspaces"));if(!e.ok)throw Error("Failed");let t=await e.json();if(Q(t.workspaces),en(t.isAdmin),t.workspaces.length>0){c(!0);let e=new URLSearchParams(window.location.search).get("ws"),a=e?t.workspaces.find(t=>t.id===e):null,n=a??[...t.workspaces].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];if(Z(n.id),$(n.rootDir),!a){let e=new URL(location.href);e.searchParams.set("ws",n.id),history.replaceState(null,"",e.toString())}}else c(!1)}catch{c(!1)}},[]);(0,W.useEffect)(()=>{ek()},[ek]);let e_=(0,ns.useEditorStore)(e=>e.currentPath),eC=a1(e=>e.recents),[eE,eS]=(0,W.useState)(!1),[eM,eA]=(0,W.useState)(!0),eD=a3(e=>e.pins),eT=(0,W.useRef)(null),eO=(0,a9.useAIPanelStore)(e=>e.activity),eI=(0,W.useMemo)(()=>{let e=new Date(Date.now()-6e4).toISOString(),t=new Set;for(let a of eO)a.at>=e&&a.path&&a.by?.startsWith("ai:")&&t.add(a.path);return t},[eO]);(0,W.useEffect)(()=>{let e=()=>{a9.useAIPanelStore.getState().loadActivity()};e();let t=setInterval(e,1e4);return()=>clearInterval(t)},[]),(0,W.useEffect)(()=>{a1.getState().loadForWorkspace(G),a3.getState().loadForWorkspace(G)},[G]),(0,W.useEffect)(()=>{let e=[...eD.map(e=>e.path),...eC.slice(0,8).map(e=>e.path)].filter((e,t,a)=>rw(e)&&a.indexOf(e)===t).slice(0,12);if(0===e.length)return;let t=("requestIdleCallback"in window?e=>window.requestIdleCallback(e):e=>window.setTimeout(e,400))(()=>{for(let t of e)(0,ns.prefetchPage)(t)});return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(t):clearTimeout(t)}},[eD,eC]);let eR=(0,W.useRef)(new URLSearchParams(window.location.search).get("path")??new URLSearchParams(window.location.search).get("file")),eF=(0,W.useRef)(!1),[eL,eP]=(0,W.useState)(!1),[eB,e$]=(0,W.useState)(!1);(0,W.useEffect)(()=>{let e=new URLSearchParams(window.location.search),t="1"===e.get("embed");eP(t),e$(t&&"1"!==e.get("chrome"))},[]);let[ez,eU]=(0,W.useState)([]),[eq,eK]=(0,W.useState)(!1),[eW,eH]=(0,W.useState)(!1),eG=(0,W.useRef)(!1),[eV,eZ]=(0,W.useState)(!1),[eX,eJ]=(0,W.useState)(!1),[eQ,eY]=(0,W.useState)(null),e0=(0,W.useRef)(null),e1=(0,W.useRef)(""),[e2,e5]=(0,W.useState)(null),[e3,e4]=(0,W.useState)(""),[e9,e7]=(0,W.useState)(null),[e6,e8]=(0,W.useState)(null),[te,tt]=(0,W.useState)(""),[ta,tr]=(0,W.useState)(null),[ts,ti]=(0,W.useState)(null),[tl,to]=(0,W.useState)(!1),[tc,td]=(0,W.useState)(null),[tu,tp]=(0,W.useState)(null),[tb,tw]=(0,W.useState)(!1),[ty,tv]=(0,W.useState)(0),[tN,tj]=(0,W.useState)(0),tk=function(e="(max-width: 767px)"){let[t,a]=(0,W.useState)(!1);return(0,W.useEffect)(()=>{let t=window.matchMedia(e),n=()=>a(t.matches);return n(),t.addEventListener("change",n),()=>t.removeEventListener("change",n)},[e]),t}(),[t_,tC]=(0,W.useState)(!1),tE=rr(e=>e.width),tS=ro(e=>e.showHidden),tM=rd(e=>e.humanize),{resolvedTheme:tD,setTheme:tO}=(0,tH.useTheme)(),tI=rr(e=>e.setWidth);(0,W.useEffect)(()=>{tk&&tC(!0)},[tk]);let[tF,tP]=(0,W.useState)(!1),[tB,t$]=(0,W.useState)(!1),[tz,tK]=(0,W.useState)(!1),[tG,tV]=(0,W.useState)(null),[tZ,tX]=(0,W.useState)(0),[tJ,tQ]=(0,W.useState)(!1),[tY,t0]=(0,W.useState)(!1),[t2,t5]=(0,W.useState)(""),[t3,t4]=(0,W.useState)(!1),[t9,t7]=(0,W.useState)(!1),[t6,t8]=(0,W.useState)(null),ae=(0,W.useRef)(null),[at,an]=(0,W.useState)(null),ar=(0,W.useRef)(null),as=(0,W.useRef)(!1),ai=(0,W.useRef)(async()=>{});(0,W.useEffect)(()=>{!G||eq||eG.current||(eG.current=!0,eH(!0),rN("").then(e=>{eU(e),eK(!0),eH(!1)}).catch(()=>{eG.current=!1,eH(!1)}))},[eq,G]);let al=(0,W.useCallback)(async e=>{let t=e.split("/");if(t.length<=1)return;let a=[],n="";for(let e=0;e<t.length-1;e++)n=n?`${n}/${t[e]}`:t[e],a.push({prefix:n,children:await rN(n)});eU(e=>{let t=e;for(let{prefix:e,children:n}of a)t=rC(t,e,e=>({...e,children:n,expanded:!0}));return t})},[]),ao=(0,W.useCallback)(async e=>{let t=await rN(e);""===e?eU(e=>{let a=new Map(e.map(e=>[e.path,e]));return t.map(e=>{let t=a.get(e.path);return t&&("dir"===t.type||"app"===t.type)?{...e,expanded:t.expanded,children:t.children}:e})}):eU(a=>rC(a,e,e=>({...e,children:t,expanded:!0})))},[]),[ac,ad]=(0,W.useState)(null),[au,am]=(0,W.useState)(null),[ap,ah]=(0,W.useState)(!1),[ax,af]=(0,W.useState)([]),[ag,ab]=(0,W.useState)(!1),[aw,ay]=(0,W.useState)(null),[av,aN]=(0,W.useState)(null),[aj,aC]=(0,W.useState)(!1),[aE,aS]=(0,W.useState)({}),[aM,aA]=(0,W.useState)({}),[aD,aT]=(0,W.useState)(null),[aO,aR]=(0,W.useState)(null),[aL,aP]=(0,W.useState)(null),aB=(0,W.useCallback)(async(e,t)=>{if(!ac){ad(e);try{let a=await (0,X.wsFetch)("/api/wiki/git-pull",{method:"POST",body:JSON.stringify({path:e})});if(!a.ok){let e=await a.json();(0,t1.showError)(e.message??e.error??"Pull failed");return}let n=await a.json();(0,t1.showSuccess)(`Pulled ${e} (${n.branch} @ ${n.sha.slice(0,7)})`),await ao(t)}catch{(0,t1.showError)("Pull failed")}finally{ad(null)}}},[ac,ao]);(0,W.useEffect)(()=>{ah(!1),af([]),ay(null),aN(null)},[tc?.path]);let a$=tc?.path;(0,W.useEffect)(()=>{if(!a$)return void am(null);let e=!1,t=setTimeout(()=>{(async()=>{try{let t=await (0,X.wsFetch)(`/api/wiki/git-file-info?path=${encodeURIComponent(a$)}`);if(e)return;if(!t.ok)return void am(null);let a=await t.json();e||am(a.info)}catch{e||am(null)}})()},200);return()=>{e=!0,clearTimeout(t)}},[a$]);let az=(0,W.useCallback)(async()=>{if(!tc)return;let e=tc.path;ah(!0),ab(!0),af([]),ay(null),aN(null);try{let t=await (0,X.wsFetch)(`/api/wiki/git-history?path=${encodeURIComponent(e)}`);if(!t.ok)return void(0,t1.showError)("Could not load history");let a=await t.json();tc.path===e&&af(a.commits)}catch{(0,t1.showError)("Could not load history")}finally{ab(!1)}},[tc]),aU=(0,W.useCallback)(async e=>{if(!tc)return;if(aw===e){ay(null),aN(null);return}let t=tc.path;ay(e),aC(!0),aN(null);try{let a=await (0,X.wsFetch)(`/api/wiki/git-diff?path=${encodeURIComponent(t)}&sha=${encodeURIComponent(e)}`);if(!a.ok)return void(0,t1.showError)("Could not load diff");let n=await a.json();tc.path===t&&aw===e&&aN(n.diff)}catch{(0,t1.showError)("Could not load diff")}finally{aC(!1)}},[tc,aw]),aq=(0,W.useCallback)(async e=>{if(aE[e]||aM[e])return;let t=!1;aA(t=>({...t,[e]:!0}));try{let a=await (0,X.wsFetch)(`/api/wiki/git-branches?path=${encodeURIComponent(e)}`);if(t)return;if(!a.ok)return void(0,t1.showError)("Could not load branches");let n=await a.json();t||aS(t=>({...t,[e]:n.branches}))}catch{t||(0,t1.showError)("Could not load branches")}finally{t||aA(t=>({...t,[e]:!1}))}return()=>{t=!0}},[aE,aM]),aK=(0,W.useCallback)(async(e,t,a)=>{if(!aD){aT(t);try{let n=await (0,X.wsFetch)("/api/wiki/git-checkout",{method:"POST",body:JSON.stringify({path:e,branch:t})});if(409===n.status)return void(0,t1.showError)("Repository has uncommitted changes");if(!n.ok){let e=await n.json();(0,t1.showError)(e.error??"Checkout failed");return}let r=await n.json();(0,t1.showSuccess)(`Switched to ${r.branch}`),aS(t=>{let a={...t};return delete a[e],a}),aR(null),aP(null),await ao(a)}catch{(0,t1.showError)("Checkout failed")}finally{aT(null)}}},[aD,ao]),aW=(0,W.useCallback)(e=>{let t=[];for(let a of e)("dir"===a.type||"app"===a.type||"node-app"===a.type)&&a.expanded&&a.children&&(t.push(a.path),t.push(...aW(a.children)));return t},[]),aH=(0,W.useRef)([]);(0,W.useEffect)(()=>{aH.current=aW(ez)},[ez,aW]);let aG=(0,W.useMemo)(()=>aW(ez).filter(e=>""!==e).slice(0,24).join("\n"),[ez,aW]),[aV,aZ]=(0,W.useState)("");(0,W.useEffect)(()=>{let e=setTimeout(()=>aZ(aG),300);return()=>clearTimeout(e)},[aG]);let aX=(0,W.useCallback)(async()=>{eZ(!0);try{let e=aW(ez),t=await rN("");for(let a of(eU(t),e)){let e=await rN(a);eU(t=>rC(t,a,t=>({...t,children:e,expanded:!0})))}}finally{eZ(!1)}},[ez,aW]),aJ=(0,W.useCallback)(async()=>{if(tc){if(rw(tc.name)){tQ(!0);try{await ns.useEditorStore.getState().loadPage(tc.path)}finally{tQ(!1)}return}if(["editor","text"].includes(rf(tc.name,tc.nodeType))||rb(tc.name)){tQ(!0);try{let e=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(tc.path)}`);if(e.ok){let t=await e.json();tV(t.content),tX(Number(e.headers.get("X-Wiki-Revision")??0))}}catch{}tQ(!1)}}},[tc]),aQ=(0,W.useCallback)(()=>{tj(e=>e+1),aJ()},[aJ]);async function aY(e){if("dir"===e.type||"app"===e.type||"node-app"===e.type)if(e.expanded)eU(t=>rC(t,e.path,e=>({...e,expanded:!1})));else if(void 0===e.children){let t=await r_(e.path);if(t)return void eU(a=>rC(a,e.path,e=>({...e,loading:!1,children:t,expanded:!0})));eU(t=>rC(t,e.path,e=>({...e,loading:!0})));let a=await rN(e.path);eU(t=>rC(t,e.path,e=>({...e,loading:!1,children:a,expanded:!0})))}else eU(t=>rC(t,e.path,e=>({...e,expanded:!0})))}async function a0(e){if("file"===e.type&&a1.getState().push({path:e.path,name:e.name},G),td({path:e.path,name:e.name,size:e.size,nodeType:"app"===e.type?"app":"node-app"===e.type?"node-app":"file"}),t0(!1),t4(!1),t8(null),tV(null),tX(0),"file"===e.type&&rw(e.name)){tQ(!0);try{await ns.useEditorStore.getState().loadPage(e.path)}finally{tQ(!1)}return}if(["editor","text"].includes(rf(e.name,e.type))||rb(e.name)){tQ(!0);try{let t=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e.path)}`);if(t.ok){let e=await t.json();tV(e.content),tX(Number(t.headers.get("X-Wiki-Revision")??0))}}catch{}tQ(!1)}}(0,W.useEffect)(()=>{tc&&rw(tc.name)&&ns.useEditorStore.getState().currentPath!==tc.path&&ns.useEditorStore.getState().loadPage(tc.path)},[tc]),(0,W.useEffect)(()=>{ar.current=tc},[tc]),(0,W.useEffect)(()=>{as.current=tY},[tY]),(0,W.useEffect)(()=>{ai.current=aJ},[aJ]),(0,W.useEffect)(()=>{if(!n||(0,tU.isLite)()||!G)return;let e=new Map;function t(t){e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),ao(t)},300))}let a=(aV?aV.split("\n"):[]).map(e=>`dir=${encodeURIComponent(e)}`).join("&"),r=new EventSource((0,X.withWs)(a?`/api/wiki/watch?${a}`:"/api/wiki/watch"));return r.onmessage=a=>{let n;try{n=JSON.parse(a.data)}catch{return}let{type:r,path:s}=n;if("rescan"===r){for(let e of(ri.useBacklinksStore.getState().invalidateAll(),t(""),aH.current))t(e);return}("add"===r||"change"===r||"unlink"===r)&&ri.useBacklinksStore.getState().invalidateAll();let i=s.split("/");if(t(i.length>1?i.slice(0,-1).join("/"):""),"change"===r&&ar.current?.path===s&&!as.current){let t=`__file__${s}`;e.has(t)&&clearTimeout(e.get(t)),e.set(t,setTimeout(()=>{e.delete(t),ai.current()},400))}},()=>{for(let t of(r.close(),e.values()))clearTimeout(t)}},[n,ao,G,aV]),(0,W.useEffect)(()=>{tw(!1)},[]);let a2=(0,W.useCallback)(e=>{let t=e.split("/").pop()??e;al(e),a0({path:e,name:t,type:"file"})},[al]),a5=(0,W.useCallback)(async e=>{let t=e.path.split("/").slice(0,-1).join("/"),a=(await rN(t)).find(t=>t.path===e.path);if(a){if("dir"===a.type){await al(e.path),await aY(a);return}if("app"===a.type||"node-app"===a.type){await al(a.path),a0({path:a.path,name:a.name,type:a.type,modifiedAt:a.modifiedAt}),await aY(a),tk&&tC(!0);return}a0({path:a.path,name:a.name,type:a.type,modifiedAt:a.modifiedAt}),tk&&tC(!0)}},[tk,a0,al,aY]);(0,W.useEffect)(()=>{if(!e_||tc&&tc.path===e_)return;let e=e_.split("/").pop()??e_;a0({path:e_,name:e,type:"file"})},[e_]);let a4=(0,W.useCallback)(async e=>{if(!e)return void td(null);let t=(0,X.toRootRelative)(e,(0,X.getEphemeralRoot)()??x);if(null===t||!(e=t))return;let a=e.split("/"),n=a[a.length-1],r=a.slice(0,-1).join("/"),s=(await rN(r)).find(t=>t.path===e);s&&(await al(e),a0({path:e,name:n,type:s.type,modifiedAt:s.modifiedAt}))},[al,x]);(0,W.useEffect)(()=>{let e=new URL(window.location.href);tc?e.searchParams.set("path",tc.path):e.searchParams.delete("path");let t=e.toString();t!==window.location.href&&window.history.pushState(null,"",t)},[tc]),(0,W.useEffect)(()=>{let e=()=>{a4(new URLSearchParams(window.location.search).get("path"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)},[a4]),(0,W.useEffect)(()=>{if(!eL)return;let e=e=>{e.origin!==window.location.origin?console.warn(`[wiki-viewer] ignored postMessage from untrusted parent origin ${e.origin}.`):e.data&&"open-file"===e.data.type&&"string"==typeof e.data.path&&a4(e.data.path)};return window.addEventListener("message",e),()=>window.removeEventListener("message",e)},[a4,eL]),(0,W.useEffect)(()=>{eF.current||eq&&(eF.current=!0,a4(eR.current))},[eq,a4]);let a7=(0,W.useCallback)(async e=>{if(e===G)return;try{await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/open`),{method:"POST"})}catch{}let t=new URL(location.href);t.searchParams.set("ws",e),t.searchParams.delete("path"),history.pushState(null,"",t.toString()),td(null),tV(null),t0(!1),eU([]),eK(!1),eG.current=!1,rs.useWikiSlugsStore.getState().invalidate(),ri.useBacklinksStore.getState().invalidateAll();let a=J.find(t=>t.id===e);a&&$(a.rootDir),Z(e)},[G,J]),a6=(0,W.useCallback)(async()=>{if(ed)try{if(!(await fetch((0,tU.apiUrl)(`/api/system/workspaces/${ed}`),{method:"DELETE"})).ok)throw Error("Failed");if(ed===G){let e=J.filter(e=>e.id!==ed);if(e.length>0){let t=[...e].sort((e,t)=>(t.lastOpenedAt??t.createdAt).localeCompare(e.lastOpenedAt??e.createdAt))[0];await a7(t.id)}else c(!1)}await ek()}catch{}finally{eu(null)}},[ed,G,J,a7,ek]),a8=(0,W.useCallback)(async e=>{if(!em){ep(e);try{let t=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/refresh`),{method:"POST"});if(!t.ok){let e=await t.json();(0,t1.showError)(e.error??"Refresh failed")}await ek()}catch{(0,t1.showError)("Refresh failed")}finally{ep(null)}}},[em,ek]),ne=(0,W.useCallback)(async e=>{if(!eh[e])try{let t=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/branch`));if(!t.ok)return;let a=await t.json();ex(t=>({...t,[e]:a.branches??[]}))}catch{}},[eh]),nt=(0,W.useCallback)(async(e,t)=>{if(!ef){eg(e),ew(t);try{let a=await fetch((0,tU.apiUrl)(`/api/system/workspaces/${e}/branch`),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:t})});if(!a.ok){let e=await a.json();(0,t1.showError)(e.error??"Branch switch failed");return}(0,t1.showSuccess)(`Switched to ${t}`),ev(null),ej(null),await ek()}catch{(0,t1.showError)("Branch switch failed")}finally{eg(null),ew(null)}}},[ef,ek]);async function na(){if(!tc)return;t7(!0),t8(null);let e=await (0,X.wsFetch)("/api/wiki/content",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:tc.path,content:t2,baseRevision:tZ})});if(e.ok){let t=await e.json();"number"==typeof t.revision&&tX(t.revision),tV(t2),t0(!1)}else t8((await e.json()).error??"Save failed");t7(!1)}let nn=(0,W.useCallback)(async(e,t)=>{let a=Array.from(e);if(a.length){eJ(!0),eY(null);try{for(let e of a){let a=new FormData;a.append("file",e),a.append("dir",t);let n=await (0,X.wsFetch)("/api/wiki/upload",{method:"POST",body:a});if(!n.ok){let e=await n.json();eY(e.error??"Upload failed"),(0,t1.showError)(e.error??"Upload failed");break}}await ao(t)}catch{eY("Upload failed.")}finally{eJ(!1),e0.current&&(e0.current.value="")}}},[ao]);function nr(e){e1.current=e,e0.current?.click()}async function ni(){let e=e3.trim();if(!e||null===e2)return;e7(null);let t=e2?`${e2}/${e}`:e,a=await (0,X.wsFetch)("/api/wiki/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:t})});a.ok?(e5(null),e4(""),await ao(e2),""!==e2&&eU(e=>rC(e,e2,e=>({...e,expanded:!0})))):e7((await a.json()).error??"Failed")}async function nl(){let e=te.trim();if(!e||null===e6)return;tr(null);let t=e.includes(".")?e:`${e}.md`,a=e6?`${e6}/${t}`:t,n=await (0,X.wsFetch)("/api/wiki/new-file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:a})});n.ok?(e8(null),tt(""),await ao(e6),""!==e6&&eU(e=>rC(e,e6,e=>({...e,expanded:!0}))),a0({path:a,name:t,type:"file",modifiedAt:new Date().toISOString()})):tr((await n.json()).error??"Failed")}function no(e){navigator.clipboard.writeText(e),(0,t1.showSuccess)("Path copied")}function nc(e){let t=e.replace(/\.(md|markdown)$/i,"");navigator.clipboard.writeText(`[[${t}]]`),(0,t1.showSuccess)("Wiki link copied")}function nd(e){let t=new URL(location.href);t.searchParams.set("path",e),G&&t.searchParams.set("ws",G),navigator.clipboard.writeText(t.toString()),(0,t1.showSuccess)("URL copied")}async function nu(e){if(tc?.path===e&&null!==tG)return tG;if(ns.useEditorStore.getState().currentPath===e)return ns.useEditorStore.getState().content;let t=await (0,X.wsFetch)(`/api/wiki/content?path=${encodeURIComponent(e)}`);if(!t.ok)throw Error("Cannot copy content");return(await t.json()).content}async function nm(e){try{let t=await nu(e);await navigator.clipboard.writeText(t),(0,t1.showSuccess)("Raw content copied")}catch{(0,t1.showError)("Could not copy file content")}}async function nh(e,t){try{let a=await nu(e);if(!rw(t)){await navigator.clipboard.writeText(a),(0,t1.showSuccess)("Content copied");return}let n=await (0,tn.markdownToHtml)(a,{pagePath:e,sanitize:!0});"ClipboardItem"in window&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([n],{type:"text/html"}),"text/plain":new Blob([a],{type:"text/plain"})})]):await navigator.clipboard.writeText(a),(0,t1.showSuccess)("Formatted content copied")}catch{(0,t1.showError)("Could not copy formatted content")}}function nx(e,a){return(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"File actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-52",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>no(e.path),children:[(0,t.jsx)(o.Copy,{className:"mr-2 h-3.5 w-3.5"}),"Copy path"]}),rw(e.name)&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nc(e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy wiki link"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nd(e.path),children:[(0,t.jsx)(k.Link,{className:"mr-2 h-3.5 w-3.5"}),"Copy URL"]}),rb(e.name)&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void nm(e.path),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy raw content"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void nh(e.path,e.name),children:[(0,t.jsx)(p.FileText,{className:"mr-2 h-3.5 w-3.5"}),"Copy formatted content"]})]}),a&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),a]})]})]})}async function nf(){ts&&(await (0,X.wsFetch)("/api/wiki",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:ts})}),(tc?.path===ts||tc?.path.startsWith(`${ts}/`))&&(td(null),tV(null)),eU(e=>(function e(t,a){return t.filter(e=>e.path!==a).map(t=>t.children?{...t,children:e(t.children,a)}:t)})(e,ts)),ti(null))}function ng(e,t,a){e.preventDefault(),e.stopPropagation();let n=ae.current;if(!n){Array.from(e.dataTransfer.types).includes("Files")&&(e.dataTransfer.dropEffect="copy",an("root"===a?"":t));return}n.path===t||t.startsWith(`${n.path}/`)||(e.dataTransfer.dropEffect="move",an("root"===a?"":t))}async function nb(e,t){e.preventDefault(),e.stopPropagation(),an(null);let a=ae.current;if(ae.current=null,!a){e.dataTransfer.files.length>0&&await nn(e.dataTransfer.files,t);return}if(a.path===t||t.startsWith(`${a.path}/`))return;let n=t?`${t}/${a.name}`:a.name;if(n!==a.path&&(await (0,X.wsFetch)("/api/wiki/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({from:a.path,to:n})})).ok){let e=a.path.includes("/")?a.path.split("/").slice(0,-1).join("/"):"";await ao(e),t!==e&&await ao(t),tc?.path===a.path&&td({path:n,name:a.name,nodeType:tc.nodeType,size:tc.size})}}let nw=tc?rf(tc.name,tc.nodeType):null,ny=!!tc&&null!==nw&&!rh.has(nw)&&(tc.size??0)>5242880&&tu!==tc.path,nv=(0,n6.useViewWidthStore)(e=>e.width),nN=(0,n6.useViewWidthStore)(e=>e.align),nj=(0,n6.useViewWidthStore)(e=>e.setWidth),nk=(0,n6.useViewWidthStore)(e=>e.setAlign),n_=null===nw||"editor"===nw||"text"===nw||"source"===nw||"notebook"===nw||"fallback"===nw,nC=n_?n6.VIEW_WIDTH_CLASS[nv]:"",nE=n_?n6.VIEW_ALIGN_CLASS[nN]:"",nS=(0,W.useRef)(null);nS.current={toggleFolder:e=>void aY(e),openViewer:e=>void a0(e),copyPath:no,copyWikiLink:nc,copyUrl:nd,copyRawContent:e=>void nm(e),copyFormattedContent:(e,t)=>void nh(e,t),handleDownload:function(e){let t=(0,X.withWs)(`/api/wiki/download?path=${encodeURIComponent(e.path)}`),a=document.createElement("a");a.href=t,a.download="file"===e.type?e.name:`${e.name}.zip`,document.body.appendChild(a),a.click(),a.remove()},triggerUpload:nr,handleCreateFile:()=>void nl(),handleCreateFolder:()=>void ni(),handleDragStart:function(e,t){ae.current=t,e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",t.path)},handleDragOver:ng,handleDropOnFolder:(e,t)=>void nb(e,t),handleGitPull:(e,t)=>void aB(e,t),handleCheckout:(e,t,a)=>void aK(e,t,a),loadBranches:e=>void aq(e),prefetch:e=>{"file"===e.type?rw(e.name)&&(0,ns.prefetchPage)(e.path):function(e){if(rj.has(e)||rk.has(e))return;let t=rN(e).then(t=>(rj.set(e,t),t)).finally(()=>rk.delete(e));rk.set(e,t),t.catch(()=>{})}(e.path)},togglePin:(e,t)=>a3.getState().toggle({path:e.path,name:e.name,type:e.type},t),setDragOverPath:an,setSidebarCollapsed:tC,setBranchDropdownNode:aR,setBranchDropdownPos:aP,setNewFileParent:e8,setNewFileName:tt,setFileCreateError:tr,setNewFolderParent:e5,setNewFolderName:e4,setFolderError:e7,setDeletingPath:ti,setDeletingIsDir:to};let nM=(0,W.useMemo)(()=>({toggleFolder:e=>nS.current.toggleFolder(e),openViewer:e=>nS.current.openViewer(e),copyPath:e=>nS.current.copyPath(e),copyWikiLink:e=>nS.current.copyWikiLink(e),copyUrl:e=>nS.current.copyUrl(e),copyRawContent:e=>nS.current.copyRawContent(e),copyFormattedContent:(e,t)=>nS.current.copyFormattedContent(e,t),handleDownload:e=>nS.current.handleDownload(e),triggerUpload:e=>nS.current.triggerUpload(e),handleCreateFile:()=>nS.current.handleCreateFile(),handleCreateFolder:()=>nS.current.handleCreateFolder(),handleDragStart:(e,t)=>nS.current.handleDragStart(e,t),handleDragOver:(e,t,a)=>nS.current.handleDragOver(e,t,a),handleDropOnFolder:(e,t)=>nS.current.handleDropOnFolder(e,t),handleGitPull:(e,t)=>nS.current.handleGitPull(e,t),handleCheckout:(e,t,a)=>nS.current.handleCheckout(e,t,a),loadBranches:e=>nS.current.loadBranches(e),prefetch:e=>nS.current.prefetch(e),togglePin:(e,t)=>nS.current.togglePin(e,t),setDragOverPath:e=>nS.current.setDragOverPath(e),setSidebarCollapsed:e=>nS.current.setSidebarCollapsed(e),setBranchDropdownNode:e=>nS.current.setBranchDropdownNode(e),setBranchDropdownPos:e=>nS.current.setBranchDropdownPos(e),setNewFileParent:e=>nS.current.setNewFileParent(e),setNewFileName:e=>nS.current.setNewFileName(e),setFileCreateError:e=>nS.current.setFileCreateError(e),setNewFolderParent:e=>nS.current.setNewFolderParent(e),setNewFolderName:e=>nS.current.setNewFolderName(e),setFolderError:e=>nS.current.setFolderError(e),setDeletingPath:e=>nS.current.setDeletingPath(e),setDeletingIsDir:e=>nS.current.setDeletingIsDir(e)}),[]);return(0,t.jsxs)("div",{className:"flex h-screen gap-0 overflow-hidden bg-background",children:[null===n&&(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}),!1===n&&(0,t.jsx)(tq,{onSelect:e=>{let t=new URL(location.href);t.searchParams.set("ws",e),t.searchParams.delete("path"),history.replaceState(null,"",t.toString()),eK(!1),eG.current=!1,Z(e),c(!0),ek()}}),!0===n&&er&&(0,t.jsxs)("div",{className:"flex-1 flex flex-col",children:[(0,t.jsx)("div",{className:"flex items-center justify-end border-b px-3 py-2 bg-muted shrink-0",children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1.5 text-xs",onClick:()=>eo(!1),children:[(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})," Cancel"]})}),(0,t.jsx)(tq,{onSelect:e=>{eo(!1),ek(),a7(e)}})]}),!0===n&&!er&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(re,{onOpenFile:a2,recents:eC,onToggleSidebar:()=>tC(e=>{let t=!e;return tk&&!1===t&&a9.useAIPanelStore.getState().close(),t}),onNewFile:()=>e8(""),onCopyPath:()=>{tc&&navigator.clipboard.writeText(tc.path)}}),!eB&&!t_&&tk&&(0,t.jsx)("div",{className:"fixed inset-0 z-40 bg-overlay backdrop-blur-[1px] md:hidden",onClick:()=>tC(!0),"aria-hidden":!0}),!eB&&!t_&&(0,t.jsxs)(a_.Card,{style:tk?void 0:{width:tE},className:"fixed inset-y-0 left-0 z-50 w-[85vw] max-w-[20rem] md:relative md:z-auto md:w-auto md:max-w-none flex flex-col shrink-0 overflow-hidden rounded-none border-r border-l-0 border-t-0 border-b-0",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b bg-muted shrink-0",children:[(0,t.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",title:"Wiki Viewer v2.9.0",children:[(0,t.jsx)("img",{src:(0,tU.apiUrl)("/logo.svg"),alt:"Wiki Viewer",className:"h-5 w-5 shrink-0"}),(0,t.jsx)("span",{className:"truncate text-xs font-semibold leading-5 tracking-tight translate-y-[0.5px]",children:"Wiki Viewer"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0 shrink-0",title:"Collapse sidebar",onClick:()=>tC(!0),children:(0,t.jsx)(M,{className:"h-3.5 w-3.5"})})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-1 px-3 py-1.5 border-b bg-muted/50 shrink-0",children:[(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 px-2 text-xs",disabled:eX,children:[eX?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(R,{className:"h-3.5 w-3.5"}),"New",(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3 opacity-60"})]})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"start",className:"w-44",children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{e8(""),tt(""),tr(null)},children:[(0,t.jsx)(m.FilePlus,{className:"mr-2 h-3.5 w-3.5"}),"New file"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{e5(""),e4(""),e7(null)},children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"New folder"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nr(""),disabled:eX,children:[(0,t.jsx)(q.Upload,{className:"mr-2 h-3.5 w-3.5"}),"Upload"]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-0.5",children:[(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Refresh tree",onClick:aX,disabled:eV,children:eV?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(F,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"AI Agent panel",onClick:()=>{a9.useAIPanelStore.getState().toggle(),tk&&tC(!0)},children:(0,t.jsx)(r,{className:"h-3.5 w-3.5"})}),(0,t.jsxs)(tR.DropdownMenu,{children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"More actions",children:(0,t.jsx)(E,{className:"h-3.5 w-3.5"})})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"end",className:"w-48",children:[Y&&J.find(e=>e.id===G)?.git&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{G&&a8(G)},disabled:em===G,children:[em===G?(0,t.jsx)(_.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(d,{className:"mr-2 h-3.5 w-3.5"}),"Pull latest"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>ro.getState().toggle(),children:[tS?(0,t.jsx)(O,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(T.Eye,{className:"mr-2 h-3.5 w-3.5"}),tS?"Hide hidden files":"Show hidden files"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>rd.getState().toggle(),children:[(0,t.jsx)(z.Type,{className:"mr-2 h-3.5 w-3.5"}),tM?"Raw file names":"Humanize names"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tO("dark"===tD?"light":"dark"),children:["dark"===tD?(0,t.jsx)(B.Sun,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(S.Moon,{className:"mr-2 h-3.5 w-3.5"}),"dark"===tD?"Light mode":"Dark mode"]}),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>t$(!0),children:[(0,t.jsx)(L,{className:"mr-2 h-3.5 w-3.5"}),"Settings"]})]})]})]})]}),eQ&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs text-destructive bg-destructive/10 shrink-0",children:[(0,t.jsx)(a.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),eQ]}),""===e2&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,t.jsx)(h.Folder,{className:"h-4 w-4 shrink-0 text-warning"}),(0,t.jsx)("input",{className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"Folder name",value:e3,onChange:e=>e4(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ni(),"Escape"===e.key&&(e5(null),e4(""))}}),e9&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:e9}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:ni,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{e5(null),e4("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]}),""===e6&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 px-2 py-1 border-b shrink-0",children:[(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-accent"}),(0,t.jsx)("input",{autoFocus:!0,className:"flex-1 bg-transparent text-sm outline-none border-b border-border min-w-0",placeholder:"filename (default .md)",value:te,onChange:e=>tt(e.target.value),onKeyDown:e=>{"Enter"===e.key&&nl(),"Escape"===e.key&&(e8(null),tt(""))}}),ta&&(0,t.jsx)("span",{className:"text-xs text-destructive",children:ta}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:nl,children:(0,t.jsx)(s.Check,{className:"h-3 w-3"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:()=>{e8(null),tt("")},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]}),(0,t.jsx)("div",{className:"border-b",children:(0,t.jsx)(rt,{onOpenFile:a2})}),(0,t.jsxs)("div",{ref:eT,className:(0,tf.cn)("flex-1 overflow-auto py-1 editorial-file-tree",""===at&&"ring-2 ring-inset ring-primary bg-primary/5"),onDragOver:e=>ng(e,"","root"),onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||an(null)},onDrop:e=>nb(e,""),children:[eD.length>0&&(0,t.jsxs)("div",{className:"border-b mb-1",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>eS(e=>!e),children:[eE?(0,t.jsx)(l.ChevronRight,{className:"h-3 w-3"}):(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3"}),(0,t.jsx)(I,{className:"h-3 w-3"}),"Pinned",(0,t.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:eD.length})]}),!eE&&eD.map(e=>(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"button",tabIndex:0,className:(0,tf.cn)("group flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",tc?.path===e.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{a5(e)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a5(e))},children:[(0,t.jsx)(rM,{name:e.name,type:e.type??"file"}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs",title:tM?e.name:void 0,children:tM?ru(e.name):e.name}),(0,t.jsx)("span",{className:"max-w-[80px] truncate text-[10px] text-muted-foreground/60",children:e.path.split("/").slice(0,-1).join("/")}),(0,t.jsx)("button",{type:"button",className:"hover-reveal shrink-0 rounded p-0.5 text-muted-foreground/50 opacity-0 transition-colors hover:bg-muted hover:text-amber-400 group-hover:opacity-100 focus:opacity-100",title:"Remove from pinned",onClick:t=>{t.stopPropagation(),a3.getState().toggle({path:e.path,name:e.name},G)},children:(0,t.jsx)(K.X,{className:"h-3 w-3"})})]})}),(0,t.jsx)(rS,{node:{path:e.path,name:e.name,type:e.type??"file"},ctx:nM,isPinned:!0,activeWorkspaceId:G})]},e.path))]}),eC.length>0&&(0,t.jsxs)("div",{className:"border-b mb-1",children:[(0,t.jsxs)("button",{type:"button",className:"flex w-full items-center gap-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground hover:text-foreground",onClick:()=>eA(e=>!e),children:[eM?(0,t.jsx)(l.ChevronRight,{className:"h-3 w-3"}):(0,t.jsx)(i.ChevronDown,{className:"h-3 w-3"}),(0,t.jsx)(v,{className:"h-3 w-3"}),"Recent",(0,t.jsx)("span",{className:"ml-auto text-[9px] tabular-nums opacity-60",children:eC.length})]}),!eM&&eC.slice(0,8).map(e=>(0,t.jsxs)(aI,{children:[(0,t.jsx)(aF,{asChild:!0,children:(0,t.jsxs)("div",{role:"button",tabIndex:0,className:(0,tf.cn)("flex items-center gap-1.5 rounded-sm px-2 py-1 text-sm cursor-pointer transition-colors select-none",tc?.path===e.path?"bg-accent-soft text-foreground font-medium":"hover:bg-muted"),onClick:()=>{a0({path:e.path,name:e.name,type:e.type??"file",modifiedAt:""}),tk&&tC(!0)},onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),a0({path:e.path,name:e.name,type:e.type??"file",modifiedAt:""}))},children:[(0,t.jsx)(rM,{name:e.name,type:e.type??"file"}),(0,t.jsx)("span",{className:"flex-1 truncate text-xs",title:tM?e.name:void 0,children:tM?ru(e.name):e.name}),(0,t.jsx)("span",{className:"text-[10px] text-muted-foreground/60 truncate max-w-[80px]",children:e.path.split("/").slice(0,-1).join("/")})]})}),(0,t.jsx)(rS,{node:{path:e.path,name:e.name,type:e.type??"file"},ctx:nM,isPinned:eD.some(t=>t.path===e.path),activeWorkspaceId:G})]},e.path))]}),eW?(0,t.jsx)("div",{className:"flex justify-center py-6",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):0===ez.length?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 px-4 py-8 text-center",children:[(0,t.jsx)("div",{className:"rounded-full bg-muted p-3",children:(0,t.jsx)(p.FileText,{className:"h-6 w-6 text-muted-foreground"})}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"No files yet"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload files or add them to the configured directory"})]}),(0,t.jsxs)(H.Button,{size:"sm",variant:"outline",className:"w-full gap-1.5 max-w-[180px]",onClick:()=>nr(""),disabled:eX,children:[eX?(0,t.jsx)(_.Loader2,{className:"h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(q.Upload,{className:"h-3.5 w-3.5"}),"Upload Files"]})]}):(0,t.jsx)(rD,{ctx:nM,nodes:ez,openPath:tc?.path??null,dragOverPath:at,branchDropdownNode:aO,branchDropdownPos:aL,nodeBranches:aE,branchesLoading:aM,checkingOutBranch:aD,pullingRepo:ac,activePaths:eI,pins:eD,isMobile:tk,activeWorkspaceId:G,newFileParent:e6,newFileName:te,fileCreateError:ta,newFolderParent:e2,newFolderName:e3,folderError:e9,sidebarScrollRef:eT})]}),(0,t.jsxs)("div",{className:"border-t px-2 py-2 bg-muted shrink-0",children:[(0,t.jsxs)(tR.DropdownMenu,{modal:!1,onOpenChange:e=>{e||(ev(null),ej(null))},children:[(0,t.jsx)(tR.DropdownMenuTrigger,{asChild:!0,children:(0,t.jsxs)(H.Button,{size:"sm",variant:"ghost",className:"w-full h-auto justify-between gap-2 px-2 py-1.5 text-left",title:x??"",children:[(0,t.jsxs)("span",{className:"flex flex-col min-w-0",children:[(0,t.jsx)("span",{className:"truncate text-xs font-medium",children:J.find(e=>e.id===G)?.name??"Workspace"}),(0,t.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:x??""})]}),(0,t.jsx)(i.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 opacity-60"})]})}),(0,t.jsxs)(tR.DropdownMenuContent,{align:"start",className:"w-[var(--radix-dropdown-menu-trigger-width)]",onInteractOutside:e=>{e.target?.closest?.("[data-branch-portal]")&&e.preventDefault()},children:[J.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>void a7(e.id),onPointerMove:e=>e.preventDefault(),onPointerLeave:e=>e.preventDefault(),className:(0,tf.cn)("gap-2",e.id===G&&"font-medium"),children:[e.id===G?(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5 shrink-0"}):(0,t.jsx)("span",{className:"w-3.5 shrink-0"}),(0,t.jsxs)("span",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5 truncate",children:[(0,t.jsx)("span",{className:"truncate",children:e.name}),e.git?Y?(0,t.jsxs)("button",{"data-branch-trigger":!0,type:"button",className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0 hover:bg-accent",title:"Switch branch",disabled:ef===e.id,onClick:t=>{if(t.stopPropagation(),t.preventDefault(),ey===e.id){ev(null),ej(null);return}let a=t.currentTarget.getBoundingClientRect();ej({top:a.bottom+4,left:a.left}),ev(e.id),ne(e.id)},children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," ",e.git.branch??"branch"]}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," ",e.git.branch??"read-only"]}):e.ssh?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(b,{className:"h-2.5 w-2.5"})," ",e.ssh.host]}):e.readOnly?(0,t.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded bg-muted px-1.5 text-[10px] text-muted-foreground font-normal shrink-0",children:[(0,t.jsx)(g,{className:"h-2.5 w-2.5"})," read-only"]}):null]}),(0,t.jsx)("span",{className:"truncate text-[10px] text-muted-foreground font-mono",children:e.rootDir}),e.git?.lastPulledAt&&rp(e.git.lastPulledAt)&&(0,t.jsxs)("span",{className:"text-[10px] text-muted-foreground/70",children:["synced ",rp(e.git.lastPulledAt)]})]}),Y&&e.git&&(0,t.jsx)("button",{className:(0,tf.cn)("shrink-0 rounded p-0.5 hover:bg-accent transition-colors",e.git.lastError?"text-destructive":"text-muted-foreground hover:text-foreground"),title:e.git.lastError?`Last refresh failed: ${e.git.lastError}`:"Refresh",disabled:em===e.id,onClick:t=>{t.stopPropagation(),t.preventDefault(),a8(e.id)},children:(0,t.jsx)(F,{className:(0,tf.cn)("h-3.5 w-3.5",em===e.id&&"animate-spin")})}),Y&&(0,t.jsx)("button",{className:"shrink-0 rounded p-0.5 text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors",title:"Delete workspace (does not delete files)",onClick:t=>{t.stopPropagation(),eu(e.id)},children:(0,t.jsx)(U.Trash2,{className:"h-3.5 w-3.5"})})]},e.id)),Y&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>eo(!0),children:[(0,t.jsx)(f,{className:"mr-2 h-3.5 w-3.5"}),"Add workspace…"]})]})]})]}),(()=>{if(!ey||!eN)return null;let e=J.find(e=>e.id===ey);return e?(0,t.jsx)(tW,{pos:eN,branches:(eh[e.id]??[]).map(t=>({name:t,current:t===e.git?.branch})),loading:!eh[e.id],busyName:ef===e.id?eb:null,disabled:ef===e.id,onPick:t=>{nt(e.id,t)},onClose:()=>{ev(null),ej(null)}}):null})()]}),(0,t.jsx)("div",{role:"separator","aria-orientation":"vertical","aria-label":"Resize sidebar",title:"Drag to resize",onMouseDown:e=>{e.preventDefault();let t=e.clientX;tP(!0);let a=document.body.style.cursor,n=document.body.style.userSelect;document.body.style.cursor="col-resize",document.body.style.userSelect="none";let r=e=>{tI(tE+(e.clientX-t))},s=()=>{tP(!1),document.body.style.cursor=a,document.body.style.userSelect=n,window.removeEventListener("mousemove",r),window.removeEventListener("mouseup",s)};window.addEventListener("mousemove",r),window.addEventListener("mouseup",s)},onDoubleClick:()=>tI(288),onKeyDown:e=>{"ArrowLeft"===e.key?(e.preventDefault(),tI(tE-16)):"ArrowRight"===e.key&&(e.preventDefault(),tI(tE+16))},tabIndex:0,"aria-valuemin":200,"aria-valuemax":600,"aria-valuenow":tE,className:(0,tf.cn)("absolute right-0 top-0 z-20 h-full w-1.5 cursor-col-resize -mr-px transition-colors hover:bg-primary/40 focus:bg-primary/40 focus:outline-none hidden md:block",tF&&"bg-primary/60")})]}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 relative",children:[!eB&&t_&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"hidden md:flex absolute left-2 top-2 z-10 h-7 w-7 p-0",title:"Show sidebar",onClick:()=>tC(!1),children:(0,t.jsx)(A,{className:"h-3.5 w-3.5"})}),!eB&&(0,t.jsxs)("div",{className:"md:hidden flex h-11 shrink-0 items-center justify-between gap-2 border-b bg-muted px-1",children:[(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"Show sidebar",onClick:()=>{tC(!1),a9.useAIPanelStore.getState().close()},children:(0,t.jsx)(A,{className:"h-4 w-4"})}),(0,t.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-semibold tracking-tight text-muted-foreground",title:tc?.path,children:[tc&&(0,t.jsx)("span",{className:"editorial-tree-typeicon shrink-0",children:"app"===nw||"html"===nw?(0,t.jsx)(y.Globe,{className:"h-4 w-4 text-foreground/70"}):ry(tc.name)?(0,t.jsx)(j.Image,{className:"h-4 w-4 text-sunshine-700"}):rb(tc.name)?(0,t.jsx)(p.FileText,{className:"h-4 w-4 text-foreground/70"}):(0,t.jsx)(u.File,{className:"h-4 w-4 text-foreground/60"})}),(0,t.jsx)("span",{className:"truncate",children:tc?tc.name:"Wiki Viewer"})]}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-9 w-9 p-0",title:"AI Agent panel",onClick:()=>{a9.useAIPanelStore.getState().open(),tC(!0)},children:(0,t.jsx)(r,{className:"h-4 w-4"})})]}),tc?"node-app"===nw?(0,t.jsx)(tL,{path:tc.path,title:tc.name}):"app"===nw||"html"===nw?(e="html"===nw?(0,X.withWs)(`/api/assets/${tc.path}`):void 0,tb?(0,t.jsx)(tT,{path:tc.path,title:tc.name,src:e,fullscreen:!0,onExit:()=>tw(!1)}):(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,t.jsxs)("div",{className:(0,tf.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!tk&&t_&&"pl-11"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"hidden md:inline-flex",children:(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:(0,t.jsx)(y.Globe,{className:"h-4 w-4 shrink-0 text-foreground/70"})})}),(0,t.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:tc.path,children:tc.path})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[nx(tc,(0,t.jsxs)(t.Fragment,{children:["html"===nw&&!tY&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>t4(e=>!e),children:[t3?(0,t.jsx)(y.Globe,{className:"mr-2 h-3.5 w-3.5"}):(0,t.jsx)(w.Code2,{className:"mr-2 h-3.5 w-3.5"}),t3?"Show preview":"Show source"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tv(e=>e+1),children:[(0,t.jsx)(F,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tw(!0),children:[(0,t.jsx)(C,{className:"mr-2 h-3.5 w-3.5"}),"Open fullscreen"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tK(!0),children:[(0,t.jsx)(P,{className:"mr-2 h-3.5 w-3.5"}),"Share"]})]})),"html"===nw&&!tY&&null!==tG&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Edit source",onClick:()=>{t0(!0),t5(tG),t8(null)},children:(0,t.jsx)(D,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{td(null),t0(!1)},children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]})]}),tY&&"html"===nw?(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,t.jsx)("textarea",{value:t2,onChange:e=>t5(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"}),(0,t.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[t6&&(0,t.jsx)("span",{className:"text-xs text-destructive mr-auto",children:t6}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",onClick:()=>{t0(!1),t8(null)},children:"Cancel"}),(0,t.jsxs)(H.Button,{size:"sm",className:"gap-1",onClick:na,disabled:t9,children:[t9&&(0,t.jsx)(_.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):t3&&"html"===nw?(0,t.jsx)(tA,{path:tc.path,title:tc.name}):(0,t.jsx)(tT,{path:tc.path,title:tc.name,src:e},ty)]})):(0,t.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[(0,t.jsxs)("div",{className:(0,tf.cn)("flex items-center justify-between px-4 py-2 border-b bg-muted shrink-0 editorial-doc-header",!tk&&t_&&"pl-11"),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,t.jsx)("span",{className:"hidden md:inline-flex",children:(0,t.jsx)("span",{className:"editorial-tree-typeicon",children:ry(tc.name)?(0,t.jsx)(j.Image,{className:"h-4 w-4 shrink-0 text-sunshine-700"}):rb(tc.name)?(0,t.jsx)(p.FileText,{className:"h-4 w-4 shrink-0 text-foreground/70"}):(0,t.jsx)(u.File,{className:"h-4 w-4 shrink-0 text-foreground/60"})})}),(0,t.jsx)("span",{className:"hidden md:inline text-sm font-normal truncate",title:tc.path,children:tc.path}),au&&(0,t.jsxs)("span",{className:"hidden md:flex items-center gap-1 text-[11px] text-muted-foreground shrink-0 ml-1",children:[(0,t.jsx)(N,{className:"h-3 w-3 shrink-0"}),(0,t.jsx)("span",{className:"truncate max-w-[100px]",children:au.author}),(0,t.jsx)("span",{title:new Date(au.date).toLocaleString(),className:"shrink-0",children:rp(au.date)})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 shrink-0",children:[nx(tc,(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>{ap?ah(!1):az()},children:[(0,t.jsx)(v,{className:"mr-2 h-3.5 w-3.5"}),ap?"Hide history":"File history"]}),(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>tK(!0),children:[(0,t.jsx)(P,{className:"mr-2 h-3.5 w-3.5"}),"Share"]}),!tY&&(0,t.jsxs)(tR.DropdownMenuItem,{onClick:aQ,disabled:tJ,children:[tJ?(0,t.jsx)(_.Loader2,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):(0,t.jsx)(F,{className:"mr-2 h-3.5 w-3.5"}),"Refresh"]}),n_&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsx)(tR.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Width"}),n6.VIEW_WIDTH_ORDER.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nj(e),className:"flex items-center justify-between text-xs",children:[n6.VIEW_WIDTH_LABEL[e],e===nv&&(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5"})]},e)),(0,t.jsx)(tR.DropdownMenuSeparator,{}),(0,t.jsx)(tR.DropdownMenuLabel,{className:"text-[11px] text-muted-foreground",children:"Alignment"}),n6.VIEW_ALIGN_ORDER.map(e=>(0,t.jsxs)(tR.DropdownMenuItem,{onClick:()=>nk(e),className:"flex items-center justify-between text-xs",children:[n6.VIEW_ALIGN_LABEL[e],e===nN&&(0,t.jsx)(s.Check,{className:"h-3.5 w-3.5"})]},e))]})]})),rb(tc.name)&&!tY&&(null!==tG||rw(tc.name))&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{t0(!0),t5(tG??""),t8(null),rw(tc.name)&&ns.useEditorStore.getState().loadPage(tc.path)},children:(0,t.jsx)(D,{className:"h-3.5 w-3.5"})}),rb(tc.name)&&tY&&rw(tc.name)&&(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",title:"Done editing",onClick:()=>{t0(!1),t8(null)},children:(0,t.jsx)(T.Eye,{className:"h-3.5 w-3.5"})}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 p-0",onClick:()=>{td(null),tV(null),t0(!1)},children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]})]}),ap&&(0,t.jsxs)("div",{className:"border-b bg-muted/30 shrink-0 max-h-[40vh] overflow-auto",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-4 py-1.5 border-b",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-muted-foreground",children:"History"}),(0,t.jsx)("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>ah(!1),children:(0,t.jsx)(K.X,{className:"h-3.5 w-3.5"})})]}),ag?(0,t.jsx)("div",{className:"flex justify-center py-4",children:(0,t.jsx)(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):0===ax.length?(0,t.jsx)("p",{className:"px-4 py-3 text-xs text-muted-foreground",children:"No history found."}):(0,t.jsx)("div",{children:ax.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("button",{type:"button",className:(0,tf.cn)("w-full text-left px-4 py-2 hover:bg-muted transition-colors",aw===e.sha&&"bg-muted"),onClick:()=>void aU(e.sha),children:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("code",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:e.shortSha}),(0,t.jsx)("span",{className:"flex-1 truncate text-xs",children:e.message}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e.author}),(0,t.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",title:new Date(e.date).toLocaleString(),children:rp(e.date)})]})}),aw===e.sha&&(0,t.jsx)("div",{className:"border-t",children:aj?(0,t.jsx)("div",{className:"flex justify-center py-3",children:(0,t.jsx)(_.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):null!==av?(0,t.jsx)("pre",{className:"overflow-auto px-4 py-2 text-[11px] font-mono leading-relaxed whitespace-pre text-foreground/80 max-h-60",children:av}):null})]},e.sha))})]}),ny?(0,t.jsx)(es,{path:tc.path,size:tc.size??0,onOpen:()=>tp(tc.path)}):tY?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:rw(tc.name)?(0,t.jsx)(et.KBEditor,{}):(0,t.jsx)("textarea",{value:t2,onChange:e=>t5(e.target.value),spellCheck:!1,className:"flex-1 w-full min-h-0 resize-none bg-background text-foreground px-4 py-3 font-mono text-[13px] leading-relaxed outline-none border-0"})}):rw(tc.name)?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):(0,t.jsx)(et.KBEditor,{mode:"viewing"})}):"csv"===nw||"pdf"===nw||"mermaid"===nw||"notebook"===nw||"image"===nw||"media"===nw||"docx"===nw||"xlsx"===nw||"pptx"===nw||"source"===nw||"fallback"===nw?(0,t.jsx)("div",{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):"csv"===nw?(0,t.jsx)(ee,{path:tc.path,title:tc.name}):"pdf"===nw?(0,t.jsx)(rm,{path:tc.path,title:tc.name}):"mermaid"===nw?(0,t.jsx)(ec,{path:tc.path,title:tc.name}):"notebook"===nw?(0,t.jsx)(tm,{path:tc.path,title:tc.name}):"image"===nw?(0,t.jsx)(ei,{path:tc.path,title:tc.name}):"media"===nw?(0,t.jsx)(el,{path:tc.path,title:tc.name,type:["mp4","webm","mov","m4v"].includes(rx(tc.name))?"video":"audio"}):"docx"===nw?(0,t.jsx)(th,{path:tc.path,title:tc.name}):"xlsx"===nw?(0,t.jsx)(tg,{path:tc.path,title:tc.name}):"pptx"===nw?(0,t.jsx)(tx,{path:tc.path,title:tc.name}):"source"===nw?(0,t.jsx)(tA,{path:tc.path,title:tc.name}):(0,t.jsx)(ea,{path:tc.path,title:tc.name})},tN):(0,t.jsx)("div",{className:"flex-1 overflow-auto p-4 min-h-0",children:(0,t.jsx)("div",{className:(0,tf.cn)("w-full",nE,nC),children:tJ?(0,t.jsx)("div",{className:"flex justify-center py-8",children:(0,t.jsx)(_.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):null!==tG?(0,t.jsx)("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words leading-relaxed",children:tG}):rb(tc.name)?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Could not load file."}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Preview not available for this file type."})})}),tY&&!rw(tc.name)&&(0,t.jsxs)("div",{className:"border-t px-4 py-2 flex items-center justify-end gap-2 bg-muted shrink-0",children:[t6&&(0,t.jsx)("span",{className:"text-xs text-destructive mr-auto",children:t6}),(0,t.jsx)(H.Button,{size:"sm",variant:"ghost",onClick:()=>{t0(!1),t8(null)},children:"Cancel"}),(0,t.jsxs)(H.Button,{size:"sm",className:"gap-1",onClick:na,disabled:t9,children:[t9&&(0,t.jsx)(_.Loader2,{className:"h-3 w-3 animate-spin"}),"Save"]})]})]}):(0,t.jsx)("div",{className:"flex-1 flex flex-col items-center justify-center",children:(0,t.jsxs)("div",{className:"flex flex-col items-center gap-2 text-center px-4",children:[(0,t.jsx)(p.FileText,{className:"h-8 w-8 text-muted-foreground"}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a file to view or edit"})]})})]}),(0,t.jsx)(ak,{open:tz,onOpenChange:tK,filePath:tc?.path??""}),!(0,tU.isLite)()&&(0,t.jsx)(aa,{open:tB,onOpenChange:t$}),(0,t.jsx)(np,{currentPath:tc?.path}),(0,t.jsx)("input",{ref:e0,type:"file",multiple:!0,className:"hidden",onChange:e=>{e.target.files&&nn(e.target.files,e1.current)}}),(0,t.jsx)(V,{open:!!ts,onOpenChange:e=>{e||ti(null)},title:tl?"Delete folder?":"Delete file?",description:tl?`"${ts?.split("/").pop()}" and all its contents will be permanently deleted.`:`"${ts?.split("/").pop()}" will be permanently removed.`,onConfirm:nf}),(0,t.jsx)(V,{open:!!ed,onOpenChange:e=>{e||eu(null)},title:"Delete workspace?",description:`"${J.find(e=>e.id===ed)?.name??""}" will be removed from the workspace list. Files on disk are NOT deleted.`,onConfirm:a6})]})]},G??"none")}],952683)}]);