@agent-spaces/server 0.3.63 → 0.3.64

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 (242) hide show
  1. package/dist/adapters/claude-code-runtime/message-format.js +1 -1
  2. package/dist/adapters/git.js +161 -57
  3. package/dist/agents/agent-designer.js +66 -12
  4. package/dist/agents/issue-task-controller.js +1 -1
  5. package/dist/app.js +50 -1
  6. package/dist/package.json +1 -1
  7. package/dist/routes/agent-commands.js +72 -0
  8. package/dist/routes/agent-sse.js +6 -0
  9. package/dist/routes/agent.js +15 -1
  10. package/dist/routes/database.js +345 -0
  11. package/dist/routes/git.js +52 -1
  12. package/dist/routes/kanban.js +39 -0
  13. package/dist/services/agent-commands.js +168 -0
  14. package/dist/services/builtin-tools/command-tools.js +117 -0
  15. package/dist/services/builtin-tools/database-tools.js +578 -0
  16. package/dist/services/builtin-tools/index.js +5 -0
  17. package/dist/services/builtin-tools/input-helpers.js +26 -0
  18. package/dist/services/builtin-tools/issue-tools.js +209 -0
  19. package/dist/services/builtin-tools/kanban-tools.js +277 -0
  20. package/dist/services/database-vector.js +244 -0
  21. package/dist/services/kanban.js +50 -0
  22. package/dist/storage/database-store.js +365 -0
  23. package/dist/storage/kanban-store.js +142 -0
  24. package/dist/web/404.html +1 -1
  25. package/dist/web/__next.__PAGE__.txt +4 -4
  26. package/dist/web/__next._full.txt +24 -29
  27. package/dist/web/__next._head.txt +4 -4
  28. package/dist/web/__next._index.txt +14 -14
  29. package/dist/web/__next._tree.txt +3 -8
  30. package/dist/web/_next/static/chunks/0-9194nbxy_6d.js +1 -0
  31. package/dist/web/_next/static/chunks/{13~y-b.b9rrw4.js → 01~quun6sefgl.js} +1 -1
  32. package/dist/web/_next/static/chunks/04a4vsq2wknm4.js +1 -0
  33. package/dist/web/_next/static/chunks/04dg4l4hv11q2.js +3 -0
  34. package/dist/web/_next/static/chunks/04fxddw-y20~-.js +7 -0
  35. package/dist/web/_next/static/chunks/04w7~5ooz_pwm.js +1 -0
  36. package/dist/web/_next/static/chunks/05oc21sj24wtq.js +1 -0
  37. package/dist/web/_next/static/chunks/{0-oog4zg4_m~m.css → 062f9zqctzg.b.css} +0 -3
  38. package/dist/web/_next/static/chunks/{014x2qbuiszni.js → 08ckpwmmwlors.js} +3 -3
  39. package/dist/web/_next/static/chunks/08k~meqbd8d6v.js +1 -0
  40. package/dist/web/_next/static/chunks/099h96wjsdb25.js +2 -0
  41. package/dist/web/_next/static/chunks/09h23logvq65m.js +1 -0
  42. package/dist/web/_next/static/chunks/0_mvduwjsm35w.js +1 -0
  43. package/dist/web/_next/static/chunks/0a5y-vhf4i5id.js +3 -0
  44. package/dist/web/_next/static/chunks/0ake2f3x2uan4.js +24 -0
  45. package/dist/web/_next/static/chunks/0ck8dw_9-1cdx.js +1 -0
  46. package/dist/web/_next/static/chunks/0f7cb9li~3jra.js +67 -0
  47. package/dist/web/_next/static/chunks/0fttswpzu69qx.js +1 -0
  48. package/dist/web/_next/static/chunks/0ghs9on7wodrm.js +1 -0
  49. package/dist/web/_next/static/chunks/0ghx3j_.-gdyd.js +1 -0
  50. package/dist/web/_next/static/chunks/0h9cu-k6z5o08.js +1 -0
  51. package/dist/web/_next/static/chunks/{02c22g~xd-y30.js → 0iuf30t0rjsjv.js} +2 -2
  52. package/dist/web/_next/static/chunks/{046me66nilkff.js → 0jb4~3qqkw2ps.js} +1 -1
  53. package/dist/web/_next/static/chunks/0k4zdm72k_bfy.js +1 -0
  54. package/dist/web/_next/static/chunks/{0kof5qdg8c2-k.js → 0n6_4so_afuwk.js} +37 -37
  55. package/dist/web/_next/static/chunks/0nb8.iteznuvx.js +1 -0
  56. package/dist/web/_next/static/chunks/0os58q93stt7j.js +3 -0
  57. package/dist/web/_next/static/chunks/0s9lmk8iauou3.js +1 -0
  58. package/dist/web/_next/static/chunks/0sp_zbx~w0am7.js +1 -0
  59. package/dist/web/_next/static/chunks/0tel~zsv4z8l_.js +1 -0
  60. package/dist/web/_next/static/chunks/0twamv4wr_dbv.js +1 -0
  61. package/dist/web/_next/static/chunks/{0_udc.6.tueey.js → 0uhol5wafdbl~.js} +1 -1
  62. package/dist/web/_next/static/chunks/0v3a_x4vt42kx.js +5 -0
  63. package/dist/web/_next/static/chunks/{002-dxhags4dj.js → 0v6hte2z-32ca.js} +2 -2
  64. package/dist/web/_next/static/chunks/0v7q4mys.mnm..css +1 -0
  65. package/dist/web/_next/static/chunks/{0ogpc3f3keopc.js → 0vbqaynjq8ga..js} +2 -2
  66. package/dist/web/_next/static/chunks/0xbaakj0dfc0..js +1 -0
  67. package/dist/web/_next/static/chunks/0z~vqzbm_q371.js +1 -0
  68. package/dist/web/_next/static/chunks/0~3xm80~j9ddg.js +1 -0
  69. package/dist/web/_next/static/chunks/{0y09i51u6ixq5.js → 10l-9myrdo3x9.js} +1 -1
  70. package/dist/web/_next/static/chunks/12jm4gwmvq-0q.js +90 -0
  71. package/dist/web/_next/static/chunks/{0aa6bcdmtpekn.js → 1442stwa0gbxe.js} +1 -1
  72. package/dist/web/_next/static/chunks/14s37n6h0_q3x.js +16 -0
  73. package/dist/web/_next/static/chunks/161ik5kfyuwtd.js +1 -0
  74. package/dist/web/_next/static/chunks/17k~zbv0_4rep.js +1 -0
  75. package/dist/web/_not-found/__next._full.txt +23 -23
  76. package/dist/web/_not-found/__next._head.txt +4 -4
  77. package/dist/web/_not-found/__next._index.txt +14 -14
  78. package/dist/web/_not-found/__next._not-found.__PAGE__.txt +2 -2
  79. package/dist/web/_not-found/__next._not-found.txt +3 -3
  80. package/dist/web/_not-found/__next._tree.txt +3 -3
  81. package/dist/web/_not-found.html +1 -1
  82. package/dist/web/_not-found.txt +23 -23
  83. package/dist/web/index.html +1 -1
  84. package/dist/web/index.txt +24 -29
  85. package/dist/web/login/__next._full.txt +32 -36
  86. package/dist/web/login/__next._head.txt +4 -4
  87. package/dist/web/login/__next._index.txt +14 -14
  88. package/dist/web/login/__next._tree.txt +3 -8
  89. package/dist/web/login/__next.login.__PAGE__.txt +4 -4
  90. package/dist/web/login/__next.login.txt +3 -3
  91. package/dist/web/login.html +1 -1
  92. package/dist/web/login.txt +32 -36
  93. package/dist/web/settings/__next._full.txt +26 -31
  94. package/dist/web/settings/__next._head.txt +4 -4
  95. package/dist/web/settings/__next._index.txt +14 -14
  96. package/dist/web/settings/__next._tree.txt +3 -8
  97. package/dist/web/settings/__next.settings.__PAGE__.txt +4 -4
  98. package/dist/web/settings/__next.settings.txt +5 -5
  99. package/dist/web/settings/agents/__next._full.txt +26 -31
  100. package/dist/web/settings/agents/__next._head.txt +4 -4
  101. package/dist/web/settings/agents/__next._index.txt +14 -14
  102. package/dist/web/settings/agents/__next._tree.txt +3 -8
  103. package/dist/web/settings/agents/__next.settings.agents.__PAGE__.txt +4 -4
  104. package/dist/web/settings/agents/__next.settings.agents.txt +3 -3
  105. package/dist/web/settings/agents/__next.settings.txt +5 -5
  106. package/dist/web/settings/agents.html +1 -1
  107. package/dist/web/settings/agents.txt +26 -31
  108. package/dist/web/settings/mcps/__next._full.txt +26 -31
  109. package/dist/web/settings/mcps/__next._head.txt +4 -4
  110. package/dist/web/settings/mcps/__next._index.txt +14 -14
  111. package/dist/web/settings/mcps/__next._tree.txt +3 -8
  112. package/dist/web/settings/mcps/__next.settings.mcps.__PAGE__.txt +4 -4
  113. package/dist/web/settings/mcps/__next.settings.mcps.txt +3 -3
  114. package/dist/web/settings/mcps/__next.settings.txt +5 -5
  115. package/dist/web/settings/mcps.html +1 -1
  116. package/dist/web/settings/mcps.txt +26 -31
  117. package/dist/web/settings/models/__next._full.txt +26 -31
  118. package/dist/web/settings/models/__next._head.txt +4 -4
  119. package/dist/web/settings/models/__next._index.txt +14 -14
  120. package/dist/web/settings/models/__next._tree.txt +3 -8
  121. package/dist/web/settings/models/__next.settings.models.__PAGE__.txt +4 -4
  122. package/dist/web/settings/models/__next.settings.models.txt +3 -3
  123. package/dist/web/settings/models/__next.settings.txt +5 -5
  124. package/dist/web/settings/models.html +1 -1
  125. package/dist/web/settings/models.txt +26 -31
  126. package/dist/web/settings/output-styles/__next._full.txt +26 -31
  127. package/dist/web/settings/output-styles/__next._head.txt +4 -4
  128. package/dist/web/settings/output-styles/__next._index.txt +14 -14
  129. package/dist/web/settings/output-styles/__next._tree.txt +3 -8
  130. package/dist/web/settings/output-styles/__next.settings.output-styles.__PAGE__.txt +4 -4
  131. package/dist/web/settings/output-styles/__next.settings.output-styles.txt +3 -3
  132. package/dist/web/settings/output-styles/__next.settings.txt +5 -5
  133. package/dist/web/settings/output-styles.html +1 -1
  134. package/dist/web/settings/output-styles.txt +26 -31
  135. package/dist/web/settings/prompts/__next._full.txt +26 -31
  136. package/dist/web/settings/prompts/__next._head.txt +4 -4
  137. package/dist/web/settings/prompts/__next._index.txt +14 -14
  138. package/dist/web/settings/prompts/__next._tree.txt +3 -8
  139. package/dist/web/settings/prompts/__next.settings.prompts.__PAGE__.txt +4 -4
  140. package/dist/web/settings/prompts/__next.settings.prompts.txt +3 -3
  141. package/dist/web/settings/prompts/__next.settings.txt +5 -5
  142. package/dist/web/settings/prompts.html +1 -1
  143. package/dist/web/settings/prompts.txt +26 -31
  144. package/dist/web/settings/providers/__next._full.txt +26 -31
  145. package/dist/web/settings/providers/__next._head.txt +4 -4
  146. package/dist/web/settings/providers/__next._index.txt +14 -14
  147. package/dist/web/settings/providers/__next._tree.txt +3 -8
  148. package/dist/web/settings/providers/__next.settings.providers.__PAGE__.txt +4 -4
  149. package/dist/web/settings/providers/__next.settings.providers.txt +3 -3
  150. package/dist/web/settings/providers/__next.settings.txt +5 -5
  151. package/dist/web/settings/providers.html +1 -1
  152. package/dist/web/settings/providers.txt +26 -31
  153. package/dist/web/settings/skills/__next._full.txt +26 -31
  154. package/dist/web/settings/skills/__next._head.txt +4 -4
  155. package/dist/web/settings/skills/__next._index.txt +14 -14
  156. package/dist/web/settings/skills/__next._tree.txt +3 -8
  157. package/dist/web/settings/skills/__next.settings.skills.__PAGE__.txt +4 -4
  158. package/dist/web/settings/skills/__next.settings.skills.txt +3 -3
  159. package/dist/web/settings/skills/__next.settings.txt +5 -5
  160. package/dist/web/settings/skills.html +1 -1
  161. package/dist/web/settings/skills.txt +26 -31
  162. package/dist/web/settings/tools/__next._full.txt +38 -0
  163. package/dist/web/settings/tools/__next._head.txt +6 -0
  164. package/dist/web/settings/tools/__next._index.txt +15 -0
  165. package/dist/web/settings/tools/__next._tree.txt +3 -0
  166. package/dist/web/settings/tools/__next.settings.tools.__PAGE__.txt +9 -0
  167. package/dist/web/settings/tools/__next.settings.tools.txt +5 -0
  168. package/dist/web/settings/tools/__next.settings.txt +7 -0
  169. package/dist/web/settings/tools.html +1 -0
  170. package/dist/web/settings/tools.txt +38 -0
  171. package/dist/web/settings.html +1 -1
  172. package/dist/web/settings.txt +26 -31
  173. package/dist/web/workflows/__next._full.txt +34 -38
  174. package/dist/web/workflows/__next._head.txt +4 -4
  175. package/dist/web/workflows/__next._index.txt +14 -14
  176. package/dist/web/workflows/__next._tree.txt +3 -8
  177. package/dist/web/workflows/__next.workflows.__PAGE__.txt +4 -4
  178. package/dist/web/workflows/__next.workflows.txt +3 -3
  179. package/dist/web/workflows.html +1 -1
  180. package/dist/web/workflows.txt +34 -38
  181. package/dist/web/workspace/_/__next._full.txt +25 -29
  182. package/dist/web/workspace/_/__next._head.txt +4 -4
  183. package/dist/web/workspace/_/__next._index.txt +14 -14
  184. package/dist/web/workspace/_/__next._tree.txt +4 -8
  185. package/dist/web/workspace/_/__next.workspace.$d$id.__PAGE__.txt +3 -3
  186. package/dist/web/workspace/_/__next.workspace.$d$id.txt +3 -3
  187. package/dist/web/workspace/_/__next.workspace.txt +3 -3
  188. package/dist/web/workspace/_.html +1 -1
  189. package/dist/web/workspace/_.txt +25 -29
  190. package/dist/web/workspaces/__next._full.txt +24 -29
  191. package/dist/web/workspaces/__next._head.txt +4 -4
  192. package/dist/web/workspaces/__next._index.txt +14 -14
  193. package/dist/web/workspaces/__next._tree.txt +3 -8
  194. package/dist/web/workspaces/__next.workspaces.__PAGE__.txt +4 -4
  195. package/dist/web/workspaces/__next.workspaces.txt +3 -3
  196. package/dist/web/workspaces.html +1 -1
  197. package/dist/web/workspaces.txt +24 -29
  198. package/dist/ws/agent-prompt.js +45 -8
  199. package/dist/ws/agent-runner.js +6 -4
  200. package/package.json +11 -10
  201. package/dist/web/_next/static/chunks/0-1bfvfwifh-m.js +0 -1
  202. package/dist/web/_next/static/chunks/04v-pqqs-2lvp.css +0 -1
  203. package/dist/web/_next/static/chunks/06w~.izyfylap.js +0 -1
  204. package/dist/web/_next/static/chunks/09t62a89~jesc.js +0 -3
  205. package/dist/web/_next/static/chunks/09y_3krccdd~u.js +0 -1
  206. package/dist/web/_next/static/chunks/0_e~hmntdfop9.js +0 -1
  207. package/dist/web/_next/static/chunks/0cke33d38fnby.js +0 -90
  208. package/dist/web/_next/static/chunks/0cyq~8xb~r5fc.js +0 -1
  209. package/dist/web/_next/static/chunks/0fxa1edqr7dve.js +0 -1
  210. package/dist/web/_next/static/chunks/0hra80eyuu37u.js +0 -1
  211. package/dist/web/_next/static/chunks/0ie7y4k2ncvnn.js +0 -1
  212. package/dist/web/_next/static/chunks/0igc~uli58ncw.js +0 -2
  213. package/dist/web/_next/static/chunks/0msb2mi3hiu5_.js +0 -67
  214. package/dist/web/_next/static/chunks/0p1n8bvfnpl41.js +0 -1
  215. package/dist/web/_next/static/chunks/0s_dva~eh2yhi.js +0 -3
  216. package/dist/web/_next/static/chunks/0typj55ox8d5i.js +0 -1
  217. package/dist/web/_next/static/chunks/0w2p4ldi2aymp.js +0 -1
  218. package/dist/web/_next/static/chunks/0zc0xgp5ourcn.js +0 -1
  219. package/dist/web/_next/static/chunks/0zmhdridea1s5.js +0 -90
  220. package/dist/web/_next/static/chunks/10.alq.6stmld.js +0 -1
  221. package/dist/web/_next/static/chunks/11b3zgk1etlkw.js +0 -7
  222. package/dist/web/_next/static/chunks/11qp8r5dotf7d.js +0 -1
  223. package/dist/web/_next/static/chunks/12mxlicp247c8.js +0 -1
  224. package/dist/web/_next/static/chunks/135w27dd8c19s.js +0 -5
  225. package/dist/web/_next/static/chunks/176dc-dtokxxi.js +0 -16
  226. package/dist/web/_next/static/chunks/17g-0pqre.anw.js +0 -1
  227. package/dist/web/_next/static/media/0a7740363b4d4863-s.1110aazvokzp..woff2 +0 -0
  228. package/dist/web/_next/static/media/0da9c7f357bd9d4d-s.0ek5sshv8wk3m.woff2 +0 -0
  229. package/dist/web/_next/static/media/1b99372b3eaef0c8-s.p.0gx2haw2tmll8.woff2 +0 -0
  230. package/dist/web/_next/static/media/41e95f694c5c4549-s.0r1jrq7neqdsq.woff2 +0 -0
  231. package/dist/web/_next/static/media/5c285b27cdda1fe8-s.p.0yo6-5yoeeudq.woff2 +0 -0
  232. package/dist/web/_next/static/media/5f9d24ebef5d5292-s.0esuu2f5si~v8.woff2 +0 -0
  233. package/dist/web/_next/static/media/6c55a692938ebbbc-s.0g6rbszwfgn9y.woff2 +0 -0
  234. package/dist/web/_next/static/media/8e6fa89aa22d24ec-s.p.0uvzar8hswo3p.woff2 +0 -0
  235. package/dist/web/_next/static/media/a218039a3287bcfd-s.p.17-1enzs_j91b.woff2 +0 -0
  236. package/dist/web/_next/static/media/b2ea385cb5ae8625-s.0kjod.kaq1k69.woff2 +0 -0
  237. package/dist/web/_next/static/media/bdc7e24a509eb931-s.0apt5mko2.qn3.woff2 +0 -0
  238. package/dist/web/_next/static/media/c3cb240f9c892514-s.163v2i5cux7-c.woff2 +0 -0
  239. package/dist/web/_next/static/media/e2334d715941921e-s.p.12skym0rqknxy.woff2 +0 -0
  240. /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_buildManifest.js +0 -0
  241. /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_clientMiddlewareManifest.js +0 -0
  242. /package/dist/web/_next/static/{OoXAsPtrUWjC1l898FSvI → e8w3vd9Eov_LDYWj_0zsE}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),r=await t.json();e({workflows:r,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let r=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await r.json();return e(e=>({workflows:[...e.workflows,a]})),a},updateWorkflow:async(e,r)=>{let a=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await a.json();t().upsertWorkflow(n)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let r=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),a=await r.json();e(e=>({workflows:[...e.workflows,a]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let r=e.workflows.findIndex(e=>e.id===t.id);if(-1!==r){let a=[...e.workflows];return a[r]=t,{workflows:a}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},867295,e=>{"use strict";let t=(0,e.i(433721).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["default",0,t])},332277,e=>{"use strict";var t=e.i(867295);e.s(["Eye",()=>t.default])},842541,e=>{"use strict";e.s(["default",0,function(e,t){return e*=1,t*=1,function(r){return e*(1-r)+t*r}}])},161610,321137,e=>{"use strict";function t(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function r(e,t){var r=Object.create(e.prototype);for(var a in t)r[a]=t[a];return r}function a(){}var n="\\s*([+-]?\\d+)\\s*",i="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",o="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",f=/^#([0-9a-f]{3,8})$/,s=RegExp(`^rgb\\(${n},${n},${n}\\)$`),l=RegExp(`^rgb\\(${o},${o},${o}\\)$`),u=RegExp(`^rgba\\(${n},${n},${n},${i}\\)$`),c=RegExp(`^rgba\\(${o},${o},${o},${i}\\)$`),d=RegExp(`^hsl\\(${i},${o},${o}\\)$`),h=RegExp(`^hsla\\(${i},${o},${o},${i}\\)$`),g={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function x(){return this.rgb().formatHex()}function p(){return this.rgb().formatRgb()}function b(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=f.exec(e))?(r=t[1].length,t=parseInt(t[1],16),6===r?w(t):3===r?new k(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===r?m(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===r?m(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=s.exec(e))?new k(t[1],t[2],t[3],1):(t=l.exec(e))?new k(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=u.exec(e))?m(t[1],t[2],t[3],t[4]):(t=c.exec(e))?m(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=d.exec(e))?W(t[1],t[2]/100,t[3]/100,1):(t=h.exec(e))?W(t[1],t[2]/100,t[3]/100,t[4]):g.hasOwnProperty(e)?w(g[e]):"transparent"===e?new k(NaN,NaN,NaN,0):null}function w(e){return new k(e>>16&255,e>>8&255,255&e,1)}function m(e,t,r,a){return a<=0&&(e=t=r=NaN),new k(e,t,r,a)}function y(e,t,r,n){var i;return 1==arguments.length?((i=e)instanceof a||(i=b(i)),i)?new k((i=i.rgb()).r,i.g,i.b,i.opacity):new k:new k(e,t,r,null==n?1:n)}function k(e,t,r,a){this.r=+e,this.g=+t,this.b=+r,this.opacity=+a}function v(){return`#${j(this.r)}${j(this.g)}${j(this.b)}`}function $(){let e=N(this.opacity);return`${1===e?"rgb(":"rgba("}${M(this.r)}, ${M(this.g)}, ${M(this.b)}${1===e?")":`, ${e})`}`}function N(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function M(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function j(e){return((e=M(e))<16?"0":"")+e.toString(16)}function W(e,t,r,a){return a<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new E(e,t,r,a)}function A(e){if(e instanceof E)return new E(e.h,e.s,e.l,e.opacity);if(e instanceof a||(e=b(e)),!e)return new E;if(e instanceof E)return e;var t=(e=e.rgb()).r/255,r=e.g/255,n=e.b/255,i=Math.min(t,r,n),o=Math.max(t,r,n),f=NaN,s=o-i,l=(o+i)/2;return s?(f=t===o?(r-n)/s+(r<n)*6:r===o?(n-t)/s+2:(t-r)/s+4,s/=l<.5?o+i:2-o-i,f*=60):s=l>0&&l<1?0:f,new E(f,s,l,e.opacity)}function E(e,t,r,a){this.h=+e,this.s=+t,this.l=+r,this.opacity=+a}function C(e){return(e=(e||0)%360)<0?e+360:e}function R(e){return Math.max(0,Math.min(1,e||0))}function T(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}t(a,b,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:x,formatHex:x,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return A(this).formatHsl()},formatRgb:p,toString:p}),t(k,y,r(a,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new k(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new k(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new k(M(this.r),M(this.g),M(this.b),N(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:v,formatHex:v,formatHex8:function(){return`#${j(this.r)}${j(this.g)}${j(this.b)}${j((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:$,toString:$})),t(E,function(e,t,r,a){return 1==arguments.length?A(e):new E(e,t,r,null==a?1:a)},r(a,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new E(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new E(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,a=r+(r<.5?r:1-r)*t,n=2*r-a;return new k(T(e>=240?e-240:e+120,n,a),T(e,n,a),T(e<120?e+240:e-120,n,a),this.opacity)},clamp(){return new E(C(this.h),R(this.s),R(this.l),N(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=N(this.opacity);return`${1===e?"hsl(":"hsla("}${C(this.h)}, ${100*R(this.s)}%, ${100*R(this.l)}%${1===e?")":`, ${e})`}`}})),e.s(["default",0,b,"rgb",0,y],321137),e.s(["color",0,b],161610)},77075,e=>{"use strict";var t=e.i(842541);e.s(["interpolateNumber",()=>t.default])},145665,181503,e=>{"use strict";var t=e.i(321137);function r(e,t,r,a,n){var i=e*e,o=i*e;return((1-3*e+3*i-o)*t+(4-6*i+3*o)*r+(1+3*e+3*i-3*o)*a+o*n)/6}let a=e=>()=>e;function n(e,t){var r=t-e;return r?function(t){return e+t*r}:a(isNaN(e)?t:e)}e.s(["default",0,a],181503);let i=function e(r){var i,o=1==(i=+r)?n:function(e,t){var r,n,o;return t-e?(r=e,n=t,r=Math.pow(r,o=i),n=Math.pow(n,o)-r,o=1/o,function(e){return Math.pow(r+e*n,o)}):a(isNaN(e)?t:e)};function f(e,r){var a=o((e=(0,t.rgb)(e)).r,(r=(0,t.rgb)(r)).r),i=o(e.g,r.g),f=o(e.b,r.b),s=n(e.opacity,r.opacity);return function(t){return e.r=a(t),e.g=i(t),e.b=f(t),e.opacity=s(t),e+""}}return f.gamma=e,f}(1);function o(e){return function(r){var a,n,i=r.length,o=Array(i),f=Array(i),s=Array(i);for(a=0;a<i;++a)n=(0,t.rgb)(r[a]),o[a]=n.r||0,f[a]=n.g||0,s[a]=n.b||0;return o=e(o),f=e(f),s=e(s),n.opacity=1,function(e){return n.r=o(e),n.g=f(e),n.b=s(e),n+""}}}o(function(e){var t=e.length-1;return function(a){var n=a<=0?a=0:a>=1?(a=1,t-1):Math.floor(a*t),i=e[n],o=e[n+1],f=n>0?e[n-1]:2*i-o,s=n<t-1?e[n+2]:2*o-i;return r((a-n/t)*t,f,i,o,s)}}),o(function(e){var t=e.length;return function(a){var n=Math.floor(((a%=1)<0?++a:a)*t),i=e[(n+t-1)%t],o=e[n%t],f=e[(n+1)%t],s=e[(n+2)%t];return r((a-n/t)*t,i,o,f,s)}}),e.s(["default",0,i],145665)},647483,e=>{"use strict";var t=e.i(842541),r=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,a=RegExp(r.source,"g");e.s(["default",0,function(e,n){var i,o,f,s,l,u=r.lastIndex=a.lastIndex=0,c=-1,d=[],h=[];for(e+="",n+="";(f=r.exec(e))&&(s=a.exec(n));)(l=s.index)>u&&(l=n.slice(u,l),d[c]?d[c]+=l:d[++c]=l),(f=f[0])===(s=s[0])?d[c]?d[c]+=s:d[++c]=s:(d[++c]=null,h.push({i:c,x:(0,t.default)(f,s)})),u=a.lastIndex;return u<n.length&&(l=n.slice(u),d[c]?d[c]+=l:d[++c]=l),d.length<2?h[0]?(i=h[0].x,function(e){return i(e)+""}):(o=n,function(){return o}):(n=h.length,function(e){for(var t,r=0;r<n;++r)d[(t=h[r]).i]=t.x(e);return d.join("")})}])},819505,238816,97376,e=>{"use strict";e.s(["genericArray",()=>r],819505);var t=e.i(213570);function r(e,r){var a,n=r?r.length:0,i=e?Math.min(n,e.length):0,o=Array(i),f=Array(n);for(a=0;a<i;++a)o[a]=(0,t.default)(e[a],r[a]);for(;a<n;++a)f[a]=r[a];return function(e){for(a=0;a<i;++a)f[a]=o[a](e);return f}}e.s(["default",0,function(e,t){t||(t=[]);var r,a=e?Math.min(t.length,e.length):0,n=t.slice();return function(i){for(r=0;r<a;++r)n[r]=e[r]*(1-i)+t[r]*i;return n}},"isNumberArray",0,function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}],238816),e.s(["default",0,function(e,t){var r=new Date;return e*=1,t*=1,function(a){return r.setTime(e*(1-a)+t*a),r}}],97376)},905660,e=>{"use strict";e.s(["default",()=>r]);var t=e.i(213570);function r(e,r){var a,n={},i={};for(a in(null===e||"object"!=typeof e)&&(e={}),(null===r||"object"!=typeof r)&&(r={}),r)a in e?n[a]=(0,t.default)(e[a],r[a]):i[a]=r[a];return function(e){for(a in n)i[a]=n[a](e);return i}}},678152,213570,e=>{"use strict";e.s(["default",()=>u],213570);var t=e.i(161610),r=e.i(145665),a=e.i(819505),n=e.i(97376),i=e.i(842541),o=e.i(905660),f=e.i(647483),s=e.i(181503),l=e.i(238816);function u(e,u){var c,d=typeof u;return null==u||"boolean"===d?(0,s.default)(u):("number"===d?i.default:"string"===d?(c=(0,t.color)(u))?(u=c,r.default):f.default:u instanceof t.color?r.default:u instanceof Date?n.default:(0,l.isNumberArray)(u)?l.default:Array.isArray(u)?a.genericArray:"function"!=typeof u.valueOf&&"function"!=typeof u.toString||isNaN(u)?o.default:i.default)(e,u)}e.s(["interpolate",0,u],678152)},212603,e=>{"use strict";var t=e.i(344180),r=e.i(465458);e.s(["Card",0,function({className:e,size:a="default",...n}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...n})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-sm text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...a})}])}]);
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,867295,e=>{"use strict";let t=(0,e.i(433721).default)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);e.s(["default",0,t])},332277,e=>{"use strict";var t=e.i(867295);e.s(["Eye",()=>t.default])},302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),r=await t.json();e({workflows:r,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let r=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),a=await r.json();return e(e=>({workflows:[...e.workflows,a]})),a},updateWorkflow:async(e,r)=>{let a=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)}),n=await a.json();t().upsertWorkflow(n)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let r=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),a=await r.json();e(e=>({workflows:[...e.workflows,a]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let r=e.workflows.findIndex(e=>e.id===t.id);if(-1!==r){let a=[...e.workflows];return a[r]=t,{workflows:a}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},842541,e=>{"use strict";e.s(["default",0,function(e,t){return e*=1,t*=1,function(r){return e*(1-r)+t*r}}])},161610,321137,e=>{"use strict";function t(e,t,r){e.prototype=t.prototype=r,r.constructor=e}function r(e,t){var r=Object.create(e.prototype);for(var a in t)r[a]=t[a];return r}function a(){}var n="\\s*([+-]?\\d+)\\s*",i="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",o="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",f=/^#([0-9a-f]{3,8})$/,s=RegExp(`^rgb\\(${n},${n},${n}\\)$`),l=RegExp(`^rgb\\(${o},${o},${o}\\)$`),u=RegExp(`^rgba\\(${n},${n},${n},${i}\\)$`),c=RegExp(`^rgba\\(${o},${o},${o},${i}\\)$`),d=RegExp(`^hsl\\(${i},${o},${o}\\)$`),h=RegExp(`^hsla\\(${i},${o},${o},${i}\\)$`),g={aliceblue:0xf0f8ff,antiquewhite:0xfaebd7,aqua:65535,aquamarine:8388564,azure:0xf0ffff,beige:0xf5f5dc,bisque:0xffe4c4,black:0,blanchedalmond:0xffebcd,blue:255,blueviolet:9055202,brown:0xa52a2a,burlywood:0xdeb887,cadetblue:6266528,chartreuse:8388352,chocolate:0xd2691e,coral:0xff7f50,cornflowerblue:6591981,cornsilk:0xfff8dc,crimson:0xdc143c,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:0xb8860b,darkgray:0xa9a9a9,darkgreen:25600,darkgrey:0xa9a9a9,darkkhaki:0xbdb76b,darkmagenta:9109643,darkolivegreen:5597999,darkorange:0xff8c00,darkorchid:0x9932cc,darkred:9109504,darksalmon:0xe9967a,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:0xff1493,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:0xb22222,floralwhite:0xfffaf0,forestgreen:2263842,fuchsia:0xff00ff,gainsboro:0xdcdcdc,ghostwhite:0xf8f8ff,gold:0xffd700,goldenrod:0xdaa520,gray:8421504,green:32768,greenyellow:0xadff2f,grey:8421504,honeydew:0xf0fff0,hotpink:0xff69b4,indianred:0xcd5c5c,indigo:4915330,ivory:0xfffff0,khaki:0xf0e68c,lavender:0xe6e6fa,lavenderblush:0xfff0f5,lawngreen:8190976,lemonchiffon:0xfffacd,lightblue:0xadd8e6,lightcoral:0xf08080,lightcyan:0xe0ffff,lightgoldenrodyellow:0xfafad2,lightgray:0xd3d3d3,lightgreen:9498256,lightgrey:0xd3d3d3,lightpink:0xffb6c1,lightsalmon:0xffa07a,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:0xb0c4de,lightyellow:0xffffe0,lime:65280,limegreen:3329330,linen:0xfaf0e6,magenta:0xff00ff,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:0xba55d3,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:0xc71585,midnightblue:1644912,mintcream:0xf5fffa,mistyrose:0xffe4e1,moccasin:0xffe4b5,navajowhite:0xffdead,navy:128,oldlace:0xfdf5e6,olive:8421376,olivedrab:7048739,orange:0xffa500,orangered:0xff4500,orchid:0xda70d6,palegoldenrod:0xeee8aa,palegreen:0x98fb98,paleturquoise:0xafeeee,palevioletred:0xdb7093,papayawhip:0xffefd5,peachpuff:0xffdab9,peru:0xcd853f,pink:0xffc0cb,plum:0xdda0dd,powderblue:0xb0e0e6,purple:8388736,rebeccapurple:6697881,red:0xff0000,rosybrown:0xbc8f8f,royalblue:4286945,saddlebrown:9127187,salmon:0xfa8072,sandybrown:0xf4a460,seagreen:3050327,seashell:0xfff5ee,sienna:0xa0522d,silver:0xc0c0c0,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:0xfffafa,springgreen:65407,steelblue:4620980,tan:0xd2b48c,teal:32896,thistle:0xd8bfd8,tomato:0xff6347,turquoise:4251856,violet:0xee82ee,wheat:0xf5deb3,white:0xffffff,whitesmoke:0xf5f5f5,yellow:0xffff00,yellowgreen:0x9acd32};function x(){return this.rgb().formatHex()}function p(){return this.rgb().formatRgb()}function b(e){var t,r;return e=(e+"").trim().toLowerCase(),(t=f.exec(e))?(r=t[1].length,t=parseInt(t[1],16),6===r?w(t):3===r?new k(t>>8&15|t>>4&240,t>>4&15|240&t,(15&t)<<4|15&t,1):8===r?m(t>>24&255,t>>16&255,t>>8&255,(255&t)/255):4===r?m(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|240&t,((15&t)<<4|15&t)/255):null):(t=s.exec(e))?new k(t[1],t[2],t[3],1):(t=l.exec(e))?new k(255*t[1]/100,255*t[2]/100,255*t[3]/100,1):(t=u.exec(e))?m(t[1],t[2],t[3],t[4]):(t=c.exec(e))?m(255*t[1]/100,255*t[2]/100,255*t[3]/100,t[4]):(t=d.exec(e))?W(t[1],t[2]/100,t[3]/100,1):(t=h.exec(e))?W(t[1],t[2]/100,t[3]/100,t[4]):g.hasOwnProperty(e)?w(g[e]):"transparent"===e?new k(NaN,NaN,NaN,0):null}function w(e){return new k(e>>16&255,e>>8&255,255&e,1)}function m(e,t,r,a){return a<=0&&(e=t=r=NaN),new k(e,t,r,a)}function y(e,t,r,n){var i;return 1==arguments.length?((i=e)instanceof a||(i=b(i)),i)?new k((i=i.rgb()).r,i.g,i.b,i.opacity):new k:new k(e,t,r,null==n?1:n)}function k(e,t,r,a){this.r=+e,this.g=+t,this.b=+r,this.opacity=+a}function v(){return`#${j(this.r)}${j(this.g)}${j(this.b)}`}function $(){let e=N(this.opacity);return`${1===e?"rgb(":"rgba("}${M(this.r)}, ${M(this.g)}, ${M(this.b)}${1===e?")":`, ${e})`}`}function N(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function M(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function j(e){return((e=M(e))<16?"0":"")+e.toString(16)}function W(e,t,r,a){return a<=0?e=t=r=NaN:r<=0||r>=1?e=t=NaN:t<=0&&(e=NaN),new E(e,t,r,a)}function A(e){if(e instanceof E)return new E(e.h,e.s,e.l,e.opacity);if(e instanceof a||(e=b(e)),!e)return new E;if(e instanceof E)return e;var t=(e=e.rgb()).r/255,r=e.g/255,n=e.b/255,i=Math.min(t,r,n),o=Math.max(t,r,n),f=NaN,s=o-i,l=(o+i)/2;return s?(f=t===o?(r-n)/s+(r<n)*6:r===o?(n-t)/s+2:(t-r)/s+4,s/=l<.5?o+i:2-o-i,f*=60):s=l>0&&l<1?0:f,new E(f,s,l,e.opacity)}function E(e,t,r,a){this.h=+e,this.s=+t,this.l=+r,this.opacity=+a}function C(e){return(e=(e||0)%360)<0?e+360:e}function R(e){return Math.max(0,Math.min(1,e||0))}function T(e,t,r){return(e<60?t+(r-t)*e/60:e<180?r:e<240?t+(r-t)*(240-e)/60:t)*255}t(a,b,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:x,formatHex:x,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return A(this).formatHsl()},formatRgb:p,toString:p}),t(k,y,r(a,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new k(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new k(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new k(M(this.r),M(this.g),M(this.b),N(this.opacity))},displayable(){return -.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:v,formatHex:v,formatHex8:function(){return`#${j(this.r)}${j(this.g)}${j(this.b)}${j((isNaN(this.opacity)?1:this.opacity)*255)}`},formatRgb:$,toString:$})),t(E,function(e,t,r,a){return 1==arguments.length?A(e):new E(e,t,r,null==a?1:a)},r(a,{brighter(e){return e=null==e?1.4285714285714286:Math.pow(1.4285714285714286,e),new E(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=null==e?.7:Math.pow(.7,e),new E(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,a=r+(r<.5?r:1-r)*t,n=2*r-a;return new k(T(e>=240?e-240:e+120,n,a),T(e,n,a),T(e<120?e+240:e-120,n,a),this.opacity)},clamp(){return new E(C(this.h),R(this.s),R(this.l),N(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){let e=N(this.opacity);return`${1===e?"hsl(":"hsla("}${C(this.h)}, ${100*R(this.s)}%, ${100*R(this.l)}%${1===e?")":`, ${e})`}`}})),e.s(["default",0,b,"rgb",0,y],321137),e.s(["color",0,b],161610)},77075,e=>{"use strict";var t=e.i(842541);e.s(["interpolateNumber",()=>t.default])},145665,181503,e=>{"use strict";var t=e.i(321137);function r(e,t,r,a,n){var i=e*e,o=i*e;return((1-3*e+3*i-o)*t+(4-6*i+3*o)*r+(1+3*e+3*i-3*o)*a+o*n)/6}let a=e=>()=>e;function n(e,t){var r=t-e;return r?function(t){return e+t*r}:a(isNaN(e)?t:e)}e.s(["default",0,a],181503);let i=function e(r){var i,o=1==(i=+r)?n:function(e,t){var r,n,o;return t-e?(r=e,n=t,r=Math.pow(r,o=i),n=Math.pow(n,o)-r,o=1/o,function(e){return Math.pow(r+e*n,o)}):a(isNaN(e)?t:e)};function f(e,r){var a=o((e=(0,t.rgb)(e)).r,(r=(0,t.rgb)(r)).r),i=o(e.g,r.g),f=o(e.b,r.b),s=n(e.opacity,r.opacity);return function(t){return e.r=a(t),e.g=i(t),e.b=f(t),e.opacity=s(t),e+""}}return f.gamma=e,f}(1);function o(e){return function(r){var a,n,i=r.length,o=Array(i),f=Array(i),s=Array(i);for(a=0;a<i;++a)n=(0,t.rgb)(r[a]),o[a]=n.r||0,f[a]=n.g||0,s[a]=n.b||0;return o=e(o),f=e(f),s=e(s),n.opacity=1,function(e){return n.r=o(e),n.g=f(e),n.b=s(e),n+""}}}o(function(e){var t=e.length-1;return function(a){var n=a<=0?a=0:a>=1?(a=1,t-1):Math.floor(a*t),i=e[n],o=e[n+1],f=n>0?e[n-1]:2*i-o,s=n<t-1?e[n+2]:2*o-i;return r((a-n/t)*t,f,i,o,s)}}),o(function(e){var t=e.length;return function(a){var n=Math.floor(((a%=1)<0?++a:a)*t),i=e[(n+t-1)%t],o=e[n%t],f=e[(n+1)%t],s=e[(n+2)%t];return r((a-n/t)*t,i,o,f,s)}}),e.s(["default",0,i],145665)},647483,e=>{"use strict";var t=e.i(842541),r=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,a=RegExp(r.source,"g");e.s(["default",0,function(e,n){var i,o,f,s,l,u=r.lastIndex=a.lastIndex=0,c=-1,d=[],h=[];for(e+="",n+="";(f=r.exec(e))&&(s=a.exec(n));)(l=s.index)>u&&(l=n.slice(u,l),d[c]?d[c]+=l:d[++c]=l),(f=f[0])===(s=s[0])?d[c]?d[c]+=s:d[++c]=s:(d[++c]=null,h.push({i:c,x:(0,t.default)(f,s)})),u=a.lastIndex;return u<n.length&&(l=n.slice(u),d[c]?d[c]+=l:d[++c]=l),d.length<2?h[0]?(i=h[0].x,function(e){return i(e)+""}):(o=n,function(){return o}):(n=h.length,function(e){for(var t,r=0;r<n;++r)d[(t=h[r]).i]=t.x(e);return d.join("")})}])},819505,238816,97376,e=>{"use strict";e.s(["genericArray",()=>r],819505);var t=e.i(213570);function r(e,r){var a,n=r?r.length:0,i=e?Math.min(n,e.length):0,o=Array(i),f=Array(n);for(a=0;a<i;++a)o[a]=(0,t.default)(e[a],r[a]);for(;a<n;++a)f[a]=r[a];return function(e){for(a=0;a<i;++a)f[a]=o[a](e);return f}}e.s(["default",0,function(e,t){t||(t=[]);var r,a=e?Math.min(t.length,e.length):0,n=t.slice();return function(i){for(r=0;r<a;++r)n[r]=e[r]*(1-i)+t[r]*i;return n}},"isNumberArray",0,function(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}],238816),e.s(["default",0,function(e,t){var r=new Date;return e*=1,t*=1,function(a){return r.setTime(e*(1-a)+t*a),r}}],97376)},905660,e=>{"use strict";e.s(["default",()=>r]);var t=e.i(213570);function r(e,r){var a,n={},i={};for(a in(null===e||"object"!=typeof e)&&(e={}),(null===r||"object"!=typeof r)&&(r={}),r)a in e?n[a]=(0,t.default)(e[a],r[a]):i[a]=r[a];return function(e){for(a in n)i[a]=n[a](e);return i}}},678152,213570,e=>{"use strict";e.s(["default",()=>u],213570);var t=e.i(161610),r=e.i(145665),a=e.i(819505),n=e.i(97376),i=e.i(842541),o=e.i(905660),f=e.i(647483),s=e.i(181503),l=e.i(238816);function u(e,u){var c,d=typeof u;return null==u||"boolean"===d?(0,s.default)(u):("number"===d?i.default:"string"===d?(c=(0,t.color)(u))?(u=c,r.default):f.default:u instanceof t.color?r.default:u instanceof Date?n.default:(0,l.isNumberArray)(u)?l.default:Array.isArray(u)?a.genericArray:"function"!=typeof u.valueOf&&"function"!=typeof u.toString||isNaN(u)?o.default:i.default)(e,u)}e.s(["interpolate",0,u],678152)},212603,e=>{"use strict";var t=e.i(344180),r=e.i(465458);e.s(["Card",0,function({className:e,size:a="default",...n}){return(0,t.jsx)("div",{"data-slot":"card","data-size":a,className:(0,r.cn)("group/card flex flex-col gap-4 overflow-hidden rounded-xl bg-card py-4 text-sm text-card-foreground ring-1 ring-foreground/10 has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:gap-3 data-[size=sm]:py-3 data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...n})},"CardContent",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-content",className:(0,r.cn)("px-4 group-data-[size=sm]/card:px-3",e),...a})},"CardDescription",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-description",className:(0,r.cn)("text-sm text-muted-foreground",e),...a})},"CardHeader",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-header",className:(0,r.cn)("group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-4 group-data-[size=sm]/card:px-3 has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-4 group-data-[size=sm]/card:[.border-b]:pb-3",e),...a})},"CardTitle",0,function({className:e,...a}){return(0,t.jsx)("div",{"data-slot":"card-title",className:(0,r.cn)("font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",e),...a})}])}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,940361,e=>{"use strict";var t=e.i(344180);e.s([],2365),e.i(2365);var n=e.i(764556),o=e.i(394822),r=e.i(174465),a=e.i(648224),i=e.i(35359);e.i(8890);var u=e.i(422561),s=e.i(526850),c=e.i(232449),d=e.i(410421),l=e.i(150129),f=e.i(969490),p=e.i(602453),m=e.i(817955),g=e.i(742665),h=e.i(87709);let x=n.forwardRef(function(e,t){let{render:o,className:a,style:x,...v}=e,{setAnchor:M,actionsRef:b,internalBackdropRef:R,backdropRef:y,positionerRef:k,allowMouseUpTriggerRef:C,initialCursorPointRef:S,rootId:I}=(0,r.useContextMenuRootContext)(!1),{store:T}=(0,i.useMenuRootContext)(!1),w=T.useState("open"),j=T.useState("disabled"),P=n.useRef(null),z=n.useRef(null),E=(0,c.useTimeout)(),O=(0,c.useTimeout)(),N=n.useRef(!1);function A(e,t,n){let o=n.type.startsWith("touch");S.current={x:e,y:t},M({getBoundingClientRect:()=>DOMRect.fromRect({width:10*!!o,height:10*!!o,x:e,y:t})}),N.current=!1,b.current?.setOpen(!0,(0,p.createChangeEventDetails)(g.REASONS.triggerPress,n)),O.start(500,()=>{N.current=!0})}function D(){E.clear(),z.current=null}return n.useEffect(()=>{let e=(0,s.ownerDocument)(P.current);return(0,u.addEventListener)(e,"contextmenu",function(e){if(j)return;let t=(0,d.getTarget)(e);((0,d.contains)(P.current,t)||(0,d.contains)(R.current,t)||(0,d.contains)(y.current,t))&&e.preventDefault()})},[y,j,R]),(0,f.useRenderElement)("div",e,{state:{open:w},ref:[P,t],props:[{onContextMenu:function(e){if(j)return;C.current=!0,(0,l.stopEvent)(e),A(e.clientX,e.clientY,e.nativeEvent);let t=(0,s.ownerDocument)(P.current);(0,u.addEventListener)(t,"mouseup",e=>{if(C.current=!1,!N.current)return;O.clear(),N.current=!1;let t=(0,d.getTarget)(e);(0,d.contains)(k.current,t)||I&&t&&(0,h.findRootOwnerId)(t)===I||b.current?.setOpen(!1,(0,p.createChangeEventDetails)(g.REASONS.cancelOpen,e))},{once:!0})},onTouchStart:function(e){if(!j&&(C.current=!1,1===e.touches.length)){e.stopPropagation();let t=e.touches[0];z.current={x:t.clientX,y:t.clientY},E.start(500,()=>{z.current&&A(z.current.x,z.current.y,e.nativeEvent)})}},onTouchMove:function(e){if(E.isStarted()&&z.current&&1===e.touches.length){let t=e.touches[0],n=Math.abs(t.clientX-z.current.x),o=Math.abs(t.clientY-z.current.y);(n>10||o>10)&&E.clear()}},onTouchEnd:D,onTouchCancel:D,style:{WebkitTouchCallout:"none"}},v],stateAttributesMapping:m.pressableTriggerOpenStateMapping})});var v=e.i(487455),M=e.i(293209),b=e.i(503662),R=e.i(33427),y=e.i(324573),k=e.i(582883),C=e.i(277658),S=e.i(349204),I=e.i(28051),T=e.i(597375),w=e.i(81752),j=e.i(59354),P=e.i(300637),z=e.i(281478),E=e.i(65255),O=e.i(327794),N=e.i(362962);e.s(["Arrow",()=>y.MenuArrow,"Backdrop",()=>v.MenuBackdrop,"CheckboxItem",()=>I.MenuCheckboxItem,"CheckboxItemIndicator",()=>T.MenuCheckboxItemIndicator,"Group",()=>k.MenuGroup,"GroupLabel",()=>C.MenuGroupLabel,"Item",()=>S.MenuItem,"LinkItem",()=>w.MenuLinkItem,"Popup",()=>R.MenuPopup,"Portal",()=>M.MenuPortal,"Positioner",()=>b.MenuPositioner,"RadioGroup",()=>j.MenuRadioGroup,"RadioItem",()=>P.MenuRadioItem,"RadioItemIndicator",()=>z.MenuRadioItemIndicator,"Root",0,function(e){let[u,s]=n.useState({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,x:0,y:0})}),c=n.useRef(null),d=n.useRef(null),l=n.useRef(null),f=n.useRef(null),p=n.useRef(!0),m=n.useRef(null),g=(0,o.useId)(),h=n.useMemo(()=>({anchor:u,setAnchor:s,actionsRef:l,backdropRef:c,internalBackdropRef:d,positionerRef:f,allowMouseUpTriggerRef:p,initialCursorPointRef:m,rootId:g}),[u,g]);return(0,t.jsx)(r.ContextMenuRootContext.Provider,{value:h,children:(0,t.jsx)(i.MenuRootContext.Provider,{value:void 0,children:(0,t.jsx)(a.Menu.Root,{...e})})})},"Separator",()=>N.Separator,"SubmenuRoot",()=>E.MenuSubmenuRoot,"SubmenuTrigger",()=>O.MenuSubmenuTrigger,"Trigger",0,x],912001);var A=e.i(912001),A=A,D=e.i(465458),L=e.i(932031);function B({className:e,align:n="start",alignOffset:o=4,side:r="right",sideOffset:a=0,...i}){return(0,t.jsx)(A.Portal,{children:(0,t.jsx)(A.Positioner,{className:"isolate z-50 outline-none",align:n,alignOffset:o,side:r,sideOffset:a,children:(0,t.jsx)(A.Popup,{"data-slot":"context-menu-content",className:(0,D.cn)("z-50 max-h-(--available-height) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...i})})})}e.i(299648),e.s(["ContextMenu",0,function({...e}){return(0,t.jsx)(A.Root,{"data-slot":"context-menu",...e})},"ContextMenuContent",0,B,"ContextMenuItem",0,function({className:e,inset:n,variant:o="default",...r}){return(0,t.jsx)(A.Item,{"data-slot":"context-menu-item","data-inset":n,"data-variant":o,className:(0,D.cn)("group/context-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 focus:*:[svg]:text-accent-foreground data-[variant=destructive]:*:[svg]:text-destructive",e),...r})},"ContextMenuSeparator",0,function({className:e,...n}){return(0,t.jsx)(A.Separator,{"data-slot":"context-menu-separator",className:(0,D.cn)("-mx-1 my-1 h-px bg-border",e),...n})},"ContextMenuSub",0,function({...e}){return(0,t.jsx)(A.SubmenuRoot,{"data-slot":"context-menu-sub",...e})},"ContextMenuSubContent",0,function({...e}){return(0,t.jsx)(B,{"data-slot":"context-menu-sub-content",className:"shadow-lg",side:"right",...e})},"ContextMenuSubTrigger",0,function({className:e,inset:n,children:o,...r}){return(0,t.jsxs)(A.SubmenuTrigger,{"data-slot":"context-menu-sub-trigger","data-inset":n,className:(0,D.cn)("flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-inset:pl-7 data-open:bg-accent data-open:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...r,children:[o,(0,t.jsx)(L.ChevronRightIcon,{className:"ml-auto"})]})},"ContextMenuTrigger",0,function({className:e,...n}){return(0,t.jsx)(A.Trigger,{"data-slot":"context-menu-trigger",className:(0,D.cn)("select-none",e),...n})}],940361)},600304,759309,e=>{"use strict";let t=(0,e.i(433721).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);e.s(["default",0,t],759309),e.s(["Send",0,t],600304)},212965,e=>{"use strict";let t=(0,e.i(433721).default)("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);e.s(["ArrowDown",0,t],212965)},889445,e=>{"use strict";let t=(0,e.i(433721).default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);e.s(["Play",0,t],889445)},346038,237597,e=>{"use strict";var t=e.i(433721);let n=(0,t.default)("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]);e.s(["Keyboard",0,n],346038);let o=(0,t.default)("pen-line",[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);e.s(["Edit3",0,o],237597)}]);
@@ -0,0 +1,3 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,885761,e=>{"use strict";var t,n,s,a=e.i(344180),r=e.i(764556),l=e.i(244073),i=e.i(31807),o=e.i(355819),c=e.i(157408),d=e.i(159619),u=e.i(962562),m=e.i(137340),p=e.i(344118),x=e.i(444204),h=e.i(433721);let g=(0,h.default)("reply",[["path",{d:"M20 18v-2a4 4 0 0 0-4-4H4",key:"5vmcpk"}],["path",{d:"m9 17-5-5 5-5",key:"nvlc11"}]]);var f=e.i(244996),v=e.i(668667),j=e.i(588785),y=e.i(209988),b=e.i(555060),N=e.i(611176),k=e.i(951841),w=e.i(996652),C=e.i(426022);let S=(0,h.default)("user-minus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);function T({open:e,onOpenChange:t,memberName:n,displayName:s,channelId:l,workspaceId:c,channels:d=[]}){let[u,m]=(0,r.useState)(!1),{channels:p,updateChannel:x}=(0,i.useChannelStore)(),h=(0,o.useAgentStore)(e=>e.agents),g="user"!==n?h.find(e=>e.id===n):void 0,f=s||g?.name||n,v=(0,k.useUserAvatar)(),j="user"===n?v:null,b=p.find(e=>e.id===l),w=b?.members.includes(n),M=async()=>{if(b&&w){m(!0);try{let e=(i.useChannelStore.getState().channels.find(e=>e.id===l)??b).members.filter(e=>e!==n);i.useChannelStore.setState(t=>({channels:t.channels.map(t=>t.id===l?{...t,members:e}:t)})),await x(c,l,{members:e}),t(!1)}finally{m(!1)}}};return(0,a.jsx)(y.Dialog,{open:e,onOpenChange:t,children:(0,a.jsxs)(y.DialogContent,{className:"sm:max-w-sm",children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:"成员信息"}),(0,a.jsx)(y.DialogDescription,{})]}),(0,a.jsxs)("div",{className:"flex items-center gap-3 pt-2",children:[(0,a.jsx)(N.AgentIcon,{agentId:"user"!==n?n:void 0,name:f,avatarUrl:j||void 0,className:"size-12 rounded-full"}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-sm font-medium truncate",children:f}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"user"===n?"成员":g?.role||n})]})]}),d.length>0&&(0,a.jsxs)("div",{className:"space-y-2 pt-2",children:[(0,a.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"所在频道"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1.5",children:d.map(e=>(0,a.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs",children:[(0,a.jsx)(C.MessageSquare,{className:"size-3"}),e]},e))})]}),w&&"user"!==n&&(0,a.jsxs)("button",{onClick:M,disabled:u,className:"flex items-center justify-center gap-2 w-full mt-2 px-3 py-2 rounded-md text-sm text-destructive hover:bg-destructive/10 disabled:opacity-50 transition-colors cursor-pointer",children:[(0,a.jsx)(S,{className:"size-4"}),u?"移除中...":"从频道移除"]})]})})}var M=e.i(465458);let I=({size:e=16})=>(0,a.jsxs)("svg",{height:e,strokeLinejoin:"round",style:{color:"currentcolor"},viewBox:"0 0 16 16",width:e,children:[(0,a.jsx)("title",{children:"Loader"}),(0,a.jsxs)("g",{clipPath:"url(#clip0_2393_1490)",children:[(0,a.jsx)("path",{d:"M8 0V4",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M8 16V12",opacity:"0.5",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M3.29773 1.52783L5.64887 4.7639",opacity:"0.9",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12.7023 1.52783L10.3511 4.7639",opacity:"0.1",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M12.7023 14.472L10.3511 11.236",opacity:"0.4",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M3.29773 14.472L5.64887 11.236",opacity:"0.6",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M15.6085 5.52783L11.8043 6.7639",opacity:"0.2",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M0.391602 10.472L4.19583 9.23598",opacity:"0.7",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M15.6085 10.4722L11.8043 9.2361",opacity:"0.3",stroke:"currentColor",strokeWidth:"1.5"}),(0,a.jsx)("path",{d:"M0.391602 5.52783L4.19583 6.7639",opacity:"0.8",stroke:"currentColor",strokeWidth:"1.5"})]}),(0,a.jsx)("defs",{children:(0,a.jsx)("clipPath",{id:"clip0_2393_1490",children:(0,a.jsx)("rect",{fill:"white",height:"16",width:"16"})})})]}),z=({className:e,size:t=16,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("inline-flex animate-spin items-center justify-center",e),...n,children:(0,a.jsx)(I,{size:t})});var D=e.i(946899),D=D;e.s([],352264),e.i(352264),e.i(8890);var R=e.i(535270),P=e.i(29905),A=e.i(756432),O=e.i(189131),E=e.i(267805);let $=r.createContext(void 0);function L(){let e=r.useContext($);if(void 0===e)throw Error((0,E.default)(10));return e}var U=e.i(969490),B=e.i(602453),F=e.i(742665);let W={value:()=>null},_=r.forwardRef(function(e,t){let{render:n,className:s,disabled:l=!1,hiddenUntilFound:i,keepMounted:o,loopFocus:c=!0,onValueChange:d,multiple:u=!1,orientation:m="vertical",value:p,defaultValue:x,style:h,...g}=e,f=(0,O.useDirection)(),v=r.useMemo(()=>{if(void 0===p)return x??[]},[p,x]),j=(0,P.useStableCallback)(d),y=r.useRef([]),[b,N]=(0,R.useControlled)({controlled:p,default:v,name:"Accordion",state:"value"}),k=(0,P.useStableCallback)((e,t)=>{let n=(0,B.createChangeEventDetails)(F.REASONS.none);if(u)if(t){let t=b.slice();if(t.push(e),j(t,n),n.isCanceled)return;N(t)}else{let t=b.filter(t=>t!==e);if(j(t,n),n.isCanceled)return;N(t)}else{let t=b[0]===e?[]:[e];if(j(t,n),n.isCanceled)return;N(t)}}),w=r.useMemo(()=>({value:b,disabled:l,orientation:m}),[b,l,m]),C=r.useMemo(()=>({accordionItemRefs:y,direction:f,disabled:l,handleValueChange:k,hiddenUntilFound:i??!1,keepMounted:o??!1,loopFocus:c,orientation:m,state:w,value:b}),[f,l,k,i,o,c,m,w,b]),S=(0,U.useRenderElement)("div",e,{state:w,ref:t,props:[{dir:f,role:"region"},g],stateAttributesMapping:W});return(0,a.jsx)($.Provider,{value:C,children:(0,a.jsx)(A.CompositeList,{elementsRef:y,children:S})})});var H=e.i(204133),q=e.i(139236),V=e.i(257295),G=e.i(619279),K=e.i(296615);let J=r.createContext(void 0);function Q(){let e=r.useContext(J);if(void 0===e)throw Error((0,E.default)(9));return e}var X=e.i(439485),Y=e.i(282458);let Z=((t={}).index="data-index",t.disabled="data-disabled",t.open="data-open",t),ee={...X.collapsibleOpenStateMapping,index:e=>Number.isInteger(e)?{[Z.index]:String(e)}:null,...Y.transitionStatusMapping,value:()=>null},et=r.forwardRef(function(e,t){let{className:n,disabled:s=!1,onOpenChange:l,render:i,value:o,style:c,...d}=e,{ref:u,index:m}=(0,K.useCompositeListItem)(),p=(0,H.useMergedRefs)(t,u),{disabled:x,handleValueChange:h,state:g,value:f}=L(),v=(0,q.useBaseUiId)(),j=o??v,y=s||x,b=r.useMemo(()=>{if(!f)return!1;for(let e=0;e<f.length;e+=1)if(f[e]===j)return!0;return!1},[f,j]),N=(0,P.useStableCallback)((e,t)=>{l?.(e,t),t.isCanceled||h(j,e)}),k=(0,V.useCollapsibleRoot)({open:b,onOpenChange:N,disabled:y}),w=r.useMemo(()=>({open:k.open,disabled:k.disabled,hidden:!k.mounted,transitionStatus:k.transitionStatus}),[k.open,k.disabled,k.mounted,k.transitionStatus]),C=r.useMemo(()=>({...k,onOpenChange:N,state:w}),[k,w,N]),S=r.useMemo(()=>({...g,index:m,disabled:y,open:b}),[y,m,b,g]),[T,M]=r.useState((0,q.useBaseUiId)()),I=r.useMemo(()=>({open:b,state:S,setTriggerId:M,triggerId:T}),[b,S,M,T]),z=(0,U.useRenderElement)("div",e,{state:S,ref:p,props:d,stateAttributesMapping:ee});return(0,a.jsx)(G.CollapsibleRootContext.Provider,{value:C,children:(0,a.jsx)(J.Provider,{value:I,children:z})})}),en=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,{state:l}=Q();return(0,U.useRenderElement)("h3",e,{state:l,ref:t,props:r,stateAttributesMapping:ee})});var es=e.i(568769),ea=e.i(277642),er=e.i(931709),el=e.i(100229),ei=e.i(150129);let eo=new Set([el.ARROW_DOWN,el.ARROW_UP,el.ARROW_RIGHT,el.ARROW_LEFT,el.HOME,el.END]),ec=r.forwardRef(function(e,t){let{disabled:n,className:s,id:a,render:l,nativeButton:i=!0,style:o,...c}=e,{panelId:d,open:u,handleTrigger:m,disabled:p}=(0,G.useCollapsibleRootContext)(),{getButtonProps:x,buttonRef:h}=(0,er.useButton)({disabled:n??p,focusableWhenDisabled:!0,native:i,composite:!0}),{accordionItemRefs:g,direction:f,loopFocus:v,orientation:j}=L(),y="rtl"===f,b="horizontal"===j,{state:N,setTriggerId:k,triggerId:w}=Q();(0,ea.useIsoLayoutEffect)(()=>(a&&k(a),()=>{k(void 0)}),[a,k]);let C=r.useMemo(()=>({"aria-controls":u?d:void 0,"aria-expanded":u,id:w,tabIndex:0,onClick:m,onKeyDown(e){if(!eo.has(e.key))return;(0,ei.stopEvent)(e);let t=function(e){let{current:t}=e,n=[];for(let e=0;e<t.length;e+=1){let s=t[e];if(!(0,es.isElementDisabled)(s)){let e=s?.querySelector('[type="button"], [role="button"]');e&&!(0,es.isElementDisabled)(e)&&n.push(e)}}return n}(g),n=t.length-1,s=-1,a=t.indexOf(e.currentTarget);function r(){s=v?a+1>n?0:a+1:Math.min(a+1,n)}function l(){s=v&&0===a?n:a-1}switch(e.key){case el.ARROW_DOWN:b||r();break;case el.ARROW_UP:b||l();break;case el.ARROW_RIGHT:b&&(y?l():r());break;case el.ARROW_LEFT:b&&(y?r():l());break;case"Home":s=0;break;case"End":s=n}s>-1&&t[s].focus()}}),[g,m,w,b,y,v,u,d]);return(0,U.useRenderElement)("button",e,{state:N,ref:[t,h],props:[C,c,x],stateAttributesMapping:X.triggerOpenStateMapping})});var ed=e.i(18158);let eu=((n={}).accordionPanelHeight="--accordion-panel-height",n.accordionPanelWidth="--accordion-panel-width",n);var em=e.i(273598);let ep=r.forwardRef(function(e,t){let{className:n,hiddenUntilFound:s,keepMounted:a,id:l,render:i,style:o,...c}=e,{hiddenUntilFound:d,keepMounted:u}=L(),{abortControllerRef:m,animationTypeRef:p,height:x,mounted:h,onOpenChange:g,open:f,panelId:v,panelRef:j,runOnceAnimationsFinish:y,setDimensions:b,setHiddenUntilFound:N,setKeepMounted:k,setMounted:w,setOpen:C,setVisible:S,transitionDimensionRef:T,visible:M,width:I,setPanelIdState:z,transitionStatus:D}=(0,G.useCollapsibleRootContext)(),R=s??d,P=a??u;(0,ea.useIsoLayoutEffect)(()=>{if(l)return z(l),()=>{z(void 0)}},[l,z]),(0,ea.useIsoLayoutEffect)(()=>{N(R)},[N,R]),(0,ea.useIsoLayoutEffect)(()=>{k(P)},[k,P]),(0,em.useOpenChangeComplete)({open:f&&"idle"===D,ref:j,onComplete(){f&&b({width:void 0,height:void 0})}});let{props:A}=(0,ed.useCollapsiblePanel)({abortControllerRef:m,animationTypeRef:p,externalRef:t,height:x,hiddenUntilFound:R,id:l??v,keepMounted:P,mounted:h,onOpenChange:g,open:f,panelRef:j,runOnceAnimationsFinish:y,setDimensions:b,setMounted:w,setOpen:C,setVisible:S,transitionDimensionRef:T,visible:M,width:I}),{state:O,triggerId:E}=Q(),$=r.useMemo(()=>({...O,transitionStatus:D}),[O,D]),B=(0,U.useRenderElement)("div",e,{state:$,ref:[t,j],props:[A,{"aria-labelledby":E,role:"region",style:{[eu.accordionPanelHeight]:void 0===x?"auto":`${x}px`,[eu.accordionPanelWidth]:void 0===I?"auto":`${I}px`}},c],stateAttributesMapping:ee});return P||R||h?B:null});e.s(["Header",0,en,"Item",0,et,"Panel",0,ep,"Root",0,_,"Trigger",0,ec],127284);var ex=e.i(127284),ex=ex,eh=e.i(250438),eg=e.i(380797),eg=eg;function ef({className:e,...t}){return(0,a.jsx)(ex.Root,{"data-slot":"accordion",className:(0,M.cn)("flex w-full flex-col",e),...t})}function ev({className:e,...t}){return(0,a.jsx)(ex.Item,{"data-slot":"accordion-item",className:(0,M.cn)("not-last:border-b",e),...t})}function ej({className:e,children:t,...n}){return(0,a.jsx)(ex.Header,{className:"flex",children:(0,a.jsxs)(ex.Trigger,{"data-slot":"accordion-trigger",className:(0,M.cn)("group/accordion-trigger relative flex flex-1 items-start justify-between rounded-lg border border-transparent py-2.5 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:after:border-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 **:data-[slot=accordion-trigger-icon]:ml-auto **:data-[slot=accordion-trigger-icon]:size-4 **:data-[slot=accordion-trigger-icon]:text-muted-foreground",e),...n,children:[t,(0,a.jsx)(eh.ChevronDownIcon,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none shrink-0 group-aria-expanded/accordion-trigger:hidden"}),(0,a.jsx)(eg.default,{"data-slot":"accordion-trigger-icon",className:"pointer-events-none hidden shrink-0 group-aria-expanded/accordion-trigger:inline"})]})})}function ey({className:e,children:t,...n}){return(0,a.jsx)(ex.Panel,{"data-slot":"accordion-content",className:"overflow-hidden text-sm data-open:animate-accordion-down data-closed:animate-accordion-up",...n,children:(0,a.jsx)("div",{className:(0,M.cn)("h-(--accordion-panel-height) pt-0 pb-2.5 data-ending-style:h-0 data-starting-style:h-0 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),children:t})})}var eb=e.i(562918);let eN=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("not-prose w-full rounded-md border",e),...t})),ek=(0,r.memo)(({className:e,name:t,model:n,...s})=>(0,a.jsx)("div",{className:(0,M.cn)("flex w-full items-center justify-between gap-4 p-3",e),...s,children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(D.default,{className:"size-4 text-muted-foreground"}),(0,a.jsx)("span",{className:"font-medium text-sm",children:t}),n&&(0,a.jsx)(eb.Badge,{className:"font-mono text-xs",variant:"secondary",children:n})]})})),ew=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("space-y-4 p-4 pt-0",e),...t})),eC=(0,r.memo)(({className:e,children:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),...n,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("subagent.instructions")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-muted-foreground text-sm",children:(0,a.jsx)("p",{children:t})})]})}),eS=(0,r.memo)(({className:e,...t})=>{let n=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:n("subagent.tools")}),(0,a.jsx)(ef,{className:"rounded-md border",multiple:!0,...t})]})}),eT=(0,r.memo)(({className:e,tool:t,value:n,...s})=>{let r="jsonSchema"in t&&t.jsonSchema?t.jsonSchema:t.inputSchema,i=(0,l.useTranslations)("chat");return(0,a.jsxs)(ev,{className:(0,M.cn)("border-b last:border-b-0",e),value:n,...s,children:[(0,a.jsx)(ej,{className:"px-3 py-2 text-sm hover:no-underline",children:t.description??i("subagent.noDescription")}),(0,a.jsx)(ey,{className:"px-3 pb-3",children:(0,a.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,a.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:JSON.stringify(r,null,2)})})})]})}),eM=(0,r.memo)(({className:e,schema:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("space-y-2",e),...n,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("subagent.outputSchema")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50",children:(0,a.jsx)("pre",{className:"overflow-auto p-3 font-mono text-xs",children:t})})]})});eN.displayName="Agent",ek.displayName="AgentHeader",ew.displayName="AgentContent",eC.displayName="AgentInstructions",eS.displayName="AgentTools",eT.displayName="AgentTool",eM.displayName="AgentOutput";var eI=e.i(905724),eI=eI,ez=e.i(551157),ez=ez;let eD=(0,h.default)("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]),eR=(0,h.default)("music-2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),eP=(0,h.default)("paperclip",[["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551",key:"1miecu"}]]),eA=(0,h.default)("video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);var eO=e.i(422373),eE=e.i(260218);e.s([],339090),e.i(339090);var e$=e.i(166392),eL=e.i(538501),eU=e.i(427396),eB=e.i(389124);let eF=r.createContext(void 0);function eW(e){let t=r.useContext(eF);if(void 0===t&&!e)throw Error((0,E.default)(50));return t}var e_=e.i(106206),eH=e.i(332976),eq=e.i(493696),eV=e.i(549154),eG=e.i(695011),eK=e.i(561213),eJ=e.i(107164);let eQ={...eG.popupStoreSelectors,instantType:(0,eH.createSelector)(e=>e.instantType),hasViewport:(0,eH.createSelector)(e=>e.hasViewport)};class eX extends eq.ReactStore{constructor(e){super({...(0,eG.createInitialPopupStoreState)(),instantType:void 0,hasViewport:!1,...e},{popupRef:r.createRef(),onOpenChange:void 0,onOpenChangeComplete:void 0,triggerElements:new eK.PopupTriggerMap,closeDelayRef:{current:300}},eQ)}setOpen=(e,t)=>{let n=t.reason,s=n===F.REASONS.triggerHover,a=e&&n===F.REASONS.triggerFocus,r=!e&&(n===F.REASONS.triggerPress||n===F.REASONS.escapeKey);if(t.preventUnmountOnClose=()=>{this.set("preventUnmountingOnClose",!0)},this.context.onOpenChange?.(e,t),t.isCanceled)return;this.state.floatingRootContext.dispatchOpenChange(e,t);let l=()=>{let s={open:e};a?s.instantType="focus":r?s.instantType="dismiss":n===F.REASONS.triggerHover&&(s.instantType=void 0);let l=t.trigger?.id??null;(l||e)&&(s.activeTriggerId=l,s.activeTriggerElement=t.trigger??null),this.update(s)};s?e_.flushSync(l):l()};static useStore(e,t){let n=(0,eV.useRefWithInit)(()=>new eX(t)).current,s=e??n,a=(0,eJ.useSyncedFloatingRootContext)({popupStore:s,onOpenChange:s.setOpen});return s.state.floatingRootContext=a,s}}var eY=e.i(279501);function eZ(e){let{open:t,defaultOpen:n=!1,onOpenChange:s,onOpenChangeComplete:l,actionsRef:i,handle:o,triggerId:c,defaultTriggerId:d=null,children:u}=e,m=eX.useStore(o?.store,{open:n,openProp:t,activeTriggerId:d,triggerIdProp:c});(0,e$.useOnFirstRender)(()=>{void 0===t&&!1===m.state.open&&!0===n&&m.update({open:!0,activeTriggerId:d})}),m.useControlledProp("openProp",t),m.useControlledProp("triggerIdProp",c),m.useContextCallback("onOpenChange",s),m.useContextCallback("onOpenChangeComplete",l);let p=m.useState("open"),x=m.select("floatingRootContext"),h=m.useState("activeTriggerId"),g=m.useState("payload");(0,eY.useImplicitActiveTrigger)(m);let{forceUnmount:f}=(0,eY.useOpenStateTransitions)(p,m);(0,ea.useIsoLayoutEffect)(()=>{p&&null==h&&m.set("payload",void 0)},[m,h,p]);let v=r.useCallback(()=>{m.setOpen(!1,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction))},[m]);r.useImperativeHandle(i,()=>({unmount:f,close:v}),[f,v]);let j=(0,eL.useDismiss)(x),{getReferenceProps:y,getTriggerProps:b,getFloatingProps:N}=(0,eU.useInteractions)([j]),k=r.useMemo(()=>y(),[y]),w=r.useMemo(()=>b(),[b]),C=r.useMemo(()=>N(),[N]);return m.useSyncedValues({activeTriggerProps:k,inactiveTriggerProps:w,popupProps:C}),(0,a.jsx)(eF.Provider,{value:m,children:"function"==typeof u?u({payload:g}):u})}let e0=r.createContext(void 0);var e1=e.i(384389);let e2=r.forwardRef(function(e,t){let{keepMounted:n=!1,...s}=e;return eW().useState("mounted")||n?(0,a.jsx)(e0.Provider,{value:n,children:(0,a.jsx)(e1.FloatingPortalLite,{ref:t,...s})}):null});var e5=e.i(817955),e3=e.i(499198),e4=e.i(604921),e6=e.i(480283);let e9=r.forwardRef(function(e,t){let{render:n,className:s,delay:a,closeDelay:l,id:i,payload:o,handle:c,style:d,...u}=e,m=eW(!0),p=c?.store??m;if(!p)throw Error((0,E.default)(89));let x=(0,q.useBaseUiId)(i),h=p.useState("isTriggerActive",x),g=p.useState("isOpenedByTrigger",x),f=p.useState("floatingRootContext"),v=r.useRef(null),j=a??600,y=l??300,{registerTrigger:b,isMountedByThisTrigger:N}=(0,eY.useTriggerDataForwarding)(x,v,p,{payload:o});(0,ea.useIsoLayoutEffect)(()=>{N&&(p.context.closeDelayRef.current=y)},[p,N,y]);let k=(0,e6.useHoverReferenceInteraction)(f,{mouseOnly:!0,move:!1,handleClose:(0,e3.safePolygon)(),delay:()=>({open:j,close:y}),triggerElementRef:v,isActiveTrigger:h,isClosing:()=>"ending"===p.select("transitionStatus")}),w=(0,e4.useFocus)(f,{delay:j}),C=p.useState("triggerProps",N);return(0,U.useRenderElement)("a",e,{state:{open:g},ref:[t,b,v],props:[k,w.reference,C,{id:x},u],stateAttributesMapping:e5.triggerOpenStateMapping})}),e8=r.createContext(void 0);function e7(){let e=r.useContext(e8);if(void 0===e)throw Error((0,E.default)(49));return e}var te=e.i(576557),tt=e.i(576487),tn=e.i(909852),ts=e.i(263635);let ta=r.forwardRef(function(e,t){let{render:n,className:s,anchor:l,positionMethod:i="absolute",side:o="bottom",align:c="center",sideOffset:d=0,alignOffset:u=0,collisionBoundary:m="clipping-ancestors",collisionPadding:p=5,arrowPadding:x=5,sticky:h=!1,disableAnchorTracking:g=!1,collisionAvoidance:f=tt.POPUP_COLLISION_AVOIDANCE,style:v,...j}=e,y=eW(),b=function(){let e=r.useContext(e0);if(void 0===e)throw Error((0,E.default)(48));return e}(),N=(0,eB.useFloatingNodeId)(),k=y.useState("open"),w=y.useState("mounted"),C=y.useState("floatingRootContext"),S=y.useState("instantType"),T=y.useState("transitionStatus"),M=y.useState("hasViewport"),I=(0,te.useAnchorPositioning)({anchor:l,floatingRootContext:C,positionMethod:i,mounted:w,side:o,sideOffset:d,align:c,alignOffset:u,arrowPadding:x,collisionBoundary:m,collisionPadding:p,sticky:h,disableAnchorTracking:g,keepMounted:b,nodeId:N,collisionAvoidance:f,adaptiveOrigin:M?tn.adaptiveOrigin:void 0}),z={open:k,side:I.side,align:I.align,anchorHidden:I.anchorHidden,instant:S},D=(0,ts.usePositioner)(e,z,{styles:I.positionerStyles,transitionStatus:T,props:j,refs:[t,y.useStateSetter("positionerElement")],hidden:!w,inert:!k});return(0,a.jsx)(e8.Provider,{value:I,children:(0,a.jsx)(eB.FloatingNode,{id:N,children:D})})});var tr=e.i(328657),tl=e.i(795914);let ti={...e5.popupStateMapping,...Y.transitionStatusMapping},to=r.forwardRef(function(e,t){let{className:n,render:s,style:a,...r}=e,l=eW(),{side:i,align:o}=e7(),c=l.useState("open"),d=l.useState("instantType"),u=l.useState("transitionStatus"),m=l.useState("popupProps"),p=l.useState("floatingRootContext");(0,em.useOpenChangeComplete)({open:c,ref:l.context.popupRef,onComplete(){c&&l.context.onOpenChangeComplete?.(!0)}});let x=(0,P.useStableCallback)(()=>l.context.closeDelayRef.current);return(0,tl.useHoverFloatingInteraction)(p,{closeDelay:x}),(0,U.useRenderElement)("div",e,{state:{open:c,side:i,align:o,instant:d,transitionStatus:u},ref:[t,l.context.popupRef,l.useStateSetter("popupElement")],props:[m,(0,tr.getDisabledMountTransitionStyles)(u),r],stateAttributesMapping:ti})}),tc=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,l=eW(),{arrowRef:i,side:o,align:c,arrowUncentered:d,arrowStyles:u}=e7(),m=l.useState("open");return(0,U.useRenderElement)("div",e,{state:{open:m,side:o,align:c,uncentered:d},ref:[i,t],props:[{style:u,"aria-hidden":!0},r],stateAttributesMapping:e5.popupStateMapping})}),td={...e5.popupStateMapping,...Y.transitionStatusMapping},tu=r.forwardRef(function(e,t){let{render:n,className:s,style:a,...r}=e,l=eW(),i=l.useState("open"),o=l.useState("mounted"),c=l.useState("transitionStatus");return(0,U.useRenderElement)("div",e,{state:{open:i,transitionStatus:c},ref:[t],props:[{role:"presentation",hidden:!o,style:{pointerEvents:"none",userSelect:"none",WebkitUserSelect:"none"}},r],stateAttributesMapping:td})}),tm=((s={}).popupWidth="--popup-width",s.popupHeight="--popup-height",s);var tp=e.i(3310);let tx={activationDirection:e=>e?{"data-activation-direction":e}:null},th=r.forwardRef(function(e,t){let{render:n,className:s,style:a,children:r,...l}=e,i=eW(),o=e7(),c=i.useState("instantType"),{children:d,state:u}=(0,tp.usePopupViewport)({store:i,side:o.side,cssVars:tm,children:r}),m={activationDirection:u.activationDirection,transitioning:u.transitioning,instant:c};return(0,U.useRenderElement)("div",e,{state:m,ref:t,props:[l,{children:d}],stateAttributesMapping:tx})});class tg{constructor(){this.store=new eX}open(e){let t=e?this.store.context.triggerElements.getById(e):void 0;if(e&&!t)throw Error((0,E.default)(88,e));this.store.setOpen(!0,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction,void 0,t))}close(){this.store.setOpen(!1,(0,B.createChangeEventDetails)(F.REASONS.imperativeAction,void 0,void 0))}get isOpen(){return this.store.state.open}}e.s(["Arrow",0,tc,"Backdrop",0,tu,"Handle",0,tg,"Popup",0,to,"Portal",0,e2,"Positioner",0,ta,"Root",0,function(e){return eW(!0)?(0,a.jsx)(eZ,{...e}):(0,a.jsx)(eB.FloatingTree,{children:(0,a.jsx)(eZ,{...e})})},"Trigger",0,e9,"Viewport",0,th,"createHandle",0,function(){return new tg}],981923),e.i(981923);let tf=e=>{if("source-document"===e.type)return"source";let t=e.mediaType??"";return t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":t.startsWith("application/")||t.startsWith("text/")?"document":"unknown"},tv=(0,r.createContext)(null),tj=(0,r.createContext)(null),ty=()=>{let e=(0,r.useContext)(tj);if(!e)throw Error("Attachment components must be used within <Attachment>");return e},tb=({variant:e="grid",className:t,children:n,...s})=>{let l=(0,r.useMemo)(()=>({variant:e}),[e]);return(0,a.jsx)(tv.Provider,{value:l,children:(0,a.jsx)("div",{className:(0,M.cn)("flex items-start","list"===e?"flex-col gap-2":"flex-wrap gap-2","grid"===e&&"ml-auto w-fit",t),...s,children:n})})},tN=({data:e,onRemove:t,className:n,children:s,...l})=>{let{variant:i}=(0,r.useContext)(tv)??{variant:"grid"},o=tf(e),c=(0,r.useMemo)(()=>({data:e,mediaCategory:o,onRemove:t,variant:i}),[e,o,t,i]);return(0,a.jsx)(tj.Provider,{value:c,children:(0,a.jsx)("div",{className:(0,M.cn)("group relative","grid"===i&&"size-24 overflow-hidden rounded-lg","inline"===i&&["flex h-8 cursor-pointer select-none items-center gap-1.5","rounded-md border border-border px-1.5","font-medium text-sm transition-all","hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50"],"list"===i&&["flex w-full items-center gap-3 rounded-lg border p-3","hover:bg-accent/50"],n),...l,children:s})})},tk=({fallbackIcon:e,className:t,...n})=>{let{data:s,mediaCategory:r,variant:l}=ty(),i="inline"===l?"size-3":"size-4";return(0,a.jsx)("div",{className:(0,M.cn)("flex shrink-0 items-center justify-center overflow-hidden","grid"===l&&"size-full bg-muted","inline"===l&&"size-5 rounded bg-background","list"===l&&"size-12 rounded bg-muted",t),...n,children:(()=>{if("image"===r&&"file"===s.type&&s.url){let e,t;return e=s.url,t=s.filename,"grid"===l?(0,a.jsx)("img",{alt:t||"Image",className:"size-full object-cover",height:96,src:e,width:96}):(0,a.jsx)("img",{alt:t||"Image",className:"size-full rounded object-cover",height:20,src:e,width:20})}if("video"===r&&"file"===s.type&&s.url)return(0,a.jsx)("video",{className:"size-full object-cover",muted:!0,src:s.url});let t={image:eD,video:eA,audio:eR,source:ez.default,document:eI.default,unknown:eP}[r];return e??(0,a.jsx)(t,{className:(0,M.cn)(i,"text-muted-foreground")})})()})},tw=({showMediaType:e=!1,className:t,...n})=>{let{data:s,variant:r}=ty(),i=function(e){let t=(0,l.useTranslations)("chat");if("source-document"===e.type)return e.title||e.filename||t("attachments.source");let n=tf(e);return e.filename||t("image"===n?"attachments.image":"attachments.attachment")}(s);return"grid"===r?null:(0,a.jsxs)("div",{className:(0,M.cn)("min-w-0 flex-1",t),...n,children:[(0,a.jsx)("span",{className:"block truncate",children:i}),e&&s.mediaType&&(0,a.jsx)("span",{className:"block truncate text-muted-foreground text-xs",children:s.mediaType})]})},tC=({label:e,className:t,children:n,...s})=>{let{onRemove:r,variant:i}=ty(),o=(0,l.useTranslations)("chat"),c=e??o("attachments.remove");return r?(0,a.jsxs)(eE.Button,{"aria-label":c,className:(0,M.cn)("grid"===i&&["absolute top-2 right-2 size-6 rounded-full p-0","bg-background/80 backdrop-blur-sm","opacity-0 transition-opacity group-hover:opacity-100","hover:bg-background","[&>svg]:size-3"],"inline"===i&&["size-5 rounded p-0","opacity-0 transition-opacity group-hover:opacity-100","[&>svg]:size-2.5"],"list"===i&&["size-8 shrink-0 rounded p-0","[&>svg]:size-4"],t),onClick:e=>{e.stopPropagation(),r()},type:"button",variant:"ghost",...s,children:[n??(0,a.jsx)(eO.XIcon,{}),(0,a.jsx)("span",{className:"sr-only",children:c})]}):null};function tS({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert",role:"alert",className:(0,M.cn)("rounded-lg border bg-background p-3 text-sm",e),...t})}function tT({className:e,...t}){return(0,a.jsx)("div",{"data-slot":"alert-description",className:(0,M.cn)("text-muted-foreground",e),...t})}let tM=(0,r.createContext)(null),tI=()=>{let e=(0,r.useContext)(tM);if(!e)throw Error("Confirmation components must be used within Confirmation");return e},tz=({className:e,approval:t,state:n,...s})=>t&&"input-streaming"!==n&&"input-available"!==n?(0,a.jsx)(tM.Provider,{value:{approval:t,state:n},children:(0,a.jsx)(tS,{className:(0,M.cn)("flex flex-col gap-2",e),...s})}):null,tD=({className:e,...t})=>(0,a.jsx)(tT,{className:(0,M.cn)("inline",e),...t}),tR=({children:e})=>{let{state:t}=tI();return"approval-requested"!==t?null:e},tP=({children:e})=>{let{approval:t,state:n}=tI();return t?.approved&&("approval-responded"===n||"output-denied"===n||"output-available"===n)?e:null},tA=({children:e})=>{let{approval:t,state:n}=tI();return t?.approved!==!1||"approval-responded"!==n&&"output-denied"!==n&&"output-available"!==n?null:e},tO=({className:e,...t})=>{let{state:n}=tI();return"approval-requested"!==n?null:(0,a.jsx)("div",{className:(0,M.cn)("flex items-center justify-end gap-2 self-end",e),...t})},tE=e=>(0,a.jsx)(eE.Button,{className:"h-8 px-3 text-sm",type:"button",...e});var t$=e.i(757106),t$=t$;let tL=(0,h.default)("dot",[["circle",{cx:"12.1",cy:"12.1",r:"1",key:"18d7e5"}]]);var tU=e.i(256186);let tB=(0,r.createContext)(null);function tF(e){let t=e.trim(),n=t.replace(/^\[[^\]]+\]\s+subagent progress\s+\|\s*/i,""),s=n!==t;return/^Claude$/i.test(n)||/^(Reading|Searching)(\.{1,3}|…)?$/i.test(n)||s&&/^(Reading|Searching)\s+\S.+$/i.test(n)||/^(Read|Search|Grep|Glob|SemanticSearch|WebSearch)\s+running\s+\(\d+s\)$/i.test(n)}let tW=()=>{let e=(0,r.useContext)(tB);if(!e)throw Error("ChainOfThought components must be used within ChainOfThought");return e},t_=(0,r.memo)(({className:e,open:t,defaultOpen:n=!1,onOpenChange:s,children:l,...i})=>{let[o,c]=(0,r.useState)(n),d=t??o,u=(0,r.useCallback)(e=>{void 0===t&&c(e),s?.(e)},[s,t]),m=(0,r.useMemo)(()=>({isOpen:d,setIsOpen:u}),[d,u]);return(0,a.jsx)(tB.Provider,{value:m,children:(0,a.jsx)("div",{className:(0,M.cn)("not-prose max-w-prose overflow-hidden space-y-4",e),...i,children:l})})}),tH=(0,r.memo)(({className:e,children:t,loading:n,...s})=>{let{isOpen:r,setIsOpen:i}=tW(),o=(0,l.useTranslations)("chat");return(0,a.jsx)(tU.Collapsible,{onOpenChange:i,open:r,children:(0,a.jsxs)(tU.CollapsibleTrigger,{className:(0,M.cn)("flex w-full items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",e),...s,children:[(0,a.jsx)(t$.default,{className:"size-4"}),(0,a.jsx)("span",{className:"flex-1 text-left",children:t??o("chainOfThought.defaultHeader")}),n&&(0,a.jsx)(z,{size:14}),(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-4 transition-transform",r?"rotate-180":"rotate-0")})]})})}),tq=(0,r.memo)(({className:e,icon:t=tL,label:n,description:s,status:r="complete",children:l,...i})=>(0,a.jsxs)("div",{className:(0,M.cn)("flex gap-2 text-sm",{complete:"text-muted-foreground",active:"text-foreground",pending:"text-muted-foreground/50"}[r],"fade-in-0 slide-in-from-top-2 animate-in",e),...i,children:[(0,a.jsxs)("div",{className:"relative mt-0.5",children:[(0,a.jsx)(t,{className:"size-4"}),(0,a.jsx)("div",{className:"-mx-px absolute top-7 bottom-0 left-1/2 w-px bg-border"})]}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-2",children:[(0,a.jsx)("div",{children:n}),s&&(0,a.jsx)("div",{className:"text-muted-foreground text-xs",children:s}),l]})]})),tV=(0,r.memo)(({className:e,...t})=>(0,a.jsx)("div",{className:(0,M.cn)("flex flex-wrap items-center gap-2",e),...t})),tG=(0,r.memo)(({className:e,children:t,...n})=>(0,a.jsx)(eb.Badge,{className:(0,M.cn)("gap-1 px-2 py-0.5 font-normal text-xs",e),variant:"secondary",...n,children:t})),tK=(0,r.memo)(({className:e,children:t,...n})=>{let{isOpen:s}=tW();return(0,a.jsx)(tU.Collapsible,{open:s,children:(0,a.jsx)(tU.CollapsibleContent,{className:(0,M.cn)("mt-2 space-y-3","data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...n,children:t})})}),tJ=(0,r.memo)(({className:e,children:t,caption:n,...s})=>(0,a.jsxs)("div",{className:(0,M.cn)("mt-2 space-y-2",e),...s,children:[(0,a.jsx)("div",{className:"relative flex max-h-[22rem] items-center justify-center overflow-hidden rounded-lg bg-muted p-3",children:t}),n&&(0,a.jsx)("p",{className:"text-muted-foreground text-xs",children:n})]}));t_.displayName="ChainOfThought",tH.displayName="ChainOfThoughtHeader",tq.displayName="ChainOfThoughtStep",tV.displayName="ChainOfThoughtSearchResults",tG.displayName="ChainOfThoughtSearchResult",tK.displayName="ChainOfThoughtContent",tJ.displayName="ChainOfThoughtImage";var tQ=e.i(299648),tX=e.i(839374),tX=tX,tY=e.i(184591),tY=tY,tZ=e.i(875350),t0=e.i(341807);let t1=(0,r.memo)(({children:e,as:t="p",className:n,duration:s=2,spread:l=2})=>{let i=(0,r.useMemo)(()=>(e?.length??0)*l,[e,l]);return(0,a.jsx)(t,{children:(0,a.jsx)(t0.motion.span,{animate:{backgroundPosition:"0% center"},className:(0,M.cn)("relative inline-block bg-[length:250%_100%,auto] bg-clip-text text-transparent","[--bg:linear-gradient(90deg,#0000_calc(50%-var(--spread)),var(--color-background),#0000_calc(50%+var(--spread)))] [background-repeat:no-repeat,padding-box]",n),initial:{backgroundPosition:"100% center"},style:{"--spread":`${i}px`,backgroundImage:"var(--bg), linear-gradient(var(--color-muted-foreground), var(--color-muted-foreground))"},transition:{repeat:1/0,duration:s,ease:"linear"},children:e})})}),t2=(0,r.createContext)({output:"",isStreaming:!1,autoScroll:!0}),t5=({output:e,isStreaming:t=!1,autoScroll:n=!0,onClear:s,className:r,children:l,...i})=>(0,a.jsx)(t2.Provider,{value:{output:e,isStreaming:t,autoScroll:n,onClear:s},children:(0,a.jsx)("div",{className:(0,M.cn)("flex flex-col overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100",r),...i,children:l??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(t3,{children:[(0,a.jsx)(t4,{}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(t6,{}),(0,a.jsxs)(t9,{children:[(0,a.jsx)(t8,{}),s&&(0,a.jsx)(t7,{})]})]})]}),(0,a.jsx)(ne,{})]})})}),t3=({className:e,children:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("flex items-center justify-between border-zinc-800 border-b px-4 py-2",e),...n,children:t}),t4=({className:e,children:t,...n})=>{let s=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center gap-2 text-sm text-zinc-400",e),...n,children:[(0,a.jsx)(tY.default,{className:"size-4"}),t??s("terminal.title")]})},t6=({className:e,children:t,...n})=>{let{isStreaming:s}=(0,r.useContext)(t2),i=(0,l.useTranslations)("chat");return s?(0,a.jsx)("div",{className:(0,M.cn)("flex items-center gap-2 text-xs text-zinc-400",e),...n,children:t??(0,a.jsx)(t1,{className:"w-16",children:i("terminal.running")})}):null},t9=({className:e,children:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("flex items-center gap-1",e),...n,children:t}),t8=({onCopy:e,onError:t,timeout:n=2e3,children:s,className:i,...o})=>{let[c,d]=(0,r.useState)(!1),{output:u}=(0,r.useContext)(t2),m=(0,l.useTranslations)("chat"),p=async()=>{if(!navigator?.clipboard?.writeText)return void t?.(Error(m("terminal.clipboardUnavailable")));try{await navigator.clipboard.writeText(u),d(!0),e?.(),setTimeout(()=>d(!1),n)}catch(e){t?.(e)}},x=c?tQ.CheckIcon:tX.default;return(0,a.jsx)(eE.Button,{className:(0,M.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",i),onClick:p,size:"icon",variant:"ghost",...o,children:s??(0,a.jsx)(x,{size:14})})},t7=({children:e,className:t,...n})=>{let{onClear:s}=(0,r.useContext)(t2);return s?(0,a.jsx)(eE.Button,{className:(0,M.cn)("size-7 shrink-0 text-zinc-400 hover:bg-zinc-800 hover:text-zinc-100",t),onClick:s,size:"icon",variant:"ghost",...n,children:e??(0,a.jsx)(tZ.Trash2Icon,{size:14})}):null},ne=({className:e,children:t,...n})=>{let{output:s,isStreaming:l,autoScroll:i}=(0,r.useContext)(t2),o=(0,r.useRef)(null);return(0,r.useEffect)(()=>{i&&o.current&&(o.current.scrollTop=o.current.scrollHeight)},[s,i]),(0,a.jsx)("div",{className:(0,M.cn)("max-h-96 overflow-auto p-4 font-mono text-sm leading-relaxed",e),ref:o,...n,children:t??(0,a.jsxs)("pre",{className:"whitespace-pre-wrap break-words",children:[s.replace(/\u001b\[[0-9;]*m/g,""),l&&(0,a.jsx)("span",{className:"ml-0.5 inline-block h-4 w-2 animate-pulse bg-zinc-100"})]})})};var nt=e.i(735207),nt=nt,D=D,nn=e.i(444741),nn=nn;let ns=(0,h.default)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);var tX=tX,na=e.i(867295),na=na;let nr=(0,h.default)("file-pen",[["path",{d:"M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34",key:"o6klzx"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z",key:"zhnas1"}]]);var eI=eI,nl=e.i(361421),nl=nl,ez=ez,ni=e.i(294543),ni=ni;let no=(0,h.default)("message-square-text",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]]);var nc=e.i(995684),nc=nc,nd=e.i(367914),nu=e.i(656744),nu=nu;let nm=(0,h.default)("square-check",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);var tY=tY;let np=(0,h.default)("webhook",[["path",{d:"M18 16.98h-5.99c-1.1 0-1.95.94-2.48 1.9A4 4 0 0 1 2 17c.01-.7.2-1.4.57-2",key:"q3hayz"}],["path",{d:"m6 17 3.13-5.78c.53-.97.1-2.18-.5-3.1a4 4 0 1 1 6.89-4.06",key:"1go1hn"}],["path",{d:"m12 6 3.13 5.73C15.66 12.7 16.9 13 18 13a4 4 0 0 1 0 8",key:"qlwsc0"}]]);var nx=e.i(212068),nx=nx,nh=e.i(940361),ng=e.i(691223),nf=e.i(613812),nv=e.i(887836);e.i(462506);var nj=e.i(950396);function ny(){let e=(0,l.useTranslations)("chat");return(0,a.jsx)("div",{className:"flex h-full items-center justify-center text-muted-foreground text-xs",children:e("readonlyCodeBlock.loading")})}let nb=(0,nv.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,a.jsx)(ny,{})});function nN({value:e,language:t="plaintext",title:n,height:s=220}){let{resolvedTheme:r}=(0,nj.useTheme)();return(0,a.jsxs)("div",{className:"overflow-hidden rounded-md border bg-background",children:[n?(0,a.jsx)("div",{className:"border-b bg-muted/30 px-2 py-1 font-mono text-muted-foreground text-xs",children:n}):null,(0,a.jsx)("div",{style:{height:s},children:(0,a.jsx)(nb,{height:"100%",language:t,value:e,options:{readOnly:!0,domReadOnly:!0,minimap:{enabled:!1},scrollBeyondLastLine:!1,fontSize:12,lineNumbers:"on",renderLineHighlight:"none",wordWrap:"on",folding:!1,overviewRulerLanes:0},theme:"dark"===r?"vs-dark":"vs"})})]})}let nk={Read:nt.default,Write:eI.default,Edit:nc.default,MultiEdit:nr,Bash:tY.default,TodoWrite:nm,Grep:nd.SearchIcon,Glob:nl.default,Search:nd.SearchIcon,SemanticSearch:nd.SearchIcon,WebSearch:ez.default,WebFetch:np,Fetch:np,Task:no,Agent:D.default,Skill:nu.default,AskUserQuestion:ni.default,LoadClaudeMd:nt.default};function nw({text:e,status:t,workspaceId:n}){let s=(0,l.useTranslations)("chat"),i=Array.from(e.trim()).length>=300,[o,c]=(0,r.useState)(!1);return(0,a.jsx)(tq,{icon:no,label:(0,a.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,a.jsx)("span",{children:s("messageParts.aiMessage")}),i?(0,a.jsx)(eE.Button,{type:"button",variant:"ghost",size:"icon",className:"ml-auto size-5",onClick:()=>c(!o),children:(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-3.5 transition-transform",o&&"rotate-180")})}):null]}),status:t,children:!i||o?(0,a.jsx)(b.Markdown,{content:e,workspaceId:n}):null})}function nC({chain:e,message:t,workspaceId:n,status:s}){var i,o;let c=(0,ng.useEditorStore)(e=>e.openFile),[d,u]=(0,r.useState)(!1),[m,p]=(0,r.useState)(null),[x,h]=(0,r.useState)(!1),[g,f]=(0,r.useState)(null),[v,j]=(0,r.useState)(!1),[y,b]=(0,r.useState)(!1),N=(0,l.useTranslations)("chat"),k=async()=>{e.filePath&&await c(n,e.filePath)},w=(0,r.useCallback)(async()=>{if(m||!e.detailId)return m;h(!0),f(null);try{let s=await fetch(`/api/workspaces/${n}/channels/${t.channelId}/messages/${t.id}/tool-details/${e.detailId}`);if(!s.ok)throw Error(await s.text());let a=await s.json();return p(a),a}catch(e){return f(e instanceof Error?e.message:N("messageParts.failedToLoadDetails")),null}finally{h(!1)}},[m,e.detailId,n,t.channelId,t.id,N]),C=async()=>{let e=!d;u(e),e&&!x&&await w()},S=async()=>{var t;let n=m??await w(),s=n?void 0!==(t=n).input||void 0!==t.output?JSON.stringify({input:t.input,output:t.output},null,2):t.raw??"":e.command??e.title;try{await navigator.clipboard.writeText(s),j(!0),setTimeout(()=>j(!1),1500)}catch{}},T=async()=>{await w(),b(!0)};return(0,a.jsxs)(tq,{icon:(i=e.toolName,i&&nk[i]?nk[i]:i?.startsWith("mcp__")||i?.startsWith("mcp-")?nx.default:"complete"===s?nn.default:ns),label:(0,a.jsxs)(nh.ContextMenu,{children:[(0,a.jsxs)(nh.ContextMenuTrigger,{className:"group/tool-step flex min-w-0 items-center gap-1.5 overflow-hidden",children:[(0,a.jsx)("span",{className:"shrink-0",children:e.filePath?e.title.replace(RegExp(`\\s+${((o=e.filePath).split(/[\\/]/).filter(Boolean).at(-1)??o).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}$`),""):e.title}),e.description?(0,a.jsx)("span",{className:"min-w-0 shrink truncate text-muted-foreground text-xs",children:e.description}):null,e.filePath?(0,a.jsxs)(eE.Button,{type:"button",variant:"ghost",size:"sm",className:"h-6 max-w-48 shrink gap-1 px-1.5 text-xs",onClick:k,children:[(0,a.jsx)(eI.default,{className:"size-3 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e.filePath})]}):null,(0,a.jsx)("div",{className:"ml-auto flex shrink-0 items-center",children:e.detailId?(0,a.jsx)(eE.Button,{type:"button",variant:"ghost",size:"icon",className:"size-5",onClick:C,children:(0,a.jsx)(eh.ChevronDownIcon,{className:(0,M.cn)("size-3.5 transition-transform",d&&"rotate-180")})}):null})]}),(0,a.jsxs)(nh.ContextMenuContent,{children:[(0,a.jsxs)(nh.ContextMenuItem,{onClick:S,children:[v?(0,a.jsx)(tQ.CheckIcon,{className:"size-4 text-green-500"}):(0,a.jsx)(tX.default,{className:"size-4"}),N("messageParts.copy")]}),(0,a.jsxs)(nh.ContextMenuItem,{onClick:T,children:[(0,a.jsx)(na.default,{className:"size-4"}),N("messageParts.view")]})]})]}),description:e.command,status:s,children:[e.answer?(0,a.jsxs)("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,a.jsx)("div",{className:"text-muted-foreground text-xs",children:N("messageParts.result")}),(0,a.jsx)("div",{className:"font-medium",children:e.answer})]}):null,d?(0,a.jsx)("div",{className:"space-y-2",children:x?(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:N("messageParts.loadingDetails")}):g?(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-destructive text-xs",children:g}):m?(0,a.jsx)(nS,{detail:m,toolName:e.toolName,filePath:e.filePath}):(0,a.jsx)("div",{className:"rounded-md border bg-muted/40 p-2 text-muted-foreground text-xs",children:N("messageParts.noDetails")})}):null,(0,a.jsx)(nI,{open:y,onOpenChange:b,detail:m,toolName:e.toolName,loading:x,error:g,t:N})]})}function nS({detail:e,toolName:t,filePath:n}){var s,r;let i,o=(0,l.useTranslations)("chat");if(/^(Bash|Shell|Command)$/i.test(t??"")){let t=function(e){if(!e||"object"!=typeof e)return"string"==typeof e?e:void 0;let t=e.command??e.Command;return"string"==typeof t?t:void 0}(e.input),n="string"==typeof e.output?e.output:JSON.stringify(e.output??"",null,2);return(0,a.jsx)(t5,{output:t?`$ ${t}
2
+ ${n}`:n})}let c=function(e,t,n){if(!e||"object"!=typeof e)return null;let s=nz(e.file_path)??nz(e.path)??n??"edit",a=function(e){if(!e||"object"!=typeof e)return;let t=nz(e.content);if(void 0!==t)return t;let n=e.file;if(n&&"object"==typeof n)return nz(n.content)}(t),r=nz(e.old_string),l=nz(e.new_string);if(void 0!==r&&void 0!==l)return{path:s,oldContent:r,newContent:a??l};let i=Array.isArray(e.edits)?e.edits:[];return i.length>0?{path:s,oldContent:i.map((e,t)=>e&&"object"==typeof e?nz(e.old_string)??`#${t+1}`:`#${t+1}`).join("\n\n"),newContent:a??i.map((e,t)=>e&&"object"==typeof e?nz(e.new_string)??`#${t+1}`:`#${t+1}`).join("\n\n")}:null}(e.input,e.output,n);if(c&&/^(Edit|MultiEdit)$/i.test(t??""))return(0,a.jsx)("div",{className:"h-80 overflow-hidden rounded-md border bg-background",children:(0,a.jsx)(nf.DiffViewer,{oldContent:c.oldContent,newContent:c.newContent,path:c.path})});let d=(s=e,r=o,i=[],void 0!==s.input&&i.push({title:r("messageParts.input"),value:nT(s.input),language:nM(s.input)?"json":"plaintext",height:180}),void 0!==s.output&&i.push({title:r("messageParts.output"),value:nT(s.output),language:nM(s.output)?"json":"plaintext",height:220}),i);return 0===d.length&&e.raw?(0,a.jsx)(nN,{title:o("messageParts.raw"),value:e.raw,language:"plaintext"}):(0,a.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,a.jsx)(nN,{title:e.title,value:e.value,language:e.language,height:e.height},e.title))})}function nT(e){return"string"==typeof e?e:JSON.stringify(e,null,2)}function nM(e){return"string"!=typeof e}function nI({open:e,onOpenChange:t,detail:n,toolName:s,loading:r,error:l,t:i}){return(0,a.jsx)(y.Dialog,{open:e,onOpenChange:t,children:(0,a.jsxs)(y.DialogContent,{className:"sm:max-w-3xl",children:[(0,a.jsx)(y.DialogHeader,{children:(0,a.jsx)(y.DialogTitle,{children:s??i("messageParts.raw")})}),r?(0,a.jsx)("div",{className:"py-8 text-center text-muted-foreground text-sm",children:i("messageParts.loadingDetails")}):l?(0,a.jsx)("div",{className:"py-8 text-center text-destructive text-sm",children:l}):n?(0,a.jsxs)("div",{className:"grid gap-4 md:grid-cols-2",children:[(0,a.jsx)(nN,{title:i("messageParts.input"),value:nT(n.input)||"-",language:nM(n.input)?"json":"plaintext",height:320}),(0,a.jsx)(nN,{title:i("messageParts.output"),value:nT(n.output)||"-",language:nM(n.output)?"json":"plaintext",height:320})]}):(0,a.jsx)("div",{className:"py-8 text-center text-muted-foreground text-sm",children:i("messageParts.noDetails")})]})})}function nz(e){return"string"==typeof e?e:void 0}var D=D,nD=e.i(191118),nR=e.i(812057),nP=e.i(368942),nA=e.i(660748);let nO=(0,r.createContext)(null),nE=()=>{let e=(0,r.useContext)(nO);if(!e)throw Error("Context components must be used within Context");return e},n$=({usedTokens:e,maxTokens:t,usage:n,modelId:s,children:r,...l})=>(0,a.jsx)(nO.Provider,{value:{usedTokens:e,maxTokens:t,usage:n,modelId:s},children:(0,a.jsx)(w.Popover,{...l,children:r})}),nL=()=>{let{usedTokens:e,maxTokens:t,usage:n}=nE(),s=e-(n?.cachedInputTokens??0),r=2*Math.PI*10;return(0,a.jsxs)("svg",{"aria-label":"Model context usage",height:"20",role:"img",style:{color:"currentcolor"},viewBox:"0 0 24 24",width:"20",children:[(0,a.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.25",r:10,stroke:"currentColor",strokeWidth:2}),(0,a.jsx)("circle",{cx:12,cy:12,fill:"none",opacity:"0.7",r:10,stroke:"currentColor",strokeDasharray:`${r} ${r}`,strokeDashoffset:r*(1-s/t),strokeLinecap:"round",strokeWidth:2,style:{transformOrigin:"center",transform:"rotate(-90deg)"}})]})},nU=({children:e,...t})=>{let{usedTokens:n,maxTokens:s,usage:l}=nE(),i=n-(l?.cachedInputTokens??0),o=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(i/s),c=((0,r.isValidElement)(e)?e:void 0)??(0,a.jsxs)(eE.Button,{type:"button",variant:"ghost",...t,children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground",children:o}),(0,a.jsx)(nL,{})]});return(0,a.jsx)(w.PopoverTrigger,{render:c})},nB=({className:e,...t})=>(0,a.jsx)(w.PopoverContent,{className:(0,M.cn)("min-w-60 divide-y overflow-hidden p-0",e),...t}),nF=({children:e,className:t,...n})=>{let{usedTokens:s,maxTokens:r,usage:l}=nE(),i=(s-(l?.cachedInputTokens??0))/r,o=new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(i),c=new Intl.NumberFormat("en-US",{notation:"compact"}).format(s),d=new Intl.NumberFormat("en-US",{notation:"compact"}).format(r);return(0,a.jsx)("div",{className:(0,M.cn)("w-full space-y-2 p-3",t),...n,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-3 text-xs",children:[(0,a.jsx)("p",{children:o}),(0,a.jsxs)("p",{className:"font-mono text-muted-foreground",children:[c," / ",d]})]}),(0,a.jsx)("div",{className:"space-y-2",children:(0,a.jsx)(nA.Progress,{className:"bg-muted",value:100*i})})]})})},nW=({children:e,className:t,...n})=>(0,a.jsx)("div",{className:(0,M.cn)("w-full p-3",t),...n,children:e}),n_=({children:e,className:t,...n})=>{let{modelId:s,usage:r}=nE(),i=(0,l.useTranslations)("chat"),o=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsx)("div",{className:(0,M.cn)("flex w-full items-center justify-between gap-3 bg-secondary p-3 text-xs",t),...n,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.totalCost")}),(0,a.jsx)("span",{children:o})]})})},nH=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.inputTokens??0;if(t)return t;if(!o)return null;let c=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.input")}),(0,a.jsx)(nK,{costText:c,tokens:o})]})},nq=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.outputTokens??0;if(t)return t;if(!o)return null;let c=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.output")}),(0,a.jsx)(nK,{costText:c,tokens:o})]})},nV=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.reasoningTokens??0;if(t)return t;if(!o)return null;let c=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.reasoning")}),(0,a.jsx)(nK,{costText:c,tokens:o})]})},nG=({className:e,children:t,...n})=>{let{usage:s,modelId:r}=nE(),i=(0,l.useTranslations)("chat"),o=s?.cachedInputTokens??0;if(t)return t;if(!o)return null;let c=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format((void 0)??0);return(0,a.jsxs)("div",{className:(0,M.cn)("flex items-center justify-between text-xs",e),...n,children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:i("context.cache")}),(0,a.jsx)(nK,{costText:c,tokens:o})]})},nK=({tokens:e,costText:t})=>(0,a.jsxs)("span",{children:[void 0===e?"—":new Intl.NumberFormat("en-US",{notation:"compact"}).format(e),t?(0,a.jsxs)("span",{className:"ml-2 text-muted-foreground",children:["• ",t]}):null]});function nJ(e){return{inputTokens:e.usage?.inputTokens??0,outputTokens:e.usage?.outputTokens??0,totalTokens:e.usage?.totalTokens??e.usedTokens,cachedInputTokens:e.usage?.cachedInputTokens??0,reasoningTokens:e.usage?.reasoningTokens??0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0}}}function nQ({part:e}){let t=e.agentContext,n=nJ(e),s=n.inputTokens+n.outputTokens+n.reasoningTokens,r=n.totalTokens>0?n.cachedInputTokens/n.totalTokens:0,l=function(e){if(e?.length)return JSON.stringify(e.map(e=>({id:e.id,type:e.type,title:e.title,toolUseId:e.toolUseId,toolName:e.toolName,characters:e.characters,tokens:e.tokens,text:e.text})),null,2)}(t?.outputItems)??t?.output,i=function(e){if(e?.length)return e.reduce((e,t)=>({characters:e.characters+(t.characters??0),tokens:e.tokens+(t.tokens??0)}),{characters:0,tokens:0})}(t?.outputItems)??nZ(t?.output),o=[{key:"systemPrompt",title:"提示词信息",value:t?.systemPrompt,empty:"此 agent 未配置独立 system prompt。"},{key:"userPrompt",title:"输入信息",value:t?.userPrompt,empty:"旧消息未记录用户输入。"},{key:"fullPrompt",title:"完整上下文",value:t?.fullPrompt,empty:"旧消息未记录完整 prompt。"},{key:"output",title:"输出信息",value:l,empty:"暂无输出信息。",stats:i}].map(e=>({...e,stats:e.stats??nZ(e.value)})),c=o.reduce((e,t)=>e+t.stats.tokens,0);return(0,a.jsxs)("div",{className:"flex flex-col gap-4 h-full",children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,a.jsx)(eb.Badge,{variant:"secondary",children:t?.name||t?.role||"Agent"}),t?.runtime?(0,a.jsx)(eb.Badge,{variant:"outline",children:t.runtime}):null,t?.model||e.modelId?(0,a.jsx)(eb.Badge,{variant:"outline",children:t?.model||e.modelId}):null,t?.sessionId?(0,a.jsx)("span",{className:"font-mono text-[11px] text-muted-foreground",children:t.sessionId}):null]}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-3 xl:grid-cols-6",children:[(0,a.jsx)(nX,{label:"有效上下文",value:s,helper:"输入 + 输出 + 推理,不含缓存命中",emphasize:!0}),(0,a.jsx)(nX,{label:"总用量(含缓存)",value:n.totalTokens,helper:"provider usage total"}),(0,a.jsx)(nX,{label:"新输入",value:n.inputTokens}),(0,a.jsx)(nX,{label:"输出",value:n.outputTokens}),(0,a.jsx)(nX,{label:"推理",value:n.reasoningTokens}),(0,a.jsx)(nX,{label:"缓存输入",value:n.cachedInputTokens,helper:`${n0(r)} of total`})]}),(0,a.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,a.jsx)(nY,{title:o[0].title,value:o[0].value,empty:o[0].empty,stats:o[0].stats,totalTokens:c},o[0].key),(0,a.jsx)(nY,{title:o[1].title,value:o[1].value,empty:o[1].empty,stats:o[1].stats,totalTokens:c},o[1].key)]}),(0,a.jsxs)("div",{className:"flex flex-1 flex-col gap-4 min-h-0",children:[(0,a.jsx)(nY,{title:o[2].title,value:o[2].value,empty:o[2].empty,stats:o[2].stats,totalTokens:c},o[2].key),(0,a.jsx)(nY,{title:o[3].title,value:o[3].value,empty:o[3].empty,stats:o[3].stats,totalTokens:c},o[3].key)]})]})}function nX({label:e,value:t,helper:n,emphasize:s}){return(0,a.jsxs)("div",{className:(0,M.cn)("rounded-md border bg-muted/30 p-3",s&&"border-primary/30 bg-primary/5"),children:[(0,a.jsx)("div",{className:"text-[11px] text-muted-foreground",children:e}),(0,a.jsx)("div",{className:(0,M.cn)("mt-1 font-mono text-sm",s&&"font-semibold text-primary"),children:n1(t??0)}),n?(0,a.jsx)("div",{className:"mt-1 text-[10px] text-muted-foreground",children:n}):null]})}function nY({title:e,value:t,empty:n,stats:s,totalTokens:r}){let l=r>0?s.tokens/r:0;return(0,a.jsxs)("section",{className:"min-w-0 overflow-hidden flex flex-col gap-2",children:[(0,a.jsxs)("div",{className:"flex min-w-0 flex-wrap items-center justify-between gap-2",children:[(0,a.jsx)("h4",{className:"text-xs font-medium text-muted-foreground",children:e}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-end gap-1.5 font-mono text-[10px] text-muted-foreground",children:[(0,a.jsx)("span",{children:n0(l)}),(0,a.jsxs)("span",{children:[n1(s.characters)," 字"]}),(0,a.jsxs)("span",{children:[n1(s.tokens)," tokens"]})]})]}),(0,a.jsx)("pre",{className:(0,M.cn)("min-w-0 flex-1 min-h-0 whitespace-pre-wrap break-words rounded-md border bg-muted/30 p-3 font-mono text-xs leading-relaxed text-foreground overflow-auto",!t?.trim()&&"text-muted-foreground",!t?.trim()&&"text-muted-foreground"),children:t?.trim()||n})]})}function nZ(e){var t;let n,s,a=e?.trim()??"";return a?{characters:Array.from(a).length,tokens:(t=a,n=t.match(/[㐀-鿿豈-﫿]/g)?.length??0,s=t.replace(/[㐀-鿿豈-﫿]/g," "),Math.max(1,Math.ceil(n+.75*(s.match(/[A-Za-z0-9_]+|[^\sA-Za-z0-9_]/g)?.length??0))))}:{characters:0,tokens:0}}function n0(e){return new Intl.NumberFormat("en-US",{style:"percent",maximumFractionDigits:1}).format(e)}function n1(e){return new Intl.NumberFormat("en-US").format(e)}function n2({message:e}){let t=(0,r.useMemo)(()=>e.parts?.filter(e=>"context"===e.type)??[],[e.parts]),n=t[t.length-1],[s,l]=(0,r.useState)(!1),[i,o]=(0,r.useState)(!1),[c,d]=(0,r.useState)(),u=(0,nP.useLLMStore)(e=>e.models),m=(0,nP.useLLMStore)(e=>e.ensure),p=n?.modelId?u.find(e=>e.modelId===n.modelId||e.name===n.modelId):void 0,x=p?.maxContextTokens??n?.maxTokens;if((0,r.useEffect)(()=>{n&&m()},[m,n]),!n||!x)return null;let h=t.reduce((e,t)=>e+t.usedTokens,0),g=t.reduce((e,t)=>({inputTokens:e.inputTokens+(t.usage?.inputTokens??0),outputTokens:e.outputTokens+(t.usage?.outputTokens??0),totalTokens:e.totalTokens+(t.usage?.totalTokens??t.usedTokens),cachedInputTokens:e.cachedInputTokens+(t.usage?.cachedInputTokens??0),reasoningTokens:e.reasoningTokens+(t.usage?.reasoningTokens??0)}),{inputTokens:0,outputTokens:0,totalTokens:0,cachedInputTokens:0,reasoningTokens:0}),f=t.length>1?{...n,usedTokens:h,usage:g}:n,v=nJ(f),j=t.find(e=>e.id===c)??t[0];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(n$,{usedTokens:f.usedTokens,maxTokens:x,modelId:f.modelId,usage:v,open:s,onOpenChange:l,children:[(0,a.jsx)(nU,{className:"h-5 gap-1 px-1.5 text-[10px]"}),(0,a.jsxs)(nB,{children:[(0,a.jsx)(nF,{}),(0,a.jsxs)(nW,{className:"space-y-2",children:[(0,a.jsx)(nH,{}),(0,a.jsx)(nq,{}),(0,a.jsx)(nV,{}),(0,a.jsx)(nG,{})]}),(0,a.jsx)(n_,{}),(0,a.jsx)("div",{className:"border-t px-3 py-2",children:(0,a.jsx)("button",{type:"button",className:"w-full text-center text-xs text-primary hover:underline cursor-pointer",onClick:()=>{l(!1),o(!0)},children:"查看详情 →"})})]})]}),(0,a.jsx)(y.Dialog,{open:i,onOpenChange:o,children:(0,a.jsxs)(y.DialogContent,{className:"!flex !w-[min(920px,calc(100vw-2rem))] !max-w-[min(920px,calc(100vw-2rem))] !flex-col gap-0 overflow-hidden p-0",children:[(0,a.jsxs)(y.DialogHeader,{className:"border-b px-5 py-4",children:[(0,a.jsx)(y.DialogTitle,{className:"text-base",children:"Agent 上下文结构"}),(0,a.jsxs)(y.DialogDescription,{className:"text-xs",children:["此条消息包含 ",t.length," 次 agent 运行。选择 tab 查看提示词、输入、输出和 token 消耗。"]})]}),t.length?(0,a.jsxs)(nR.Tabs,{value:j?.id,onValueChange:d,className:"min-h-0 flex flex-1 gap-0",children:[(0,a.jsx)("div",{className:"flex w-56 shrink-0 flex-col border-r",children:(0,a.jsx)(nR.TabsList,{className:"!flex h-auto w-full flex-col items-stretch gap-1 rounded-none border-0 bg-transparent p-2",children:t.map((e,t)=>(0,a.jsxs)(nR.TabsTrigger,{value:e.id,className:"!w-full justify-start gap-2 px-3 py-2 text-xs",children:[(0,a.jsx)("span",{className:"flex size-5 shrink-0 items-center justify-center rounded-full bg-muted font-mono text-[10px] text-muted-foreground",children:t+1}),(0,a.jsx)(D.default,{className:"size-3.5 shrink-0"}),(0,a.jsx)("span",{className:"min-w-0 truncate",children:e.agentContext?.name||e.agentContext?.role||`Agent ${t+1}`})]},e.id))})}),(0,a.jsx)(nD.ScrollArea,{className:"max-h-[min(68vh,720px)] min-w-0 flex-1",children:t.map(e=>(0,a.jsx)(nR.TabsContent,{value:e.id,className:"m-0 min-w-0 p-5",children:(0,a.jsx)(nQ,{part:e})},e.id))})]}):null]})})]})}function n5({message:e,isUser:t,workspaceId:n}){let s=(0,l.useTranslations)("chat"),r=e.parts??[],i=r.filter(e=>"context"!==e.type),o=i.some(e=>"text"===e.type),c=0===r.length&&e.content;return(0,a.jsxs)("div",{className:"space-y-3 min-w-0 overflow-hidden",children:[e.attachments?.length?(0,a.jsx)(n6,{attachments:e.attachments,isUser:t}):null,i.length>0?i.map(t=>(0,a.jsx)(n3,{part:function(e){if("text"!==e.type)return e;let t=n8(e.text);return t===e.text?e:{...e,text:t}}(t),message:e,workspaceId:n},t.id)):null,!o&&c?t?(0,a.jsx)(n9,{content:e.content}):(0,a.jsx)(b.Markdown,{content:n8(e.content),workspaceId:n}):null,"pending"===e.status&&0===i.length?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-muted-foreground",children:[(0,a.jsx)(z,{size:14}),(0,a.jsx)("span",{children:s("messageParts.agentProcessing")})]}):null]})}function n3({part:e,message:t,workspaceId:n}){let s=(0,l.useTranslations)("chat");switch(e.type){case"text":return(0,a.jsx)(b.Markdown,{content:e.text,workspaceId:n});case"user_message":return(0,a.jsx)(n4,{text:e.text,senderName:e.senderName||"用户"});case"reasoning":return(0,a.jsxs)(t_,{defaultOpen:"streaming"===e.status,className:"max-w-none",children:[(0,a.jsx)(tH,{loading:"streaming"===e.status,children:s("streaming"===e.status?"messageParts.agentThinking":"messageParts.aiIntermediateOutput")}),(0,a.jsx)(tK,{className:"max-h-[300px] overflow-y-auto",children:(0,a.jsx)("div",{className:"pl-6 text-xs text-muted-foreground",children:(0,a.jsx)(b.Markdown,{content:e.text,workspaceId:n})})})]});case"chain":let r=e.chains.filter(e=>!tF(e.text??e.description??e.title)),i=r.filter(e=>"message"!==e.kind).length;if(0===r.length)return null;return(0,a.jsxs)(t_,{defaultOpen:"pending"===t.status,className:"max-w-none",children:[(0,a.jsx)(tH,{loading:"pending"===t.status||"streaming"===t.status,children:s("messageParts.chainSteps",{count:i})}),(0,a.jsx)(tK,{className:"max-h-[300px] overflow-y-auto",children:r.map(e=>{let s="completed"===e.status;return"message"===e.kind?(0,a.jsx)(nw,{text:e.text??e.title,status:s?"complete":"active",workspaceId:n},e.id):(0,a.jsx)(nC,{chain:e,message:t,workspaceId:n,status:s?"complete":"active"},e.id)})})]});case"terminal":return(0,a.jsx)(t5,{output:e.command?`$ ${e.command}
3
+ ${e.output}`:e.output,isStreaming:"streaming"===e.status,className:"error"===e.status?"border-destructive/40":void 0});case"confirmation":{var o,c;let t=(o=e.id,(c=e.approval)&&void 0!==c.approved?{id:c.id,approved:c.approved,reason:c.reason}:{id:c?.id??o});return(0,a.jsxs)(tz,{approval:t,state:void 0===t.approved?"approval-requested":"approval-responded",children:[(0,a.jsxs)(tD,{children:[(0,a.jsxs)(tR,{children:[e.title,e.description?(0,a.jsx)("span",{className:"block text-xs",children:e.description}):null]}),(0,a.jsx)(tP,{children:e.title}),(0,a.jsx)(tA,{children:e.approval?.reason??e.title})]}),(0,a.jsxs)(tO,{children:[(0,a.jsx)(tE,{variant:"outline",children:s("messageParts.reject")}),(0,a.jsx)(tE,{children:s("messageParts.approve")})]})]})}case"context":case"ask_user_question":default:return null;case"subagent":let d=e.output&&!tF(e.output)?e.output:void 0;return(0,a.jsxs)(eN,{children:[(0,a.jsx)(ek,{name:e.name,model:e.model}),e.instructions||d||e.tools?.length?(0,a.jsxs)(ew,{children:[e.instructions?(0,a.jsx)(eC,{children:e.instructions}):null,d?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)("span",{className:"font-medium text-muted-foreground text-sm",children:s("messageParts.result")}),(0,a.jsx)("div",{className:"rounded-md bg-muted/50 p-3 text-sm",children:(0,a.jsx)(b.Markdown,{content:d,workspaceId:n})})]}):null,e.tools?.length?(0,a.jsx)(eS,{children:e.tools.map((e,t)=>(0,a.jsx)(eT,{value:`tool-${t}`,tool:{description:e.description??e.name,inputSchema:e.inputSchema,jsonSchema:e.jsonSchema}},`${e.name??"tool"}-${t}`))}):null]}):null]})}}function n4({text:e,senderName:t}){return(0,a.jsxs)("div",{className:"not-prose rounded-md border border-primary/20 bg-primary/5 px-3 py-2 text-sm",children:[(0,a.jsxs)("div",{className:"mb-1 text-xs font-medium text-primary",children:[t,":"]}),(0,a.jsx)(n9,{content:e})]})}function n6({attachments:e,isUser:t}){return(0,a.jsx)(tb,{variant:"inline",className:t?"justify-end":"justify-start",children:e.map((e,t)=>{var n,s;return(0,a.jsxs)(tN,{data:(n=e,s=t,{id:`${n.path||n.name}-${s}`,type:"file",filename:n.name,mediaType:n.type,url:n.url||n.path}),children:[(0,a.jsx)(tk,{}),(0,a.jsx)(tw,{showMediaType:!0})]},`${e.path}-${t}`)})})}function n9({content:e}){return/<[a-z][\s\S]*>/i.test(e)?(0,a.jsx)("span",{className:"tiptap tiptap-message",dangerouslySetInnerHTML:{__html:e}}):(0,a.jsx)("span",{className:"whitespace-pre-wrap break-all",children:e})}function n8(e){let t=[...e.split(/\r?\n/)];for(;t.length>1&&t.length%2==0;){let e=t.length/2,n=t.slice(0,e),s=t.slice(e);if(n7(n.join("\n"))!==n7(s.join("\n")))break;t=n}return t.join("\n")}function n7(e){return e.trim().replace(/\s+/g," ")}function se({message:e,workspaceId:t,onEdit:n,onDelete:s,onReply:i}){let c=(0,l.useTranslations)("common"),h="user"===e.senderId,w=(0,o.useAgentStore)(e=>e.agents),C=h?void 0:w.find(t=>t.id===e.senderId),S=h?c("you"):C?.name||e.senderId,M=(0,k.useUserAvatar)(),I=new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),[z,D]=(0,r.useState)(!1),[R,P]=(0,r.useState)(!1),[A,O]=(0,r.useState)(!1),E=e.replies??[],$="streaming"===e.status||"pending"===e.status||"waiting_for_user"===e.status,[L,U]=(0,r.useState)(()=>e.metadata?.duration??0);(0,r.useEffect)(()=>{if(!$&&e.metadata?.duration!=null)return void U(e.metadata.duration);if(!$)return;let t=new Date(e.createdAt).getTime();U(Date.now()-t);let n=setInterval(()=>U(Date.now()-t),1e3);return()=>clearInterval(n)},[e.metadata?.duration,e.createdAt,$]);let B=!h&&($||"completed"===e.status||"error"===e.status)&&L>0,F=(0,r.useCallback)(async()=>{let t=st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content;await navigator.clipboard.writeText(t),D(!0),setTimeout(()=>D(!1),2e3)},[e.content]);return(0,a.jsxs)("div",{className:`group flex gap-2 px-3 py-1.5 ${h?"flex-row-reverse":""}`,children:[(0,a.jsx)(N.AgentIcon,{agentId:h?void 0:e.senderId,name:S,avatarUrl:h&&M||void 0,onClick:()=>P(!0),className:"size-7 rounded-full"}),(0,a.jsxs)("div",{className:`flex flex-col min-w-0 w-[80%] ${h?"items-end":"items-start"}`,children:[!h&&(0,a.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,a.jsx)("span",{className:"text-xs font-medium text-foreground",children:S}),e.senderRole&&(0,a.jsx)("span",{className:"text-[10px] bg-muted px-1.5 py-0.5 rounded text-muted-foreground",children:e.senderRole}),e.metadata?.model&&(0,a.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground",children:e.metadata.model}),(0,a.jsx)(n2,{message:e}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:I})]}),(0,a.jsxs)("div",{className:`min-w-0 max-w-full text-sm rounded-lg px-3 py-2 ${h?"bg-primary text-primary-foreground":"bg-muted"}`,children:[(0,a.jsx)(n5,{message:e,isUser:h,workspaceId:t}),(E.length>0||B)&&(0,a.jsxs)("div",{className:"mt-1 flex items-center justify-between gap-3 border-t border-border/30 pt-1",children:[(0,a.jsx)(sn,{replies:E,currentUserLabel:c("you")}),(0,a.jsxs)("div",{className:"ml-auto flex items-center justify-end gap-1",children:[!$&&"completed"===e.status&&(0,a.jsx)(f.CheckCircle2,{className:"h-3 w-3 text-green-500 shrink-0"}),!$&&"error"===e.status&&(0,a.jsx)(v.XCircle,{className:"h-3 w-3 text-destructive shrink-0"}),B&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(x.Clock,{className:"h-3 w-3 text-muted-foreground"}),(0,a.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:[function(e){let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m ${t%60}s`;let s=Math.floor(n/60);return`${s}h ${n%60}m`}(L),$&&(0,a.jsx)("span",{className:"animate-pulse ml-0.5",children:"..."})]})]})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-0.5 h-6 opacity-0 group-hover:opacity-100 transition-opacity",children:[(0,a.jsx)("button",{onClick:()=>i?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"回复",children:(0,a.jsx)(g,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:F,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"复制",children:z?(0,a.jsx)(p.Check,{className:"h-3.5 w-3.5 text-green-500"}):(0,a.jsx)(d.Copy,{className:"h-3.5 w-3.5"})}),h&&(0,a.jsx)("button",{onClick:()=>n?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"编辑",children:(0,a.jsx)(u.Pencil,{className:"h-3.5 w-3.5"})}),!h&&e.content&&(0,a.jsx)("button",{onClick:()=>O(!0),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors cursor-pointer",title:"全屏查看",children:(0,a.jsx)(j.Maximize2,{className:"h-3.5 w-3.5"})}),(0,a.jsx)("button",{onClick:()=>s?.(e),className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-destructive transition-colors cursor-pointer",title:"删除",children:(0,a.jsx)(m.Trash2,{className:"h-3.5 w-3.5"})})]})]}),(0,a.jsx)(T,{open:R,onOpenChange:P,memberName:e.senderId,channelId:e.channelId,workspaceId:t}),!h&&A&&(0,a.jsx)(y.Dialog,{open:A,onOpenChange:O,children:(0,a.jsxs)(y.DialogPortal,{children:[(0,a.jsx)(y.DialogOverlay,{}),(0,a.jsxs)(y.DialogContent,{className:"max-w-4xl max-h-[85vh] flex flex-col gap-0",children:[(0,a.jsx)(y.DialogHeader,{children:(0,a.jsx)(y.DialogTitle,{children:S})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:(0,a.jsx)(b.Markdown,{content:st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content,workspaceId:t})})]})]})})]})}function st(e){return/<[a-z][\s\S]*>/i.test(e)}function sn({replies:e,currentUserLabel:t}){return 0===e.length?(0,a.jsx)("span",{className:"min-w-0"}):(0,a.jsxs)(w.Popover,{children:[(0,a.jsxs)(w.PopoverTrigger,{render:(0,a.jsx)("button",{type:"button",className:"min-w-0 truncate text-[11px] text-muted-foreground transition-colors hover:text-foreground cursor-pointer"}),children:["有 ",e.length," 条回复消息"]}),(0,a.jsx)(w.PopoverContent,{align:"start",sideOffset:4,className:"w-96 max-w-[calc(100vw-2rem)] p-2",children:(0,a.jsx)("div",{className:"max-h-96 space-y-2 overflow-y-auto pr-1",children:e.map(e=>(0,a.jsxs)("div",{className:"rounded-md border bg-muted/30 px-3 py-2 text-sm",children:[(0,a.jsxs)("div",{className:"mb-1 flex items-center justify-between gap-2 text-xs text-muted-foreground",children:[(0,a.jsx)("span",{children:"user"===e.senderId?t:e.senderRole||e.senderId}),(0,a.jsx)("span",{children:new Date(e.createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsx)("div",{className:"whitespace-pre-wrap break-words",children:st(e.content)?e.content.replace(/<[^>]*>/g,""):e.content})]},e.id))})})]})}var ss=e.i(917955),sa={outline:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"},filled:{xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"}};let sr=(e,t,n,s)=>{let a=(0,r.forwardRef)(({color:n="currentColor",size:a=24,stroke:l=2,title:i,className:o,children:c,...d},u)=>(0,r.createElement)("svg",{ref:u,...sa[e],width:a,height:a,className:["tabler-icon",`tabler-icon-${t}`,o].join(" "),..."filled"===e?{fill:n}:{strokeWidth:l,stroke:n},...d},[i&&(0,r.createElement)("title",{key:"svg-title"},i),...s.map(([e,t])=>(0,r.createElement)(e,t)),...Array.isArray(c)?c:[c]]));return a.displayName=`${n}`,a},sl=sr("outline","chevron-up","ChevronUp",[["path",{d:"M6 15l6 -6l6 6",key:"svg-0"}]]),si=sr("outline","microphone","Microphone",[["path",{d:"M9 5a3 3 0 0 1 3 -3a3 3 0 0 1 3 3v5a3 3 0 0 1 -3 3a3 3 0 0 1 -3 -3l0 -5",key:"svg-0"}],["path",{d:"M5 10a7 7 0 0 0 14 0",key:"svg-1"}],["path",{d:"M8 21l8 0",key:"svg-2"}],["path",{d:"M12 17l0 4",key:"svg-3"}]]),so=sr("outline","paperclip","Paperclip",[["path",{d:"M15 7l-6.5 6.5a1.5 1.5 0 0 0 3 3l6.5 -6.5a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9l6.5 -6.5",key:"svg-0"}]]),sc=sr("outline","plus","Plus",[["path",{d:"M12 5l0 14",key:"svg-0"}],["path",{d:"M5 12l14 0",key:"svg-1"}]]),sd=sr("outline","wand","Wand",[["path",{d:"M6 21l15 -15l-3 -3l-15 15l3 3",key:"svg-0"}],["path",{d:"M15 6l3 3",key:"svg-1"}],["path",{d:"M9 3a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-2"}],["path",{d:"M19 13a2 2 0 0 0 2 2a2 2 0 0 0 -2 2a2 2 0 0 0 -2 -2a2 2 0 0 0 2 -2",key:"svg-3"}]]);var su=e.i(437122),sm=e.i(568772),sp=e.i(99567),sx=e.i(332339),sh=e.i(780207),sg=e.i(898822),sf=e.i(972097),sv=e.i(162519),sj=e.i(199302),sy=e.i(939785),sb=e.i(111092),sN=e.i(822162);let sk=new sb.PluginKey("agentResourceSuggestion"),sw=new sb.PluginKey("fileSearchSuggestion");var sC=e.i(444433),sS=e.i(230698),sT=e.i(272736);let sM=sr("outline","file-text","FileText",[["path",{d:"M14 3v4a1 1 0 0 0 1 1h4",key:"svg-0"}],["path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2",key:"svg-1"}],["path",{d:"M9 9l1 0",key:"svg-2"}],["path",{d:"M9 13l6 0",key:"svg-3"}],["path",{d:"M9 17l6 0",key:"svg-4"}]]),sI=sr("outline","message-circle-plus","MessageCirclePlus",[["path",{d:"M12.007 19.98a9.869 9.869 0 0 1 -4.307 -.98l-4.7 1l1.3 -3.9c-2.324 -3.437 -1.426 -7.872 2.1 -10.374c3.526 -2.501 8.59 -2.296 11.845 .48c1.992 1.7 2.93 4.04 2.747 6.34",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}]]),sz=sr("outline","tools","Tools",[["path",{d:"M3 21h4l13 -13a1.5 1.5 0 0 0 -4 -4l-13 13v4",key:"svg-0"}],["path",{d:"M14.5 5.5l4 4",key:"svg-1"}],["path",{d:"M12 8l-5 -5l-4 4l5 5",key:"svg-2"}],["path",{d:"M7 8l-1.5 1.5",key:"svg-3"}],["path",{d:"M16 12l5 5l-4 4l-5 -5",key:"svg-4"}],["path",{d:"M16 17l-1.5 1.5",key:"svg-5"}]]);function sD(e){let t=new Set,n=e=>{if(e&&("mention"===e.type&&"string"==typeof e.attrs?.id&&t.add(e.attrs.id),Array.isArray(e.content)))for(let t of e.content)n(t)};return n(e),[...t]}function sR(e,t){return e?{type:"doc",content:e.split("\n").map(e=>{let n=function(e,t){let n,s=[],a=/@(\S+)/g,r=0;for(;null!==(n=a.exec(e));){n.index>r&&s.push({type:"text",text:e.slice(r,n.index)});let l=n[1],i=t.find(e=>e.name===l||e.id===l||e.role===l);i?s.push({type:"mention",attrs:{id:i.id,label:i.name||i.role}}):s.push({type:"text",text:n[0]}),r=a.lastIndex}return r<e.length&&s.push({type:"text",text:e.slice(r)}),s}(e,t);return{type:"paragraph",content:n.length>0?n:void 0}})}:{type:"doc",content:[{type:"paragraph"}]}}async function sP(e){let t=new FormData;t.append("file",e.file);let n=await fetch("/api/upload",{method:"POST",body:t});if(!n.ok)throw Error(`Upload failed: ${e.file.name}`);let s=await n.json();return{name:s.name,path:s.url,url:s.url,type:s.type,size:s.size}}let sA=sr("outline","pin","Pin",[["path",{d:"M15 4.5l-4 4l-4 1.5l-1.5 1.5l7 7l1.5 -1.5l1.5 -4l4 -4",key:"svg-0"}],["path",{d:"M9 15l-4.5 4.5",key:"svg-1"}],["path",{d:"M14.5 4l5.5 5.5",key:"svg-2"}]]),sO=sr("filled","pin-filled","PinFilled",[["path",{d:"M15.113 3.21l.094 .083l5.5 5.5a1 1 0 0 1 -1.175 1.59l-3.172 3.171l-1.424 3.797a1 1 0 0 1 -.158 .277l-.07 .08l-1.5 1.5a1 1 0 0 1 -1.32 .082l-.095 -.083l-2.793 -2.792l-3.793 3.792a1 1 0 0 1 -1.497 -1.32l.083 -.094l3.792 -3.793l-2.792 -2.793a1 1 0 0 1 -.083 -1.32l.083 -.094l1.5 -1.5a1 1 0 0 1 .258 -.187l.098 -.042l3.796 -1.425l3.171 -3.17a1 1 0 0 1 1.497 -1.26z",key:"svg-0"}]]),sE=sr("outline","user-plus","UserPlus",[["path",{d:"M8 7a4 4 0 1 0 8 0a4 4 0 0 0 -8 0",key:"svg-0"}],["path",{d:"M16 19h6",key:"svg-1"}],["path",{d:"M19 16v6",key:"svg-2"}],["path",{d:"M6 21v-2a4 4 0 0 1 4 -4h4",key:"svg-3"}]]),s$=sr("outline","bell","Bell",[["path",{d:"M10 5a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3a4 4 0 0 0 2 3h-16a4 4 0 0 0 2 -3v-3a7 7 0 0 1 4 -6",key:"svg-0"}],["path",{d:"M9 17v1a3 3 0 0 0 6 0v-1",key:"svg-1"}]]),sL=sr("outline","bell-off","BellOff",[["path",{d:"M9.346 5.353c.21 -.129 .428 -.246 .654 -.353a2 2 0 1 1 4 0a7 7 0 0 1 4 6v3m-1 3h-13a4 4 0 0 0 2 -3v-3a6.996 6.996 0 0 1 1.273 -3.707",key:"svg-0"}],["path",{d:"M9 17v1a3 3 0 0 0 6 0v-1",key:"svg-1"}],["path",{d:"M3 3l18 18",key:"svg-2"}]]);function sU({agents:e,activeAgent:t,pinnedMentionId:n,isPinned:s,channel:r,onActivateAgent:i,onTogglePin:o,onOpenAddMember:c,onToggleNotify:d}){let u=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:"flex items-center gap-1 mb-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 overflow-x-auto scrollbar-none flex-1 min-w-0",children:[(0,a.jsx)("button",{type:"button",onClick:c,className:"shrink-0 inline-flex items-center justify-center size-6 rounded-full text-muted-foreground border border-dashed border-muted-foreground/40 hover:bg-accent hover:text-foreground transition-all cursor-pointer",title:u("input.manageMembers"),children:(0,a.jsx)(sE,{className:"size-3.5"})}),e.map(e=>{let r=e.id===t?.id;return(0,a.jsxs)("button",{type:"button",onClick:()=>i(e),className:(0,M.cn)("shrink-0 inline-flex items-center gap-1 h-6 pl-0.5 pr-1 rounded-full text-xs transition-all",r?"bg-primary/10 text-primary border border-primary/30":"text-muted-foreground border border-transparent hover:bg-accent"),children:[(0,a.jsx)(N.AgentIcon,{agentId:e.id,name:e.name||e.role,avatarUrl:e.avatarUrl,className:"size-5 rounded-full text-[9px]"}),(0,a.jsx)("span",{className:"max-w-[80px] truncate",children:e.name||e.role}),r?(0,a.jsx)("span",{role:"button",tabIndex:0,onClick:e=>{e.stopPropagation(),o()},onKeyDown:e=>{("Enter"===e.key||" "===e.key)&&(e.stopPropagation(),o())},className:(0,M.cn)("inline-flex items-center justify-center size-4 rounded-full hover:bg-primary/20 transition-colors",s?"text-primary":"text-primary/50"),title:s?u("input.unpinAgent"):u("input.pinAgent"),children:s?(0,a.jsx)(sO,{className:"size-2.5"}):(0,a.jsx)(sA,{className:"size-2.5"})}):n===e.id?(0,a.jsx)(sO,{className:"size-2.5 text-muted-foreground/50"}):null]},e.id)})]}),(0,a.jsx)("button",{type:"button",onClick:d,className:(0,M.cn)("shrink-0 inline-flex items-center gap-1 h-6 px-1.5 rounded-full text-xs transition-all",r.notifyOnComplete?"bg-primary/10 text-primary border border-primary/30":"text-muted-foreground border border-transparent hover:bg-accent"),title:u("input.notifyOnComplete"),children:r.notifyOnComplete?(0,a.jsx)(s$,{className:"size-3"}):(0,a.jsx)(sL,{className:"size-3"})})]})}let sB=sr("outline","chevron-down","ChevronDown",[["path",{d:"M6 9l6 6l6 -6",key:"svg-0"}]]),sF=sr("outline","circle-check","CircleCheck",[["path",{d:"M3 12a9 9 0 1 0 18 0a9 9 0 1 0 -18 0",key:"svg-0"}],["path",{d:"M9 12l2 2l4 -4",key:"svg-1"}]]),sW=sr("outline","circle-dashed","CircleDashed",[["path",{d:"M8.56 3.69a9 9 0 0 0 -2.92 1.95",key:"svg-0"}],["path",{d:"M3.69 8.56a9 9 0 0 0 -.69 3.44",key:"svg-1"}],["path",{d:"M3.69 15.44a9 9 0 0 0 1.95 2.92",key:"svg-2"}],["path",{d:"M8.56 20.31a9 9 0 0 0 3.44 .69",key:"svg-3"}],["path",{d:"M15.44 20.31a9 9 0 0 0 2.92 -1.95",key:"svg-4"}],["path",{d:"M20.31 15.44a9 9 0 0 0 .69 -3.44",key:"svg-5"}],["path",{d:"M20.31 8.56a9 9 0 0 0 -1.95 -2.92",key:"svg-6"}],["path",{d:"M15.44 3.69a9 9 0 0 0 -3.44 -.69",key:"svg-7"}]]),s_=sr("outline","loader-2","Loader2",[["path",{d:"M12 3a9 9 0 1 0 9 9",key:"svg-0"}]]),sH=sr("outline","plug","Plug",[["path",{d:"M9.785 6l8.215 8.215l-2.054 2.054a5.81 5.81 0 1 1 -8.215 -8.215l2.054 -2.054",key:"svg-0"}],["path",{d:"M4 20l3.5 -3.5",key:"svg-1"}],["path",{d:"M15 4l-3.5 3.5",key:"svg-2"}],["path",{d:"M20 9l-3.5 3.5",key:"svg-3"}]]),sq=sr("outline","puzzle","Puzzle",[["path",{d:"M4 7h3a1 1 0 0 0 1 -1v-1a2 2 0 0 1 4 0v1a1 1 0 0 0 1 1h3a1 1 0 0 1 1 1v3a1 1 0 0 0 1 1h1a2 2 0 0 1 0 4h-1a1 1 0 0 0 -1 1v3a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-1a2 2 0 0 0 -4 0v1a1 1 0 0 1 -1 1h-3a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1h1a2 2 0 0 0 0 -4h-1a1 1 0 0 1 -1 -1v-3a1 1 0 0 1 1 -1",key:"svg-0"}]]),sV=sr("outline","trash","Trash",[["path",{d:"M4 7l16 0",key:"svg-0"}],["path",{d:"M10 11l0 6",key:"svg-1"}],["path",{d:"M14 11l0 6",key:"svg-2"}],["path",{d:"M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2 -2l1 -12",key:"svg-3"}],["path",{d:"M9 7v-3a1 1 0 0 1 1 -1h4a1 1 0 0 1 1 1v3",key:"svg-4"}]]);function sG(e,t){return e.subject||e.title||e.activeForm||e.content||t}function sK({mcps:e,skills:t,tools:n,todos:s,onClearTodos:r}){let i=(0,l.useTranslations)("chat");return(0,a.jsxs)("div",{className:"flex items-center gap-0 pt-2",children:[(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sH,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.mcp"),e.length?` ${e.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:e.length?e.map(e=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(sH,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sH,{size:16,className:"opacity-60"}),i("input.noMcp")]})})})]}),(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sq,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.skill"),t.length?` ${t.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:t.length?t.map(e=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(sq,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:e})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sq,{size:16,className:"opacity-60"}),i("input.noSkills")]})})})]}),(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sz,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.tools"),n.length?` ${n.length}`:""]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"min-w-[200px] max-w-xs rounded-2xl p-1.5 bg-popover border-border",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:n.length?n.map(({name:e,label:t,icon:n})=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs truncate",children:[(0,a.jsx)(n,{size:16,className:"opacity-60 shrink-0"}),(0,a.jsx)("span",{className:"truncate",children:t})]},e)):(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-muted-foreground",children:[(0,a.jsx)(sz,{size:16,className:"opacity-60"}),i("input.noTools")]})})})]}),s&&s.length>0&&(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsxs)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 rounded-full border border-transparent hover:bg-accent text-muted-foreground text-xs"}),children:[(0,a.jsx)(sF,{className:"size-3"}),(0,a.jsxs)("span",{children:[i("input.todos")," ",s.length]}),(0,a.jsx)(sB,{className:"size-3"})]}),(0,a.jsxs)(ss.DropdownMenuContent,{align:"start",className:"w-80 rounded-2xl p-1.5 bg-popover border-border",children:[(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-0.5",children:s.map((e,t)=>(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs gap-2",onSelect:e=>e.preventDefault(),children:["completed"===e.status?(0,a.jsx)(sF,{size:14,className:"text-green-500 shrink-0"}):"in_progress"===e.status?(0,a.jsx)(s_,{size:14,className:"text-blue-500 shrink-0 animate-spin",style:{animationDuration:"3s"}}):(0,a.jsx)(sW,{size:14,className:"text-muted-foreground shrink-0"}),(0,a.jsx)("span",{className:(0,M.cn)("todo-text-scroll","completed"===e.status&&"line-through text-muted-foreground"),children:sG(e,i("untitledTodo"))})]},e.id||`${sG(e,i("untitledTodo"))}-${t}`))}),r&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ss.DropdownMenuSeparator,{}),(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs text-destructive focus:text-destructive gap-2 justify-center cursor-pointer",onClick:e=>{e.stopPropagation(),r()},children:[(0,a.jsx)(sV,{size:14}),i("input.clearTodos")]})]})]})]}),(0,a.jsx)("div",{className:"flex-1"})]})}let sJ=(0,r.forwardRef)(function({channelName:e,channelId:t,workspaceId:n,channel:s,agents:c,messages:d=[],onSend:u,isProcessing:m=!1,onStop:p,replyTo:x,onCancelReply:h},g){let f=(0,l.useTranslations)("chat"),[v,j]=(0,r.useState)(!1),{isRecording:y,start:b,stop:N}=function(){let[e,t]=(0,r.useState)(!1),[n,s]=(0,r.useState)(null),a=(0,r.useRef)(null),l=(0,r.useRef)(null),i=(0,r.useRef)(null),o=(0,r.useRef)(null),c=(0,r.useRef)(null),d=(0,r.useRef)(()=>{}),u=(0,r.useCallback)(async()=>{let e=(0,su.getToken)();console.log("[speech] loading config, token:",e?"present":"missing");let t=await fetch("/api/speech-recognition",{headers:e?{Authorization:`Bearer ${e}`}:{}});if(console.log("[speech] config response status:",t.status),!t.ok)return null;let n=await t.json();return console.log("[speech] configs found:",n.length,n.length>0?n[0]:""),n.length>0?n[0]:null},[]),m=(0,r.useCallback)(()=>{c.current&&(clearInterval(c.current),c.current=null),i.current?.disconnect(),l.current?.close(),o.current?.getTracks().forEach(e=>e.stop()),a.current?.readyState===WebSocket.OPEN&&(a.current.send(JSON.stringify({type:"end"})),a.current.close()),a.current=null,i.current=null,l.current=null,o.current=null,t(!1)},[]);return(0,r.useEffect)(()=>{d.current=m},[m]),{isRecording:e,start:(0,r.useCallback)(async e=>{let n,r=await u();if(!r)return console.warn("[speech] no config found, aborting"),!1;s(r);let c=(0,su.getToken)(),m="https:"===location.protocol?"wss:":"ws:",p=`${m}//${location.host}/ws/speech?token=${c??""}&configId=${r.id}`;console.log("[speech] connecting to",p.replace(/token=[^&]+/,"token=***"));let x=new WebSocket(p);a.current=x,x.onmessage=t=>{try{let n=JSON.parse(t.data);if(n.error)return void console.error("[speech] error from server:",n.error);n.text&&(console.log("[speech] result:",n.text,"isFinal:",n.isFinal),e(n.text,n.isFinal))}catch(e){console.error("[speech] failed to parse message:",e)}},x.onerror=e=>{console.error("[speech] WebSocket error",e),d.current()};try{await new Promise((e,t)=>{x.onopen=()=>{console.log("[speech] WebSocket connected"),e()},x.onerror=e=>{console.error("[speech] WebSocket connect failed",e),t(Error("WS connect failed"))}})}catch{return!1}try{n=await navigator.mediaDevices.getUserMedia({audio:{sampleRate:16e3,channelCount:1,echoCancellation:!0}}),console.log("[speech] microphone acquired, tracks:",n.getAudioTracks().length)}catch(e){return console.error("[speech] microphone access denied:",e),x.close(),!1}o.current=n;let h=new AudioContext({sampleRate:16e3});l.current=h,console.log("[speech] AudioContext sampleRate:",h.sampleRate);let g=h.createMediaStreamSource(n),f=h.createScriptProcessor(4096,1,1);i.current=f;let v=0;return f.onaudioprocess=e=>{if(x.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0),n=new Int16Array(t.length);for(let e=0;e<t.length;e++){let s=Math.max(-1,Math.min(1,t[e]));n[e]=s<0?32768*s:32767*s}x.send(n.buffer),(++v<=3||v%50==0)&&console.log("[speech] sent audio chunk #",v,"size:",n.buffer.byteLength)},g.connect(f),f.connect(h.destination),t(!0),!0},[u]),stop:m,config:n}}(),[k,w]=(0,r.useState)([]),[C,S]=(0,r.useState)([]),[T,I]=(0,r.useState)(!1),[z,D]=(0,r.useState)(!1),R=(0,r.useRef)(m),P=(0,r.useRef)(u),A=(0,r.useRef)(null),O=(0,r.useRef)(null),E=(0,r.useRef)(!1),$=(0,r.useRef)(null),L=(0,r.useRef)(c),U=(0,r.useRef)(s),B=(0,r.useRef)([]),F=(0,r.useRef)({mcps:[],tools:[]}),{saveDraft:W,clearDraft:_,updateChannel:H}=(0,i.useChannelStore)(),[q,V]=(0,r.useState)(!1),G=(0,o.useAgentStore)(e=>e.agents),K=s.pinnedMentionId,J=K===k[0]&&!!K,Q=(0,r.useMemo)(()=>{if(0===k.length)return[];let e=new Map(c.map(e=>[e.id,e]));return k.map(t=>e.get(t)).filter(e=>!!e)},[c,k])[0],X=(0,r.useMemo)(()=>(function(e){if(!e)return[];let t=e.mcpServers;return!t||"object"!=typeof t||Array.isArray(t)?[]:Object.keys(t)})(Q?.mcps),[Q?.mcps]),Y=(0,r.useMemo)(()=>Q?.skills??[],[Q?.skills]),Z=(0,r.useMemo)(()=>{let e=new Set(Q?.tools??[]);return(sC.BUILT_IN_AGENT_TOOLS??[]).filter(t=>e.has(t.name)).map(e=>{var t;return{...e,icon:"CreateCurrentChannelIssue"===(t=e.name)?sc:"ViewCurrentChannelIssue"===t?sM:"AddCurrentChannelComment"===t?sI:sz}})},[Q?.tools]),ee=(0,r.useMemo)(()=>Z.map(e=>({name:e.name,label:e.label})),[Z]),et=(0,r.useMemo)(()=>{let e=new Map;for(let t of d)t.senderId&&"user"!==t.senderId&&e.set(t.senderId,t.createdAt);return e},[d]),en=(0,r.useMemo)(()=>{let e=Q?.id;return[...c].sort((t,n)=>{if(t.id===e)return -1;if(n.id===e)return 1;let s=et.get(t.id)??"";return(et.get(n.id)??"").localeCompare(s)})},[c,Q?.id,et]);(0,r.useEffect)(()=>{R.current=m},[m]),(0,r.useEffect)(()=>{P.current=u},[u]),(0,r.useEffect)(()=>{L.current=c},[c]),(0,r.useEffect)(()=>{U.current=s},[s]),(0,r.useEffect)(()=>{B.current=Y},[Y]),(0,r.useEffect)(()=>{F.current={mcps:X,tools:ee}},[X,ee]);let es=(0,r.useCallback)(e=>{O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{e.trim()?W(n,t,e):_(n,t)},1e3)},[n,t,W,_]),ea=(0,r.useCallback)(async()=>{let e=A.current;if(!e||R.current||E.current)return;let s=e.getText().trim();if(!s&&0===C.length)return;let a=sD(e.getJSON());E.current=!0,I(!0),O.current&&(clearTimeout(O.current),O.current=null);try{let r=await Promise.all(C.map(sP));P.current(s?function(e){if(!e)return e;let t=e.replace(/<\/?p>/g,"");return/<[^>]+>/.test(t)?e:e.replace(/<\/p>\s*<p>/g,"\n").replace(/<\/?p>/g,"")}(e.getHTML()):"",a,r,x?.id),e.commands.clearContent(),S(e=>(e.forEach(e=>URL.revokeObjectURL(e.preview)),[])),w([]),h?.(),_(n,t)}finally{E.current=!1,I(!1)}},[C,n,t,x?.id,h,_]),{getRootProps:er,getInputProps:el,open:ei}=(0,sg.useDropzone)({noClick:!0,noKeyboard:!0,multiple:!0,accept:{"image/*":[],"application/pdf":[".pdf"],"application/msword":[".doc"],"application/vnd.openxmlformats-officedocument.wordprocessingml.document":[".docx"],"text/*":[".txt",".md",".csv",".json"]},onDrop:e=>{S(t=>[...t,...e.map(e=>({file:e,preview:URL.createObjectURL(e)}))])}});(0,r.useEffect)(()=>()=>{C.forEach(e=>URL.revokeObjectURL(e.preview))},[C]);let eo=(0,r.useCallback)((e,t)=>{let{tr:n}=e.state,s=!1,a=[];e.state.doc.descendants((e,n)=>{"mention"===e.type.name&&e.attrs?.id!==t&&a.push({pos:n,nodeSize:e.nodeSize})});for(let e=a.length-1;e>=0;e--){let{pos:t,nodeSize:r}=a[e];n.delete(t,t+r),s=!0}s&&e.view.dispatch(n)},[]),ec=(0,r.useRef)(x);(0,r.useEffect)(()=>{ec.current=x},[x]);let ed=(0,r.useMemo)(()=>sh.default.configure({HTMLAttributes:{class:"mention"},suggestion:{char:"@",items:({query:e})=>{if(ec.current)return[];let t=e.toLowerCase();return L.current.filter(e=>!1!==e.enabled&&`${e.name} ${e.role} ${e.description||""}`.toLowerCase().includes(t)).slice(0,6).map(e=>({id:e.id,label:e.name||e.role,description:`${e.role}${e.description?` \xb7 ${e.description}`:""}`}))},command:({editor:e,range:t,props:n})=>{eo(e,n.id),e.chain().focus().insertContentAt(t,[{type:"mention",attrs:n}]).run()},render:()=>(0,sv.createSuggestionRenderer)()}}),[eo]),eu=(0,r.useMemo)(()=>(0,sj.createSlashExtension)(()=>B.current),[]),em=(0,r.useMemo)(()=>{let e;return e=null,sy.Extension.create({name:"fileSearch",addOptions:()=>({suggestion:{char:"#",items:async({query:t})=>{if(!t.trim())return[];e?.abort(),e=new AbortController;try{let s=await fetch(`/api/workspaces/${n}/search/files?q=${encodeURIComponent(t.trim())}`,{signal:e.signal});if(!s.ok)return[];return((await s.json()).results||[]).filter(e=>"file"===e.type).slice(0,10).map(e=>({id:e.path,title:e.name,description:e.path}))}catch{return[]}},command:({editor:e,range:t,props:n})=>{e.chain().focus().deleteRange(t).insertContent(n.description+" ").run()},render:()=>(0,sv.createSuggestionRenderer)()}}),addProseMirrorPlugins(){return[(0,sN.default)({pluginKey:sw,editor:this.editor,...this.options.suggestion})]}})},[n]),ep=(0,r.useMemo)(()=>(function(e=()=>({mcps:[],tools:[]})){return sy.Extension.create({name:"agentResource",addOptions:()=>({suggestion:{char:"$",items:({query:t})=>(function({mcps:e,tools:t},n){let s=n.toLowerCase(),a=new Set,r=[];for(let t of e){let e=t.trim(),n=`mcp:${e}`;!(!e||a.has(n))&&(a.add(n),e.toLowerCase().includes(s)&&r.push({id:n,title:e,description:"mcp",kind:"mcp",value:e}))}for(let e of t){let t=e.name.trim(),n=e.label.trim()||t,l=`tool:${t}`;!(!t||a.has(l))&&(a.add(l),`${t} ${n}`.toLowerCase().includes(s)&&r.push({id:l,title:n,description:`tool \xb7 ${t}`,kind:"tool",value:t}))}return r})(e(),t),command:({editor:e,range:t,props:n})=>{e.chain().focus().deleteRange(t).insertContent(`[use ${n.kind}: ${n.value}]`).run()},render:()=>(0,sv.createSuggestionRenderer)()}}),addProseMirrorPlugins(){return[(0,sN.default)({pluginKey:sk,editor:this.editor,...this.options.suggestion})]}})})(()=>F.current),[]),ex=(0,r.useRef)(ea);ex.current=ea;let eh=(0,sm.useEditor)({immediatelyRender:!1,extensions:[sp.default,sx.default.configure({placeholder:f("input.placeholder",{channel:e})}),ed,eu,ep,em],editorProps:{attributes:{class:"tiptap tiptap-chat"},handleKeyDown:(e,t)=>"Enter"===t.key&&!t.shiftKey&&!document.querySelector(".suggestion-menu")&&(t.preventDefault(),ex.current(),!0),handlePaste:(e,t)=>{let n,s=t.clipboardData?.getData("text/html");if(s?.includes('data-type="mention"'))return!1;let a=t.clipboardData?.getData("text/plain");if(!a||!/@\S+/.test(a))return!1;let r=L.current;if(0===r.length)return!1;let l=/@(\S+)/g,i=!1;for(;null!==(n=l.exec(a));)if(r.some(e=>e.name===n[1]||e.id===n[1]||e.role===n[1])){i=!0;break}if(!i)return!1;let o=A.current;return!!o&&(o.commands.insertContent(sR(a,r)),!0)}},content:"",onUpdate:({editor:e})=>{let t=sD(e.getJSON());w(e=>e.length===t.length&&e.every((e,n)=>e===t[n])?e:t),es(e.getHTML())}},[ed,eu,ep,em,e]);(0,r.useEffect)(()=>{A.current=eh},[eh]);let eg=(0,r.useCallback)(e=>{if(!eh||k[0]===e.id)return;eo(eh,e.id);let t=eh.getText().trim(),n=[{type:"mention",attrs:{id:e.id,label:e.name||e.role}},{type:"text",text:" "+t}];eh.commands.setContent({type:"doc",content:[{type:"paragraph",content:n}]},{emitUpdate:!0}),eh.commands.focus("end")},[eh,k,eo]);(0,r.useEffect)(()=>{if(!eh||$.current===t)return;$.current=t,O.current&&(clearTimeout(O.current),O.current=null);let e=U.current.draft,n=U.current.pinnedMentionId,s=n?L.current.find(e=>e.id===n):void 0,a=e?.content?e.content:s?[{type:"mention",attrs:{id:s.id,label:s.name||s.role}},{type:"text",text:" "}]:"";eh.commands.setContent(a,{emitUpdate:!1}),w(sD(eh.getJSON()))},[eh,t]),(0,r.useImperativeHandle)(g,()=>({setContent:(e,t)=>{if(eh){if(e.includes('data-type="mention"'))eh.commands.setContent(e,{emitUpdate:!1});else{let n=/<[a-z][\s\S]*>/i.test(e)?e.replace(/<[^>]*>/g,""):e,s=t??L.current;s.length>0&&/@\S+/.test(n)?eh.commands.setContent(sR(n,s),{emitUpdate:!1}):eh.commands.setContent(n,{emitUpdate:!1})}eh.commands.focus("end")}},focus:()=>{eh?.commands.focus("end")}}),[eh]);let ef=(0,r.useCallback)(()=>{ea()},[ea]),ev=(!!(0,sm.useEditorState)({editor:eh,selector:e=>!!e.editor?.getText().trim()})||C.length>0)&&!T,ej=(0,r.useCallback)(e=>{S(t=>{let n=[...t],[s]=n.splice(e,1);return s&&URL.revokeObjectURL(s.preview),n})},[]),ey=(0,r.useCallback)(()=>{let e=k[0];e&&H(n,t,{pinnedMentionId:J?void 0:e})},[k,J,n,t,H]),eb=(0,r.useCallback)(()=>{y?N():b((e,t)=>{let n=A.current;n&&t&&n.chain().focus().insertContent(e).run()})},[y,b,N]),eN=(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(ss.DropdownMenu,{children:[(0,a.jsx)(ss.DropdownMenuTrigger,{render:(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0 rounded-full border border-border hover:bg-accent"}),children:(0,a.jsx)(sc,{className:"size-3"})}),(0,a.jsx)(ss.DropdownMenuContent,{align:"start",className:"max-w-xs rounded-2xl p-1.5",children:(0,a.jsx)(ss.DropdownMenuGroup,{className:"space-y-1",children:(0,a.jsxs)(ss.DropdownMenuItem,{className:"rounded-[calc(1rem-6px)] text-xs",onClick:ei,children:[(0,a.jsx)(so,{size:16,className:"opacity-60"}),f("input.attachFiles")]})})})]}),(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",onClick:()=>D(!z),className:(0,M.cn)("h-7 px-2 rounded-full border border-border hover:bg-accent",{"bg-primary/10 text-primary border-primary/30":z,"text-muted-foreground":!z}),children:[(0,a.jsx)(sd,{className:"size-3"}),(0,a.jsx)("span",{className:"text-xs",children:f("input.autoMode")})]}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"sm",onClick:eb,className:(0,M.cn)("h-7 w-7 p-0 rounded-full border border-border hover:bg-accent",{"bg-red-500/10 text-red-500 border-red-500/30 animate-pulse":y,"text-muted-foreground":!y}),title:f(y?"input.voiceStop":"input.voiceStart"),children:(0,a.jsx)(si,{className:"size-3"})})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex justify-center -mt-0.5",children:(0,a.jsx)("button",{type:"button",onClick:()=>j(e=>!e),className:"p-0.5 text-muted-foreground/60 hover:text-foreground transition-colors cursor-pointer",children:(0,a.jsx)(sl,{className:(0,M.cn)("size-3.5 transition-transform",v&&"rotate-180")})})}),!v&&(0,a.jsxs)("div",{className:"border-t px-4 py-2",children:[!x&&(0,a.jsx)(sU,{agents:en,activeAgent:Q,pinnedMentionId:K,isPinned:J,channel:s,onActivateAgent:eg,onTogglePin:ey,onOpenAddMember:()=>V(!0),onToggleNotify:()=>H(n,t,{notifyOnComplete:!s.notifyOnComplete})}),(0,a.jsx)(sf.ComposerShell,{workspaceId:n,editor:eh,canSubmit:ev,onSubmit:ef,onStop:p,isProcessing:m||T,actions:eN,dropzoneProps:er(),hiddenInput:(0,a.jsx)("input",{...el(),"data-chat-file-input":""}),replyLabel:x?.label,onCancelReply:h}),C.length>0&&(0,a.jsx)(tb,{variant:"inline",className:"mt-2 justify-start",children:C.map((e,t)=>(0,a.jsxs)(tN,{data:{id:`${e.file.name}-${e.file.lastModified}`,type:"file",filename:e.file.name,mediaType:e.file.type,url:e.preview},onRemove:()=>ej(t),children:[(0,a.jsx)(tk,{}),(0,a.jsx)(tw,{}),(0,a.jsx)(tC,{})]},`${e.file.name}-${e.file.lastModified}-${t}`))}),(0,a.jsx)(sK,{mcps:X,skills:Y,tools:Z,todos:s.todos,onClearTodos:()=>H(n,t,{todos:[]})})]}),(0,a.jsx)(sS.AddMemberDialog,{open:q,onOpenChange:V,candidates:G.filter(e=>!1!==e.enabled).map(e=>({id:e.id,label:(0,sT.getAgentDisplayName)(e),description:e.role})),defaultSelected:s.members,onAdd:e=>{let s=G.filter(e=>!1!==e.enabled);H(n,t,{members:(0,sT.normalizeChannelMembersToAgentIds)(s,e)})}})]})});var sQ=e.i(681622),sX=e.i(613087);let sY=({className:e,status:t,...n})=>(0,a.jsx)(eb.Badge,{className:(0,M.cn)("flex items-center gap-2","group",t,e),variant:"secondary",...n}),sZ=({className:e,...t})=>(0,a.jsxs)("span",{className:(0,M.cn)("relative flex h-2 w-2",e),...t,children:[(0,a.jsx)("span",{className:(0,M.cn)("absolute inline-flex h-full w-full animate-ping rounded-full opacity-75","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")}),(0,a.jsx)("span",{className:(0,M.cn)("relative inline-flex h-2 w-2 rounded-full","group-[.online]:bg-emerald-500","group-[.offline]:bg-red-500","group-[.maintenance]:bg-blue-500","group-[.degraded]:bg-amber-500")})]}),s0=({className:e,children:t,...n})=>(0,a.jsx)("span",{className:(0,M.cn)("text-muted-foreground",e),...n,children:t??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"hidden group-[.online]:block",children:"Online"}),(0,a.jsx)("span",{className:"hidden group-[.offline]:block",children:"Offline"}),(0,a.jsx)("span",{className:"hidden group-[.maintenance]:block",children:"Maintenance"}),(0,a.jsx)("span",{className:"hidden group-[.degraded]:block",children:"Degraded"})]})});var s1=e.i(767467),s2=ni,s5=e.i(583705),s3=e.i(759309),s3=s3,s4=e.i(307858),s6=e.i(14452),s9=e.i(227634),s8=e.i(325443),s7=e.i(511800),ae=e.i(529658),at=e.i(929709),an=e.i(79882),as=e.i(478117);function aa({name:e,agentId:t,description:n,onClick:s}){return(0,a.jsxs)("button",{type:"button",onClick:s,className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left transition-colors cursor-pointer",children:[(0,a.jsx)(N.AgentIcon,{agentId:t,name:e,className:"size-7 rounded-full"}),(0,a.jsxs)("span",{className:"min-w-0",children:[(0,a.jsx)("span",{className:"block text-sm truncate",children:e}),n&&(0,a.jsx)("span",{className:"block text-xs text-muted-foreground truncate",children:n})]})]})}var ar=e.i(250226);function al({workspaceId:e,channel:t,agents:n,allChannels:s,onDeleted:o}){let c=(0,l.useTranslations)("chat"),d=(0,l.useTranslations)("common"),{updateChannel:p,deleteChannel:x}=(0,i.useChannelStore)(),[h,g]=(0,r.useState)(!1),[f,v]=(0,r.useState)(!1),[j,b]=(0,r.useState)(""),[N,k]=(0,r.useState)(!1),[w,C]=(0,r.useState)(!1),S=n.filter(e=>!1!==e.enabled),M=S.map(e=>({id:e.id,label:(0,sT.getAgentDisplayName)(e),description:e.role})),I=async()=>{await x(e,t.id),C(!1),ar.useMobilePanelStore.getState().setActivePanel("channel-list"),o?.()};return(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsx)("div",{className:"flex items-center justify-between px-4 h-12 border-b shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:["agent"===t.type?(0,a.jsx)(s8.Bot,{className:"size-4 text-muted-foreground shrink-0"}):"issue"===t.type?(0,a.jsx)(s7.AlertCircle,{className:"size-4 text-muted-foreground shrink-0"}):(0,a.jsx)(s9.Hash,{className:"size-4 text-muted-foreground shrink-0"}),(0,a.jsxs)("span",{className:"text-sm font-medium truncate",children:["#",t.name]})]})}),(0,a.jsxs)(nR.Tabs,{defaultValue:"info",className:"flex flex-col flex-1 min-h-0",children:[(0,a.jsxs)(nR.TabsList,{className:"w-full rounded-none border-b bg-transparent h-9 p-0 shrink-0",children:[(0,a.jsxs)(nR.TabsTrigger,{value:"info",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,a.jsx)(s5.Info,{className:"size-3.5"}),c("channel.info")]}),(0,a.jsxs)(nR.TabsTrigger,{value:"members",className:"flex-1 gap-1.5 data-[state=active]:shadow-none data-[state=active]:border-b-2 data-[state=active]:border-primary rounded-none",children:[(0,a.jsx)(ae.Users,{className:"size-3.5"}),c("channel.members")]})]}),(0,a.jsxs)(nD.ScrollArea,{className:"flex-1 min-h-0",children:[(0,a.jsxs)(nR.TabsContent,{value:"info",className:"p-4 mt-0 space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3",children:[(0,a.jsx)("div",{className:"flex items-center justify-center size-10 rounded-lg bg-muted",children:"agent"===t.type?(0,a.jsx)(s8.Bot,{className:"size-5 text-muted-foreground"}):"issue"===t.type?(0,a.jsx)(s7.AlertCircle,{className:"size-5 text-muted-foreground"}):(0,a.jsx)(s9.Hash,{className:"size-5 text-muted-foreground"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("p",{className:"text-sm font-medium",children:["#",t.name]}),(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[c("channel.type")," ",c(`channel.${t.type}`)]})]}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>g(!0),children:(0,a.jsx)(u.Pencil,{className:"size-3.5"})})]}),(0,a.jsxs)("div",{className:"space-y-2 text-sm",children:[(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:c("channel.channelId")}),(0,a.jsxs)("span",{className:"font-mono text-xs",children:[t.id.slice(0,8),"..."]})]}),(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:c("channel.memberCount")}),(0,a.jsx)("span",{children:t.members.length})]}),(0,a.jsxs)("div",{className:"flex justify-between py-1 border-b",children:[(0,a.jsx)("span",{className:"text-muted-foreground",children:c("channel.createdAt")}),(0,a.jsx)("span",{children:new Date(t.createdAt).toLocaleDateString()})]})]})]}),(0,a.jsxs)(nR.TabsContent,{value:"members",className:"p-4 mt-0 space-y-1",children:[0===t.members.length&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-4 text-center",children:c("channel.noMembers")}),t.members.map(e=>(0,a.jsx)(aa,{name:(0,sT.getMemberDisplayName)(S,e),agentId:"user"!==e?e:void 0,description:"user"!==e?e:void 0,onClick:()=>{b(e),v(!0)}},e)),(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",className:"w-full mt-2 text-xs text-muted-foreground",onClick:()=>k(!0),children:[(0,a.jsx)(at.UserPlus,{className:"size-3.5 mr-1"}),c("channel.addMember")]})]})]})]}),(0,a.jsxs)("div",{className:"shrink-0 p-3 border-t space-y-1",children:[(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",className:"w-full text-xs",onClick:()=>p(e,t.id,{archived:!t.archived}),children:[(0,a.jsx)(an.Archive,{className:"size-3.5 mr-1"}),c(t.archived?"channel.unarchive":"channel.archive")]}),(0,a.jsxs)(eE.Button,{variant:"ghost",size:"sm",className:"w-full text-xs text-destructive hover:text-destructive hover:bg-destructive/10",onClick:()=>C(!0),children:[(0,a.jsx)(m.Trash2,{className:"size-3.5 mr-1"}),c("channel.delete")]})]}),(0,a.jsx)(as.ChannelDialog,{open:h,onOpenChange:g,workspaceId:e,channel:t,agents:n,onSubmit:n=>p(e,t.id,{...n,members:(0,sT.normalizeChannelMembersToAgentIds)(S,n.members)})}),(0,a.jsx)(T,{open:f,onOpenChange:v,memberName:j,displayName:(0,sT.getMemberDisplayName)(S,j),channelId:t.id,workspaceId:e,channels:s.filter(e=>e.members.includes(j)).map(e=>e.name)}),(0,a.jsx)(sS.AddMemberDialog,{open:N,onOpenChange:k,candidates:M,defaultSelected:t.members,onAdd:n=>{p(e,t.id,{members:(0,sT.normalizeChannelMembersToAgentIds)(S,n)})}}),(0,a.jsx)(y.Dialog,{open:w,onOpenChange:C,children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:c("channel.delete")}),(0,a.jsx)(y.DialogDescription,{children:c("channel.deleteConfirm")})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:d("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:I,children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),d("delete")]})]})]})})]})}var ai=e.i(249673),ao=e.i(650654);function ac({messages:e,reverse:t}){var n;let s,l,i,[c,d]=(0,r.useState)(null),[u,m]=(0,r.useState)(!1),[p,x]=(0,r.useState)(0),h=(0,r.useRef)(null),g=t?[...e].reverse():e,f=(0,r.useCallback)(e=>{d(e);let t=document.getElementById(`msg-${g[e].id}`);t?.scrollIntoView({behavior:"smooth",block:"center"})},[g]),v=(0,r.useCallback)((e,t)=>{if(!t||!h.current)return;d(e);let n=h.current.getBoundingClientRect(),s=t.getBoundingClientRect();x(s.top-n.top+s.height/2)},[]);return 0===g.length?null:(0,a.jsxs)("div",{ref:h,className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 flex flex-col items-center",onMouseEnter:()=>m(!0),onMouseLeave:()=>{m(!1),d(null)},children:[(0,a.jsx)("button",{className:`flex-shrink-0 mb-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${u?"opacity-100":"opacity-0 pointer-events-none"} ${null===c||c<=0?"invisible":""}`,onClick:()=>{null!==c&&c>0&&f(c-1)},children:(0,a.jsx)(ai.ChevronUp,{className:"size-3.5"})}),(0,a.jsx)("div",{className:"flex-1 w-full max-h-[70vh] overflow-y-auto scrollbar-none",children:(0,a.jsx)("div",{className:"flex flex-col gap-[3px] px-1 py-0.5",children:g.map((e,t)=>(0,a.jsx)("div",{className:"flex justify-center",children:(0,a.jsx)("button",{className:`h-[4px] rounded-full transition-all duration-150 ${c===t?"bg-primary w-6":"user"===e.senderId?"bg-primary/30 hover:bg-primary/50 w-5":"bg-muted-foreground/25 hover:bg-muted-foreground/40 w-5"}`,onClick:()=>f(t),onMouseEnter:e=>v(t,e.currentTarget)})},e.id))})}),(0,a.jsx)("button",{className:`flex-shrink-0 mt-0.5 flex items-center justify-center size-5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-all ${u?"opacity-100":"opacity-0 pointer-events-none"} ${null===c||c>=g.length-1?"invisible":""}`,onClick:()=>{null!==c&&c<g.length-1&&f(c+1)},children:(0,a.jsx)(ao.ChevronDown,{className:"size-3.5"})}),u&&null!==c&&(0,a.jsxs)("div",{className:"absolute right-full mr-3 w-56 rounded-lg border bg-popover p-2.5 shadow-lg z-50 animate-in fade-in-0 zoom-in-95 duration-75",style:{top:p,transform:"translateY(-50%)"},children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5 mb-1",children:[(0,a.jsx)("span",{className:"font-medium text-xs",children:"user"===g[c].senderId?"You":(0,o.findAgentById)(g[c].senderId)?.name??g[c].senderId}),(0,a.jsx)("span",{className:"text-[10px] text-muted-foreground",children:new Date(g[c].createdAt).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground line-clamp-3 leading-relaxed",children:(n=g[c],l=(s=n.parts?.find(e=>"text"===e.type))?s.text:n.content,(i=/<[a-z][\s\S]*>/i.test(l)?l.replace(/<[^>]*>/g,""):l).length>150?i.slice(0,150)+"...":i)})]})]})}var ad=e.i(636288),au=e.i(327964);let am={general:{status:"online"},issue:{status:"degraded"},agent:{status:"maintenance"}};function ap({members:e}){let t=e.filter(e=>"user"!==e).slice(0,4),n=e.length-t.length-!!e.includes("user");return(0,a.jsxs)(ad.AvatarGroup,{className:"ml-1 [&>[data-slot=avatar]]:size-5",children:[t.map(e=>(0,a.jsx)(N.AgentIcon,{agentId:e,className:"size-5 rounded-full"},e)),n>0&&(0,a.jsxs)(ad.AvatarGroupCount,{className:"!size-5 text-[10px]",children:["+",n]})]})}function ax({question:e,onAnswer:t}){let n=(0,l.useTranslations)("chat"),[s,i]=(0,r.useState)(""),[o,c]=(0,r.useState)(!1),d=e=>{let n=e.trim();n&&!o&&(c(!0),t(n),i(""))};return(0,a.jsx)("div",{className:"border-t bg-background px-4 py-3",children:(0,a.jsx)("div",{className:"rounded-md border bg-muted/30 p-3",children:(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[(0,a.jsx)(s2.default,{className:"mt-0.5 size-4 shrink-0 text-muted-foreground"}),(0,a.jsxs)("div",{className:"min-w-0 flex-1 space-y-3",children:[(0,a.jsx)("div",{className:"text-sm font-medium",children:e.question}),e.choices.length>0?(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:e.choices.map(e=>(0,a.jsx)(eE.Button,{type:"button",size:"sm",variant:"outline",disabled:o,onClick:()=>d(e),className:"h-8",children:e},e))}):null,(0,a.jsxs)("form",{className:"flex gap-2",onSubmit:e=>{e.preventDefault(),d(s)},children:[(0,a.jsx)(sQ.Input,{value:s,onChange:e=>i(e.target.value),disabled:o,className:"h-8 text-sm",placeholder:n("pendingQuestion.placeholder")}),(0,a.jsx)(eE.Button,{type:"submit",size:"icon-sm",disabled:!s.trim()||o,children:(0,a.jsx)(s3.default,{className:"size-3.5"})})]})]})]})})})}e.s(["ChatPanel",0,function({workspaceId:e}){let t=(0,l.useTranslations)("chat"),n=(0,l.useTranslations)("common"),{activeChannelId:s,channels:d,messages:u,loadMessages:p,loadChannelState:x,sendMessage:h,addMessage:g,updateMessage:f,stopProcessingMessages:v,deleteMessage:j,clearMessages:b,upsertChannel:N}=(0,i.useChannelStore)(),k=(0,r.useRef)(null),[w,C]=(0,r.useState)(!1),[S,T]=(0,r.useState)(null),[M,I]=(0,r.useState)(!1),[z,D]=(0,r.useState)(null),[R,P]=(0,r.useState)(!1),[A,O]=(0,r.useState)(!1),E=(0,r.useRef)(null),$=(0,o.useAgentStore)(e=>e.agents),L=(0,o.useAgentStore)(e=>e.ensure),U=d.find(e=>e.id===s),B=(0,r.useMemo)(()=>s&&u[s]||[],[s,u]),F=B[B.length-1]?.status,W=(0,r.useMemo)(()=>(function(e){for(let t=e.length-1;t>=0;t-=1){let n=e[t];if("waiting_for_user"!==n.status)continue;let s=n.parts?.find(e=>"ask_user_question"===e.type&&"answered"!==e.status);if(s&&"ask_user_question"===s.type)return{messageId:n.id,questionId:s.id,question:s.question,choices:s.choices??[]}}return null})(B),[B]),_=(0,r.useMemo)(()=>{if(!U)return[];let e=new Map($.filter(e=>!1!==e.enabled).map(e=>[e.id,e]));return U.members.map(t=>e.get(t)).filter(e=>!!e)},[$,U]);(0,r.useEffect)(()=>{s&&(O(!1),P(!0),p(e,s).finally(()=>P(!1))),L()},[s,e,p,L]),(0,r.useEffect)(()=>{let t=(0,c.getWS)(e),n=t.on("channel.message",e=>{e.channelId===s&&g(e.channelId,e)}),a=t.on("channel.message.updated",e=>{e.channelId===s&&f(e.channelId,e)}),r=t.on("channel.message.deleted",e=>{e.channelId===s&&j(e.channelId,e.messageId)}),l=t.on("channel.messages.cleared",e=>{e.channelId===s&&i.useChannelStore.setState(e=>({messages:{...e.messages,[s]:[]}}))}),o=t.on("channel.updated",e=>{e.id===s&&N(e)});return()=>{n(),a(),r(),l(),o()}},[e,s,g,f,j,N]),(0,r.useEffect)(()=>{let e=k.current?.parentElement;e&&(e.scrollTop=0)},[B.length]),(0,r.useEffect)(()=>{if(!s||!e||!(F&&["pending","streaming","waiting_for_user"].includes(F)||A))return;let t=!1,n=async()=>{let n=await x(e,s);!t&&n&&(O(n.active),await p(e,s))},a=setInterval(n,3e3);return n(),()=>{t=!0,clearInterval(a)}},[s,e,A,F,p,x]);let H=(0,r.useCallback)((t,n,a,r)=>{s&&h(e,s,t,n,a,r)},[e,s,h]),q=A||B.length>0&&["pending","streaming","waiting_for_user"].includes(B[B.length-1].status??""),V=(0,r.useCallback)(()=>{s&&(v(s),(0,c.getWS)(e).send("channel.stop",{channelId:s}))},[e,s,v]),G=(0,r.useCallback)(e=>{E.current?.setContent(e.content,_)},[_]),K=(0,r.useCallback)(e=>{T(e)},[]),J=(0,r.useCallback)(e=>{let t="user"===e.senderId?void 0:$.find(t=>t.id===e.senderId);D({id:e.id,label:"user"===e.senderId?n("you"):t?.name||e.senderId}),E.current?.focus?.()},[$,n]),Q=(0,r.useCallback)(async()=>{S&&(await fetch(`/api/workspaces/${e}/channels/${S.channelId}/messages/${S.id}`,{method:"DELETE"}),T(null))},[e,S]);if(!U)return(0,a.jsx)("div",{className:"flex items-center justify-center h-full text-muted-foreground text-sm",children:t("emptyState")});let X=(()=>{let e=am[U.type];if(0===B.length)return{label:t("status.idle"),status:"degraded"};let n=B[B.length-1].status;if("waiting_for_user"===n)return{label:t("status.waitingForUser"),status:"degraded"};if("streaming"===n||"pending"===n)return{label:t("status.running"),status:"maintenance"};if("completed"===n)return{label:t("status.success"),status:"online"};if("error"===n){let e=B.slice(-3);return e.length>=3&&e.every(e=>"error"===e.status)?{label:t("status.error"),status:"offline"}:{label:t("status.running"),status:"degraded"}}return{label:t(`channelType.${U.type}`),status:e.status}})();return(0,a.jsxs)("div",{className:"flex h-full",children:[(0,a.jsxs)("div",{className:"flex flex-col flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 border-b",children:[(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",className:"md:hidden shrink-0",onClick:()=>ar.useMobilePanelStore.getState().setActivePanel("channel-list"),children:(0,a.jsx)(s1.ArrowLeft,{className:"size-4"})}),(0,a.jsxs)("span",{className:"text-sm font-semibold truncate shrink min-w-0",children:["# ",U.name]}),(0,a.jsxs)(sY,{status:X.status,children:[(0,a.jsx)(sZ,{}),(0,a.jsx)(s0,{children:X.label})]}),(0,a.jsx)(ap,{members:U.members}),(0,a.jsx)("div",{className:"flex-1"}),U.issueId&&(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>au.useIssueStore.getState().setActiveIssue(U.issueId),title:t("viewRelatedIssue"),children:(0,a.jsx)(s4.ExternalLink,{className:"size-4"})}),B.length>0&&(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>I(!0),children:(0,a.jsx)(m.Trash2,{className:"size-4"})}),(0,a.jsx)(eE.Button,{variant:"ghost",size:"icon-sm",onClick:()=>C(!0),children:(0,a.jsx)(s5.Info,{className:"size-4"})})]}),(0,a.jsxs)("div",{className:"flex-1 min-h-0 relative",children:[(0,a.jsxs)("div",{className:"h-full overflow-y-auto overflow-x-hidden py-2",children:[R&&0===B.length?(0,a.jsx)("div",{className:"space-y-4 px-4",children:Array.from({length:4},(e,t)=>(0,a.jsxs)("div",{className:"flex gap-3",children:[(0,a.jsx)(sX.Skeleton,{className:"size-6 rounded-full shrink-0 mt-0.5"}),(0,a.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(sX.Skeleton,{className:"h-4 w-20"}),(0,a.jsx)(sX.Skeleton,{className:"h-3 w-12"})]}),(0,a.jsx)(sX.Skeleton,{className:"h-4 w-full"}),(0,a.jsx)(sX.Skeleton,{className:"h-4 w-3/4"})]})]},t))}):null,!R&&[...B].reverse().map(t=>(0,a.jsx)("div",{id:`msg-${t.id}`,children:(0,a.jsx)(se,{message:t,workspaceId:e,onEdit:G,onDelete:K,onReply:J})},t.id)),(0,a.jsx)("div",{ref:k})]}),(0,a.jsx)(ac,{messages:B,reverse:!0})]}),W?(0,a.jsx)(ax,{question:W,onAnswer:t=>{(0,c.getWS)(e).send("channel.answer_question",{channelId:U.id,messageId:W.messageId,questionId:W.questionId,answer:t})}}):null,(0,a.jsx)(sJ,{ref:E,channelName:U.name,channelId:U.id,workspaceId:e,channel:U,agents:_,messages:B,onSend:H,isProcessing:q,onStop:V,replyTo:z,onCancelReply:()=>D(null)})]}),(0,a.jsx)(s6.Sheet,{open:w,onOpenChange:C,children:(0,a.jsxs)(s6.SheetContent,{side:"right",className:"w-80 p-0 gap-0",children:[(0,a.jsxs)(s6.SheetHeader,{className:"sr-only",children:[(0,a.jsx)(s6.SheetTitle,{children:U.name}),(0,a.jsx)(s6.SheetDescription,{children:"Channel info panel"})]}),(0,a.jsx)(al,{workspaceId:e,channel:U,agents:$,allChannels:d,onDeleted:()=>C(!1)})]})}),(0,a.jsx)(y.Dialog,{open:!!S,onOpenChange:e=>{e||T(null)},children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:t("deleteMessage.title")}),(0,a.jsx)(y.DialogDescription,{children:t("deleteMessage.description")})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:n("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:Q,children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),n("delete")]})]})]})}),(0,a.jsx)(y.Dialog,{open:M,onOpenChange:I,children:(0,a.jsxs)(y.DialogContent,{children:[(0,a.jsxs)(y.DialogHeader,{children:[(0,a.jsx)(y.DialogTitle,{children:t("clearMessages.title")}),(0,a.jsx)(y.DialogDescription,{children:t("clearMessages.description",{channel:U?.name})})]}),(0,a.jsxs)(y.DialogFooter,{children:[(0,a.jsx)(y.DialogClose,{render:(0,a.jsx)(eE.Button,{variant:"outline"}),children:n("cancel")}),(0,a.jsxs)(eE.Button,{variant:"destructive",onClick:async()=>{U&&await b(e,U.id),I(!1)},children:[(0,a.jsx)(m.Trash2,{className:"size-3.5"}),t("clearMessages.confirm")]})]})]})})]})}],885761)},773354,e=>{e.n(e.i(885761))}]);
@@ -0,0 +1,7 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,448303,e=>{"use strict";var t=e.i(344180),n=e.i(764556),s=e.i(129981),a=e.i(62669),i=e.i(194228),l=e.i(601039),r=e.i(378371),o=e.i(212965),c=e.i(381253),d=e.i(357301),u=e.i(137340),x=e.i(650654),h=e.i(327962),m=e.i(415360),p=e.i(210),f=e.i(253307),g=e.i(953700),j=e.i(450158),b=e.i(486657),C=e.i(363156),y=e.i(691223),v=e.i(244073);function w({workspaceId:e,onInitialized:s}){let a=(0,v.useTranslations)("git.notInitialized"),i=(0,C.useGitStore)(e=>e.initRepo),[l,r]=(0,n.useState)(!1),o=(0,n.useCallback)(async()=>{r(!0),await i(e),r(!1),s()},[e,i,s]);return(0,t.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center gap-3 p-4",children:[(0,t.jsx)(h.GitBranch,{size:32,className:"text-muted-foreground/40"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground text-center",children:a("message")}),(0,t.jsx)("button",{onClick:o,disabled:l,className:"text-xs px-3 py-1.5 rounded bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed",children:a(l?"initializing":"initialize")})]})}var N=e.i(209988),k=e.i(260218),M=e.i(681622);function S({open:e,onOpenChange:s,onSubmit:a}){let i=(0,v.useTranslations)("git.remote"),l=(0,v.useTranslations)("common"),[r,o]=(0,n.useState)("origin"),[c,d]=(0,n.useState)(""),[u,x]=(0,n.useState)(!1),h=async()=>{if(r.trim()&&c.trim()){x(!0);try{await a(r.trim(),c.trim()),d(""),s(!1)}finally{x(!1)}}};return(0,t.jsx)(N.Dialog,{open:e,onOpenChange:s,children:(0,t.jsxs)(N.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsx)(N.DialogHeader,{children:(0,t.jsx)(N.DialogTitle,{children:i("bindTitle")})}),(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:i("nameLabel")}),(0,t.jsx)(M.Input,{value:r,onChange:e=>o(e.target.value),placeholder:i("namePlaceholder"),className:"h-8 text-xs"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"text-xs text-muted-foreground mb-1 block",children:i("urlLabel")}),(0,t.jsx)(M.Input,{value:c,onChange:e=>d(e.target.value),placeholder:i("urlPlaceholder"),className:"h-8 text-xs",onKeyDown:e=>"Enter"===e.key&&e.preventDefault()})]})]}),(0,t.jsxs)(N.DialogFooter,{children:[(0,t.jsx)(N.DialogClose,{render:(0,t.jsx)(k.Button,{variant:"outline",size:"sm"}),children:l("cancel")}),(0,t.jsx)(k.Button,{size:"sm",onClick:h,disabled:!r.trim()||!c.trim()||u,children:i(u?"adding":"addRemote")})]})]})})}var D=e.i(613812),T=e.i(964970),z=e.i(564822),I=e.i(613087),B=e.i(940361),F=e.i(360112);let $={modified:"text-yellow-600",added:"text-green-600",deleted:"text-red-600",renamed:"text-blue-600",untracked:"text-gray-500",conflicted:"text-red-500"},O={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"U",conflicted:"!"};function P(e){return e instanceof Error?e.message:String(e)}function A({open:e,onOpenChange:s,title:a,label:i,placeholder:l,onSubmit:r}){let o=(0,v.useTranslations)("common"),[c,d]=(0,n.useState)(""),u=()=>{c.trim()&&(r(c.trim()),s(!1))};return(0,t.jsx)(N.Dialog,{open:e,onOpenChange:s,children:(0,t.jsxs)(N.DialogContent,{className:"sm:max-w-sm",children:[(0,t.jsx)(N.DialogHeader,{children:(0,t.jsx)(N.DialogTitle,{children:a})}),(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)("label",{className:"text-sm font-medium",children:i}),(0,t.jsx)(M.Input,{value:c,onChange:e=>d(e.target.value),placeholder:l,autoFocus:!0,onKeyDown:e=>{"Enter"===e.key&&c.trim()&&u()}})]}),(0,t.jsxs)(N.DialogFooter,{children:[(0,t.jsx)(k.Button,{variant:"outline",onClick:()=>s(!1),children:o("cancel")}),(0,t.jsx)(k.Button,{disabled:!c.trim(),onClick:u,children:o("confirm")})]})]})})}function E({confirm:e,open:n,onOpenChange:s,onConfirm:a}){let i=(0,v.useTranslations)("common"),l=(0,v.useTranslations)("git.changes");return(0,t.jsx)(N.Dialog,{open:n,onOpenChange:s,children:(0,t.jsxs)(N.DialogContent,{className:"sm:max-w-sm",children:[(0,t.jsx)(N.DialogHeader,{children:(0,t.jsx)(N.DialogTitle,{children:l(e?.type==="all"?"discardAll":"discard")})}),(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e?.type==="all"?l("confirmDiscardAll"):l("confirmDiscardFile",{file:e?.type==="single"?e.path:""})}),(0,t.jsxs)(N.DialogFooter,{children:[(0,t.jsx)(k.Button,{variant:"outline",onClick:()=>s(!1),children:i("cancel")}),(0,t.jsx)(k.Button,{variant:"destructive",onClick:a,children:l("discard")})]})]})})}var G=e.i(887836);e.i(462506);var H=e.i(950396);let L=(0,G.default)(()=>e.A(863812).then(e=>e.default),{loadableGenerated:{modules:[158480]},ssr:!1,loading:()=>(0,t.jsx)("div",{className:"flex items-center justify-center h-32 text-muted-foreground text-xs",children:"Loading editor..."})});function R({open:e,onOpenChange:n,content:s,onContentChange:a,saving:i,onSave:l}){let r=(0,v.useTranslations)("common"),{resolvedTheme:o}=(0,H.useTheme)();return(0,t.jsx)(N.Dialog,{open:e,onOpenChange:n,children:(0,t.jsxs)(N.DialogContent,{className:"sm:max-w-2xl",children:[(0,t.jsx)(N.DialogHeader,{children:(0,t.jsx)(N.DialogTitle,{children:".gitignore"})}),(0,t.jsx)("div",{className:"h-80 border rounded overflow-hidden",children:(0,t.jsx)(L,{height:"100%",language:"plaintext",value:s,onChange:e=>a(e??""),options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,padding:{top:8},lineNumbers:"on"},theme:"dark"===o?"vs-dark":"vs"})}),(0,t.jsxs)(N.DialogFooter,{children:[(0,t.jsx)(N.DialogClose,{render:(0,t.jsx)(k.Button,{variant:"outline",size:"sm"}),children:r("cancel")}),(0,t.jsx)(k.Button,{size:"sm",onClick:l,disabled:i,children:r(i?"saving":"save")})]})]})})}let U=(0,e.i(433721).default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);function W({x:e,y:s,path:a,onAddToGitignore:i,onOpenFile:l,onDiscard:r,onClose:o}){let u=(0,n.useRef)(null),x=(0,v.useTranslations)("git.changes"),h=(0,v.useTranslations)("common");(0,n.useEffect)(()=>(document.addEventListener("click",o),()=>document.removeEventListener("click",o)),[o]);let m=a.split("/").pop(),p=a.lastIndexOf("/"),f=p>=0?a.substring(0,p+1):a;return(0,t.jsxs)("div",{ref:u,className:"fixed z-[100] bg-popover border rounded-lg shadow-md py-1 text-xs min-w-40 ring-1 ring-foreground/10",style:{left:e,top:s},children:[(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left cursor-pointer",onClick:()=>{l(a),o()},children:[(0,t.jsx)(c.FileCode,{size:13}),(0,t.jsx)("span",{children:h("open")})]}),(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left cursor-pointer",onClick:()=>{r(a),o()},children:[(0,t.jsx)(d.RotateCcw,{size:13}),(0,t.jsx)("span",{children:x("discardAll")})]}),(0,t.jsx)("div",{className:"my-1 border-t"}),(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left cursor-pointer",onClick:()=>i(m),children:[(0,t.jsx)(U,{size:13}),(0,t.jsx)("span",{children:x("ignoreThisFile")}),(0,t.jsx)("span",{className:"ml-auto text-muted-foreground truncate max-w-24",children:m})]}),(0,t.jsxs)("button",{className:"flex items-center gap-2 w-full px-3 py-1.5 hover:bg-accent text-left cursor-pointer",onClick:()=>{f&&i(f)},children:[(0,t.jsx)(U,{size:13}),(0,t.jsx)("span",{children:x("ignoreFilePath",{path:f})})]})]})}var K=e.i(31807),V=e.i(355819);function J({workspaceId:e,entry:n,onRefreshAll:s,onOpenPrompt:a}){let i=(0,v.useTranslations)("git.commits"),{getCommitDiff:l,getRemoteUrl:r,checkout:o,checkoutDetached:c,createBranch:d,deleteBranch:u,createTag:x,cherryPick:h,getMergeBase:m}=(0,C.useGitStore)(),p=(0,y.useEditorStore)(e=>e.openCommitDiff),{activeChannelId:f,sendMessage:g}=(0,K.useChannelStore)(),j=(0,V.useAgentStore)(e=>e.agents),b=async()=>{try{let t=await l(e,n.hash);t.length>0&&p(e,n.hash,n.message,t)}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},w=async()=>{try{let t=await r(e);if(!t)return void F.toast.error(i("contextMenu.failed"),{description:"No remote URL"});window.open(t.replace(/\.git$/,"")+"/commit/"+n.hash,"_blank")}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},N=async()=>{try{await o(e,n.hash),F.toast.success(i("contextMenu.checkedOut")),s()}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},k=async()=>{try{await c(e,n.hash),F.toast.success(i("contextMenu.checkedOut")),s()}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},M=async()=>{try{await h(e,n.hash),F.toast.success(i("contextMenu.cherryPicked")),s()}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},S=async()=>{try{let t=await l(e,n.hash);C.useGitStore.setState({diffs:t}),F.toast.info(i("contextMenu.comparingWith",{hash:n.hash.slice(0,7)}))}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},D=async()=>{try{let t=await m(e);if(!t)return void F.toast.error(i("contextMenu.failed"),{description:"No merge base"});let s=await l(e,n.hash);C.useGitStore.setState({diffs:s}),F.toast.info(i("contextMenu.comparingWith",{hash:t.slice(0,7)}))}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}},T=async()=>{if(!f)return void F.toast.error(i("contextMenu.failed"),{description:"No active channel"});let t=j.find(e=>e.enabled&&"bot"!==e.role&&"scheduler"!==e.role),s=await l(e,n.hash).then(e=>e.map(e=>e.path).join("\n")).catch(()=>"");g(e,f,t?`@${t.name} Explain the changes in commit \`${n.hash.slice(0,7)}\`: ${n.message.split("\n")[0]}
2
+
3
+ Changed files:
4
+ ${s}`:`Explain the changes in commit \`${n.hash.slice(0,7)}\`: ${n.message.split("\n")[0]}
5
+
6
+ Changed files:
7
+ ${s}`,t?[t.id]:[])};return(0,t.jsxs)(B.ContextMenuContent,{className:"min-w-48",children:[(0,t.jsx)(B.ContextMenuItem,{onClick:b,children:i("contextMenu.openChanges")}),(0,t.jsx)(B.ContextMenuItem,{onClick:w,children:i("contextMenu.openOnGitHub")}),(0,t.jsx)(B.ContextMenuSeparator,{}),(0,t.jsx)(B.ContextMenuItem,{onClick:N,children:i("contextMenu.checkout")}),(0,t.jsx)(B.ContextMenuItem,{onClick:k,children:i("contextMenu.checkoutDetached")}),(0,t.jsx)(B.ContextMenuItem,{onClick:()=>{a(i("contextMenu.createBranch"),i("contextMenu.branchName"),"feature/...",async t=>{try{await d(e,t,n.hash),F.toast.success(i("contextMenu.branchCreated")),s()}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}})},children:i("contextMenu.createBranch")}),(0,t.jsx)(B.ContextMenuItem,{onClick:()=>{let t=C.useGitStore.getState().branches.filter(e=>!e.current);t.length?a(i("contextMenu.deleteBranch"),i("contextMenu.branchToDelete"),t.map(e=>e.name).join(", "),async t=>{try{await u(e,t),F.toast.success(i("contextMenu.branchDeleted")),s()}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}}):F.toast.error(i("contextMenu.failed"),{description:"No other branches"})},children:i("contextMenu.deleteBranch")}),(0,t.jsx)(B.ContextMenuItem,{onClick:()=>{a(i("contextMenu.createTag"),i("contextMenu.tagName"),"v1.0.0",async t=>{try{await x(e,t,n.hash),F.toast.success(i("contextMenu.tagCreated"))}catch(e){F.toast.error(i("contextMenu.failed"),{description:P(e)})}})},children:i("contextMenu.createTag")}),(0,t.jsx)(B.ContextMenuSeparator,{}),(0,t.jsx)(B.ContextMenuItem,{onClick:M,children:i("contextMenu.cherryPick")}),(0,t.jsx)(B.ContextMenuSeparator,{}),(0,t.jsxs)(B.ContextMenuSub,{children:[(0,t.jsx)(B.ContextMenuSubTrigger,{children:i("contextMenu.compareWith")}),(0,t.jsxs)(B.ContextMenuSubContent,{children:[(0,t.jsx)(B.ContextMenuItem,{onClick:S,children:i("contextMenu.compareWithRemote")}),(0,t.jsx)(B.ContextMenuItem,{onClick:D,children:i("contextMenu.compareWithMergeBase")})]})]}),(0,t.jsx)(B.ContextMenuSeparator,{}),(0,t.jsx)(B.ContextMenuItem,{onClick:()=>{navigator.clipboard.writeText(n.hash),F.toast.success(i("contextMenu.commitIdCopied"))},children:i("contextMenu.copyCommitId")}),(0,t.jsx)(B.ContextMenuItem,{onClick:()=>{navigator.clipboard.writeText(n.message),F.toast.success(i("contextMenu.commitMessageCopied"))},children:i("contextMenu.copyCommitMessage")}),(0,t.jsx)(B.ContextMenuSeparator,{}),(0,t.jsx)(B.ContextMenuItem,{onClick:T,children:i("contextMenu.explainChanges")})]})}function X({workspaceId:e,entry:s,onClose:i}){let l=(0,v.useTranslations)("git.commits"),r=(0,z.useIsMobile)(),o=(0,C.useGitStore)(e=>e.getCommitDiff),[c,d]=(0,n.useState)([]),[u,x]=(0,n.useState)(!1),[h,m]=(0,n.useState)(null),p=!!s;(0,n.useEffect)(()=>{if(!s){d([]),m(null);return}x(!0),m(null),o(e,s.hash).then(e=>{d(e),e.length>0&&m(e[0].path)}).catch(()=>d([])).finally(()=>x(!1))},[s,e,o]);let f=c.find(e=>e.path===h),g=(0,n.useCallback)(()=>{i(),d([]),m(null)},[i]);return(0,t.jsx)(N.Dialog,{open:p,onOpenChange:e=>!e&&g(),children:(0,t.jsxs)(N.DialogContent,{className:`${r?"w-[95vw] max-w-[95vw] h-[90vh]":"!max-w-none w-[80vw] h-[80vh]"} flex flex-col p-0 gap-0`,children:[(0,t.jsxs)(N.DialogHeader,{className:"px-4 py-3 border-b shrink-0",children:[(0,t.jsxs)(N.DialogTitle,{className:"text-sm font-medium flex items-center gap-2 flex-wrap",children:[(0,t.jsx)("code",{className:"font-mono text-blue-600",children:s?.hash.slice(0,7)}),(0,t.jsx)("span",{className:"truncate",children:s?.message.split("\n")[0]})]}),s&&(0,t.jsxs)("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[(0,t.jsx)("span",{children:s.author}),(0,t.jsx)("span",{children:new Date(s.date).toLocaleString()}),c.length>0&&(0,t.jsx)("span",{children:l("detailFileCount",{count:c.length})})]})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 flex flex-col",children:u?(0,t.jsx)("div",{className:"flex-1 flex items-center justify-center",children:(0,t.jsx)(a.Loader2,{className:"h-5 w-5 animate-spin text-muted-foreground"})}):r?(0,t.jsx)(_,{diffs:c,selectedFile:h,onSelect:m,selectedDiff:f}):(0,t.jsx)(Y,{diffs:c,selectedFile:h,onSelect:m,selectedDiff:f})})]})})}function Y({diffs:e,selectedFile:n,onSelect:s,selectedDiff:a}){return(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex",children:[(0,t.jsx)("div",{className:"w-48 border-r overflow-auto shrink-0",children:e.map(e=>(0,t.jsxs)("button",{onClick:()=>s(e.path),className:`w-full text-left px-2 py-1.5 text-xs font-mono flex items-center gap-1.5 border-b hover:bg-accent cursor-pointer ${n===e.path?"bg-accent":""}`,children:[(0,t.jsx)(c.FileCode,{size:13,className:"shrink-0 text-muted-foreground"}),(0,t.jsx)("span",{className:"truncate",children:e.path})]},e.path))}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:a?(0,t.jsx)(D.DiffViewer,{oldContent:a.oldContent,newContent:a.newContent,path:a.path,isBinary:a.isBinary}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"Select a file"})})]})}function _({diffs:e,selectedFile:n,onSelect:s,selectedDiff:a}){return(0,t.jsxs)("div",{className:"flex-1 min-h-0 flex flex-col",children:[(0,t.jsx)("div",{className:"flex overflow-x-auto border-b shrink-0 gap-0.5 px-1 py-1",children:e.map(e=>(0,t.jsx)("button",{onClick:()=>s(e.path),className:`shrink-0 text-xs font-mono px-2 py-1 rounded border ${n===e.path?"bg-accent border-accent":"border-transparent hover:bg-accent/50"} truncate max-w-[140px]`,children:e.path},e.path))}),(0,t.jsx)("div",{className:"flex-1 min-h-0",children:a?(0,t.jsx)(D.DiffViewer,{oldContent:a.oldContent,newContent:a.newContent,path:a.path,isBinary:a.isBinary}):(0,t.jsx)("div",{className:"flex items-center justify-center h-full text-xs text-muted-foreground",children:"Select a file"})})]})}e.s(["GitCommitsPanel",0,function({workspaceId:e}){let k=(0,v.useTranslations)("common"),M=(0,v.useTranslations)("git.commits"),G=(0,v.useTranslations)("git.changes"),H=(0,z.useIsMobile)(),{log:L,loading:U,notGitRepo:K,status:V,branches:Y,diffs:_,selectedFile:q,loadStatus:Q,loadDiffs:Z,loadLog:ee,loadBranches:et,commit:en,discard:es,discardAll:ea,stage:ei,unstage:el,resolveFile:er,checkout:eo,selectFile:ec,commitMsg:ed,setCommitMsg:eu,fetchRemote:ex}=(0,C.useGitStore)(),eh=(0,y.useEditorStore)(e=>e.openFile),em=(0,y.useEditorStore)(e=>e.openCommitDiff),[ep,ef]=(0,n.useState)(!1),[eg,ej]=(0,n.useState)(!1),[eb,eC]=(0,n.useState)(!1),[ey,ev]=(0,n.useState)({open:!1,title:"",label:"",placeholder:"",onSubmit:()=>{}}),[ew,eN]=(0,n.useState)(null),[ek,eM]=(0,n.useState)(!1),[eS,eD]=(0,n.useState)(""),[eT,ez]=(0,n.useState)(!1),[eI,eB]=(0,n.useState)(!1),[eF,e$]=(0,n.useState)(null),[eO,eP]=(0,n.useState)(null),eA=V?.ahead??0,eE=V?.behind??0,eG=(V?.files.length??0)>0,eH=_.find(e=>e.path===q),eL=(0,n.useCallback)(async()=>{await ex(e).catch(()=>{}),await Promise.all([Q(e),Z(e),ee(e)])},[e,ex,Q,Z,ee]),eR=(0,n.useCallback)(()=>{eL(),et(e)},[e,eL,et]),{syncing:eU,remoteDialogOpen:eW,setRemoteDialogOpen:eK,handleSync:eV,handleRemoteSubmit:eJ,handleSyncChanges:eX}=function(e,t){let s=(0,v.useTranslations)("git.commits"),a=(0,v.useTranslations)("git.changes"),{push:i,pull:l,getRemotes:r,addRemote:o}=(0,C.useGitStore)(),[c,d]=(0,n.useState)(null),[u,x]=(0,n.useState)(!1),[h,m]=(0,n.useState)(null),p=async n=>{"push"===n?(await i(e),F.toast.success(s("pushedSuccessfully"))):(await l(e),F.toast.success(s("pulledSuccessfully"))),t()},f=async n=>{d(n);try{if(!(await r(e)).length){m(n),x(!0);return}await p(n)}catch(e){P(e)?.includes("No remote")?(m(n),x(!0)):F.toast.error("push"===n?s("pushFailed"):s("pullFailed"),{description:P(e)}),"pull"===n&&await t()}finally{d(null)}},g=async(t,n)=>{await o(e,t,n),F.toast.success(s("remoteAdded")),h&&(await p(h),m(null))},j=(0,n.useCallback)(async()=>{d("push");try{if(!(await r(e)).length)return void x(!0);await i(e),await l(e),F.toast.success(a("syncedSuccessfully")),t()}catch(e){P(e)?.includes("No remote")?x(!0):F.toast.error(a("syncFailed"),{description:P(e)}),await t()}finally{d(null)}},[e,i,l,r,t,a]);return{syncing:c,remoteDialogOpen:u,setRemoteDialogOpen:x,handleSync:f,handleRemoteSubmit:g,handleSyncChanges:j}}(e,eL);(0,n.useEffect)(()=>{eL(),et(e)},[e,eL,et]),(0,n.useEffect)(()=>{let t=setInterval(()=>{Q(e),Z(e)},5e3);return()=>clearInterval(t)},[e,Q,Z]);let eY=(0,n.useCallback)(async t=>{ef(!1),await eo(e,t),eL(),et(e)},[e,eo,eL,et]),e_=(0,n.useCallback)(async()=>{ed.trim()&&(ej(!0),ec(null),await en(e,ed.trim()),eu(""),ej(!1),eL())},[e,ed,en,eL,ec,eu]),eq=(0,n.useCallback)(async()=>{if(!eb&&!eg){eC(!0);try{let t=await fetch(`/api/workspaces/${e}/git/generate-commit-message`,{method:"POST"});if(!t.ok){let e=await t.json().catch(()=>({error:"Failed"}));throw Error(e.error)}let n=await t.json();n.message&&eu(n.message)}catch(e){F.toast.error(P(e)||G("failedCommitMessage"))}finally{eC(!1)}}},[e,eb,eg,eu,G]),eQ=(0,n.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&e_()},[e_]),eZ=(0,n.useCallback)(e=>{ec(e===q?null:e)},[q,ec]),e0=(0,n.useCallback)((t,n)=>{t.stopPropagation(),eh(e,n)},[e,eh]),e1=(0,n.useCallback)((e,t)=>{e.stopPropagation(),e$({type:"single",path:t})},[]),e3=(0,n.useCallback)(async(t,n,s)=>{t.stopPropagation(),s?await el(e,n):await ei(e,n),eL()},[e,eL,ei,el]),e5=(0,n.useCallback)(async(t,n)=>{await er(e,t,n,!0),ec(null),eL(),F.toast.success("冲突已解决并暂存")},[e,eL,er,ec]),e2=(0,n.useCallback)(()=>{e$({type:"all"})},[]),e4=(0,n.useCallback)(async()=>{eF&&("single"===eF.type?await es(e,eF.path):await ea(e),e$(null),eL())},[e,eF,es,ea,eL]);(0,n.useCallback)(async()=>{try{let t=await fetch(`/api/workspaces/${e}/files/content?path=.gitignore`),n=await t.json();eD(n.content??"")}catch{eD("")}eM(!0)},[e]);let e6=(0,n.useCallback)(async()=>{eB(!0);try{await fetch(`/api/workspaces/${e}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:".gitignore",content:eS})}),eM(!1),eL()}finally{eB(!1)}},[e,eS,eL]),e8=(0,n.useCallback)(async t=>{eN(null);try{let n=await fetch(`/api/workspaces/${e}/files/content?path=.gitignore`),s=(await n.json()).content??"";if(s.split("\n").filter(Boolean).includes(t))return;let a=s&&!s.endsWith("\n")?s+"\n"+t+"\n":s+t+"\n";await fetch(`/api/workspaces/${e}/files/content`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:".gitignore",content:a})}),eL()}catch{}},[e,eL]),e9=(e,t,n,s)=>{ev({open:!0,title:e,label:t,placeholder:n,onSubmit:s})};return K?(0,t.jsxs)("div",{className:"flex flex-col h-full overflow-hidden rounded-t-xl bg-background",children:[(0,t.jsx)("div",{className:"flex items-center px-2 py-1.5 border-b",children:(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:M("title")})}),(0,t.jsx)(w,{workspaceId:e,onInitialized:eL})]}):(0,t.jsxs)("div",{className:`flex h-full overflow-hidden rounded-t-xl bg-background ${H?"flex-col":""}`,children:[(0,t.jsxs)("div",{className:`flex flex-col bg-muted/20 ${H?"w-full border-b max-h-[40%]":"w-64 border-r"}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b",children:[(0,t.jsxs)("div",{className:"relative flex-1 min-w-0",children:[(0,t.jsxs)("button",{onClick:()=>ef(!ep),className:"flex items-center gap-1 text-xs font-medium text-muted-foreground hover:text-foreground active:opacity-70 transition-all duration-100 cursor-pointer w-full",children:[(0,t.jsx)(h.GitBranch,{size:13,className:"shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:V?.branch??"..."}),V&&eG&&(0,t.jsxs)("span",{className:"text-muted-foreground",children:["(",V.files.length,")"]}),(0,t.jsx)(x.ChevronDown,{size:12,className:"shrink-0"})]}),ep&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"absolute left-0 top-full z-50 mt-1 w-48 bg-popover border rounded shadow-md py-0.5 max-h-60 overflow-auto",children:[Y.map(e=>(0,t.jsx)("button",{onClick:()=>eY(e.name),className:`w-full text-left px-2 py-1 text-xs hover:bg-accent active:scale-[0.98] active:bg-accent transition-all duration-100 cursor-pointer truncate ${e.current?"font-semibold text-foreground":"text-muted-foreground"}`,children:e.name},e.name)),0===Y.length&&(0,t.jsx)("div",{className:"px-2 py-1 text-xs text-muted-foreground",children:G("noBranches")})]}),(0,t.jsx)("div",{className:"fixed inset-0 z-40",onClick:()=>ef(!1)})]})]}),eG&&(0,t.jsx)("button",{onClick:e2,className:"p-1 text-muted-foreground hover:text-destructive active:scale-90 transition-all duration-100 cursor-pointer",title:G("discardAll"),children:(0,t.jsx)(u.Trash2,{size:13})}),(0,t.jsx)("button",{onClick:()=>{_.length>0&&em(e,"unstaged",G("unstagedChanges"),_)},disabled:!eG,className:"p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer disabled:opacity-30",title:G("viewDiff"),children:(0,t.jsx)(f.FileDiff,{size:13})}),(0,t.jsx)("button",{onClick:eL,className:"p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer",title:k("refresh"),children:(0,t.jsx)(l.RefreshCw,{size:13})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-auto",children:[V?.files.map(e=>(0,t.jsxs)("div",{onClick:()=>eZ(e.path),onContextMenu:t=>{t.preventDefault(),t.stopPropagation(),eN({x:t.clientX,y:t.clientY,path:e.path})},className:`group w-full text-left px-2 py-1 text-xs font-mono flex items-center gap-1.5 hover:bg-accent cursor-pointer ${q===e.path?"bg-accent":""}`,children:[(0,t.jsx)("span",{className:`w-4 text-center font-bold shrink-0 ${$[e.status]}`,children:O[e.status]}),e.conflicted&&(0,t.jsx)(b.AlertTriangle,{size:12,className:"shrink-0 text-red-500"}),(0,t.jsx)("span",{className:"truncate flex-1",children:e.path}),(0,t.jsxs)("span",{className:"hidden group-hover:flex md:flex items-center gap-0.5 shrink-0",children:[(0,t.jsx)("button",{onClick:t=>e3(t,e.path,e.staged),disabled:e.conflicted,className:"p-0.5 rounded hover:bg-accent/80 active:scale-90 transition-all duration-100 cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed",title:e.staged?"Unstage":"Stage",children:e.staged?(0,t.jsx)(j.Minus,{size:13}):(0,t.jsx)(g.Plus,{size:13})}),(0,t.jsx)("button",{onClick:t=>e0(t,e.path),className:"p-0.5 rounded hover:bg-accent/80 active:scale-90 transition-all duration-100 cursor-pointer",title:k("open"),children:(0,t.jsx)(c.FileCode,{size:13})}),(0,t.jsx)("button",{onClick:t=>e1(t,e.path),className:"p-0.5 rounded hover:bg-accent/80 active:scale-90 transition-all duration-100 cursor-pointer",title:G("discardAll"),children:(0,t.jsx)(d.RotateCcw,{size:13})})]})]},e.path)),V?.clean&&(0,t.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:G("noChanges")})]}),eG?(0,t.jsxs)("div",{className:"border-t p-2 space-y-1.5",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("textarea",{value:ed,onChange:e=>eu(e.target.value),onKeyDown:eQ,placeholder:G("commitMessagePlaceholder"),rows:3,className:"w-full resize-none text-xs px-2 pt-1 pr-8 pb-7 border rounded bg-background disabled:opacity-50",disabled:eg||eb}),(0,t.jsx)("button",{type:"button",onClick:eq,disabled:eb||eg||!eG,className:"absolute bottom-1.5 right-1.5 p-1 rounded text-muted-foreground hover:text-foreground hover:bg-accent active:scale-90 cursor-pointer disabled:opacity-30 disabled:cursor-not-allowed transition-all duration-100",title:"AI generate commit message",children:eb?(0,t.jsx)(a.Loader2,{size:14,className:"animate-spin"}):(0,t.jsx)(m.Sparkles,{size:14})})]}),(0,t.jsx)("button",{onClick:e_,disabled:!ed.trim()||eg,className:"w-full text-xs px-2 py-1 rounded bg-primary text-primary-foreground active:scale-[0.98] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed",children:eg?G("committing"):G("commit")})]}):eA>0?(0,t.jsx)("div",{className:"border-t p-2",children:(0,t.jsxs)("button",{onClick:eX,disabled:null!==eU,className:"w-full text-xs px-2 py-1 rounded bg-primary text-primary-foreground active:scale-[0.98] transition-all duration-100 cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-1.5",children:[eU?(0,t.jsx)(a.Loader2,{size:13,className:"animate-spin"}):(0,t.jsx)(s.Upload,{size:13}),eU?G("syncing"):G("syncChanges")]})}):null]}),(0,t.jsxs)("div",{className:"flex-1 flex flex-col min-w-0 overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-2 py-1.5 border-b shrink-0",children:[(0,t.jsx)("span",{className:"text-xs font-medium text-muted-foreground",children:L.length>0?M("titleWithCount",{count:L.length}):M("title")}),(0,t.jsxs)("div",{className:"flex items-center gap-1",children:[(0,t.jsxs)("button",{onClick:()=>eV("push"),disabled:null!==eU,className:"relative p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer disabled:opacity-50",title:eA>0?M("pushNCommits",{count:eA}):"Push",children:["push"===eU?(0,t.jsx)(a.Loader2,{size:13,className:"animate-spin"}):(0,t.jsx)(r.ArrowUp,{size:13}),eA>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-foreground px-1 text-[9px] font-medium leading-none text-background",children:eA})]}),(0,t.jsxs)("button",{onClick:()=>eV("pull"),disabled:null!==eU,className:"relative p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer disabled:opacity-50",title:eE>0?M("pullNCommits",{count:eE}):"Pull",children:["pull"===eU?(0,t.jsx)(a.Loader2,{size:13,className:"animate-spin"}):(0,t.jsx)(o.ArrowDown,{size:13}),eE>0&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-foreground px-1 text-[9px] font-medium leading-none text-background",children:eE})]}),(0,t.jsx)("button",{onClick:eL,className:"p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer",children:(0,t.jsx)(l.RefreshCw,{size:13})}),(0,t.jsx)("button",{onClick:()=>ez(!0),className:"p-1 text-muted-foreground hover:text-foreground active:scale-90 transition-all duration-100 cursor-pointer",title:M("settingsTitle"),children:(0,t.jsx)(p.Settings2,{size:13})})]})]}),eH?(0,t.jsx)("div",{className:"flex-1 min-h-0",children:(0,t.jsx)(D.DiffViewer,{oldContent:eH.oldContent,newContent:eH.newContent,path:eH.path,isBinary:eH.isBinary,mergeMode:!!eH.isConflict,onResolve:eH.isConflict?e=>e5(eH.path,e):void 0})}):(0,t.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto",children:[U&&!L.length&&(0,t.jsx)("div",{className:"p-2 space-y-1",children:(0,t.jsx)(I.SkeletonGroup,{count:6,children:e=>(0,t.jsxs)("div",{className:"px-2 py-1.5 border-b space-y-1.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(I.Skeleton,{className:"h-3 w-10 rounded"}),(0,t.jsx)(I.Skeleton,{className:"h-3 flex-1"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 pl-7",children:[(0,t.jsx)(I.Skeleton,{className:"h-3 w-20"}),(0,t.jsx)(I.Skeleton,{className:"h-3 w-16"})]})]},e)})}),L.map(n=>{let s=!!V?.remoteHeadHash&&n.hash.startsWith(V.remoteHeadHash.substring(0,7)),a=!!V?.headHash&&n.hash.startsWith(V.headHash.substring(0,7));return(0,t.jsxs)(B.ContextMenu,{children:[(0,t.jsx)(B.ContextMenuTrigger,{children:(0,t.jsxs)("div",{onClick:()=>eP(n),className:`px-2 py-1.5 border-b border-l-2 hover:bg-accent cursor-pointer ${a?"border-l-foreground":s?"border-l-blue-500":"border-l-transparent"}`,children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[s&&(0,t.jsx)("span",{title:M("remoteTrackingBranch"),children:(0,t.jsx)(i.GitCommitHorizontal,{size:13,className:"shrink-0 text-blue-500"})}),(0,t.jsx)("code",{className:"text-xs font-mono text-blue-600 shrink-0",children:n.hash.slice(0,7)}),(0,t.jsx)("span",{className:"text-xs truncate",children:n.message.split("\n")[0]}),a&&(0,t.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground bg-muted px-1 rounded",children:"HEAD"})]}),(0,t.jsxs)("div",{className:`flex items-center gap-2 mt-0.5 ${s?"pl-[21px]":""}`,children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:n.author}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:new Date(n.date).toLocaleDateString()})]})]})}),(0,t.jsx)(J,{workspaceId:e,entry:n,onRefreshAll:eR,onOpenPrompt:e9})]},n.hash)}),!U&&!L.length&&(0,t.jsx)("div",{className:"p-2 text-xs text-muted-foreground",children:M("noCommits")})]})]}),ew&&(0,t.jsx)(W,{x:ew.x,y:ew.y,path:ew.path,onAddToGitignore:e8,onOpenFile:t=>eh(e,t),onDiscard:e=>e$({type:"single",path:e}),onClose:()=>eN(null)}),(0,t.jsx)(S,{open:eW,onOpenChange:eK,onSubmit:eJ}),(0,t.jsx)(A,{open:ey.open,onOpenChange:e=>ev(t=>({...t,open:e})),title:ey.title,label:ey.label,placeholder:ey.placeholder,onSubmit:e=>{ey.onSubmit(e),ev(e=>({...e,open:!1}))}}),(0,t.jsx)(R,{open:ek,onOpenChange:eM,content:eS,onContentChange:eD,saving:eI,onSave:e6}),(0,t.jsx)(N.Dialog,{open:eT,onOpenChange:ez,children:(0,t.jsxs)(N.DialogContent,{className:"sm:max-w-md",children:[(0,t.jsx)(N.DialogHeader,{children:(0,t.jsx)(N.DialogTitle,{children:M("settingsTitle")})}),(0,t.jsx)(T.GitSettingsForm,{scope:"local",workspaceId:e})]})}),(0,t.jsx)(E,{confirm:eF,open:!!eF,onOpenChange:e=>!e&&e$(null),onConfirm:e4}),(0,t.jsx)(X,{workspaceId:e,entry:eO,onClose:()=>eP(null)})]})}],448303)},514669,e=>{e.n(e.i(448303))}]);
@@ -0,0 +1 @@
1
+ (globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,600304,759309,e=>{"use strict";let t=(0,e.i(433721).default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);e.s(["default",0,t],759309),e.s(["Send",0,t],600304)},595390,272736,e=>{"use strict";var t=e.i(344180),s=e.i(764556),l=e.i(681622),a=e.i(611176),i=e.i(972846);let r=e=>!["scheduler","task_creator","bot"].includes(e.description||"")&&"agent-generator"!==e.id;function n(e){return e.name?.trim()||e.role}e.s(["MemberPicker",0,function({candidates:e,selected:n,onToggle:o,searchPlaceholder:d,emptyText:c,label:u,filter:f}){let[m,p]=(0,s.useState)(""),h=e.filter(f??r).filter(e=>`${e.label} ${e.description||""}`.toLowerCase().includes(m.toLowerCase()));return(0,t.jsxs)("div",{className:"space-y-2",children:[u&&(0,t.jsx)("label",{className:"text-sm font-medium",children:u}),(0,t.jsx)(l.Input,{value:m,onChange:e=>p(e.target.value),placeholder:d}),(0,t.jsxs)("div",{className:"max-h-40 overflow-y-auto space-y-0.5",children:[0===h.length&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground py-2 text-center",children:c||"No items found"}),h.map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>o(e.id),className:"flex items-center gap-2 w-full px-2 py-1.5 rounded-md hover:bg-muted text-left text-sm transition-colors",children:[(0,t.jsx)(a.AgentIcon,{agentId:"user"!==e.id?e.id:void 0,name:e.label,className:"size-5 rounded-full"}),(0,t.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"block truncate",children:e.label}),e.description&&(0,t.jsx)("span",{className:"block truncate text-xs text-muted-foreground",children:e.description})]}),(0,t.jsx)("div",{className:`flex items-center justify-center size-4 rounded border shrink-0 ${n.includes(e.id)?"bg-primary border-primary text-primary-foreground":"border-input"}`})]},e.id))]}),n.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5",children:n.map(s=>{let l=e.find(e=>e.id===s),r=l?.label||s;return(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-md bg-muted px-2 py-0.5 text-xs max-w-[160px] min-w-0",children:["user"===s?(0,t.jsx)("span",{className:"truncate",children:r}):(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 min-w-0",children:[(0,t.jsx)(a.AgentIcon,{agentId:s,name:r,className:"size-3.5 rounded-full shrink-0"}),(0,t.jsx)("span",{className:"truncate",children:r})]}),(0,t.jsx)("button",{type:"button",onClick:()=>o(s),className:"hover:text-destructive shrink-0 cursor-pointer",children:(0,t.jsx)(i.X,{className:"size-3"})})]},s)})})]})}],595390),e.s(["getAgentDisplayName",0,n,"getMemberDisplayName",0,function(e,t){if("user"===t)return"user";let s=e.find(e=>e.id===t);return s?n(s):t},"normalizeChannelMembersToAgentIds",0,function(e,t){let s=new Set(e.map(e=>e.id)),l=[],a=new Set;for(let e of t)s.has(e)&&(a.has(e)||(a.add(e),l.push(e)));return l}],272736)},889445,e=>{"use strict";let t=(0,e.i(433721).default)("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);e.s(["Play",0,t],889445)},444204,e=>{"use strict";let t=(0,e.i(433721).default)("clock",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]]);e.s(["Clock",0,t],444204)},583705,e=>{"use strict";let t=(0,e.i(433721).default)("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);e.s(["Info",0,t],583705)},302773,e=>{"use strict";let t=(0,e.i(816709).create)((e,t)=>({workflows:[],currentWorkflow:null,isLoading:!1,loadWorkflows:async()=>{e({isLoading:!0});try{let t=await fetch("/api/workflows"),s=await t.json();e({workflows:s,isLoading:!1})}catch{e({isLoading:!1})}},createWorkflow:async t=>{let s=await fetch("/api/workflows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}),l=await s.json();return e(e=>({workflows:[...e.workflows,l]})),l},updateWorkflow:async(e,s)=>{let l=await fetch(`/api/workflows/${e}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)}),a=await l.json();t().upsertWorkflow(a)},deleteWorkflow:async e=>{await fetch(`/api/workflows/${e}`,{method:"DELETE"}),t().removeWorkflow(e)},duplicateWorkflow:async t=>{let s=await fetch(`/api/workflows/${t}/duplicate`,{method:"POST"}),l=await s.json();e(e=>({workflows:[...e.workflows,l]}))},setCurrentWorkflow:t=>e({currentWorkflow:t}),upsertWorkflow:t=>{e(e=>{let s=e.workflows.findIndex(e=>e.id===t.id);if(-1!==s){let l=[...e.workflows];return l[s]=t,{workflows:l}}return{workflows:[...e.workflows,t]}})},removeWorkflow:t=>{e(e=>({workflows:e.workflows.filter(e=>e.id!==t),currentWorkflow:e.currentWorkflow?.id===t?null:e.currentWorkflow}))}}));e.s(["useWorkflowStore",0,t])},358989,e=>{"use strict";var t=e.i(344180),s=e.i(764556),l=e.i(244073),a=e.i(209988),i=e.i(260218),r=e.i(681622),n=e.i(788010),o=e.i(595390),d=e.i(272736),c=e.i(302773);let u=["draft","planned","in_progress","review_pending","changes_requested","approved","completed","archived"];e.s(["EditIssueDialog",0,function({issue:e,open:f,onOpenChange:m,agents:p=[],onSave:h}){let[x,w]=(0,s.useState)(e.title),[g,k]=(0,s.useState)(e.description),[y,b]=(0,s.useState)(e.status),[j,v]=(0,s.useState)(e.members||[]),[N,C]=(0,s.useState)(!1),[_,S]=(0,s.useState)(e.workflowId??""),{workflows:T,loadWorkflows:W}=(0,c.useWorkflowStore)(),I=(0,l.useTranslations)("issue"),D=(0,l.useTranslations)("common");(0,s.useEffect)(()=>{f&&(w(e.title),k(e.description),b(e.status),v(e.members?.length?[...e.members]:[]),S(e.workflowId??""))},[f,e]),(0,s.useEffect)(()=>{f&&W()},[f,W]);let M=async()=>{if(x.trim()){C(!0);try{await h({title:x.trim(),description:g.trim(),status:y,members:j,workflowId:"__none__"===_?null:_||null}),m(!1)}finally{C(!1)}}},P=(0,s.useMemo)(()=>p.filter(e=>!1!==e.enabled).map(e=>({id:e.id,label:(0,d.getMemberDisplayName)(p,e.id),description:e.role})),[p]);return(0,t.jsx)(a.Dialog,{open:f,onOpenChange:m,children:(0,t.jsxs)(a.DialogContent,{className:"sm:max-w-md max-h-[85vh] p-0 gap-0 flex flex-col overflow-hidden",children:[(0,t.jsxs)(a.DialogHeader,{className:"px-4 py-4 shrink-0",children:[(0,t.jsx)(a.DialogTitle,{children:I("edit.title")}),(0,t.jsx)(a.DialogDescription,{children:I("edit.description")})]}),(0,t.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 pb-4",children:(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)(r.Input,{placeholder:I("edit.titlePlaceholder"),value:x,onChange:e=>w(e.target.value),onKeyDown:e=>"Enter"===e.key&&e.preventDefault()}),(0,t.jsx)(n.Textarea,{placeholder:I("edit.descriptionPlaceholder"),value:g,onChange:e=>k(e.target.value),rows:3}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:I("edit.statusLabel")}),(0,t.jsx)("select",{value:y,onChange:e=>b(e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:u.map(e=>(0,t.jsx)("option",{value:e,children:I(`status.${e}`)},e))})]}),(0,t.jsxs)("div",{className:"space-y-1.5",children:[(0,t.jsx)("label",{className:"text-sm font-medium text-foreground",children:"Workflow Template"}),(0,t.jsxs)("select",{value:_||"__none__",onChange:e=>(e=>{if(S(e),!e)return;let t=T.find(t=>t.id===e);if(!t)return;let s=t.nodes.map(e=>e.data.agentConfigId);v(e=>Array.from(new Set([...e,...s])))})("__none__"===e.target.value?"":e.target.value),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",children:[(0,t.jsx)("option",{value:"__none__",children:"None (use default pipeline)"}),T.map(e=>(0,t.jsxs)("option",{value:e.id,children:[e.name," (",e.nodes.length," agents)"]},e.id))]})]}),(0,t.jsx)(o.MemberPicker,{candidates:P,selected:j,onToggle:e=>{v(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},label:I("edit.membersLabel"),searchPlaceholder:I("edit.searchAgent"),emptyText:I("edit.noAgents")}),(0,t.jsxs)("div",{className:"flex justify-end gap-2 pt-2",children:[(0,t.jsx)(i.Button,{variant:"outline",onClick:()=>m(!1),children:D("cancel")}),(0,t.jsx)(i.Button,{onClick:M,disabled:!x.trim()||N,children:D(N?"saving":"save")})]})]})})]})})}])}]);