profclaw 0.0.1-beta.1

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 (942) hide show
  1. package/.env.example +215 -0
  2. package/CHANGELOG.md +49 -0
  3. package/CONTRIBUTING.md +119 -0
  4. package/Dockerfile +107 -0
  5. package/LICENSE +661 -0
  6. package/README.md +196 -0
  7. package/config/agents.yml +55 -0
  8. package/config/budget.yml +15 -0
  9. package/config/pricing.yml +46 -0
  10. package/config/settings.yml +168 -0
  11. package/dist/adapters/claude-code.d.ts +46 -0
  12. package/dist/adapters/claude-code.js +215 -0
  13. package/dist/adapters/index.d.ts +4 -0
  14. package/dist/adapters/index.js +4 -0
  15. package/dist/adapters/ollama.d.ts +45 -0
  16. package/dist/adapters/ollama.js +277 -0
  17. package/dist/adapters/openclaw.d.ts +60 -0
  18. package/dist/adapters/openclaw.js +289 -0
  19. package/dist/adapters/registry.d.ts +56 -0
  20. package/dist/adapters/registry.js +163 -0
  21. package/dist/agents/executor.d.ts +78 -0
  22. package/dist/agents/executor.js +657 -0
  23. package/dist/agents/index.d.ts +10 -0
  24. package/dist/agents/index.js +27 -0
  25. package/dist/agents/stop-conditions.d.ts +108 -0
  26. package/dist/agents/stop-conditions.js +299 -0
  27. package/dist/agents/types.d.ts +185 -0
  28. package/dist/agents/types.js +14 -0
  29. package/dist/ai/embedding-service.d.ts +96 -0
  30. package/dist/ai/embedding-service.js +333 -0
  31. package/dist/auth/api-tokens.d.ts +71 -0
  32. package/dist/auth/api-tokens.js +235 -0
  33. package/dist/auth/auth-service.d.ts +75 -0
  34. package/dist/auth/auth-service.js +557 -0
  35. package/dist/auth/device-identity.d.ts +96 -0
  36. package/dist/auth/device-identity.js +250 -0
  37. package/dist/auth/github-oauth.d.ts +20 -0
  38. package/dist/auth/github-oauth.js +59 -0
  39. package/dist/auth/jira-oauth.d.ts +25 -0
  40. package/dist/auth/jira-oauth.js +75 -0
  41. package/dist/auth/linear-oauth.d.ts +21 -0
  42. package/dist/auth/linear-oauth.js +59 -0
  43. package/dist/auth/middleware.d.ts +44 -0
  44. package/dist/auth/middleware.js +190 -0
  45. package/dist/auth/pairing-codes.d.ts +109 -0
  46. package/dist/auth/pairing-codes.js +274 -0
  47. package/dist/auth/password.d.ts +53 -0
  48. package/dist/auth/password.js +126 -0
  49. package/dist/auth/qr-pairing.d.ts +36 -0
  50. package/dist/auth/qr-pairing.js +138 -0
  51. package/dist/auth/slack-oauth.d.ts +31 -0
  52. package/dist/auth/slack-oauth.js +80 -0
  53. package/dist/backup/index.d.ts +50 -0
  54. package/dist/backup/index.js +184 -0
  55. package/dist/browser/adapters.d.ts +25 -0
  56. package/dist/browser/adapters.js +32 -0
  57. package/dist/browser/cli.d.ts +19 -0
  58. package/dist/browser/cli.js +277 -0
  59. package/dist/browser/compression.d.ts +32 -0
  60. package/dist/browser/compression.js +269 -0
  61. package/dist/browser/extensions.d.ts +144 -0
  62. package/dist/browser/extensions.js +251 -0
  63. package/dist/browser/index.d.ts +37 -0
  64. package/dist/browser/index.js +43 -0
  65. package/dist/browser/refs.d.ts +46 -0
  66. package/dist/browser/refs.js +120 -0
  67. package/dist/browser/search.d.ts +36 -0
  68. package/dist/browser/search.js +193 -0
  69. package/dist/browser/service.d.ts +94 -0
  70. package/dist/browser/service.js +358 -0
  71. package/dist/browser/snapshot.d.ts +19 -0
  72. package/dist/browser/snapshot.js +250 -0
  73. package/dist/browser/tools.d.ts +259 -0
  74. package/dist/browser/tools.js +463 -0
  75. package/dist/browser/types.d.ts +134 -0
  76. package/dist/browser/types.js +17 -0
  77. package/dist/chat/agentic-executor.d.ts +108 -0
  78. package/dist/chat/agentic-executor.js +739 -0
  79. package/dist/chat/api-key-detector.d.ts +41 -0
  80. package/dist/chat/api-key-detector.js +290 -0
  81. package/dist/chat/auto-reply.d.ts +90 -0
  82. package/dist/chat/auto-reply.js +272 -0
  83. package/dist/chat/conversations.d.ts +91 -0
  84. package/dist/chat/conversations.js +297 -0
  85. package/dist/chat/execution/audit.d.ts +192 -0
  86. package/dist/chat/execution/audit.js +323 -0
  87. package/dist/chat/execution/executor.d.ts +56 -0
  88. package/dist/chat/execution/executor.js +654 -0
  89. package/dist/chat/execution/guardrails.d.ts +98 -0
  90. package/dist/chat/execution/guardrails.js +571 -0
  91. package/dist/chat/execution/index.d.ts +61 -0
  92. package/dist/chat/execution/index.js +129 -0
  93. package/dist/chat/execution/model-capability.d.ts +34 -0
  94. package/dist/chat/execution/model-capability.js +96 -0
  95. package/dist/chat/execution/process-pool.d.ts +110 -0
  96. package/dist/chat/execution/process-pool.js +290 -0
  97. package/dist/chat/execution/pty.d.ts +92 -0
  98. package/dist/chat/execution/pty.js +285 -0
  99. package/dist/chat/execution/rate-limiter.d.ts +87 -0
  100. package/dist/chat/execution/rate-limiter.js +305 -0
  101. package/dist/chat/execution/registry.d.ts +54 -0
  102. package/dist/chat/execution/registry.js +220 -0
  103. package/dist/chat/execution/sandbox.d.ts +109 -0
  104. package/dist/chat/execution/sandbox.js +684 -0
  105. package/dist/chat/execution/secrets.d.ts +45 -0
  106. package/dist/chat/execution/secrets.js +338 -0
  107. package/dist/chat/execution/security.d.ts +179 -0
  108. package/dist/chat/execution/security.js +739 -0
  109. package/dist/chat/execution/self-correction.d.ts +162 -0
  110. package/dist/chat/execution/self-correction.js +557 -0
  111. package/dist/chat/execution/session-manager.d.ts +79 -0
  112. package/dist/chat/execution/session-manager.js +356 -0
  113. package/dist/chat/execution/session-spawn/config.d.ts +37 -0
  114. package/dist/chat/execution/session-spawn/config.js +83 -0
  115. package/dist/chat/execution/session-spawn/index.d.ts +10 -0
  116. package/dist/chat/execution/session-spawn/index.js +10 -0
  117. package/dist/chat/execution/session-spawn/manager.d.ts +35 -0
  118. package/dist/chat/execution/session-spawn/manager.js +418 -0
  119. package/dist/chat/execution/session-spawn/types.d.ts +117 -0
  120. package/dist/chat/execution/session-spawn/types.js +16 -0
  121. package/dist/chat/execution/smart-prompts.d.ts +34 -0
  122. package/dist/chat/execution/smart-prompts.js +151 -0
  123. package/dist/chat/execution/stream-results.d.ts +65 -0
  124. package/dist/chat/execution/stream-results.js +156 -0
  125. package/dist/chat/execution/tool-router.d.ts +76 -0
  126. package/dist/chat/execution/tool-router.js +296 -0
  127. package/dist/chat/execution/tools/agents-list.d.ts +49 -0
  128. package/dist/chat/execution/tools/agents-list.js +165 -0
  129. package/dist/chat/execution/tools/browser.d.ts +12 -0
  130. package/dist/chat/execution/tools/browser.js +14 -0
  131. package/dist/chat/execution/tools/canvas.d.ts +61 -0
  132. package/dist/chat/execution/tools/canvas.js +150 -0
  133. package/dist/chat/execution/tools/complete-task.d.ts +72 -0
  134. package/dist/chat/execution/tools/complete-task.js +104 -0
  135. package/dist/chat/execution/tools/cron-tool.d.ts +204 -0
  136. package/dist/chat/execution/tools/cron-tool.js +680 -0
  137. package/dist/chat/execution/tools/discord-actions.d.ts +120 -0
  138. package/dist/chat/execution/tools/discord-actions.js +361 -0
  139. package/dist/chat/execution/tools/exec.d.ts +43 -0
  140. package/dist/chat/execution/tools/exec.js +223 -0
  141. package/dist/chat/execution/tools/file-ops.d.ts +175 -0
  142. package/dist/chat/execution/tools/file-ops.js +723 -0
  143. package/dist/chat/execution/tools/git.d.ts +143 -0
  144. package/dist/chat/execution/tools/git.js +395 -0
  145. package/dist/chat/execution/tools/github.d.ts +42 -0
  146. package/dist/chat/execution/tools/github.js +184 -0
  147. package/dist/chat/execution/tools/glinr-ops.d.ts +202 -0
  148. package/dist/chat/execution/tools/glinr-ops.js +694 -0
  149. package/dist/chat/execution/tools/image-analyze.d.ts +29 -0
  150. package/dist/chat/execution/tools/image-analyze.js +127 -0
  151. package/dist/chat/execution/tools/index.d.ts +64 -0
  152. package/dist/chat/execution/tools/index.js +245 -0
  153. package/dist/chat/execution/tools/integrations.d.ts +109 -0
  154. package/dist/chat/execution/tools/integrations.js +237 -0
  155. package/dist/chat/execution/tools/link-understand.d.ts +34 -0
  156. package/dist/chat/execution/tools/link-understand.js +307 -0
  157. package/dist/chat/execution/tools/maintenance.d.ts +29 -0
  158. package/dist/chat/execution/tools/maintenance.js +105 -0
  159. package/dist/chat/execution/tools/memory-tools.d.ts +76 -0
  160. package/dist/chat/execution/tools/memory-tools.js +278 -0
  161. package/dist/chat/execution/tools/openai-image-gen.d.ts +51 -0
  162. package/dist/chat/execution/tools/openai-image-gen.js +212 -0
  163. package/dist/chat/execution/tools/profclaw-ops.d.ts +204 -0
  164. package/dist/chat/execution/tools/profclaw-ops.js +665 -0
  165. package/dist/chat/execution/tools/session-spawn.d.ts +146 -0
  166. package/dist/chat/execution/tools/session-spawn.js +544 -0
  167. package/dist/chat/execution/tools/session-status.d.ts +38 -0
  168. package/dist/chat/execution/tools/session-status.js +185 -0
  169. package/dist/chat/execution/tools/sessions-list.d.ts +49 -0
  170. package/dist/chat/execution/tools/sessions-list.js +153 -0
  171. package/dist/chat/execution/tools/sessions-send.d.ts +48 -0
  172. package/dist/chat/execution/tools/sessions-send.js +207 -0
  173. package/dist/chat/execution/tools/sessions-spawn.d.ts +51 -0
  174. package/dist/chat/execution/tools/sessions-spawn.js +137 -0
  175. package/dist/chat/execution/tools/slack-actions.d.ts +90 -0
  176. package/dist/chat/execution/tools/slack-actions.js +272 -0
  177. package/dist/chat/execution/tools/subagent-orchestrate.d.ts +66 -0
  178. package/dist/chat/execution/tools/subagent-orchestrate.js +313 -0
  179. package/dist/chat/execution/tools/system.d.ts +121 -0
  180. package/dist/chat/execution/tools/system.js +415 -0
  181. package/dist/chat/execution/tools/telegram-actions.d.ts +126 -0
  182. package/dist/chat/execution/tools/telegram-actions.js +339 -0
  183. package/dist/chat/execution/tools/test-run.d.ts +43 -0
  184. package/dist/chat/execution/tools/test-run.js +391 -0
  185. package/dist/chat/execution/tools/tts-speak.d.ts +39 -0
  186. package/dist/chat/execution/tools/tts-speak.js +199 -0
  187. package/dist/chat/execution/tools/web-fetch.d.ts +42 -0
  188. package/dist/chat/execution/tools/web-fetch.js +247 -0
  189. package/dist/chat/execution/tools/web-search.d.ts +53 -0
  190. package/dist/chat/execution/tools/web-search.js +130 -0
  191. package/dist/chat/execution/types.d.ts +337 -0
  192. package/dist/chat/execution/types.js +8 -0
  193. package/dist/chat/execution/workflows/built-in.d.ts +10 -0
  194. package/dist/chat/execution/workflows/built-in.js +249 -0
  195. package/dist/chat/execution/workflows/executor.d.ts +13 -0
  196. package/dist/chat/execution/workflows/executor.js +259 -0
  197. package/dist/chat/execution/workflows/index.d.ts +5 -0
  198. package/dist/chat/execution/workflows/index.js +5 -0
  199. package/dist/chat/execution/workflows/trigger.d.ts +15 -0
  200. package/dist/chat/execution/workflows/trigger.js +111 -0
  201. package/dist/chat/execution/workflows/types.d.ts +80 -0
  202. package/dist/chat/execution/workflows/types.js +2 -0
  203. package/dist/chat/failover/error.d.ts +73 -0
  204. package/dist/chat/failover/error.js +412 -0
  205. package/dist/chat/failover/index.d.ts +10 -0
  206. package/dist/chat/failover/index.js +11 -0
  207. package/dist/chat/failover/model-fallback.d.ts +97 -0
  208. package/dist/chat/failover/model-fallback.js +328 -0
  209. package/dist/chat/failover/types.d.ts +47 -0
  210. package/dist/chat/failover/types.js +8 -0
  211. package/dist/chat/format/chunk.d.ts +59 -0
  212. package/dist/chat/format/chunk.js +253 -0
  213. package/dist/chat/format/index.d.ts +7 -0
  214. package/dist/chat/format/index.js +7 -0
  215. package/dist/chat/format/tool-result-formatter.d.ts +30 -0
  216. package/dist/chat/format/tool-result-formatter.js +177 -0
  217. package/dist/chat/group.d.ts +232 -0
  218. package/dist/chat/group.js +311 -0
  219. package/dist/chat/index.d.ts +21 -0
  220. package/dist/chat/index.js +30 -0
  221. package/dist/chat/memory.d.ts +108 -0
  222. package/dist/chat/memory.js +343 -0
  223. package/dist/chat/message-handler.d.ts +38 -0
  224. package/dist/chat/message-handler.js +274 -0
  225. package/dist/chat/proactive/index.d.ts +167 -0
  226. package/dist/chat/proactive/index.js +721 -0
  227. package/dist/chat/prompt-adapter.d.ts +52 -0
  228. package/dist/chat/prompt-adapter.js +245 -0
  229. package/dist/chat/providers/dingtalk/index.d.ts +69 -0
  230. package/dist/chat/providers/dingtalk/index.js +225 -0
  231. package/dist/chat/providers/discord/index.d.ts +264 -0
  232. package/dist/chat/providers/discord/index.js +657 -0
  233. package/dist/chat/providers/feishu/index.d.ts +97 -0
  234. package/dist/chat/providers/feishu/index.js +362 -0
  235. package/dist/chat/providers/googlechat/index.d.ts +269 -0
  236. package/dist/chat/providers/googlechat/index.js +634 -0
  237. package/dist/chat/providers/imessage/index.d.ts +61 -0
  238. package/dist/chat/providers/imessage/index.js +166 -0
  239. package/dist/chat/providers/index.d.ts +76 -0
  240. package/dist/chat/providers/index.js +430 -0
  241. package/dist/chat/providers/irc/index.d.ts +101 -0
  242. package/dist/chat/providers/irc/index.js +557 -0
  243. package/dist/chat/providers/line/index.d.ts +113 -0
  244. package/dist/chat/providers/line/index.js +434 -0
  245. package/dist/chat/providers/matrix/index.d.ts +161 -0
  246. package/dist/chat/providers/matrix/index.js +559 -0
  247. package/dist/chat/providers/mattermost/index.d.ts +106 -0
  248. package/dist/chat/providers/mattermost/index.js +425 -0
  249. package/dist/chat/providers/msteams/index.d.ts +198 -0
  250. package/dist/chat/providers/msteams/index.js +694 -0
  251. package/dist/chat/providers/nextcloud/index.d.ts +52 -0
  252. package/dist/chat/providers/nextcloud/index.js +156 -0
  253. package/dist/chat/providers/nostr/index.d.ts +60 -0
  254. package/dist/chat/providers/nostr/index.js +200 -0
  255. package/dist/chat/providers/qq/index.d.ts +57 -0
  256. package/dist/chat/providers/qq/index.js +260 -0
  257. package/dist/chat/providers/registry.d.ts +89 -0
  258. package/dist/chat/providers/registry.js +213 -0
  259. package/dist/chat/providers/signal/index.d.ts +88 -0
  260. package/dist/chat/providers/signal/index.js +357 -0
  261. package/dist/chat/providers/slack/index.d.ts +52 -0
  262. package/dist/chat/providers/slack/index.js +477 -0
  263. package/dist/chat/providers/synology/index.d.ts +50 -0
  264. package/dist/chat/providers/synology/index.js +138 -0
  265. package/dist/chat/providers/telegram/index.d.ts +148 -0
  266. package/dist/chat/providers/telegram/index.js +492 -0
  267. package/dist/chat/providers/tlon/index.d.ts +44 -0
  268. package/dist/chat/providers/tlon/index.js +243 -0
  269. package/dist/chat/providers/twitch/index.d.ts +79 -0
  270. package/dist/chat/providers/twitch/index.js +349 -0
  271. package/dist/chat/providers/types.d.ts +437 -0
  272. package/dist/chat/providers/types.js +14 -0
  273. package/dist/chat/providers/webchat/index.d.ts +38 -0
  274. package/dist/chat/providers/webchat/index.js +214 -0
  275. package/dist/chat/providers/wecom/index.d.ts +62 -0
  276. package/dist/chat/providers/wecom/index.js +228 -0
  277. package/dist/chat/providers/whatsapp/index.d.ts +147 -0
  278. package/dist/chat/providers/whatsapp/index.js +396 -0
  279. package/dist/chat/providers/zalo/index.d.ts +54 -0
  280. package/dist/chat/providers/zalo/index.js +158 -0
  281. package/dist/chat/providers/zalo-personal/index.d.ts +53 -0
  282. package/dist/chat/providers/zalo-personal/index.js +212 -0
  283. package/dist/chat/skills.d.ts +82 -0
  284. package/dist/chat/skills.js +410 -0
  285. package/dist/chat/system-prompts.d.ts +76 -0
  286. package/dist/chat/system-prompts.js +407 -0
  287. package/dist/chat/tool-handler.d.ts +57 -0
  288. package/dist/chat/tool-handler.js +336 -0
  289. package/dist/chat/tools.d.ts +373 -0
  290. package/dist/chat/tools.js +512 -0
  291. package/dist/cli/commands/agent.d.ts +3 -0
  292. package/dist/cli/commands/agent.js +108 -0
  293. package/dist/cli/commands/auth.d.ts +12 -0
  294. package/dist/cli/commands/auth.js +301 -0
  295. package/dist/cli/commands/browser.d.ts +3 -0
  296. package/dist/cli/commands/browser.js +138 -0
  297. package/dist/cli/commands/canvas.d.ts +3 -0
  298. package/dist/cli/commands/canvas.js +155 -0
  299. package/dist/cli/commands/channels.d.ts +3 -0
  300. package/dist/cli/commands/channels.js +167 -0
  301. package/dist/cli/commands/chat.d.ts +9 -0
  302. package/dist/cli/commands/chat.js +360 -0
  303. package/dist/cli/commands/completion.d.ts +3 -0
  304. package/dist/cli/commands/completion.js +170 -0
  305. package/dist/cli/commands/config.d.ts +3 -0
  306. package/dist/cli/commands/config.js +193 -0
  307. package/dist/cli/commands/cost.d.ts +3 -0
  308. package/dist/cli/commands/cost.js +134 -0
  309. package/dist/cli/commands/daemon.d.ts +3 -0
  310. package/dist/cli/commands/daemon.js +381 -0
  311. package/dist/cli/commands/devices.d.ts +3 -0
  312. package/dist/cli/commands/devices.js +150 -0
  313. package/dist/cli/commands/doctor.d.ts +3 -0
  314. package/dist/cli/commands/doctor.js +295 -0
  315. package/dist/cli/commands/logs.d.ts +3 -0
  316. package/dist/cli/commands/logs.js +139 -0
  317. package/dist/cli/commands/mcp.d.ts +15 -0
  318. package/dist/cli/commands/mcp.js +157 -0
  319. package/dist/cli/commands/memory.d.ts +3 -0
  320. package/dist/cli/commands/memory.js +170 -0
  321. package/dist/cli/commands/models.d.ts +3 -0
  322. package/dist/cli/commands/models.js +197 -0
  323. package/dist/cli/commands/nodes.d.ts +3 -0
  324. package/dist/cli/commands/nodes.js +193 -0
  325. package/dist/cli/commands/onboard.d.ts +13 -0
  326. package/dist/cli/commands/onboard.js +360 -0
  327. package/dist/cli/commands/plugin.d.ts +15 -0
  328. package/dist/cli/commands/plugin.js +226 -0
  329. package/dist/cli/commands/provider.d.ts +16 -0
  330. package/dist/cli/commands/provider.js +320 -0
  331. package/dist/cli/commands/security.d.ts +3 -0
  332. package/dist/cli/commands/security.js +180 -0
  333. package/dist/cli/commands/serve.d.ts +3 -0
  334. package/dist/cli/commands/serve.js +179 -0
  335. package/dist/cli/commands/session.d.ts +3 -0
  336. package/dist/cli/commands/session.js +172 -0
  337. package/dist/cli/commands/setup.d.ts +13 -0
  338. package/dist/cli/commands/setup.js +636 -0
  339. package/dist/cli/commands/skill.d.ts +15 -0
  340. package/dist/cli/commands/skill.js +191 -0
  341. package/dist/cli/commands/status.d.ts +3 -0
  342. package/dist/cli/commands/status.js +71 -0
  343. package/dist/cli/commands/summary.d.ts +3 -0
  344. package/dist/cli/commands/summary.js +160 -0
  345. package/dist/cli/commands/task.d.ts +3 -0
  346. package/dist/cli/commands/task.js +170 -0
  347. package/dist/cli/commands/ticket.d.ts +3 -0
  348. package/dist/cli/commands/ticket.js +421 -0
  349. package/dist/cli/commands/tools.d.ts +9 -0
  350. package/dist/cli/commands/tools.js +508 -0
  351. package/dist/cli/commands/tui.d.ts +3 -0
  352. package/dist/cli/commands/tui.js +158 -0
  353. package/dist/cli/commands/tunnel.d.ts +3 -0
  354. package/dist/cli/commands/tunnel.js +135 -0
  355. package/dist/cli/commands/webhooks.d.ts +3 -0
  356. package/dist/cli/commands/webhooks.js +191 -0
  357. package/dist/cli/index.d.ts +3 -0
  358. package/dist/cli/index.js +127 -0
  359. package/dist/cli/utils/api.d.ts +17 -0
  360. package/dist/cli/utils/api.js +63 -0
  361. package/dist/cli/utils/config.d.ts +31 -0
  362. package/dist/cli/utils/config.js +81 -0
  363. package/dist/cli/utils/output.d.ts +58 -0
  364. package/dist/cli/utils/output.js +148 -0
  365. package/dist/core/deployment.d.ts +30 -0
  366. package/dist/core/deployment.js +114 -0
  367. package/dist/core/sandbox-config.d.ts +63 -0
  368. package/dist/core/sandbox-config.js +148 -0
  369. package/dist/costs/budget.d.ts +28 -0
  370. package/dist/costs/budget.js +57 -0
  371. package/dist/costs/persistence.d.ts +77 -0
  372. package/dist/costs/persistence.js +210 -0
  373. package/dist/costs/pricing.d.ts +16 -0
  374. package/dist/costs/pricing.js +39 -0
  375. package/dist/costs/token-tracker.d.ts +34 -0
  376. package/dist/costs/token-tracker.js +141 -0
  377. package/dist/cron/heartbeat.d.ts +23 -0
  378. package/dist/cron/heartbeat.js +109 -0
  379. package/dist/cron/index.d.ts +22 -0
  380. package/dist/cron/index.js +37 -0
  381. package/dist/cron/issue-poller.d.ts +15 -0
  382. package/dist/cron/issue-poller.js +174 -0
  383. package/dist/cron/scheduler.d.ts +315 -0
  384. package/dist/cron/scheduler.js +1008 -0
  385. package/dist/cron/stale-checker.d.ts +16 -0
  386. package/dist/cron/stale-checker.js +61 -0
  387. package/dist/cron/templates.d.ts +107 -0
  388. package/dist/cron/templates.js +395 -0
  389. package/dist/diagnostics/exporters.d.ts +21 -0
  390. package/dist/diagnostics/exporters.js +138 -0
  391. package/dist/diagnostics/index.d.ts +10 -0
  392. package/dist/diagnostics/index.js +9 -0
  393. package/dist/diagnostics/middleware.d.ts +12 -0
  394. package/dist/diagnostics/middleware.js +58 -0
  395. package/dist/diagnostics/tracer.d.ts +133 -0
  396. package/dist/diagnostics/tracer.js +257 -0
  397. package/dist/discovery/index.d.ts +8 -0
  398. package/dist/discovery/index.js +7 -0
  399. package/dist/discovery/mdns.d.ts +40 -0
  400. package/dist/discovery/mdns.js +249 -0
  401. package/dist/gateway/index.d.ts +35 -0
  402. package/dist/gateway/index.js +36 -0
  403. package/dist/gateway/router.d.ts +110 -0
  404. package/dist/gateway/router.js +649 -0
  405. package/dist/gateway/types.d.ts +275 -0
  406. package/dist/gateway/types.js +2 -0
  407. package/dist/gateway/workflows.d.ts +37 -0
  408. package/dist/gateway/workflows.js +748 -0
  409. package/dist/hooks/agent-webhook.d.ts +277 -0
  410. package/dist/hooks/agent-webhook.js +197 -0
  411. package/dist/hooks/index.d.ts +13 -0
  412. package/dist/hooks/index.js +15 -0
  413. package/dist/hooks/prompt-submit.d.ts +45 -0
  414. package/dist/hooks/prompt-submit.js +111 -0
  415. package/dist/hooks/schemas.d.ts +563 -0
  416. package/dist/hooks/schemas.js +108 -0
  417. package/dist/hooks/session-end.d.ts +25 -0
  418. package/dist/hooks/session-end.js +153 -0
  419. package/dist/hooks/tool-use.d.ts +41 -0
  420. package/dist/hooks/tool-use.js +201 -0
  421. package/dist/hooks/types.d.ts +76 -0
  422. package/dist/hooks/types.js +7 -0
  423. package/dist/integrations/cloudflare-tunnel.d.ts +78 -0
  424. package/dist/integrations/cloudflare-tunnel.js +268 -0
  425. package/dist/integrations/github-client.d.ts +27 -0
  426. package/dist/integrations/github-client.js +79 -0
  427. package/dist/integrations/github-projects.d.ts +97 -0
  428. package/dist/integrations/github-projects.js +433 -0
  429. package/dist/integrations/github-ticket-sync.d.ts +82 -0
  430. package/dist/integrations/github-ticket-sync.js +352 -0
  431. package/dist/integrations/github.d.ts +11 -0
  432. package/dist/integrations/github.js +241 -0
  433. package/dist/integrations/jira-client.d.ts +30 -0
  434. package/dist/integrations/jira-client.js +67 -0
  435. package/dist/integrations/jira.d.ts +13 -0
  436. package/dist/integrations/jira.js +108 -0
  437. package/dist/integrations/linear-client.d.ts +23 -0
  438. package/dist/integrations/linear-client.js +52 -0
  439. package/dist/integrations/linear.d.ts +15 -0
  440. package/dist/integrations/linear.js +312 -0
  441. package/dist/integrations/tailscale.d.ts +68 -0
  442. package/dist/integrations/tailscale.js +173 -0
  443. package/dist/integrations/web-search.d.ts +112 -0
  444. package/dist/integrations/web-search.js +287 -0
  445. package/dist/intelligence/index.d.ts +8 -0
  446. package/dist/intelligence/index.js +8 -0
  447. package/dist/intelligence/ollama.d.ts +50 -0
  448. package/dist/intelligence/ollama.js +213 -0
  449. package/dist/intelligence/rules.d.ts +39 -0
  450. package/dist/intelligence/rules.js +308 -0
  451. package/dist/labels/index.d.ts +93 -0
  452. package/dist/labels/index.js +248 -0
  453. package/dist/mcp/browser-tools.d.ts +10 -0
  454. package/dist/mcp/browser-tools.js +16 -0
  455. package/dist/mcp/client.d.ts +54 -0
  456. package/dist/mcp/client.js +153 -0
  457. package/dist/mcp/index.d.ts +12 -0
  458. package/dist/mcp/index.js +13 -0
  459. package/dist/mcp/server.d.ts +40 -0
  460. package/dist/mcp/server.js +826 -0
  461. package/dist/mcp/tool-adapter.d.ts +49 -0
  462. package/dist/mcp/tool-adapter.js +193 -0
  463. package/dist/memory/experience-store.d.ts +121 -0
  464. package/dist/memory/experience-store.js +439 -0
  465. package/dist/memory/index.d.ts +8 -0
  466. package/dist/memory/index.js +25 -0
  467. package/dist/memory/memory-service.d.ts +312 -0
  468. package/dist/memory/memory-service.js +1172 -0
  469. package/dist/memory/memory-watcher.d.ts +116 -0
  470. package/dist/memory/memory-watcher.js +239 -0
  471. package/dist/middleware/logging.d.ts +34 -0
  472. package/dist/middleware/logging.js +184 -0
  473. package/dist/middleware/rate-limit.d.ts +29 -0
  474. package/dist/middleware/rate-limit.js +91 -0
  475. package/dist/notifications/in-app.d.ts +28 -0
  476. package/dist/notifications/in-app.js +53 -0
  477. package/dist/notifications/index.d.ts +3 -0
  478. package/dist/notifications/index.js +3 -0
  479. package/dist/notifications/push.d.ts +74 -0
  480. package/dist/notifications/push.js +175 -0
  481. package/dist/notifications/slack.d.ts +32 -0
  482. package/dist/notifications/slack.js +157 -0
  483. package/dist/plugins/clawhub.d.ts +70 -0
  484. package/dist/plugins/clawhub.js +260 -0
  485. package/dist/plugins/loader.d.ts +23 -0
  486. package/dist/plugins/loader.js +140 -0
  487. package/dist/plugins/marketplace.d.ts +77 -0
  488. package/dist/plugins/marketplace.js +275 -0
  489. package/dist/plugins/registry.d.ts +122 -0
  490. package/dist/plugins/registry.js +352 -0
  491. package/dist/plugins/sandbox.d.ts +77 -0
  492. package/dist/plugins/sandbox.js +287 -0
  493. package/dist/plugins/scaffolder.d.ts +28 -0
  494. package/dist/plugins/scaffolder.js +409 -0
  495. package/dist/plugins/sdk.d.ts +35 -0
  496. package/dist/plugins/sdk.js +8 -0
  497. package/dist/plugins/search/brave.d.ts +9 -0
  498. package/dist/plugins/search/brave.js +157 -0
  499. package/dist/plugins/search/duckduckgo.d.ts +9 -0
  500. package/dist/plugins/search/duckduckgo.js +171 -0
  501. package/dist/plugins/search/index.d.ts +13 -0
  502. package/dist/plugins/search/index.js +23 -0
  503. package/dist/plugins/search/searxng.d.ts +9 -0
  504. package/dist/plugins/search/searxng.js +170 -0
  505. package/dist/plugins/search/serper.d.ts +9 -0
  506. package/dist/plugins/search/serper.js +135 -0
  507. package/dist/plugins/search/tavily.d.ts +9 -0
  508. package/dist/plugins/search/tavily.js +146 -0
  509. package/dist/plugins/types.d.ts +174 -0
  510. package/dist/plugins/types.js +8 -0
  511. package/dist/projects/index.d.ts +133 -0
  512. package/dist/projects/index.js +897 -0
  513. package/dist/projects/types.d.ts +444 -0
  514. package/dist/projects/types.js +207 -0
  515. package/dist/providers/adapters/anthropic.d.ts +26 -0
  516. package/dist/providers/adapters/anthropic.js +306 -0
  517. package/dist/providers/adapters/base.d.ts +53 -0
  518. package/dist/providers/adapters/base.js +99 -0
  519. package/dist/providers/adapters/ollama.d.ts +30 -0
  520. package/dist/providers/adapters/ollama.js +292 -0
  521. package/dist/providers/ai-sdk.d.ts +178 -0
  522. package/dist/providers/ai-sdk.js +1552 -0
  523. package/dist/providers/core/index.d.ts +8 -0
  524. package/dist/providers/core/index.js +10 -0
  525. package/dist/providers/core/models.d.ts +31 -0
  526. package/dist/providers/core/models.js +949 -0
  527. package/dist/providers/core/types.d.ts +117 -0
  528. package/dist/providers/core/types.js +83 -0
  529. package/dist/providers/index.d.ts +7 -0
  530. package/dist/providers/index.js +7 -0
  531. package/dist/providers/registry.d.ts +93 -0
  532. package/dist/providers/registry.js +228 -0
  533. package/dist/providers/schema-utils.d.ts +23 -0
  534. package/dist/providers/schema-utils.js +545 -0
  535. package/dist/providers/types.d.ts +609 -0
  536. package/dist/providers/types.js +279 -0
  537. package/dist/queue/failure-handler.d.ts +93 -0
  538. package/dist/queue/failure-handler.js +379 -0
  539. package/dist/queue/index.d.ts +23 -0
  540. package/dist/queue/index.js +86 -0
  541. package/dist/queue/memory-queue.d.ts +30 -0
  542. package/dist/queue/memory-queue.js +429 -0
  543. package/dist/queue/notifications.d.ts +6 -0
  544. package/dist/queue/notifications.js +128 -0
  545. package/dist/queue/task-queue.d.ts +55 -0
  546. package/dist/queue/task-queue.js +518 -0
  547. package/dist/queue/webhook-queue.d.ts +47 -0
  548. package/dist/queue/webhook-queue.js +158 -0
  549. package/dist/routes/agents.d.ts +4 -0
  550. package/dist/routes/agents.js +45 -0
  551. package/dist/routes/auth.d.ts +19 -0
  552. package/dist/routes/auth.js +492 -0
  553. package/dist/routes/backup.d.ts +6 -0
  554. package/dist/routes/backup.js +71 -0
  555. package/dist/routes/chat.d.ts +10 -0
  556. package/dist/routes/chat.js +1678 -0
  557. package/dist/routes/clawhub.d.ts +8 -0
  558. package/dist/routes/clawhub.js +89 -0
  559. package/dist/routes/costs.d.ts +4 -0
  560. package/dist/routes/costs.js +78 -0
  561. package/dist/routes/cron.d.ts +11 -0
  562. package/dist/routes/cron.js +708 -0
  563. package/dist/routes/devices.d.ts +9 -0
  564. package/dist/routes/devices.js +490 -0
  565. package/dist/routes/discord.d.ts +15 -0
  566. package/dist/routes/discord.js +524 -0
  567. package/dist/routes/dlq.d.ts +4 -0
  568. package/dist/routes/dlq.js +64 -0
  569. package/dist/routes/gateway.d.ts +4 -0
  570. package/dist/routes/gateway.js +253 -0
  571. package/dist/routes/health.d.ts +29 -0
  572. package/dist/routes/health.js +296 -0
  573. package/dist/routes/hooks.d.ts +4 -0
  574. package/dist/routes/hooks.js +170 -0
  575. package/dist/routes/import.d.ts +9 -0
  576. package/dist/routes/import.js +540 -0
  577. package/dist/routes/index.d.ts +38 -0
  578. package/dist/routes/index.js +39 -0
  579. package/dist/routes/integrations.d.ts +10 -0
  580. package/dist/routes/integrations.js +200 -0
  581. package/dist/routes/labels.d.ts +8 -0
  582. package/dist/routes/labels.js +240 -0
  583. package/dist/routes/mcp.d.ts +14 -0
  584. package/dist/routes/mcp.js +125 -0
  585. package/dist/routes/memory.d.ts +10 -0
  586. package/dist/routes/memory.js +622 -0
  587. package/dist/routes/notifications.d.ts +9 -0
  588. package/dist/routes/notifications.js +154 -0
  589. package/dist/routes/oobe.d.ts +10 -0
  590. package/dist/routes/oobe.js +405 -0
  591. package/dist/routes/openapi.d.ts +9 -0
  592. package/dist/routes/openapi.js +537 -0
  593. package/dist/routes/plugins.d.ts +8 -0
  594. package/dist/routes/plugins.js +108 -0
  595. package/dist/routes/projects.d.ts +8 -0
  596. package/dist/routes/projects.js +592 -0
  597. package/dist/routes/push.d.ts +8 -0
  598. package/dist/routes/push.js +75 -0
  599. package/dist/routes/search.d.ts +4 -0
  600. package/dist/routes/search.js +189 -0
  601. package/dist/routes/security.d.ts +10 -0
  602. package/dist/routes/security.js +189 -0
  603. package/dist/routes/settings.d.ts +4 -0
  604. package/dist/routes/settings.js +119 -0
  605. package/dist/routes/setup.d.ts +11 -0
  606. package/dist/routes/setup.js +525 -0
  607. package/dist/routes/skills.d.ts +13 -0
  608. package/dist/routes/skills.js +152 -0
  609. package/dist/routes/slack.d.ts +12 -0
  610. package/dist/routes/slack.js +999 -0
  611. package/dist/routes/states.d.ts +8 -0
  612. package/dist/routes/states.js +123 -0
  613. package/dist/routes/stats.d.ts +6 -0
  614. package/dist/routes/stats.js +369 -0
  615. package/dist/routes/summaries.d.ts +4 -0
  616. package/dist/routes/summaries.js +344 -0
  617. package/dist/routes/sync.d.ts +13 -0
  618. package/dist/routes/sync.js +268 -0
  619. package/dist/routes/tasks.d.ts +4 -0
  620. package/dist/routes/tasks.js +473 -0
  621. package/dist/routes/telegram.d.ts +14 -0
  622. package/dist/routes/telegram.js +420 -0
  623. package/dist/routes/tickets.d.ts +4 -0
  624. package/dist/routes/tickets.js +1090 -0
  625. package/dist/routes/tokens.d.ts +4 -0
  626. package/dist/routes/tokens.js +83 -0
  627. package/dist/routes/tools.d.ts +14 -0
  628. package/dist/routes/tools.js +790 -0
  629. package/dist/routes/tunnels.d.ts +8 -0
  630. package/dist/routes/tunnels.js +145 -0
  631. package/dist/routes/users.d.ts +15 -0
  632. package/dist/routes/users.js +998 -0
  633. package/dist/routes/voice.d.ts +8 -0
  634. package/dist/routes/voice.js +127 -0
  635. package/dist/routes/webchat.d.ts +11 -0
  636. package/dist/routes/webchat.js +173 -0
  637. package/dist/routes/webhook-dedup.d.ts +11 -0
  638. package/dist/routes/webhook-dedup.js +49 -0
  639. package/dist/routes/webhooks.d.ts +4 -0
  640. package/dist/routes/webhooks.js +71 -0
  641. package/dist/routes/whatsapp.d.ts +14 -0
  642. package/dist/routes/whatsapp.js +391 -0
  643. package/dist/security/audit-scanner.d.ts +32 -0
  644. package/dist/security/audit-scanner.js +217 -0
  645. package/dist/security/fs-guard.d.ts +41 -0
  646. package/dist/security/fs-guard.js +206 -0
  647. package/dist/security/prompt-guard.d.ts +47 -0
  648. package/dist/security/prompt-guard.js +198 -0
  649. package/dist/security/ssrf-guard.d.ts +38 -0
  650. package/dist/security/ssrf-guard.js +266 -0
  651. package/dist/security/types.d.ts +92 -0
  652. package/dist/security/types.js +8 -0
  653. package/dist/server/route-loader.d.ts +15 -0
  654. package/dist/server/route-loader.js +135 -0
  655. package/dist/server.d.ts +5 -0
  656. package/dist/server.js +835 -0
  657. package/dist/settings/index.d.ts +841 -0
  658. package/dist/settings/index.js +451 -0
  659. package/dist/skills/compiler.d.ts +83 -0
  660. package/dist/skills/compiler.js +358 -0
  661. package/dist/skills/frontmatter.d.ts +33 -0
  662. package/dist/skills/frontmatter.js +175 -0
  663. package/dist/skills/index.d.ts +19 -0
  664. package/dist/skills/index.js +24 -0
  665. package/dist/skills/installer.d.ts +22 -0
  666. package/dist/skills/installer.js +220 -0
  667. package/dist/skills/loader.d.ts +72 -0
  668. package/dist/skills/loader.js +484 -0
  669. package/dist/skills/prompt-builder.d.ts +48 -0
  670. package/dist/skills/prompt-builder.js +135 -0
  671. package/dist/skills/registry.d.ts +115 -0
  672. package/dist/skills/registry.js +225 -0
  673. package/dist/skills/types.d.ts +202 -0
  674. package/dist/skills/types.js +24 -0
  675. package/dist/states/index.d.ts +64 -0
  676. package/dist/states/index.js +142 -0
  677. package/dist/storage/adapter.d.ts +146 -0
  678. package/dist/storage/adapter.js +2 -0
  679. package/dist/storage/index.d.ts +48 -0
  680. package/dist/storage/index.js +135 -0
  681. package/dist/storage/libsql.d.ts +99 -0
  682. package/dist/storage/libsql.js +1873 -0
  683. package/dist/storage/migrations.d.ts +65 -0
  684. package/dist/storage/migrations.js +289 -0
  685. package/dist/storage/schema.d.ts +10185 -0
  686. package/dist/storage/schema.js +1113 -0
  687. package/dist/summaries/extractor.d.ts +56 -0
  688. package/dist/summaries/extractor.js +377 -0
  689. package/dist/summaries/index.d.ts +13 -0
  690. package/dist/summaries/index.js +14 -0
  691. package/dist/summaries/storage.d.ts +51 -0
  692. package/dist/summaries/storage.js +101 -0
  693. package/dist/summaries/templates.d.ts +68 -0
  694. package/dist/summaries/templates.js +245 -0
  695. package/dist/sync/adapters/base.d.ts +42 -0
  696. package/dist/sync/adapters/base.js +142 -0
  697. package/dist/sync/adapters/github.d.ts +45 -0
  698. package/dist/sync/adapters/github.js +445 -0
  699. package/dist/sync/adapters/linear.d.ts +40 -0
  700. package/dist/sync/adapters/linear.js +434 -0
  701. package/dist/sync/config.d.ts +388 -0
  702. package/dist/sync/config.js +281 -0
  703. package/dist/sync/engine.d.ts +112 -0
  704. package/dist/sync/engine.js +623 -0
  705. package/dist/sync/index.d.ts +31 -0
  706. package/dist/sync/index.js +34 -0
  707. package/dist/sync/integration.d.ts +53 -0
  708. package/dist/sync/integration.js +231 -0
  709. package/dist/sync/types.d.ts +249 -0
  710. package/dist/sync/types.js +30 -0
  711. package/dist/tickets/index.d.ts +139 -0
  712. package/dist/tickets/index.js +1406 -0
  713. package/dist/tickets/types.d.ts +817 -0
  714. package/dist/tickets/types.js +310 -0
  715. package/dist/tools/adapters.d.ts +56 -0
  716. package/dist/tools/adapters.js +183 -0
  717. package/dist/tools/index.d.ts +66 -0
  718. package/dist/tools/index.js +105 -0
  719. package/dist/tools/types.d.ts +117 -0
  720. package/dist/tools/types.js +20 -0
  721. package/dist/types/agent.d.ts +101 -0
  722. package/dist/types/agent.js +2 -0
  723. package/dist/types/errors.d.ts +150 -0
  724. package/dist/types/errors.js +338 -0
  725. package/dist/types/index.d.ts +3 -0
  726. package/dist/types/index.js +3 -0
  727. package/dist/types/summary.d.ts +638 -0
  728. package/dist/types/summary.js +137 -0
  729. package/dist/types/task.d.ts +123 -0
  730. package/dist/types/task.js +46 -0
  731. package/dist/utils/ai-cache.d.ts +72 -0
  732. package/dist/utils/ai-cache.js +204 -0
  733. package/dist/utils/ai-inference.d.ts +57 -0
  734. package/dist/utils/ai-inference.js +190 -0
  735. package/dist/utils/ai-responder.d.ts +44 -0
  736. package/dist/utils/ai-responder.js +272 -0
  737. package/dist/utils/circuit-breaker.d.ts +139 -0
  738. package/dist/utils/circuit-breaker.js +281 -0
  739. package/dist/utils/config-loader.d.ts +12 -0
  740. package/dist/utils/config-loader.js +44 -0
  741. package/dist/utils/crypto.d.ts +10 -0
  742. package/dist/utils/crypto.js +59 -0
  743. package/dist/utils/env-validator.d.ts +44 -0
  744. package/dist/utils/env-validator.js +236 -0
  745. package/dist/utils/file-lock.d.ts +85 -0
  746. package/dist/utils/file-lock.js +204 -0
  747. package/dist/utils/logger.d.ts +153 -0
  748. package/dist/utils/logger.js +282 -0
  749. package/dist/utils/metrics.d.ts +183 -0
  750. package/dist/utils/metrics.js +345 -0
  751. package/dist/utils/security.d.ts +90 -0
  752. package/dist/utils/security.js +347 -0
  753. package/dist/voice/index.d.ts +79 -0
  754. package/dist/voice/index.js +144 -0
  755. package/dist/voice/stt/whisper.d.ts +13 -0
  756. package/dist/voice/stt/whisper.js +116 -0
  757. package/dist/voice/tts/elevenlabs.d.ts +18 -0
  758. package/dist/voice/tts/elevenlabs.js +178 -0
  759. package/dist/voice/tts/openai-tts.d.ts +19 -0
  760. package/dist/voice/tts/openai-tts.js +127 -0
  761. package/dist/voice/tts/system.d.ts +26 -0
  762. package/dist/voice/tts/system.js +146 -0
  763. package/dist/voice/wake-word.d.ts +44 -0
  764. package/dist/voice/wake-word.js +145 -0
  765. package/docker-compose.yml +222 -0
  766. package/package.json +154 -0
  767. package/profclaw.mjs +24 -0
  768. package/skills/1password/SKILL.md +155 -0
  769. package/skills/api-tester/SKILL.md +177 -0
  770. package/skills/apple-notes/SKILL.md +167 -0
  771. package/skills/apple-reminders/SKILL.md +178 -0
  772. package/skills/bear-notes/SKILL.md +166 -0
  773. package/skills/blogwatcher/SKILL.md +177 -0
  774. package/skills/camsnap/SKILL.md +130 -0
  775. package/skills/code-generation/SKILL.md +139 -0
  776. package/skills/code-review/SKILL.md +116 -0
  777. package/skills/coding-agent/SKILL.md +184 -0
  778. package/skills/cron-manager/SKILL.md +141 -0
  779. package/skills/debug-helper/SKILL.md +134 -0
  780. package/skills/docker-ops/SKILL.md +246 -0
  781. package/skills/file-manager/SKILL.md +160 -0
  782. package/skills/git-workflow/SKILL.md +171 -0
  783. package/skills/github-issues/SKILL.md +244 -0
  784. package/skills/gog/SKILL.md +191 -0
  785. package/skills/goplaces/SKILL.md +156 -0
  786. package/skills/healthcheck/SKILL.md +270 -0
  787. package/skills/himalaya/SKILL.md +165 -0
  788. package/skills/mcp-discovery/SKILL.md +109 -0
  789. package/skills/memory-manager/SKILL.md +151 -0
  790. package/skills/model-usage/SKILL.md +177 -0
  791. package/skills/nano-banana-pro/SKILL.md +214 -0
  792. package/skills/nano-pdf/SKILL.md +165 -0
  793. package/skills/notion/SKILL.md +147 -0
  794. package/skills/obsidian/SKILL.md +163 -0
  795. package/skills/openai-image-gen/SKILL.md +194 -0
  796. package/skills/openai-whisper/SKILL.md +98 -0
  797. package/skills/openai-whisper-api/SKILL.md +130 -0
  798. package/skills/openhue/SKILL.md +203 -0
  799. package/skills/oracle/SKILL.md +236 -0
  800. package/skills/phone-control/SKILL.md +201 -0
  801. package/skills/profclaw-assistant/SKILL.md +81 -0
  802. package/skills/profclaw-projects/SKILL.md +68 -0
  803. package/skills/profclaw-tickets/SKILL.md +91 -0
  804. package/skills/session-logs/SKILL.md +216 -0
  805. package/skills/sherpa-onnx-tts/SKILL.md +134 -0
  806. package/skills/skill-creator/SKILL.md +183 -0
  807. package/skills/songsee/SKILL.md +170 -0
  808. package/skills/spotify-player/SKILL.md +254 -0
  809. package/skills/summarize/SKILL.md +155 -0
  810. package/skills/system-admin/SKILL.md +179 -0
  811. package/skills/things-mac/SKILL.md +179 -0
  812. package/skills/tmux/SKILL.md +170 -0
  813. package/skills/trello/SKILL.md +154 -0
  814. package/skills/video-frames/SKILL.md +127 -0
  815. package/skills/weather/SKILL.md +186 -0
  816. package/skills/web-research/SKILL.md +128 -0
  817. package/skills/xurl/SKILL.md +198 -0
  818. package/ui/README.md +73 -0
  819. package/ui/dist/assets/ActivityView-CkPgKhwm.js +1 -0
  820. package/ui/dist/assets/AgentList-C3SVdeEz.js +1 -0
  821. package/ui/dist/assets/AnalyticsDashboard-DVU--vlP.js +1 -0
  822. package/ui/dist/assets/AreaChart-B5qMEGWj.js +1 -0
  823. package/ui/dist/assets/CartesianChart-B50bcUJi.js +36 -0
  824. package/ui/dist/assets/ChatView-BZFJs7w_.js +10 -0
  825. package/ui/dist/assets/CostsDashboard-ChfH8BlG.js +1 -0
  826. package/ui/dist/assets/EstimateSelect-CLpB4NQO.js +1 -0
  827. package/ui/dist/assets/FloatingChatbot-CBzBY9a0.js +2 -0
  828. package/ui/dist/assets/InviteCodeManagement-DsbdPa6W.js +2 -0
  829. package/ui/dist/assets/ProjectDetail-BEM3tFXg.js +2 -0
  830. package/ui/dist/assets/ProjectDetail-D1-0B2xV.css +1 -0
  831. package/ui/dist/assets/ProjectIcon-CN1FmFAk.js +1 -0
  832. package/ui/dist/assets/ProjectList-DSDaNhxQ.js +4 -0
  833. package/ui/dist/assets/Settings-dPVcqC_d.js +6 -0
  834. package/ui/dist/assets/StatusIndicator-DA3NAo_b.js +1 -0
  835. package/ui/dist/assets/SummaryDetail-Bjnf9lT8.js +27 -0
  836. package/ui/dist/assets/SummaryList-ENwKDBKW.js +1 -0
  837. package/ui/dist/assets/TaskDetail-DnwG6MzB.js +1 -0
  838. package/ui/dist/assets/TaskList-D9Ug_HiV.js +1 -0
  839. package/ui/dist/assets/TicketBoard-CviH1571.js +1 -0
  840. package/ui/dist/assets/TicketDetail-8Jk8O-33.js +1 -0
  841. package/ui/dist/assets/TicketList-B-iV4rRA.js +1 -0
  842. package/ui/dist/assets/UserManagement-CPZ8s7s2.js +2 -0
  843. package/ui/dist/assets/ViewSwitcher-BUyOOWDI.js +1 -0
  844. package/ui/dist/assets/alert-dialog-BOmnTkN-.js +7 -0
  845. package/ui/dist/assets/archive-D5my9zOG.js +1 -0
  846. package/ui/dist/assets/badge-B4ov81_m.js +1 -0
  847. package/ui/dist/assets/brain-C53ElFLD.js +1 -0
  848. package/ui/dist/assets/bug-D0TJoCYn.js +1 -0
  849. package/ui/dist/assets/calendar-BkWIhKa1.js +1 -0
  850. package/ui/dist/assets/chevron-up-BRTtndUZ.js +1 -0
  851. package/ui/dist/assets/circle-x-BN89YhbS.js +1 -0
  852. package/ui/dist/assets/constants-fc7TFI7u.js +1 -0
  853. package/ui/dist/assets/cpu-B41x1-vV.js +1 -0
  854. package/ui/dist/assets/database-D9Cnfmzj.js +1 -0
  855. package/ui/dist/assets/defineProperty-CoXUr7_6.js +2 -0
  856. package/ui/dist/assets/dialog-DrWB4EYD.js +1 -0
  857. package/ui/dist/assets/element-adapter-DL0DQilL.js +4 -0
  858. package/ui/dist/assets/ellipsis-NuUWekvu.js +1 -0
  859. package/ui/dist/assets/ellipsis-vertical-BueMfuCw.js +1 -0
  860. package/ui/dist/assets/file-code-HR9829Jc.js +1 -0
  861. package/ui/dist/assets/folder-open-C_7oYEqe.js +1 -0
  862. package/ui/dist/assets/funnel-B5gmNXGf.js +1 -0
  863. package/ui/dist/assets/git-branch-BRMiJmV3.js +1 -0
  864. package/ui/dist/assets/git-commit-horizontal-CXOUQeJI.js +1 -0
  865. package/ui/dist/assets/globe-CCspjvus.js +1 -0
  866. package/ui/dist/assets/hash-g3102kPC.js +1 -0
  867. package/ui/dist/assets/history-CNqcBBrV.js +1 -0
  868. package/ui/dist/assets/index-27mTPKuh.js +1 -0
  869. package/ui/dist/assets/index-BMx3fH-e.js +1 -0
  870. package/ui/dist/assets/index-C9jNQXzL.js +1 -0
  871. package/ui/dist/assets/index-CEZ6R2Uw.js +7 -0
  872. package/ui/dist/assets/index-DURTouJI.js +1 -0
  873. package/ui/dist/assets/index-WclMPci1.css +1 -0
  874. package/ui/dist/assets/index-kb4AJXUB.js +67 -0
  875. package/ui/dist/assets/layers-CLXiHN6o.js +1 -0
  876. package/ui/dist/assets/layout-dashboard-B07MFhBs.js +1 -0
  877. package/ui/dist/assets/lightbulb-B2dgG5ks.js +1 -0
  878. package/ui/dist/assets/link-2-BxNmr9hL.js +1 -0
  879. package/ui/dist/assets/markdown-renderer-CjU6hBcW.js +36 -0
  880. package/ui/dist/assets/message-square-Bf2-CVbt.js +1 -0
  881. package/ui/dist/assets/pencil-D096Ey62.js +1 -0
  882. package/ui/dist/assets/play-DfdcSI3x.js +1 -0
  883. package/ui/dist/assets/popover-BV0QJDQq.js +1 -0
  884. package/ui/dist/assets/progress-DjPEDJfI.js +1 -0
  885. package/ui/dist/assets/rocket-CPsTc-5G.js +1 -0
  886. package/ui/dist/assets/select-LsO16slr.js +1 -0
  887. package/ui/dist/assets/send-BDYBZDUZ.js +1 -0
  888. package/ui/dist/assets/server-B3k6noce.js +1 -0
  889. package/ui/dist/assets/settings-2-Cu4xTjhG.js +1 -0
  890. package/ui/dist/assets/sheet-BScLnPKX.js +1 -0
  891. package/ui/dist/assets/shield-check-CQqkwufI.js +1 -0
  892. package/ui/dist/assets/shield-off-ZFruH9KO.js +1 -0
  893. package/ui/dist/assets/skeleton-CtkIA_MU.js +1 -0
  894. package/ui/dist/assets/smartphone-DnoksVkc.js +1 -0
  895. package/ui/dist/assets/square-uD9ZHMfW.js +1 -0
  896. package/ui/dist/assets/switch-MQPnwGJK.js +1 -0
  897. package/ui/dist/assets/table-B8cqlywA.js +1 -0
  898. package/ui/dist/assets/tag-wEJQRWlV.js +1 -0
  899. package/ui/dist/assets/textarea-D5LJCOGl.js +1 -0
  900. package/ui/dist/assets/timer-mbGHegmr.js +1 -0
  901. package/ui/dist/assets/tooltip-Df1CunSp.js +1 -0
  902. package/ui/dist/assets/trash-2-B4oAXsX-.js +1 -0
  903. package/ui/dist/assets/trending-up-BGWxvlmZ.js +1 -0
  904. package/ui/dist/assets/wand-sparkles-CZy4xvL3.js +1 -0
  905. package/ui/dist/assets/wrench-ByZkjO6m.js +1 -0
  906. package/ui/dist/audio-worklets/vad-processor.js +132 -0
  907. package/ui/dist/brand/profclaw-appicon-192.png +0 -0
  908. package/ui/dist/brand/profclaw-appicon-512.png +0 -0
  909. package/ui/dist/brand/profclaw-appicon-shadow.svg +51 -0
  910. package/ui/dist/brand/profclaw-appicon.svg +50 -0
  911. package/ui/dist/brand/profclaw-favicon-coral-bg-128.png +0 -0
  912. package/ui/dist/brand/profclaw-favicon-coral-bg-64.png +0 -0
  913. package/ui/dist/brand/profclaw-favicon-coral-bg.svg +52 -0
  914. package/ui/dist/brand/profclaw-favicon-coral-body-128.png +0 -0
  915. package/ui/dist/brand/profclaw-favicon-coral-body.svg +41 -0
  916. package/ui/dist/brand/profclaw-favicon-shadow-128.png +0 -0
  917. package/ui/dist/brand/profclaw-favicon-shadow-64.png +0 -0
  918. package/ui/dist/brand/profclaw-favicon-shadow.svg +51 -0
  919. package/ui/dist/brand/profclaw-mark-coral-256.png +0 -0
  920. package/ui/dist/brand/profclaw-mark-coral-64.png +0 -0
  921. package/ui/dist/brand/profclaw-mark-coral.svg +31 -0
  922. package/ui/dist/brand/profclaw-mono-white.svg +18 -0
  923. package/ui/dist/brand/profclaw-text-dark.svg +18 -0
  924. package/ui/dist/brand/profclaw-text-light.svg +18 -0
  925. package/ui/dist/brand/profclaw-wordmark-dark.svg +48 -0
  926. package/ui/dist/brand/profclaw-wordmark-light.svg +48 -0
  927. package/ui/dist/brand/safari-pinned-tab.svg +15 -0
  928. package/ui/dist/favicon/android-chrome-192x192.png +0 -0
  929. package/ui/dist/favicon/android-chrome-384x384.png +0 -0
  930. package/ui/dist/favicon/android-chrome-512x512.png +0 -0
  931. package/ui/dist/favicon/apple-touch-icon.png +0 -0
  932. package/ui/dist/favicon/browserconfig.xml +9 -0
  933. package/ui/dist/favicon/favicon-16x16.png +0 -0
  934. package/ui/dist/favicon/favicon-32x32.png +0 -0
  935. package/ui/dist/favicon/favicon.ico +0 -0
  936. package/ui/dist/favicon/mstile-150x150.png +0 -0
  937. package/ui/dist/favicon/safari-pinned-tab.svg +46 -0
  938. package/ui/dist/favicon/site.webmanifest +22 -0
  939. package/ui/dist/index.html +32 -0
  940. package/ui/dist/manifest.json +49 -0
  941. package/ui/dist/sw.js +124 -0
  942. package/ui/dist/vite.svg +1 -0
@@ -0,0 +1,10 @@
1
+ import{c as ee,S as Ve,j as e,i as d,ai as vt,k as P,h as Ss,D as Ts,x as _s,y as Is,z as wt,aw as As,ax as Kt,B as Ae,Z as Ut,a as nt,F as We,r as l,K as ae,g as re,T as Be,V as Ye,w as je,a5 as ve,N as ot,O as it,Q as lt,l as we,ay as qt,R as ct,an as Ms,X as dt,ae as Rs,L as ne,az as Nt,aA as kt,I as Es,P as Ct,s as Ds,aB as Ls,aC as Ps,aD as Os,aE as $s,aF as Fs,aG as zs,aH as Vs,aI as Ks,aJ as Us,ak as qs,a0 as Gs,a1 as Hs,J as Js,v as ut,C as Me,u as se,_ as mt,U as Bs,n as Ws,q as Ys,o as _e,t as O,m as J}from"./index-kb4AJXUB.js";import{S as Qe,a as Xe,b as Ze,c as et,d as $e}from"./select-LsO16slr.js";import{T as ie,a as le,b as ce}from"./tooltip-Df1CunSp.js";import{B as xt}from"./badge-B4ov81_m.js";import{B as Ke}from"./brain-C53ElFLD.js";import{C as Qs}from"./cpu-B41x1-vV.js";import{M as Xs,a as Gt,b as Ie}from"./markdown-renderer-CjU6hBcW.js";import{H as Fe}from"./history-CNqcBBrV.js";import{c as Zs,C as St,f as er,M as Ht,V as tr,b as sr,T as rr,S as Jt}from"./constants-fc7TFI7u.js";import{S as tt}from"./settings-2-Cu4xTjhG.js";import{T as st}from"./trash-2-B4oAXsX-.js";import{C as ar,R as nr}from"./rocket-CPsTc-5G.js";import{C as Bt}from"./smartphone-DnoksVkc.js";import{a as or,B as Wt}from"./bug-D0TJoCYn.js";import{W as Ue}from"./wrench-ByZkjO6m.js";import{L as ir}from"./lightbulb-B2dgG5ks.js";import{D as rt}from"./database-D9Cnfmzj.js";import{F as B}from"./file-code-HR9829Jc.js";import{G as at}from"./globe-CCspjvus.js";import{T as lr,S as cr,a as dr,b as ur,c as mr,d as xr}from"./sheet-BScLnPKX.js";import{G as Tt}from"./git-branch-BRMiJmV3.js";import{T as hr}from"./textarea-D5LJCOGl.js";import{S as Yt}from"./send-BDYBZDUZ.js";import{A as pr,h as gr,a as fr,b as br,c as yr,d as jr,e as vr,f as wr,g as Nr}from"./alert-dialog-BOmnTkN-.js";import{F as _t}from"./folder-open-C_7oYEqe.js";import{D as kr,b as Cr,c as Sr,d as Tr,e as _r}from"./dialog-DrWB4EYD.js";import{C as ze}from"./circle-x-BN89YhbS.js";import{S as Qt}from"./shield-check-CQqkwufI.js";import{S as Ir}from"./shield-off-ZFruH9KO.js";import"./chevron-up-BRTtndUZ.js";import"./defineProperty-CoXUr7_6.js";import"./tag-wEJQRWlV.js";const Ar=[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V3",key:"1lcnhd"}],["path",{d:"M19 21V9",key:"unv183"}]],Mr=ee("chart-no-axes-column",Ar);const Rr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Er=ee("circle-dot",Rr);const Dr=[["path",{d:"M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0",key:"1dfaln"}],["path",{d:"M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4",key:"1qnva7"}]],It=ee("ear",Dr);const Lr=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Pr=ee("folder",Lr);const Or=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],$r=ee("git-pull-request",Or);const Fr=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],zr=ee("image-plus",Fr);const Vr=[["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"}]],Kr=ee("image",Vr);const Ur=[["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:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],he=ee("message-square-plus",Ur);const qr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Gr=ee("mic-off",qr);const Hr=[["path",{d:"M15.707 21.293a1 1 0 0 1-1.414 0l-1.586-1.586a1 1 0 0 1 0-1.414l5.586-5.586a1 1 0 0 1 1.414 0l1.586 1.586a1 1 0 0 1 0 1.414z",key:"nt11vn"}],["path",{d:"m18 13-1.375-6.874a1 1 0 0 0-.746-.776L3.235 2.028a1 1 0 0 0-1.207 1.207L5.35 15.879a1 1 0 0 0 .776.746L13 18",key:"15qc1e"}],["path",{d:"m2.3 2.3 7.286 7.286",key:"1wuzzi"}],["circle",{cx:"11",cy:"11",r:"2",key:"xmgehs"}]],Jr=ee("pen-tool",Hr),Br={essential:8,standard:30,full:72},Wr={basic:{label:"Basic",description:"Standard instruction following, suitable for most conversational tasks.",colorClass:"bg-amber-500/15 text-amber-600 border-amber-500/25",Icon:Qs},instruction:{label:"Instruction",description:"Advanced instruction following with multi-step reasoning capabilities.",colorClass:"bg-blue-500/15 text-blue-600 border-blue-500/25",Icon:Ke},reasoning:{label:"Reasoning",description:"Full agentic reasoning with planning, reflection, and complex tool use.",colorClass:"bg-green-500/15 text-green-600 border-green-500/25",Icon:Ve}};function Yr({modelId:t,toolTier:s,capabilityLevel:a,className:n}){const r=Wr[a],i=Br[s],{Icon:c}=r;return e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsxs(xt,{variant:"outline",className:d("flex items-center gap-1.5 px-2 py-0.5 text-xs font-medium cursor-default select-none border",r.colorClass,n),children:[e.jsx(c,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:r.label}),e.jsx("span",{className:"opacity-60",children:"·"}),e.jsxs("span",{className:"opacity-70",children:[i," tools"]})]})}),e.jsx(ce,{side:"bottom",children:e.jsxs("div",{className:"space-y-1.5 max-w-56",children:[e.jsx("div",{className:"font-semibold text-xs",children:t}),e.jsx("p",{className:"text-xs text-muted-foreground leading-relaxed",children:r.description}),e.jsxs("div",{className:"flex items-center gap-2 pt-0.5 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"capitalize",children:[s," tier"]}),e.jsx("span",{children:"-"}),e.jsxs("span",{children:[i," tools available"]})]})]})})]})}const Qr={bot:Ae,code:Bt,"clipboard-list":ar,"bar-chart-2":Mr,"pen-tool":Jr};function At({icon:t,className:s}){if(t==="bot")return e.jsx(Kt,{className:s});const a=Qr[t]||Ae;return e.jsx(a,{className:s})}function Xr({currentPreset:t,presets:s,selectedPreset:a,selectedModel:n,aliases:r,providers:i,healthyProviders:c,memoryStats:m,conversationId:f,enabledPlugins:b=0,focusedView:y=!1,modelCapability:T,onPresetChange:k,onModelChange:D,onNewChat:E,onOpenHistory:R,onOpenProviderSetup:F,onClearChat:p,onToggleFocusedView:A}){const C=m?.stats.usagePercentage??0;return e.jsx("div",{className:"px-3 py-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[e.jsx("div",{className:"h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shrink-0 border-primary/10 shadow-lg shadow-primary/5",children:e.jsx(Ve,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-sm font-semibold truncate",children:"Chat"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.length>0?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500 shrink-0"}),e.jsxs("span",{className:"truncate",children:[c.length," active"]})]}):e.jsx("button",{onClick:F,className:"text-amber-500 hover:underline truncate",children:"Configure provider"}),f&&m&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1 hover:text-foreground transition-colors","aria-label":`Context usage: ${Math.round(C)}%`,children:[e.jsx(Ke,{className:"h-3 w-3 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"w-8 h-1 bg-muted rounded-full overflow-hidden","aria-hidden":"true",children:e.jsx("div",{className:d("h-full rounded-full transition-all duration-300",C<=50&&"bg-green-500",C>50&&C<=70&&"bg-primary",C>70&&C<=90&&"bg-amber-500",C>90&&"bg-red-500"),style:{width:`${Math.min(C,100)}%`}})})]})}),e.jsx(ce,{side:"bottom",children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"font-medium text-sm",children:"Context Memory"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-0.5",children:[e.jsxs("p",{children:[m.stats.messageCount," messages · ~",m.stats.estimatedTokens.toLocaleString()," tokens"]}),e.jsxs("p",{children:["Using ",Math.round(C),"% of ",(m.stats.contextWindow/1e3).toFixed(0),"k window"]}),m.stats.needsCompaction&&e.jsx("p",{className:"text-amber-500",children:"Will compact on next message"})]})]})})]})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsxs("div",{className:"hidden sm:flex items-center bg-muted/40 rounded-xl p-0.5",children:[e.jsxs(Qe,{value:a,onValueChange:k,children:[e.jsxs(Xe,{className:"h-7 w-auto border-0 bg-transparent shadow-none text-xs gap-1 px-2 hover:bg-muted/60 rounded-lg","aria-label":"Select chat preset",children:[e.jsx(At,{icon:t?.icon||"bot",className:"h-3.5 w-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"hidden md:inline max-w-[80px] truncate",children:e.jsx(Ze,{})})]}),e.jsx(et,{className:"glass-dropdown",children:s.map(j=>e.jsx($e,{value:j.id,children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(At,{icon:j.icon,className:"h-4 w-4"}),e.jsx("span",{children:j.name})]})},j.id))})]}),e.jsx("div",{className:"w-px h-4 bg-border/50"}),e.jsxs(Qe,{value:n,onValueChange:D,children:[e.jsx(Xe,{className:"h-7 w-auto border-0 bg-transparent shadow-none text-xs gap-1.5 px-2 hover:bg-muted/60 rounded-lg","aria-label":"Select AI model",children:e.jsx(Ze,{})}),e.jsxs(et,{className:"glass-dropdown min-w-45",children:[(()=>{const j=new Set(i.map(v=>v.type)),N=r.filter(v=>j.has(v.provider)).reduce((v,g)=>{const S=g.provider;return(!v[S]||g.alias.length<v[S].alias.length)&&(v[S]=g),v},{});return Object.entries(N).sort(([,v],[,g])=>{const S=i.find(U=>U.type===v.provider)?.healthy?1:0;return(i.find(U=>U.type===g.provider)?.healthy?1:0)-S||v.provider.localeCompare(g.provider)}).map(([v,g])=>{const K=i.find(H=>H.type===v)?.healthy,U=v==="ollama";return e.jsx($e,{value:g.alias,className:"py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:d("h-1.5 w-1.5 rounded-full shrink-0",K?"bg-green-500":"bg-amber-400")}),e.jsx("span",{className:"capitalize font-medium",children:g.alias}),e.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:U?"Local":g.provider})]})},g.alias)})})(),e.jsx("div",{className:"border-t border-border/50 mt-1 pt-1",children:e.jsxs("button",{type:"button",onClick:j=>{j.preventDefault(),j.stopPropagation(),F()},className:"w-full flex items-center gap-2 px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/50 rounded-sm transition-colors",children:[e.jsx(vt,{className:"h-3 w-3"}),e.jsx("span",{children:"Manage Providers..."})]})})]})]})]}),T&&e.jsx(Yr,{modelId:n,toolTier:T.toolTier,capabilityLevel:T.capabilityLevel,className:"hidden sm:flex"}),A&&e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",onClick:A,className:d("h-8 w-8 shrink-0",y&&"bg-primary/10 text-primary"),"aria-label":y?"Exit focused view":"Enter focused view","aria-pressed":y,children:y?e.jsx(Xs,{className:"h-4 w-4","aria-hidden":"true"}):e.jsx(Gt,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(ce,{children:y?"Exit focused view":"Focused view"})]}),e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",onClick:E,className:"h-8 w-8 shrink-0","aria-label":"New chat",children:e.jsx(he,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(ce,{children:"New chat"})]}),e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",onClick:R,className:"h-8 w-8 shrink-0","aria-label":"View history",children:e.jsx(Fe,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(ce,{children:"History"})]}),e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",onClick:F,className:"h-8 w-8 shrink-0","aria-label":"Manage API keys",children:e.jsx(vt,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsx(ce,{children:"API Keys"})]}),e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 relative",asChild:!0,"aria-label":`Plugins and Tools (${b} enabled)`,children:e.jsxs(Ss,{to:"/settings/plugins",children:[e.jsx(Zs,{className:"h-4 w-4","aria-hidden":"true"}),b>0&&e.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-primary text-[9px] font-medium text-primary-foreground flex items-center justify-center","aria-hidden":"true",children:b})]})})}),e.jsx(ce,{children:"Plugins & Tools"})]}),e.jsxs(Ts,{children:[e.jsx(_s,{asChild:!0,children:e.jsx(P,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":"Chat settings",children:e.jsx(tt,{className:"h-4 w-4","aria-hidden":"true"})})}),e.jsxs(Is,{align:"end",className:"w-44 glass-dropdown",children:[e.jsxs(wt,{onClick:E,children:[e.jsx(he,{className:"h-4 w-4 mr-2"}),"New Chat"]}),e.jsx(As,{}),e.jsxs(wt,{onClick:p,className:"text-destructive focus:text-destructive",children:[e.jsx(st,{className:"h-4 w-4 mr-2"}),"Clear Chat"]})]})]})]})]})})}const Mt={urgent:"bg-red-500",critical:"bg-red-500",high:"bg-orange-500",medium:"bg-yellow-500",low:"bg-blue-400",none:"bg-muted-foreground/30"},Zr={bug:Wt,feature:ir,improvement:Ue,task:nt,epic:Ut,story:or,subtask:Er},Rt={backlog:"bg-muted-foreground/10 text-muted-foreground",todo:"bg-blue-500/10 text-blue-400",in_progress:"bg-primary/10 text-primary",in_review:"bg-purple-500/10 text-purple-400",done:"bg-green-500/10 text-green-400",cancelled:"bg-red-500/10 text-red-400"};function ea(t){return t.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Et({ticketKey:t,title:s,status:a,type:n,priority:r,labels:i,url:c}){const m=Zr[n]||nt,f=Mt[r]||Mt.none,b=Rt[a]||Rt.backlog,y=e.jsxs("div",{className:"flex items-center gap-3 py-2.5 px-3 rounded-xl recessed-card overflow-hidden relative group/ticket",children:[e.jsx("div",{className:d("absolute left-0 top-0 bottom-0 w-1 rounded-l-xl",f)}),e.jsx("div",{className:"h-8 w-8 flex items-center justify-center rounded-lg bg-foreground/5 shrink-0 ml-1",children:e.jsx(m,{className:"h-4 w-4 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[11px] font-bold text-primary/70 shrink-0",children:t}),e.jsx("span",{className:"text-[13px] font-medium truncate",children:s})]}),i&&i.length>0&&e.jsxs("div",{className:"flex items-center gap-1 mt-0.5",children:[i.slice(0,3).map(T=>e.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-foreground/5 text-muted-foreground/70 font-medium",children:T},T)),i.length>3&&e.jsxs("span",{className:"text-[9px] text-muted-foreground/50",children:["+",i.length-3]})]})]}),e.jsx("span",{className:d("text-[10px] font-bold uppercase tracking-wider px-2 py-1 rounded-md shrink-0",b),children:ea(a)})]});return c?e.jsx("a",{href:c,className:"block hover:opacity-90 transition-opacity",target:"_blank",rel:"noopener noreferrer",children:y}):y}function Dt({name:t,projectKey:s,icon:a,color:n,ticketCount:r,description:i}){return e.jsxs("div",{className:"flex items-center gap-3 py-2.5 px-3 rounded-xl recessed-card overflow-hidden",children:[e.jsx("div",{className:d("h-9 w-9 flex items-center justify-center rounded-lg shrink-0 text-lg",n?"":"bg-primary/10"),style:n?{backgroundColor:`${n}20`,color:n}:void 0,children:a||e.jsx(We,{className:"h-4.5 w-4.5 text-primary"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[13px] font-semibold truncate",children:t}),e.jsx("span",{className:"text-[10px] font-bold text-muted-foreground/50 uppercase tracking-wider shrink-0",children:s})]}),i&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 truncate mt-0.5",children:i})]}),r!==void 0&&e.jsx("div",{className:"flex items-center gap-1 shrink-0",children:e.jsxs("span",{className:"text-[11px] font-bold text-muted-foreground/70 bg-foreground/5 px-2 py-0.5 rounded-full",children:[r," ticket",r!==1?"s":""]})})]})}function ta(t){if(!t||typeof t!="object")return;const s=t;return s.data&&typeof s.data=="object"?s.data:s}function Lt(t){const s=t.key,a=t.title;return!s||!a?null:{ticketKey:s,title:a,status:t.status||"todo",type:t.type||"task",priority:t.priority||"medium",labels:t.labels}}function Pt(t){const s=t.name,a=t.key;return!s||!a?null:{name:s,projectKey:a,icon:t.icon,color:t.color,ticketCount:t.ticketCount,description:t.description}}function sa({toolName:t,result:s,output:a}){const n=ta(s);if((t==="create_ticket"||t==="update_ticket"||t==="get_ticket")&&n){const r=Lt(n);if(r)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Et,{...r}),a&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 mt-1",children:e.jsx(Ie,{content:a})})]})}if(t==="list_tickets"&&n){const r=n.tickets??[];if(r.length>0){const i=r.slice(0,5),c=r.length-i.length;return e.jsxs("div",{className:"space-y-1.5",children:[i.map((m,f)=>{const b=Lt(m);return b?e.jsx(Et,{...b},b.ticketKey||f):null}),c>0&&e.jsxs("div",{className:"text-[11px] text-muted-foreground/50 text-center py-1",children:["and ",c," more ticket",c!==1?"s":""]})]})}}if(t==="create_project"&&n){const r=Pt(n);if(r)return e.jsxs("div",{className:"space-y-2",children:[e.jsx(Dt,{...r}),a&&e.jsx("div",{className:"text-[11px] text-muted-foreground/60 mt-1",children:e.jsx(Ie,{content:a})})]})}if(t==="list_projects"&&n){const r=n.projects??[];if(r.length>0)return e.jsx("div",{className:"space-y-1.5",children:r.map((i,c)=>{const m=Pt(i);return m?e.jsx(Dt,{...m},m.projectKey||c):null})})}if(a)return e.jsx(Ie,{content:a});if(s!=null){const r=typeof s=="string"?s:JSON.stringify(s,null,2);return!r||r==="{}"||r==="[]"||r==='""'?e.jsx("div",{className:"text-[12px] text-muted-foreground/50 italic py-2",children:"No output returned"}):e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all border border-white/5 scrollbar-glass",children:r})}return e.jsx("div",{className:"text-[12px] text-muted-foreground/50 italic py-2",children:"No output returned"})}const Ot={exec:ae,bash:ae,shell:ae,read_file:B,write_file:B,edit_file:B,search_files:je,grep:je,glob:je,web_fetch:at,web_search:at,system_info:Ye,env_vars:Ye,git_status:B,git_diff:B,git_log:B,git_commit:B,database:rt,query:rt,create_ticket:Be,update_ticket:Be,get_ticket:Be,list_tickets:nt,create_project:We,list_projects:We,cron_create:re,cron_list:re,cron_trigger:re,cron_pause:re,cron_delete:re,cron_archive:re,cron_history:re,default:ae};function ra(t){return{exec:"Run Command",bash:"Bash",shell:"Shell",read_file:"Read File",write_file:"Write File",edit_file:"Edit File",search_files:"Search Files",grep:"Search Content",glob:"Find Files",web_fetch:"Fetch URL",web_search:"Web Search",system_info:"System Info",env_vars:"Environment",git_status:"Git Status",git_diff:"Git Diff",git_log:"Git Log",git_commit:"Git Commit",create_ticket:"Create Ticket",update_ticket:"Update Ticket",get_ticket:"Get Ticket",list_tickets:"List Tickets",create_project:"Create Project",list_projects:"List Projects",cron_create:"Create Job",cron_list:"List Jobs",cron_trigger:"Trigger Job",cron_pause:"Pause/Resume Job",cron_delete:"Delete Job",cron_archive:"Archive Job",cron_history:"Job History"}[t]||t.replace(/_/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function aa(t){const s=Object.entries(t);if(s.length===0)return"";if(s.length===1){const[a,n]=s[0];if(a==="command"||a==="path"||a==="query"||a==="url")return String(n)}return s.map(([a,n])=>{const r=typeof n=="string"?n:JSON.stringify(n),i=r.length>50?r.slice(0,50)+"...":r;return`${a}: ${i}`}).join(", ")}function Xt(t){if(!t||typeof t!="object")return{hasSmartOutput:!1};const s=t,a=typeof s.output=="string"?s.output:void 0,n=s.data!==void 0?s.data:void 0;return{output:a,data:n,hasSmartOutput:!!a}}function na(t){const{output:s,data:a}=Xt(t.result);if(s){const n=s.match(/^#{1,3}\s+(.+)/m);if(n)return n[1].trim();const r=s.split(`
2
+ `).find(i=>i.trim());if(r){const i=r.replace(/^[#*\s]+/,"").replace(/\*\*/g,"").trim();return i.length>80?i.slice(0,80)+"...":i}}if(a&&typeof a=="object"){const n=a;if(n.key&&n.title)return`${n.key}: ${n.title}`;if(n.name&&n.key)return`${n.name} (${n.key})`;if(n.total!==void 0)return`${n.total} result(s)`}return""}function oa(t,s){if(t.status)return t.status;if(s){if(t.result&&typeof t.result=="object"){const a=t.result;if(a.pending===!0)return"pending";if(a.success===!1||a.error)return"error"}return"success"}}function $t({tool:t,className:s}){const[a,n]=l.useState(!1),[r,i]=l.useState("summary"),[c,m]=l.useState(!1),f=Ot[t.name]||Ot.default,b=ra(t.name),y=aa(t.arguments),T=t.result!==void 0&&t.result!==null,{output:k,hasSmartOutput:D}=Xt(t.result),R=D||["create_ticket","update_ticket","get_ticket","list_tickets","create_project","list_projects"].includes(t.name),F=T?na(t):"",p=oa(t,T),A=p==="success",C=p==="error",j=p==="pending"||p==="running",N=async()=>{let u;r==="summary"&&k?u=k:u=T?typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2):"",await navigator.clipboard.writeText(u),m(!0),setTimeout(()=>m(!1),2e3)};return e.jsxs("div",{className:d("my-3 premium-card overflow-hidden group/card",C&&"border-red-500/20",s),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-label":`${a?"Collapse":"Expand"} ${b} tool results`,className:"w-full px-4 py-3 flex items-center gap-3 hover:bg-foreground/[0.02] transition-colors text-left",children:[e.jsx("div",{className:d("h-10 w-10 flex items-center justify-center rounded-xl transition-all duration-300",C?"bg-red-500/10 text-red-500 shadow-[0_0_15px_-3px_rgba(239,68,68,0.3)]":j?"bg-blue-500/10 text-blue-500":"bg-primary/10 text-primary shadow-[0_0_15px_-3px_var(--primary-glow)]"),children:e.jsx(f,{className:d("h-5 w-5",j&&"animate-pulse"),"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"font-semibold text-[14px] leading-tight tracking-tight",children:b}),e.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-primary animate-pulse status-glow-info"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-primary",children:"Running"})]}),A&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 status-glow-success"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-green-500",children:"Success"})]}),C&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-1.5 w-1.5 rounded-full bg-red-500 status-glow-destructive"}),e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-red-500",children:"Failed"})]})]})]}),F?e.jsx("div",{className:"text-[11px] text-muted-foreground/80 truncate opacity-70 group-hover/card:opacity-100 transition-opacity",children:F}):y?e.jsx("div",{className:"text-[11px] text-muted-foreground/80 font-mono truncate opacity-60 group-hover/card:opacity-100 transition-opacity",children:y}):null]}),e.jsxs("div",{className:"ml-2 flex items-center gap-2",children:[t.duration!=null&&e.jsx("span",{className:"text-[10px] font-mono font-medium text-muted-foreground/40",children:t.duration>=1e3?`${(t.duration/1e3).toFixed(1)}s`:`${t.duration}ms`}),T&&e.jsx("div",{className:d("p-1 rounded-md transition-transform duration-200",a&&"rotate-180"),children:e.jsx(ve,{className:"h-4 w-4 text-muted-foreground/50"})})]})]}),j&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"h-2 rounded-full overflow-hidden bg-muted/30",children:e.jsx("div",{className:"h-full w-full skeleton-shimmer rounded-full bg-blue-500/20"})})}),!a&&T&&!R&&y&&e.jsx("div",{className:"px-4 pb-3",children:e.jsx("div",{className:"recessed-card p-2 rounded-lg",children:e.jsxs("div",{className:"text-[11px] text-muted-foreground/90 font-mono line-clamp-2 leading-relaxed",children:[typeof t.result=="string"?t.result.slice(0,100):JSON.stringify(t.result,null,2).slice(0,100),JSON.stringify(t.result).length>100?"...":""]})})}),a&&T&&e.jsxs("div",{className:"border-t border-border/10",children:[e.jsxs("div",{className:"px-4 py-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[R&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:u=>{u.stopPropagation(),i("summary")},className:d("flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider transition-all",r==="summary"?"bg-primary/10 text-primary":"text-muted-foreground/50 hover:text-muted-foreground hover:bg-foreground/5"),"aria-label":"Show summary view",children:[e.jsx(ot,{className:"h-3 w-3"}),"Summary"]}),e.jsxs("button",{onClick:u=>{u.stopPropagation(),i("json")},className:d("flex items-center gap-1 px-2 py-1 rounded-md text-[10px] font-bold uppercase tracking-wider transition-all",r==="json"?"bg-primary/10 text-primary":"text-muted-foreground/50 hover:text-muted-foreground hover:bg-foreground/5"),"aria-label":"Show JSON view",children:[e.jsx(Bt,{className:"h-3 w-3"}),"JSON"]})]}),!R&&e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50",children:"Output"})]}),e.jsx("button",{onClick:u=>{u.stopPropagation(),N()},className:"p-1.5 rounded-lg hover:bg-white/5 transition-all text-muted-foreground hover:text-foreground","aria-label":"Copy tool output",children:c?e.jsx(it,{className:"h-3.5 w-3.5 text-green-400","aria-hidden":"true"}):e.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),e.jsx("div",{className:"px-4 pb-4",children:r==="summary"?e.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl bg-black/10 p-4 border border-white/5 overflow-y-auto max-h-80 scrollbar-glass",children:e.jsx(sa,{toolName:t.name,result:t.result,output:k})}):e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto max-h-80 overflow-y-auto whitespace-pre-wrap break-all border border-white/5 scrollbar-glass",children:typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2)})})]})]})}function ia({tools:t,className:s}){const[a,n]=l.useState(t.length<3);return t.length===0?null:t.length<3?e.jsx("div",{className:s,children:t.map(r=>e.jsx($t,{tool:r},r.id))}):e.jsx("div",{className:s,children:a?e.jsxs(e.Fragment,{children:[t.map(r=>e.jsx($t,{tool:r},r.id)),e.jsxs("button",{onClick:()=>n(!1),className:"w-full text-center py-1.5 text-[11px] text-muted-foreground/60 hover:text-muted-foreground transition-colors",children:["Collapse ",t.length," tools"]})]}):e.jsxs("button",{onClick:()=>n(!0),className:"w-full flex items-center justify-center gap-2 py-2.5 px-4 rounded-xl border border-border/20 bg-card/30 hover:bg-card/50 transition-colors",children:[e.jsx(ae,{className:"h-3.5 w-3.5 text-muted-foreground/60"}),e.jsxs("span",{className:"text-[12px] font-medium text-muted-foreground/80",children:["Show ",t.length," tool calls"]})]})})}function la({thinking:t,isStreaming:s=!1,className:a,defaultOpen:n}){const[r,i]=l.useState(n??s);if(l.useEffect(()=>{s&&i(!0)},[s]),!t)return null;const c=t.split(/\s+/).length;return e.jsxs("div",{className:d("mb-3",a),children:[e.jsxs("button",{onClick:()=>i(!r),className:d("flex items-center gap-3 w-full px-4 py-3 rounded-2xl transition-all duration-300 group text-left","premium-card",s&&"bg-primary/5"),"aria-expanded":r,"aria-label":r?"Collapse thinking":"Expand thinking",children:[e.jsxs("div",{className:d("relative flex items-center justify-center h-8 w-8 rounded-xl shadow-inner transition-all duration-300",s?"bg-primary/20 shadow-[0_0_15px_-3px_var(--primary-glow)]":"bg-muted shadow-sm"),children:[e.jsx(Ke,{className:d("h-4 w-4 transition-all duration-500",s?"text-primary animate-pulse":"text-muted-foreground",r&&!s?"text-foreground":"",r?"scale-110 rotate-[15deg]":"scale-100")}),s&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2.5 w-2.5 rounded-full bg-primary animate-ping shadow-[0_0_8px_var(--primary-glow)]"})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsx("span",{className:d("text-[13px] font-bold tracking-tight transition-colors",s?"text-primary":"text-foreground/80"),children:s?e.jsxs("span",{className:"flex items-center gap-1.5 uppercase text-[10px] tracking-widest font-black",children:["Thinking",e.jsxs("span",{className:"inline-flex gap-0.5",children:[e.jsx("span",{className:"animate-bounce",style:{animationDelay:"0ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"150ms"},children:"."}),e.jsx("span",{className:"animate-bounce",style:{animationDelay:"300ms"},children:"."})]})]}):r?"Analytic Reasoning":"View Process Trace"}),!s&&e.jsxs("span",{className:"text-[10px] uppercase font-bold tracking-widest text-muted-foreground/60",children:[c," tokens distilled"]})]}),e.jsx("div",{className:d("h-6 w-6 flex items-center justify-center rounded-lg transition-all duration-300",r?"rotate-90 bg-zinc-100 dark:bg-zinc-800":"bg-transparent"),children:e.jsx(we,{className:d("h-3.5 w-3.5",r?"text-zinc-900 dark:text-zinc-100":"text-zinc-400")})})]}),e.jsx("div",{className:d("grid transition-all duration-500 cubic-bezier(0.4, 0, 0.2, 1)",r?"grid-rows-[1fr] opacity-100 mt-2":"grid-rows-[0fr] opacity-0"),children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:d("px-5 py-4 rounded-2xl glass","max-h-[32rem] overflow-y-auto scrollbar-glass"),children:e.jsx("pre",{className:"whitespace-pre-wrap font-mono text-[12px] text-muted-foreground leading-relaxed",children:t})})})})]})}function ca({jsonBlocks:t,className:s}){const[a,n]=l.useState(!1);return!t||t.length===0?null:e.jsxs("div",{className:d("mb-3",s),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-label":a?"Collapse raw output":"Expand raw output",className:d("flex items-center gap-2 px-3 py-1.5 rounded-lg","bg-amber-100 dark:bg-amber-500/15","hover:bg-amber-200 dark:hover:bg-amber-500/25","border border-amber-300 dark:border-amber-500/30","transition-colors text-left text-xs"),children:[e.jsxs("span",{className:"text-amber-700 dark:text-amber-400",children:[t.length," raw output",t.length>1?"s":""," filtered"]}),e.jsx(we,{className:d("h-3 w-3 text-amber-600 dark:text-amber-400/70 transition-transform",a&&"rotate-90")})]}),e.jsx("div",{className:d("grid transition-all duration-200",a?"grid-rows-[1fr] opacity-100 mt-2":"grid-rows-[0fr] opacity-0"),children:e.jsx("div",{className:"overflow-hidden",children:e.jsx("div",{className:"px-3 py-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-200 dark:border-amber-500/20",children:t.map((r,i)=>e.jsx("pre",{className:"text-xs text-amber-800 dark:text-amber-300/80 font-mono whitespace-pre-wrap",children:r},i))})})})]})}const da=[/<thinking>([\s\S]*?)<\/thinking>/gi,/^(Since there's no specific prompt.*?(?=\n\n|$))/gim,/^(I'll create a hypothetical.*?(?=\n\n|$))/gim,/^(Let me think about.*?(?=\n\n|$))/gim,/^(Thinking about this.*?(?=\n\n|$))/gim],ua=[/\{\s*"name"\s*:\s*"[^"]+"\s*,\s*"parameters"\s*:\s*\{[^}]*\}\s*\}/g,/\{\s*"function"\s*:\s*"[^"]+"\s*,\s*"args"\s*:\s*\{[^}]*\}\s*\}/g,/\{\s*["']?name["']?\s*:\s*["'][^"']+["']\s*,\s*["']?parameters["']?\s*:\s*\{[^}]*\}\s*\}/gi];function ma(t){let s=t,a=[];const n=[];let r=!1;for(const i of da){const c=s.matchAll(i);for(const m of c)m[1]&&(a.push(m[1].trim()),r=!0);s=s.replace(i,"")}for(const i of ua){const c=s.matchAll(i);for(const m of c)n.push(m[0]),r=!0;s=s.replace(i,"")}return s=s.replace(/\n{3,}/g,`
3
+
4
+ `).trim(),!s&&(a.length>0||n.length>0)&&(s="I'm processing your request. Check my reasoning below for details."),{content:s,thinking:a.length>0?a.join(`
5
+
6
+ `):null,filteredJson:n,wasProcessed:r}}const xa={code:{label:"Code",Icon:St,colorClass:"text-violet-400 bg-violet-500/10"},html:{label:"HTML",Icon:St,colorClass:"text-orange-400 bg-orange-500/10"},markdown:{label:"Markdown",Icon:ot,colorClass:"text-blue-400 bg-blue-500/10"},mermaid:{label:"Mermaid",Icon:Tt,colorClass:"text-emerald-400 bg-emerald-500/10"},diagram:{label:"Diagram",Icon:Tt,colorClass:"text-emerald-400 bg-emerald-500/10"},svg:{label:"SVG",Icon:Kr,colorClass:"text-pink-400 bg-pink-500/10"},table:{label:"Table",Icon:lr,colorClass:"text-cyan-400 bg-cyan-500/10"},chart:{label:"Chart",Icon:qt,colorClass:"text-yellow-400 bg-yellow-500/10"}};function ha(t){return t.replace(/<script[\s\S]*?<\/script>/gi,"")}function pa(t){try{const s=JSON.parse(t);return Array.isArray(s)&&s.length>0&&typeof s[0]=="object"?s:null}catch{return null}}function ga({content:t,language:s}){return e.jsx("pre",{className:d("text-[12px] font-mono leading-relaxed bg-black/20 rounded-xl p-4 overflow-x-auto","border border-white/5 scrollbar-glass whitespace-pre-wrap break-all max-h-96",s&&`language-${s}`),children:e.jsx("code",{children:t})})}function fa({content:t}){return e.jsx("iframe",{srcDoc:t,sandbox:"allow-scripts",title:"HTML artifact",className:"w-full rounded-xl border border-border/20 bg-white",style:{minHeight:"200px",maxHeight:"480px"},"aria-label":"Rendered HTML content"})}function ba({content:t}){const s=ha(t);return e.jsx("div",{className:"flex items-center justify-center rounded-xl border border-border/20 bg-white/5 p-4 overflow-auto max-h-96",dangerouslySetInnerHTML:{__html:s},"aria-label":"SVG artifact"})}function ya({content:t}){const s=pa(t);if(!s)return e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto border border-white/5 whitespace-pre-wrap break-all max-h-96",children:t});const a=Object.keys(s[0]);return e.jsx("div",{className:"overflow-auto max-h-96 rounded-xl border border-border/20",children:e.jsxs("table",{className:"w-full text-[13px] border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-muted/40 border-b border-border/30",children:a.map(n=>e.jsx("th",{className:"px-3 py-2 text-left font-semibold text-muted-foreground tracking-tight",children:n},n))})}),e.jsx("tbody",{children:s.map((n,r)=>e.jsx("tr",{className:"border-b border-border/10 hover:bg-foreground/[0.02] transition-colors",children:a.map(i=>e.jsx("td",{className:"px-3 py-2 text-foreground/80",children:String(n[i]??"")},i))},r))})]})})}function ja({content:t}){return e.jsxs("div",{className:"rounded-xl border border-border/20 bg-muted/20 p-4",children:[e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/60 mb-3",children:"Mermaid source (rendered on load)"}),e.jsx("div",{className:"mermaid text-[13px] font-mono text-foreground/80 whitespace-pre-wrap",children:t})]})}function va(){return e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 rounded-xl border border-border/20 bg-muted/20 p-10",children:[e.jsx(qt,{className:"h-12 w-12 text-muted-foreground/30","aria-hidden":"true"}),e.jsx("p",{className:"text-sm text-muted-foreground/60",children:"Chart rendering coming soon"})]})}function wa({artifact:t,highlighted:s=!1}){const[a,n]=l.useState(!1),[r,i]=l.useState(!1),c=xa[t.type],{Icon:m,label:f,colorClass:b}=c,y=t.title||`Untitled ${f}`,T=async D=>{D.stopPropagation(),await navigator.clipboard.writeText(t.content),i(!0),setTimeout(()=>i(!1),2e3)},k=()=>{switch(t.type){case"code":return e.jsx(ga,{content:t.content,language:t.language});case"html":return e.jsx(fa,{content:t.content});case"markdown":return e.jsx("div",{className:"prose prose-sm prose-invert max-w-none rounded-xl bg-black/10 p-4 border border-white/5",children:e.jsx(Ie,{content:t.content})});case"mermaid":case"diagram":return e.jsx(ja,{content:t.content});case"svg":return e.jsx(ba,{content:t.content});case"table":return e.jsx(ya,{content:t.content});case"chart":return e.jsx(va,{});default:return e.jsx("pre",{className:"text-[12px] font-mono bg-black/20 rounded-xl p-4 overflow-x-auto border border-white/5 whitespace-pre-wrap break-all max-h-96",children:t.content})}};return e.jsxs("div",{id:`canvas-artifact-${t.id}`,className:d("my-3 rounded-2xl border overflow-hidden transition-all duration-300","bg-card/60 backdrop-blur-sm shadow-sm",s?"border-primary/40 shadow-primary/10 shadow-md":"border-border/20"),children:[e.jsxs("button",{onClick:()=>n(!a),"aria-expanded":a,"aria-controls":`canvas-content-${t.id}`,"aria-label":`${a?"Collapse":"Expand"} ${f} artifact: ${y}`,className:"w-full flex items-center gap-3 px-4 py-3 hover:bg-foreground/[0.02] transition-colors text-left",children:[e.jsx("div",{className:d("h-8 w-8 rounded-lg flex items-center justify-center shrink-0",b),children:e.jsx(m,{className:"h-4 w-4","aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-semibold text-[13px] leading-tight truncate",children:y}),e.jsxs("p",{className:"text-[10px] font-bold uppercase tracking-widest text-muted-foreground/50 mt-0.5",children:[f,t.language?` · ${t.language}`:""]})]}),e.jsxs("div",{className:"flex items-center gap-1 ml-auto shrink-0",children:[e.jsx("button",{onClick:T,"aria-label":"Copy artifact content",className:"p-1.5 rounded-lg hover:bg-white/5 transition-all text-muted-foreground/50 hover:text-foreground",children:r?e.jsx(it,{className:"h-3.5 w-3.5 text-green-400","aria-hidden":"true"}):e.jsx(lt,{className:"h-3.5 w-3.5","aria-hidden":"true"})}),a?e.jsx(ve,{className:"h-4 w-4 text-muted-foreground/40","aria-hidden":"true"}):e.jsx(we,{className:"h-4 w-4 text-muted-foreground/40","aria-hidden":"true"})]})]}),a&&e.jsxs("div",{id:`canvas-content-${t.id}`,className:"border-t border-border/10 px-4 pb-4 pt-3",children:[(t.type==="html"||t.type==="svg")&&e.jsxs("div",{className:"flex items-center gap-1.5 mb-2 text-[10px] text-muted-foreground/50",children:[e.jsx(Gt,{className:"h-3 w-3","aria-hidden":"true"}),e.jsx("span",{children:"Sandboxed preview"})]}),k()]})]})}function Na({className:t}){return e.jsx(Ae,{className:t})}function ka(t,s){return l.useMemo(()=>s||!t?{content:t,thinking:null,filteredJson:[],wasProcessed:!1}:ma(t),[t,s])}function Ca({messages:t,currentPreset:s,quickActions:a,healthyProviders:n,copiedId:r,onCopy:i,onRetry:c,onQuickAction:m,onOpenProviderSetup:f}){const b=l.useRef(null);return l.useEffect(()=>{b.current?.scrollIntoView({behavior:"smooth"})},[t]),t.length===0?e.jsx("div",{className:"flex-1 premium-card rounded-[2rem] p-8 overflow-y-auto",children:e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center max-w-lg mx-auto",children:[e.jsx("div",{className:"h-24 w-24 rounded-3xl glass-heavy flex items-center justify-center mb-8 shadow-xl shadow-primary/10 border-primary/5",children:!s?.icon||s.icon==="bot"?e.jsx(Kt,{className:"h-14 w-14"}):e.jsx(Na,{icon:s.icon,className:"h-12 w-12 text-primary/60"})}),e.jsx("h2",{className:"text-3xl font-bold mb-4 tracking-tighter text-foreground font-heading graduate-text-gradient",children:s?.name||"Start a conversation"}),e.jsx("p",{className:"text-base leading-relaxed text-muted-foreground mb-10 opacity-80",children:s?.description||"Ask me anything about profClaw, your tasks, or get help with coding."}),n>0&&a.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-4 w-full",children:a.slice(0,4).map(y=>e.jsxs("button",{onClick:()=>m(y.prompt),className:"px-5 py-4 rounded-xl glass hover:bg-primary/5 border-primary/5 hover:border-primary/20 text-sm font-semibold transition-all duration-300 hover:-translate-y-1 active:scale-[0.98] text-left group shadow-lg","aria-label":`Quick action: ${y.label}`,children:[e.jsx("p",{className:"truncate group-hover:text-primary transition-colors",children:y.label}),e.jsx("div",{className:"h-0.5 w-6 bg-primary/20 mt-2 rounded-full group-hover:bg-primary group-hover:w-12 transition-all duration-500"})]},y.id))}),n===0&&e.jsxs("button",{onClick:f,className:"group flex items-center gap-2 px-8 py-3.5 rounded-full bg-primary text-primary-foreground hover:brightness-110 active:scale-95 transition-all font-bold shadow-xl shadow-primary/25","aria-label":"Configure a provider to start chatting",children:[e.jsx(ct,{className:"h-4 w-4 group-hover:rotate-180 transition-transform duration-700 ease-in-out"}),"Configure Provider"]})]})}):e.jsxs("div",{className:"flex-1 glass rounded-2xl p-4 overflow-y-auto overflow-x-hidden space-y-4",role:"log","aria-live":"polite","aria-relevant":"additions",children:[t.map(y=>e.jsx(Sa,{message:y,copiedId:r,onCopy:i,onRetry:c},y.id)),e.jsx("div",{ref:b})]})}function Sa({message:t,copiedId:s,onCopy:a,onRetry:n}){const r=ka(t.content,t.isLoading??!1);return e.jsxs("div",{className:d("flex gap-3",t.role==="user"?"flex-row-reverse":""),children:[e.jsx("div",{className:d("h-9 w-9 rounded-xl flex items-center justify-center shrink-0 border transition-all duration-300 shadow-sm",t.role==="user"?"bg-primary/10 border-primary/20 text-primary hidden sm:flex":"bg-muted/50 border-border/50 text-muted-foreground"),children:t.role==="user"?e.jsx(Ms,{className:"h-5 w-5"}):e.jsx(Ae,{className:"h-5 w-5"})}),e.jsxs("div",{className:d("max-w-[85%] sm:max-w-[75%] rounded-2xl px-5 py-3 group relative transition-all duration-300",t.role==="user"?"bg-primary text-primary-foreground shadow-lg shadow-primary/10 ml-auto rounded-tr-sm":"premium-card text-foreground shadow-sm rounded-tl-sm",t.error&&"border border-destructive/50 bg-destructive/5"),children:[t.role==="user"&&e.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/10 to-transparent rounded-[2rem] pointer-events-none"}),t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground py-1 px-1",children:[e.jsxs("div",{className:"flex gap-1",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce",style:{animationDelay:"0ms"}}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce",style:{animationDelay:"200ms"}}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce",style:{animationDelay:"400ms"}})]}),e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-widest text-zinc-400 dark:text-zinc-600",children:"Thinking"})]}):e.jsxs(e.Fragment,{children:[t.images&&t.images.length>0&&e.jsx("div",{className:"flex gap-2 mb-2 flex-wrap",children:t.images.map((i,c)=>e.jsx("img",{src:i,alt:`Attached image ${c+1}`,className:"h-20 w-20 object-cover rounded-lg"},c))}),t.role==="assistant"&&r.thinking&&e.jsx(la,{thinking:r.thinking,isStreaming:!1}),t.role==="assistant"&&r.filteredJson.length>0&&e.jsx(ca,{jsonBlocks:r.filteredJson}),t.toolCalls&&t.toolCalls.length>0&&e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-2",children:[e.jsx(ae,{className:"h-3 w-3"}),e.jsxs("span",{children:["Used ",t.toolCalls.length," tool",t.toolCalls.length>1?"s":""]})]}),e.jsx(ia,{tools:t.toolCalls})]}),t.toolCalls?.filter(i=>i.name==="canvas_render").map((i,c)=>{let m=null;try{const f=typeof i.result=="string"?JSON.parse(i.result):i.result;if(f?.artifact&&typeof f.artifact=="object")m=f.artifact;else if(f?.data&&typeof f.data=="object"){const b=f.data;b.artifactId&&b.type&&(m={id:String(b.artifactId),type:b.type,title:b.title,content:String(b.preview??"")})}}catch{}return m?e.jsx(wa,{artifact:m},`canvas-${c}`):null}),e.jsx("div",{className:d("text-[15px] leading-relaxed",t.role==="user"?"font-medium selection:bg-white/30":"selection:bg-primary/20",t.role==="user"&&"text-shadow-sm"),children:t.role==="assistant"?e.jsx(Ie,{content:r.content}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.error&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-destructive",children:t.error}),e.jsxs(P,{variant:"ghost",size:"sm",onClick:()=>n(t.id),className:"h-6 px-2","aria-label":"Retry message",children:[e.jsx(ct,{className:"h-3 w-3 mr-1","aria-hidden":"true"}),"Retry"]})]}),t.usage&&e.jsx("div",{className:"mt-2 pt-2 border-t border-border/10 text-[10px] text-muted-foreground/60 flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2 bg-muted/30 rounded-md px-2 py-0.5 border border-border/20",children:[e.jsxs("span",{children:[t.usage.totalTokens.toLocaleString()," tokens"]}),t.usage.cost&&t.usage.cost>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"opacity-30",children:"|"}),e.jsxs("span",{children:["$",t.usage.cost.toFixed(4)]})]})]})}),t.role==="assistant"&&!t.isLoading&&e.jsx("button",{onClick:()=>a(r.content,t.id),className:"opacity-0 group-hover:opacity-100 absolute top-2 right-2 p-2 rounded-xl glass-heavy hover:bg-primary/10 border-primary/10 transition-all duration-300 hover:scale-110 active:scale-95","aria-label":"Copy message content",children:s===t.id?e.jsx(it,{className:"h-3.5 w-3.5 text-success shadow-[0_0_8px_var(--success)]","aria-hidden":"true"}):e.jsx(lt,{className:"h-3.5 w-3.5 text-muted-foreground/60","aria-hidden":"true"})})]})]})]})}function Ta({value:t,onChange:s,onSend:a,isPending:n,disabled:r,placeholder:i="Type a message...",pendingImages:c,onImageSelect:m,onImageRemove:f,isRecording:b,onStartRecording:y,onStopRecording:T,agentMode:k=!1,onToggleAgentMode:D,talkModeState:E="idle",onToggleTalkMode:R,voiceAvailable:F}){const p=F?.stt??!0,A=l.useRef(null),C=l.useRef(null);l.useEffect(()=>{A.current&&(A.current.style.height="auto",A.current.style.height=`${Math.min(A.current.scrollHeight,200)}px`)},[t]);const j=N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),a())};return e.jsxs("div",{className:"mt-2 space-y-2",children:[c.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap px-1",children:c.map((N,u)=>e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:N,alt:`Pending upload ${u+1}`,className:"h-16 w-16 object-cover rounded-xl shadow-md transition-all"}),e.jsx("button",{onClick:()=>f(u),className:"absolute -top-1.5 -right-1.5 h-6 w-6 rounded-full bg-background border border-border flex items-center justify-center text-muted-foreground hover:text-destructive transition-all shadow-md active:scale-90 z-10 opacity-0 group-hover:opacity-100","aria-label":"Remove image",children:e.jsx(dt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]},u))}),e.jsxs("div",{className:d("relative rounded-[1.5rem] px-3 py-2 flex items-end gap-3 transition-all duration-300","field-recessed shadow-none",k&&"bg-primary/5 border-primary/20"),children:[e.jsx("input",{ref:C,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:m}),e.jsxs("div",{className:"flex items-center gap-1 relative z-10 pb-0.5 pl-1",children:[D&&e.jsx(P,{variant:"ghost",size:"icon",className:d("h-9 w-9 shrink-0 rounded-xl transition-all",k?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-muted"),onClick:D,disabled:n||r,"aria-label":k?"Agent mode (tools enabled)":"Chat mode (click for tools)","aria-pressed":k,children:k?e.jsx(Ae,{className:"h-5 w-5","aria-hidden":"true"}):e.jsx(er,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx(P,{variant:"ghost",size:"icon",className:"h-9 w-9 shrink-0 rounded-xl text-muted-foreground hover:bg-muted transition-all",onClick:()=>C.current?.click(),disabled:n||r,"aria-label":"Add image",children:e.jsx(zr,{className:"h-5 w-5","aria-hidden":"true"})}),E==="idle"&&e.jsxs("div",{className:"relative",children:[e.jsx(P,{variant:"ghost",size:"icon",className:d("h-9 w-9 shrink-0 rounded-xl transition-all",b?"bg-destructive/10 text-destructive animate-pulse":p?"text-muted-foreground hover:bg-muted":"opacity-40 cursor-not-allowed text-muted-foreground"),onClick:b?T:y,disabled:n||r,title:p?void 0:"Voice input unavailable - configure STT in Settings > Voice","aria-label":b?"Stop recording":p?"Start recording":"Voice input unavailable","aria-pressed":b,children:b?e.jsx(Gr,{className:"h-5 w-5","aria-hidden":"true"}):e.jsx(Ht,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:d("absolute top-0.5 right-0.5 h-2 w-2 rounded-full",p?"bg-green-500":"bg-red-500"),"aria-hidden":"true"})]}),R&&e.jsxs("div",{className:"relative",children:[e.jsx(P,{variant:"ghost",size:"icon",className:d("h-9 w-9 shrink-0 rounded-xl transition-all",E!=="idle"?"bg-green-500/20 text-green-500":p?"text-muted-foreground hover:bg-muted":"opacity-40 cursor-not-allowed text-muted-foreground"),onClick:R,disabled:n||r,title:!p&&E==="idle"?"Talk Mode unavailable - configure STT in Settings > Voice":void 0,"aria-label":E!=="idle"?"Stop Talk Mode":p?"Start Talk Mode":"Talk Mode unavailable","aria-pressed":E!=="idle",children:e.jsx(Rs,{className:"h-5 w-5","aria-hidden":"true"})}),e.jsx("span",{className:d("absolute top-0.5 right-0.5 h-2 w-2 rounded-full",p?"bg-green-500":"bg-red-500"),"aria-hidden":"true"})]})]}),e.jsx(hr,{ref:A,value:t,onChange:N=>s(N.target.value),onKeyDown:j,placeholder:k?"Give me a task to work on...":i,"aria-label":k?"Give me a task to work on":i,className:d("min-h-[3rem] max-h-48 resize-none border-0 bg-transparent text-[15px]","focus-visible:ring-0 focus-visible:ring-offset-0 py-3 px-2 relative z-10 leading-relaxed font-medium","placeholder:text-[var(--muted-foreground)]/50 transition-colors",k&&"placeholder:text-primary/40"),disabled:n||r}),e.jsx(P,{onClick:a,disabled:!t.trim()||n||r,size:"icon","aria-label":"Send message",variant:"black",className:d("h-9 w-9 shrink-0 rounded-xl transition-all mb-0.5 mr-0.5","hover:scale-105 active:scale-95"),children:n?e.jsx(ne,{className:"h-4 w-4 animate-spin","aria-hidden":"true"}):e.jsx(Yt,{className:"h-4 w-4","aria-hidden":"true"})})]})]})}function _a({open:t,onOpenChange:s,conversations:a,currentConversationId:n,onSelectConversation:r,onNewChat:i}){return e.jsx(cr,{open:t,onOpenChange:s,children:e.jsx(dr,{className:"glass border-l-0 p-0 w-[280px]",children:e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"p-4 border-b border-border/50",children:e.jsxs(ur,{children:[e.jsxs(mr,{className:"flex items-center gap-2 text-sm",children:[e.jsx(Fe,{className:"h-4 w-4"}),"History"]}),e.jsx(xr,{className:"text-xs",children:"Recent conversations"})]})}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2 space-y-1",children:a.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-40 text-center px-4",children:[e.jsx(he,{className:"h-8 w-8 text-muted-foreground/30 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"No conversations yet"}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:"Start a new chat to see history"})]}):a.map(c=>e.jsx("button",{onClick:()=>r(c.id),"aria-label":`Select conversation: ${c.title}`,className:d("w-full text-left px-3 py-2.5 rounded-xl transition-all group",n===c.id?"bg-primary/10 text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground"),children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(he,{className:"h-4 w-4 mt-0.5 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:c.title}),e.jsx("p",{className:"text-xs text-muted-foreground truncate mt-0.5",children:c.preview||"No messages"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-xs text-muted-foreground/70",children:[e.jsxs("span",{children:[c.messageCount," msgs"]}),e.jsx("span",{children:"·"}),e.jsx("span",{children:new Date(c.updatedAt).toLocaleDateString()})]})]})]})},c.id))}),e.jsx("div",{className:"p-3 border-t border-border/50",children:e.jsxs(P,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:()=>{i(),s(!1)},children:[e.jsx(he,{className:"h-3.5 w-3.5 mr-1.5","aria-hidden":"true"}),"New Conversation"]})})]})})})}function Ia({isOpen:t,onToggle:s,title:a,subtitle:n,icon:r,width:i=280,position:c="left",children:m,headerActions:f,footer:b,className:y,showCollapsedToggle:T=!0}){const k=T?48:0;return e.jsxs("div",{className:d("relative shrink-0 transition-all duration-300 ease-out h-full",y),style:{width:t?i:k},children:[!t&&T&&e.jsxs("div",{className:"group h-full flex flex-col items-center py-3 bg-card/60 backdrop-blur-sm hover:bg-card/80 transition-colors",children:[e.jsx(P,{variant:"ghost",size:"icon",onClick:s,className:"h-10 w-10 rounded-xl bg-primary/10 hover:bg-primary/20 text-primary transition-all group-hover:scale-105",title:`Open ${a||"sidebar"}`,children:c==="left"?e.jsx(Nt,{className:"h-5 w-5"}):e.jsx(kt,{className:"h-5 w-5"})}),a&&e.jsx("div",{className:"absolute left-12 top-3 bg-popover/95 backdrop-blur-sm text-popover-foreground px-2.5 py-1.5 rounded-lg text-xs font-medium shadow-lg border border-border/50 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50",children:a}),e.jsx("div",{className:"flex-1 flex items-center justify-center mt-4",children:e.jsx("div",{className:"w-1 h-16 rounded-full bg-primary/20 group-hover:bg-primary/40 transition-colors"})})]}),t&&e.jsxs("div",{className:d("relative flex flex-col h-full overflow-hidden","bg-card/90 backdrop-blur-xl","border-r border-border/20","animate-in slide-in-from-left-2 duration-200",c==="right"&&"border-l border-r-0 slide-in-from-right-2"),style:{width:i},children:[(a||f)&&e.jsxs("div",{className:"flex items-center justify-between px-3 py-2.5 border-b border-border/30",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[r&&e.jsx("span",{className:"text-muted-foreground/70 shrink-0",children:r}),e.jsxs("div",{className:"min-w-0",children:[a&&e.jsx("h3",{className:"text-[13px] font-semibold truncate",children:a}),n&&e.jsx("p",{className:"text-[9px] text-muted-foreground/60 truncate",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[f,e.jsx(P,{variant:"ghost",size:"icon",onClick:s,className:"h-6 w-6 rounded hover:bg-muted/60 shrink-0",title:"Collapse sidebar",children:c==="left"?e.jsx(kt,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(Nt,{className:"h-3 w-3 text-muted-foreground"})})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:m}),b&&e.jsx("div",{className:"border-t border-border/30 px-3 py-2.5",children:b})]})]})}const Aa="chat-sidebar-open",Ft={today:"Today",yesterday:"Yesterday",last7days:"Last 7 Days",last30days:"Last 30 Days",older:"Older"};function Ma(t){const a=new Date().getTime()-t.getTime(),n=Math.floor(a/1e3),r=Math.floor(n/60),i=Math.floor(r/60),c=Math.floor(i/24);return n<60?"just now":r<60?`${r}m ago`:i<24?`${i}h ago`:c===1?"yesterday":c<7?`${c}d ago`:c<30?`${Math.floor(c/7)}w ago`:c<365?`${Math.floor(c/30)}mo ago`:`${Math.floor(c/365)}y ago`}function Ra(t){const s=new Date,a=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(a.getTime()-1440*60*1e3),r=new Date(a.getTime()-10080*60*1e3),i=new Date(a.getTime()-720*60*60*1e3);return t>=a?"today":t>=n?"yesterday":t>=r?"last7days":t>=i?"last30days":"older"}function Ea(t){const s={today:[],yesterday:[],last7days:[],last30days:[],older:[]};return t.forEach(a=>{const n=new Date(a.updatedAt),r=Ra(n);s[r].push(a)}),s}function Da({isOpen:t,onToggle:s,conversations:a,currentConversationId:n,onSelectConversation:r,onNewChat:i,onDeleteConversation:c,projects:m=[],width:f=300,persistState:b=!0}){const[y,T]=l.useState(""),[k,D]=l.useState(new Set),[E,R]=l.useState("time");l.useEffect(()=>{b&&localStorage.setItem(Aa,JSON.stringify(t))},[t,b]);const{filteredConversations:F,groupedByTime:p,groupedByProject:A}=l.useMemo(()=>{const u=y.trim()?a.filter(g=>g.title.toLowerCase().includes(y.toLowerCase())||g.preview?.toLowerCase().includes(y.toLowerCase())):a,v={_none:[]};return m.forEach(g=>{v[g.id]=[]}),u.forEach(g=>{const S=g.projectId;S&&v[S]?v[S].push(g):v._none.push(g)}),{filteredConversations:u,groupedByTime:Ea(u),groupedByProject:v}},[a,y,m]),C=l.useCallback(u=>{D(v=>{const g=new Set(v);return g.has(u)?g.delete(u):g.add(u),g})},[]),j=["today","yesterday","last7days","last30days","older"],N=["_none",...m.map(u=>u.id)];return e.jsxs(Ia,{isOpen:t,onToggle:s,title:"Chats",subtitle:`${a.length} conversation${a.length!==1?"s":""}`,icon:e.jsx(Fe,{className:"h-4 w-4"}),width:f,headerActions:e.jsxs("div",{className:"flex items-center",children:[m.length>0&&e.jsx(P,{variant:"ghost",size:"icon",onClick:()=>R(E==="time"?"project":"time"),className:"h-6 w-6 rounded hover:bg-muted/60","aria-label":E==="time"?"Group by project":"Group by time",children:E==="time"?e.jsx(_t,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"}):e.jsx(Fe,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"})}),e.jsx(P,{variant:"ghost",size:"icon",onClick:i,className:"h-6 w-6 rounded hover:bg-muted/60","aria-label":"New chat",children:e.jsx(Ct,{className:"h-3 w-3 text-muted-foreground","aria-hidden":"true"})})]}),footer:e.jsxs(P,{variant:"outline",size:"sm",className:"w-full text-xs border-dashed border-border/50 hover:border-primary/30 hover:bg-primary/5",onClick:i,"aria-label":"Start new chat",children:[e.jsx(Ct,{className:"h-3 w-3 mr-1.5","aria-hidden":"true"}),"New Chat"]}),children:[e.jsx("div",{className:"px-3 py-3 border-b border-white/[0.03]",children:e.jsxs("div",{className:"relative group/search",children:[e.jsx(je,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground/30 group-focus-within/search:text-primary transition-colors","aria-hidden":"true"}),e.jsx(Es,{placeholder:"Search conversations...","aria-label":"Search chat history",value:y,onChange:u=>T(u.target.value),className:"h-9 pl-10 pr-10 text-xs"}),y&&e.jsx("button",{onClick:()=>T(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded-lg hover:bg-white/10 transition-colors","aria-label":"Clear search",children:e.jsx(dt,{className:"h-3.5 w-3.5 text-muted-foreground/40","aria-hidden":"true"})})]})}),e.jsx("div",{className:"flex-1 px-2 pb-2",children:F.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-60 text-center px-6",children:[e.jsx("div",{className:"w-16 h-16 rounded-[1.25rem] bg-gradient-to-br from-muted/20 to-muted/5 flex items-center justify-center mb-4 shadow-inner border border-white/5",children:e.jsx(he,{className:"h-8 w-8 text-muted-foreground/20"})}),e.jsx("p",{className:"text-sm font-semibold text-muted-foreground/90 tracking-tight",children:y?"No results found":"Empty history"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1.5 leading-relaxed",children:y?`We couldn't find any chats matching "${y}"`:"Start your first conversation to see it here."})]}):E==="time"?e.jsx("div",{className:"py-1 space-y-0.5",children:j.map(u=>{const v=p[u];if(v.length===0)return null;const g=k.has(u);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>C(u),"aria-expanded":!g,"aria-label":`${g?"Expand":"Collapse"} ${Ft[u]} group`,className:"w-full flex items-center gap-2 px-3 py-2 text-[10px] font-bold uppercase tracking-[0.1em] text-muted-foreground/60 hover:text-muted-foreground/90 transition-colors",children:[e.jsx("div",{className:d("transition-transform duration-300",g?"-rotate-90":"rotate-0"),children:e.jsx(ve,{className:"h-3 w-3","aria-hidden":"true"})}),e.jsx("span",{className:"nav-group-label",children:Ft[u]}),e.jsx("div",{className:"flex-1 h-px bg-white/[0.03] mx-2"}),e.jsx("span",{className:"text-[10px] tabular-nums opacity-60",children:v.length})]}),!g&&e.jsx("div",{className:"space-y-0.5",children:v.map(S=>e.jsx(zt,{conversation:S,isActive:n===S.id,onSelect:()=>r(S.id),onDelete:c?()=>c(S.id):void 0},S.id))})]},u)})}):e.jsx("div",{className:"py-1 space-y-0.5",children:N.map(u=>{const v=A[u]||[];if(v.length===0)return null;const g=k.has(u),S=m.find(U=>U.id===u),K=u==="_none"?"No Project":S?.name||"Unknown";return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>C(u),"aria-expanded":!g,"aria-label":`${g?"Expand":"Collapse"} ${K} group`,className:"w-full flex items-center gap-1.5 px-2 py-1.5 text-xs font-medium text-muted-foreground/50 hover:text-muted-foreground/70 rounded-md hover:bg-muted/30 transition-colors",children:[g?e.jsx(Pr,{className:"h-3 w-3"}):e.jsx(_t,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:K}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground/40",children:v.length})]}),!g&&e.jsx("div",{className:"space-y-0.5",children:v.map(U=>e.jsx(zt,{conversation:U,isActive:n===U.id,onSelect:()=>r(U.id),onDelete:c?()=>c(U.id):void 0},U.id))})]},u)})})})]})}function zt({conversation:t,isActive:s,onSelect:a,onDelete:n}){const r=l.useMemo(()=>Ma(new Date(t.updatedAt)),[t.updatedAt]);return e.jsxs("div",{className:d("group relative flex items-center gap-3 px-3 py-3 rounded-xl transition-all duration-300 cursor-pointer mx-1",s?"bg-[#0a0a0b] text-white shadow-lg shadow-black/20 nav-item-active z-10":"text-muted-foreground hover:nav-item-hover"),onClick:a,children:[e.jsx("div",{className:d("w-9 h-9 rounded-xl flex items-center justify-center shrink-0 shadow-sm border transition-all duration-300",s?"bg-white/10 border-white/20 shadow-md text-white":"bg-white/[0.03] border-white/5"),children:e.jsx(he,{className:d("h-4 w-4 transition-transform duration-500",s?"text-white scale-110":"text-muted-foreground/40 group-hover:scale-110")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:d("text-[13px] font-semibold truncate leading-tight tracking-tight",s?"text-white":"text-foreground/80"),children:t.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[10px] font-medium tracking-wide",children:[e.jsxs("span",{className:d(s?"text-white/70":"text-muted-foreground/40"),children:[t.messageCount," messages"]}),e.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-current opacity-20"}),e.jsx("span",{className:d(s?"text-white/70":"text-muted-foreground/40"),children:r})]})]}),n&&e.jsxs(pr,{children:[e.jsx(gr,{asChild:!0,children:e.jsx("button",{className:d("absolute right-1.5 top-1/2 -translate-y-1/2 p-1 rounded transition-all","opacity-0 group-hover:opacity-100","hover:bg-destructive/15 hover:text-destructive","focus:opacity-100 focus:outline-none"),onClick:i=>i.stopPropagation(),"aria-label":`Delete conversation ${t.title}`,children:e.jsx(st,{className:"h-3 w-3","aria-hidden":"true"})})}),e.jsxs(fr,{onClick:i=>i.stopPropagation(),children:[e.jsxs(br,{children:[e.jsxs(yr,{className:"flex items-center gap-2",children:[e.jsx(st,{className:"h-5 w-5 text-destructive"}),"Delete Conversation"]}),e.jsxs(jr,{className:"pt-2",children:["Are you sure you want to delete ",e.jsxs("span",{className:"font-medium text-foreground",children:['"',t.title,'"']}),"? This will permanently remove all ",t.messageCount," messages and cannot be undone."]})]}),e.jsxs(vr,{className:"mt-4",children:[e.jsx(wr,{className:"rounded-xl",children:"Cancel"}),e.jsx(Nr,{onClick:i=>{i.stopPropagation(),n()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90 rounded-xl",children:"Delete"})]})]})]})]})}const La=[{type:"anthropic",name:"Anthropic",description:"Claude Opus, Sonnet, Haiku",Logo:Ls,setupUrl:"https://console.anthropic.com/settings/keys",envVar:"ANTHROPIC_API_KEY",placeholder:"sk-ant-...",status:"stable"},{type:"openai",name:"OpenAI",description:"GPT-4.5, o1, o3-mini",Logo:Ps,setupUrl:"https://platform.openai.com/api-keys",envVar:"OPENAI_API_KEY",placeholder:"sk-...",status:"stable"},{type:"azure",name:"Azure OpenAI",description:"Enterprise GPT-4, GPT-4o",Logo:Os,setupUrl:"https://portal.azure.com/#view/Microsoft_Azure_ProjectOxford/CognitiveServicesHub/~/OpenAI",envVar:"AZURE_OPENAI_API_KEY",placeholder:"Enter API key...",status:"stable"},{type:"google",name:"Google AI",description:"Gemini 2.5 Pro, Flash",Logo:$s,setupUrl:"https://makersuite.google.com/app/apikey",envVar:"GOOGLE_API_KEY",placeholder:"AIza...",status:"stable"},{type:"xai",name:"xAI (Grok)",description:"Grok 2, Grok 3",Logo:Fs,setupUrl:"https://console.x.ai/",envVar:"XAI_API_KEY",placeholder:"xai-...",status:"beta"},{type:"groq",name:"Groq",description:"Ultra-fast inference",Logo:zs,setupUrl:"https://console.groq.com/keys",envVar:"GROQ_API_KEY",placeholder:"gsk_...",status:"stable"},{type:"deepseek",name:"DeepSeek",description:"DeepSeek R1, Chat, Coder",Logo:Vs,setupUrl:"https://platform.deepseek.com/api_keys",envVar:"DEEPSEEK_API_KEY",placeholder:"sk-...",status:"beta"},{type:"openrouter",name:"OpenRouter",description:"300+ models, one API",Logo:Ks,setupUrl:"https://openrouter.ai/keys",envVar:"OPENROUTER_API_KEY",placeholder:"sk-or-...",status:"stable"},{type:"ollama",name:"Ollama",description:"Local models, free",Logo:Us,setupUrl:"https://ollama.ai/download",envVar:"OLLAMA_BASE_URL",placeholder:"http://localhost:11434",status:"stable"}];function Pa({open:t,onOpenChange:s,providers:a,onSaveApiKey:n}){const r=Ds(),[i,c]=l.useState({}),[m,f]=l.useState({}),[b,y]=l.useState(null),[T,k]=l.useState(null),E=a.filter(p=>p.healthy).length,R=async p=>{const A=i[p];if(A){y(p);try{await n(p,A),c(C=>({...C,[p]:""})),k(null)}finally{y(null)}}},F=()=>{s(!1),r("/settings/ai-providers")};return e.jsx(kr,{open:t,onOpenChange:s,children:e.jsxs(Cr,{className:"sm:max-w-lg p-0 gap-0 overflow-hidden",children:[e.jsx(Sr,{className:"p-6 pb-4 bg-gradient-to-b from-primary/5 to-transparent",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(Ve,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx(Tr,{className:"text-lg",children:"Connect AI Providers"}),e.jsx(_r,{className:"text-sm",children:E>0?e.jsxs("span",{className:"text-green-500",children:[E," connected"]}):"Add API keys to get started"})]})]})}),e.jsx("div",{className:"px-6 pb-4",children:e.jsx("div",{className:"grid grid-cols-2 gap-2",children:La.map(p=>{const C=a.find(N=>N.type===p.type)?.healthy,j=T===p.type;return e.jsxs("div",{className:d("relative rounded-xl border transition-all cursor-pointer",C?"border-green-500/40 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-muted/30",j&&"col-span-2 bg-muted/50"),children:[e.jsxs("div",{role:"button",tabIndex:0,"aria-label":`Configure ${p.name}`,"aria-expanded":j,className:"flex items-center gap-3 p-3 focus-visible:ring-2 focus-visible:ring-primary outline-none",onClick:()=>k(j?null:p.type),onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),k(j?null:p.type))},children:[e.jsx("div",{className:d("h-9 w-9 rounded-lg flex items-center justify-center shrink-0",C?"bg-green-500/10":"bg-muted"),children:e.jsx(p.Logo,{className:d("h-5 w-5",C&&"text-green-600"),"aria-hidden":"true"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:p.name}),p.status==="beta"&&e.jsx("span",{className:"text-xs font-semibold px-1.5 py-0.5 rounded bg-amber-500/20 text-amber-600 dark:text-amber-400 uppercase tracking-wide shrink-0",children:"Beta"}),p.status==="experimental"&&e.jsx("span",{className:"text-xs font-semibold px-1.5 py-0.5 rounded bg-indigo-500/20 text-indigo-600 dark:text-indigo-400 uppercase tracking-wide shrink-0",children:"Exp"}),C&&e.jsx(qs,{className:"h-3.5 w-3.5 text-green-500 shrink-0","aria-hidden":"true"})]}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:p.description})]})]}),j&&e.jsx("div",{className:"px-3 pb-3 pt-1 border-t border-border/50",children:p.type==="azure"?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Azure OpenAI requires endpoint URL, deployment name, and API key."}),e.jsxs(P,{size:"sm",variant:"outline",onClick:N=>{N.stopPropagation(),s(!1),r("/settings/ai-providers")},className:"w-full gap-2",children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),"Configure in Settings"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx("input",{type:m[p.type]?"text":"password",placeholder:p.placeholder,value:i[p.type]||"",onChange:N=>c(u=>({...u,[p.type]:N.target.value})),onClick:N=>N.stopPropagation(),className:"w-full field pr-9",autoFocus:!0}),e.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),f(u=>({...u,[p.type]:!u[p.type]}))},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground","aria-label":m[p.type]?"Hide API key":"Show API key",children:m[p.type]?e.jsx(Gs,{className:"h-4 w-4","aria-hidden":"true"}):e.jsx(Hs,{className:"h-4 w-4","aria-hidden":"true"})})]}),e.jsx(P,{size:"sm",onClick:N=>{N.stopPropagation(),R(p.type)},disabled:!i[p.type]||b===p.type,className:"px-3",children:b===p.type?e.jsx(ne,{className:"h-4 w-4 animate-spin"}):"Save"})]}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("a",{href:p.setupUrl,target:"_blank",rel:"noopener noreferrer",onClick:N=>N.stopPropagation(),className:"text-xs text-primary hover:underline flex items-center gap-1",children:["Get API Key",e.jsx(Js,{className:"h-3 w-3"})]}),p.type==="ollama"&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Run: ",e.jsx("code",{className:"bg-muted px-1 rounded",children:"ollama serve"})]})]})]})})]},p.type)})})}),e.jsxs("div",{className:"px-6 py-4 border-t bg-muted/30 flex items-center justify-between",children:[e.jsxs(P,{variant:"ghost",size:"sm",onClick:F,className:"text-muted-foreground hover:text-foreground gap-2",children:[e.jsx(tt,{className:"h-4 w-4"}),"Manage All Providers"]}),e.jsx(P,{onClick:()=>s(!1),size:"sm",children:"Done"})]})]})})}function Oa({events:t,isActive:s,className:a}){const[n,r]=l.useState(!0),[i,c]=l.useState(!1),[m,f]=l.useState([]),[b,y]=l.useState(null),[T,k]=l.useState(null),[D,E]=l.useState(0),[R,F]=l.useState(null),p=typeof window<"u"&&localStorage.getItem("profclaw-dev-mode")==="true";if(l.useEffect(()=>{const j=[];let N=0;const u=new Map;for(const v of t)switch(v.type){case"thinking:start":case"thinking:update":y(v.data.message||"Thinking...");break;case"thinking:end":y(null);break;case"step:start":{N=v.data.step,j.find(S=>S.step===N)||j.push({step:N,toolCalls:[],complete:!1});break}case"step:complete":{const g=v.data,S=j.find(K=>K.step===g.step);S&&(S.complete=!0);break}case"tool:call":{const g=v.data,S={id:g.id,name:g.name,args:g.args,startTime:v.timestamp,status:"pending"};u.set(g.id,S);const K=j.find(U=>U.step===g.step);K&&K.toolCalls.push(S);break}case"tool:result":{const g=v.data,S=u.get(g.id);S&&(S.result=g.result,S.status=g.status==="executed"?"success":"error",S.error=g.error,S.duration=g.duration);break}case"summary":{const g=v.data;k(g.summary);break}case"complete":{const g=v.data;E(g.totalTokens);break}case"error":{const g=v.data;F(g.message);break}}f(j)},[t]),l.useEffect(()=>{if(!s&&(T||R)){const j=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(j)}},[s,T,R]),t.length===0&&!s)return null;const A=m.reduce((j,N)=>j+N.toolCalls.length,0),C=m.filter(j=>j.complete).length;return e.jsxs("div",{className:d("rounded-xl bg-card/50 backdrop-blur-sm overflow-hidden transition-all duration-300",s?"ring-1 ring-blue-500/30 shadow-sm shadow-blue-500/10":R?"ring-1 ring-destructive/30":"bg-muted/30",a),children:[e.jsxs("button",{onClick:()=>r(!n),className:d("w-full flex items-center gap-3 text-left hover:bg-muted/30 transition-colors",s?"p-3 animate-pulse":p?"p-3":"px-3 py-2"),children:[n?e.jsx(ve,{className:"h-4 w-4 text-muted-foreground shrink-0"}):e.jsx(we,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:s?e.jsxs(e.Fragment,{children:[e.jsx(Ke,{className:"h-4 w-4 text-blue-500 animate-pulse shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate",children:b||`Executing step ${C+1}...`})]}):R?e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"h-4 w-4 text-destructive shrink-0"}),e.jsx("span",{className:"text-sm font-medium text-destructive truncate",children:"Execution failed"})]}):p?e.jsxs(e.Fragment,{children:[e.jsx(Ve,{className:"h-4 w-4 text-green-400 shrink-0"}),e.jsxs("span",{className:"text-sm font-medium truncate",children:["Completed in ",C," step",C!==1?"s":""]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-2 w-2 rounded-full bg-green-500 shrink-0"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Done"})]})}),(p||s)&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground shrink-0",children:[A>0&&e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-muted/50",children:[e.jsx(Ue,{className:"h-3 w-3"}),A]}),D>0&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full bg-muted/50",children:[D.toLocaleString()," tokens"]})]})]}),n&&e.jsxs("div",{className:"border-t border-border/20 p-3 space-y-3",children:[R&&e.jsx("div",{className:"p-3 rounded-lg bg-destructive/10 border border-destructive/20 text-sm text-destructive",children:R}),T&&!R&&e.jsx("div",{className:"p-3 rounded-lg bg-green-500/10 border border-green-500/20 text-sm",children:T}),m.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{variant:"ghost",size:"sm",className:"text-xs h-6 px-2",onClick:()=>c(!i),children:i?"Hide details":"Show details"}),i&&e.jsx("div",{className:"space-y-2 pl-2 border-l-2 border-blue-500/20",children:m.map(j=>e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[j.complete?e.jsx(Me,{className:"h-3.5 w-3.5 text-green-400"}):e.jsx(ne,{className:"h-3.5 w-3.5 text-blue-500 animate-spin"}),e.jsxs("span",{className:"font-medium",children:["Step ",j.step]}),e.jsxs("span",{className:"text-muted-foreground text-xs",children:[j.toolCalls.length," tool call",j.toolCalls.length!==1?"s":""]})]}),j.toolCalls.length>0&&e.jsx("div",{className:"ml-5 space-y-1",children:j.toolCalls.map(N=>e.jsx($a,{toolCall:N},N.id))})]},j.step))})]}),s&&!b&&m.length===0&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ne,{className:"h-4 w-4 animate-spin"}),e.jsx("span",{children:"Initializing agent..."})]})]})]})}function $a({toolCall:t}){const[s,a]=l.useState(!1);return e.jsxs("div",{className:"rounded-lg bg-muted/30 overflow-hidden",children:[e.jsxs("button",{onClick:()=>a(!s),className:"w-full flex items-center gap-2 p-2 text-left hover:bg-muted/50 transition-colors",children:[s?e.jsx(ve,{className:"h-3 w-3 text-muted-foreground"}):e.jsx(we,{className:"h-3 w-3 text-muted-foreground"}),e.jsx(Ue,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"text-xs font-mono flex-1 truncate",children:t.name}),t.status==="pending"?e.jsx(ne,{className:"h-3 w-3 text-blue-500 animate-spin"}):t.status==="success"?e.jsx(Me,{className:"h-3 w-3 text-green-400"}):e.jsx(ut,{className:"h-3 w-3 text-destructive"}),t.duration&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[t.duration,"ms"]})]}),s&&e.jsxs("div",{className:"border-t border-border/20 p-2 space-y-2",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Arguments"}),e.jsx("pre",{className:"text-xs bg-background/50 rounded p-2 overflow-x-auto",children:JSON.stringify(t.args,null,2)})]}),t.result!==void 0&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:"Result"}),e.jsx("pre",{className:"text-xs bg-background/50 rounded p-2 overflow-x-auto max-h-32 overflow-y-auto",children:typeof t.result=="string"?t.result:JSON.stringify(t.result,null,2)})]}),t.error&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-medium text-destructive mb-1",children:"Error"}),e.jsx("pre",{className:"text-xs bg-destructive/10 rounded p-2 overflow-x-auto text-destructive",children:t.error})]})]})]})}const Fa={idle:"Idle",listening:"Listening...",recording:"Recording...",transcribing:"Transcribing...",sending:"Sending...",speaking:"Speaking..."};function za({state:t,isCalibrating:s}){if(s)return e.jsx(ne,{className:"h-5 w-5 animate-spin text-amber-500"});switch(t){case"listening":return e.jsx(It,{className:"h-5 w-5 text-green-500"});case"recording":return e.jsx(Ht,{className:"h-5 w-5 text-red-500"});case"transcribing":return e.jsx(ne,{className:"h-5 w-5 animate-spin text-muted-foreground"});case"sending":return e.jsx(Yt,{className:"h-5 w-5 text-primary"});case"speaking":return e.jsx(tr,{className:"h-5 w-5 animate-pulse text-blue-500"});default:return e.jsx(It,{className:"h-5 w-5 text-muted-foreground"})}}function Va({energy:t,isRecording:s}){const a=Math.min(1,Math.max(0,t)),n=s?"bg-red-500":"bg-green-500",r=a>.005;return e.jsx("div",{className:"flex items-end justify-center gap-1 h-5",children:[1,2,3].map(i=>e.jsx("div",{className:d("w-1 rounded-full transition-all duration-75 origin-bottom",n,r?"opacity-100":"opacity-30"),style:{height:`${Math.max(4,a*20)}px`,animation:r?`eq-bounce-${i} ${.4+i*.1}s ease-in-out infinite`:"none"}},i))})}function Ka({state:t,energy:s,lastTranscription:a,isCalibrating:n,noiseFloor:r,selectedVoice:i,onVoiceChange:c,onStop:m,ttsAvailable:f=!0}){const b=t==="recording",[y,T]=l.useState(!1),[k,D]=l.useState(!0),{data:E}=se({queryKey:["talk-mode-voices"],queryFn:async()=>{const A=await fetch(`${sr}/api/voice/voices`);return A.ok?A.json():{voices:[]}},staleTime:300*1e3,retry:1}),R=E?.voices??[];l.useEffect(()=>{if(!a)return;D(!0);const A=setTimeout(()=>D(!1),5e3);return()=>clearTimeout(A)},[a]);const F=l.useCallback(()=>{T(!0),setTimeout(()=>m(),200)},[m]),p=/mac/i.test(navigator.platform)?"⌘":"Ctrl";return e.jsxs("div",{className:d("fixed bottom-24 right-6 z-50","w-72 rounded-2xl border border-border/60 bg-background/80 p-4 shadow-xl","backdrop-blur-md",y?"animate-[talk-mode-out_0.2s_ease-in_forwards]":"animate-[talk-mode-in_0.3s_ease-out]"),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:d("relative flex items-center justify-center",b&&"animate-[recording-ring_1.5s_ease-in-out_infinite]"),style:{borderRadius:"50%"},children:e.jsx(za,{state:t,isCalibrating:n})}),e.jsx("span",{className:"text-sm font-medium",children:n?"Calibrating...":Fa[t]})]}),e.jsx("button",{type:"button",onClick:F,className:d("flex h-7 w-7 items-center justify-center rounded-full","bg-muted text-muted-foreground transition-colors","hover:bg-destructive/10 hover:text-destructive","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"),"aria-label":"Stop Talk Mode",children:e.jsx(dt,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-3",children:[e.jsx(Va,{energy:s,isRecording:b}),e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-muted",children:e.jsx("div",{className:d("h-full rounded-full transition-all duration-75",b?"bg-red-500":"bg-green-500"),style:{width:`${Math.min(1,Math.max(0,s))*100}%`}})})]}),!f&&e.jsx("p",{className:"mt-2 text-[11px] text-amber-400/80 bg-amber-500/10 rounded-lg px-2 py-1",children:"TTS not configured - responses won't be spoken"}),!n&&r>0&&e.jsxs("p",{className:"mt-1 text-[10px] text-muted-foreground/60",children:["Noise floor: ",r.toFixed(4)]}),a.length>0&&e.jsx("p",{className:d("mt-3 line-clamp-2 text-xs text-muted-foreground transition-opacity duration-500",k?"opacity-100":"opacity-0"),children:a}),R.length>0&&e.jsx("div",{className:"mt-3 border-t border-border/40 pt-3",children:e.jsxs(Qe,{value:i,onValueChange:c,children:[e.jsx(Xe,{className:"h-8 text-xs",children:e.jsx(Ze,{placeholder:"Default voice"})}),e.jsxs(et,{children:[e.jsx($e,{value:"default",children:"Default voice"}),R.map(A=>e.jsx($e,{value:A.id,children:A.name},A.id))]})]})}),e.jsxs("p",{className:"mt-2 text-[10px] text-muted-foreground/40 text-right",children:[p,"+Shift+V"]})]})}const Ua=[{id:"deploy",label:"Deploy",Icon:nr},{id:"review",label:"Review",Icon:$r},{id:"debug",label:"Debug",Icon:Wt},{id:"research",label:"Research",Icon:je},{id:"test",label:"Test",Icon:rr},{id:"refactor",label:"Refactor",Icon:ct}];function qa({onWorkflowSelect:t,disabled:s=!1,className:a}){return e.jsx("div",{className:d("hidden md:flex items-center gap-1.5 overflow-x-auto scrollbar-none py-1",a),children:Ua.map(({id:n,label:r,Icon:i})=>e.jsxs(P,{variant:"outline",size:"sm",disabled:s,onClick:()=>t(n),className:d("flex items-center gap-1.5 h-7 px-3 rounded-full text-xs font-medium shrink-0","text-muted-foreground hover:text-foreground","border-border/50 hover:border-border","transition-colors duration-150"),children:[e.jsx(i,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{children:r})]},n))})}function Ga(t){const s=t.toLowerCase();return s.includes("search")||s.includes("find")?je:s.includes("web")||s.includes("http")||s.includes("fetch")?at:s.includes("file")||s.includes("read")||s.includes("write")?ot:s.includes("run")||s.includes("exec")||s.includes("bash")?ae:s.includes("db")||s.includes("query")||s.includes("sql")?rt:Ue}function Ha(t,s){const n=(s??Date.now())-t;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(1)}s`}function Ja({status:t}){return t==="running"?e.jsxs("span",{className:"relative flex h-3 w-3 shrink-0 mt-0.5",children:[e.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-60"}),e.jsx("span",{className:"relative inline-flex rounded-full h-3 w-3 bg-blue-500"})]}):t==="completed"?e.jsx(Me,{className:"h-3.5 w-3.5 text-green-400 shrink-0 mt-0.5"}):t==="failed"?e.jsx(ze,{className:"h-3.5 w-3.5 text-destructive shrink-0 mt-0.5"}):t==="retried"?e.jsx(ze,{className:"h-3.5 w-3.5 text-amber-400 shrink-0 mt-0.5"}):e.jsx("span",{className:"h-3 w-3 rounded-full border-2 border-muted-foreground/40 shrink-0 mt-0.5"})}function Ba({call:t,isLast:s}){const a=Ga(t.toolName),n=t.status==="running",r=t.status==="failed";return e.jsxs("li",{className:"relative flex gap-3 pb-3 last:pb-0",children:[!s&&e.jsx("span",{className:"absolute left-[5px] top-4 bottom-0 w-px bg-border/40","aria-hidden":"true"}),e.jsx(Ja,{status:t.status}),e.jsxs("div",{className:"flex-1 min-w-0 -mt-0.5",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(a,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:d("text-xs font-mono truncate",r&&"text-destructive",n&&"text-foreground font-medium"),children:t.toolName}),e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground shrink-0",children:[e.jsx(re,{className:"h-3 w-3"}),Ha(t.startedAt,t.completedAt)]}),t.retryCount!==void 0&&t.retryCount>0&&e.jsxs(xt,{variant:"outline",className:"h-4 px-1.5 text-[10px] border-amber-500/30 text-amber-500 bg-amber-500/10",children:["retry ",t.retryCount]})]}),r&&t.error&&e.jsx("p",{className:"mt-0.5 text-xs text-destructive/80 truncate",children:t.error})]})]})}function Wa({toolCalls:t,isExecuting:s,className:a}){const[n,r]=l.useState(!1);if(t.length===0&&!s)return null;const i=t.filter(f=>f.status==="completed").length,c=t.filter(f=>f.status==="failed").length,m=t.find(f=>f.status==="running");return e.jsxs("div",{className:d("rounded-xl border border-border/40 bg-card/40 backdrop-blur-sm overflow-hidden",s&&"ring-1 ring-blue-500/20",a),children:[e.jsxs("button",{type:"button",onClick:()=>r(f=>!f),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/20 transition-colors",children:[n?e.jsx(ve,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}):e.jsx(we,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),s?e.jsx(ne,{className:"h-3.5 w-3.5 text-blue-500 animate-spin shrink-0"}):c>0?e.jsx(ze,{className:"h-3.5 w-3.5 text-destructive shrink-0"}):e.jsx(Me,{className:"h-3.5 w-3.5 text-green-400 shrink-0"}),e.jsx("span",{className:"text-xs font-medium flex-1 truncate",children:s&&m?`Running ${m.toolName}...`:s?"Executing tools...":`${t.length} tool call${t.length!==1?"s":""}`}),e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[i>0&&e.jsxs("span",{className:"text-green-500",children:[i," done"]}),c>0&&e.jsxs("span",{className:"text-destructive",children:[c," failed"]})]})]}),n&&t.length>0&&e.jsx("div",{className:"border-t border-border/30 px-3 pt-3 pb-2",children:e.jsx("ul",{className:"space-y-0",children:t.map((f,b)=>e.jsx(Ba,{call:f,isLast:b===t.length-1},f.id))})}),n&&t.length===0&&s&&e.jsx("div",{className:"border-t border-border/30 px-3 py-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsx(ne,{className:"h-3.5 w-3.5 animate-spin"}),e.jsx("span",{children:"Waiting for tool calls..."})]})}),n&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx(P,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs text-muted-foreground",onClick:()=>r(!1),children:"Collapse"})})]})}const Ya=[{id:"ask-everything",label:"Ask Everything",description:"Approve every tool call before execution.",Icon:mt,iconClass:"text-muted-foreground",activeClass:"bg-muted text-foreground border-border"},{id:"ask-dangerous",label:"Ask Dangerous",description:"Auto-approve safe tools. Prompt before write, delete, or network operations.",Icon:Qt,iconClass:"text-blue-500",activeClass:"bg-blue-500/10 text-blue-600 border-blue-500/30"},{id:"semi-autonomous",label:"Semi-Autonomous",description:"Auto-approve most tools. Only prompt for irreversible or high-impact actions.",Icon:Jt,iconClass:"text-amber-500",activeClass:"bg-amber-500/10 text-amber-600 border-amber-500/30"},{id:"full-autonomous",label:"Full Autonomous",description:"No approval prompts. The agent executes all tools without interruption.",Icon:Ir,iconClass:"text-destructive",activeClass:"bg-destructive/10 text-destructive border-destructive/30",warn:!0}];function Qa({level:t,onChange:s,disabled:a=!1,className:n}){return e.jsxs("div",{className:d("space-y-2",n),children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium text-muted-foreground select-none",children:[e.jsx(mt,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:"Autonomy Level"})]}),e.jsx("div",{role:"radiogroup","aria-label":"Autonomy level",className:"flex gap-1.5 flex-wrap",children:Ya.map(r=>{const i=t===r.id,{Icon:c}=r;return e.jsxs(ie,{children:[e.jsx(le,{asChild:!0,children:e.jsxs("button",{type:"button",role:"radio","aria-checked":i,disabled:a,onClick:()=>s(r.id),className:d("flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium","border transition-all duration-150 select-none outline-none","focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1","disabled:opacity-50 disabled:cursor-not-allowed",i?r.activeClass:"bg-transparent text-muted-foreground border-border/50 hover:border-border hover:text-foreground"),children:[e.jsx(c,{className:d("h-3.5 w-3.5 shrink-0",i?"":r.iconClass)}),e.jsx("span",{children:r.label}),r.warn&&i&&e.jsx(xt,{variant:"outline",className:"ml-0.5 h-4 px-1.5 text-[10px] border-destructive/40 text-destructive bg-destructive/10",children:"Caution"})]})}),e.jsx(ce,{side:"top",children:e.jsx("p",{className:"text-xs max-w-48",children:r.description})})]},r.id)})})]})}const Zt="profclaw-talk-mode-config",es="profclaw-talk-mode-voice",Xa=300*1e3,Za="/audio-worklets/vad-processor.js",Oe={enabled:!1,autoSend:!0,autoTts:!0,continuous:!0,speechThreshold:.01,silenceDuration:1500};function en(){try{const t=localStorage.getItem(Zt);if(!t)return Oe;const s=JSON.parse(t);return typeof s!="object"||s===null?Oe:{...Oe,...s}}catch{return Oe}}function tn(t){try{localStorage.setItem(Zt,JSON.stringify(t))}catch{}}function sn(){try{return localStorage.getItem(es)??""}catch{return""}}function rn(){return/mac/i.test(navigator.platform)}function an(t={}){const{onTranscription:s,onSend:a}=t,[n,r]=l.useState("idle"),[i,c]=l.useState(0),[m,f]=l.useState(""),[b,y]=l.useState(!1),[T,k]=l.useState(0),[D,E]=l.useState(sn),[R,F]=l.useState(en),p=l.useRef(null),A=l.useRef(null),C=l.useRef(null),j=l.useRef(null),N=l.useRef(null),u=l.useRef([]),v=l.useRef(null),g=l.useRef(null),S=l.useRef(R);S.current=R;const K=l.useRef(n);K.current=n;const U=l.useRef(D);U.current=D;const H=l.useCallback(M=>{F(_=>{const z={..._,...M};return tn(z),z})},[]),qe=l.useCallback(M=>{E(M);try{localStorage.setItem(es,M)}catch{}},[]),W=l.useCallback(()=>{v.current&&clearTimeout(v.current),v.current=setTimeout(()=>{K.current==="listening"&&Y()},Xa)},[]),pe=l.useCallback(()=>{v.current&&(clearTimeout(v.current),v.current=null)},[]),Ne=l.useCallback(async M=>{if(M.trim()){C.current&&C.current.disconnect(),r("speaking");try{const _=U.current,z={text:M};_&&_!=="default"&&(z.voice=_);const V=await fetch("/api/voice/synthesize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)});if(!V.ok)throw new Error(`Synthesize failed: ${V.status}`);const X=await V.blob(),ue=URL.createObjectURL(X),fe=new Audio(ue);g.current=fe,await new Promise(Ce=>{fe.onended=()=>Ce(),fe.onerror=()=>Ce(),fe.play().catch(()=>Ce())}),URL.revokeObjectURL(ue),g.current=null}finally{j.current&&C.current&&p.current&&j.current.connect(C.current),S.current.continuous&&K.current==="speaking"?(r("listening"),W()):r("idle")}}},[W]),Re=l.useCallback(async M=>{r("transcribing");try{const _=new FormData;_.append("audio",M,"recording.webm");const z=await fetch("/api/voice/transcribe",{method:"POST",body:_});if(!z.ok)throw new Error(`Transcribe failed: ${z.status}`);const V=await z.json();if(typeof V!="object"||V===null||!("text"in V)||typeof V.text!="string")throw new Error("Invalid transcription response");const X=V.text.trim();if(!X){r("listening"),W();return}if(f(X),s?.(X),S.current.autoSend&&a){r("sending");try{await a(X)}finally{r("listening"),W()}}else r("listening"),W()}catch{r("listening"),W()}},[s,a,W]),de=l.useCallback(()=>{if(!A.current)return;u.current=[];const M=new MediaRecorder(A.current,{mimeType:MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm"});M.ondataavailable=_=>{_.data.size>0&&u.current.push(_.data)},M.onstop=()=>{const _=new Blob(u.current,{type:M.mimeType});u.current=[],Re(_)},M.start(),N.current=M,r("recording")},[Re]),ke=l.useCallback(()=>{const M=N.current;M&&M.state!=="inactive"&&M.stop(),N.current=null},[]),Q=l.useCallback(M=>{const _=M.data;if(typeof _!="object"||_===null)return;const{type:z}=_;if(z==="energy"){const V=_.value;typeof V=="number"&&c(V)}else if(z==="calibrated"){const V=_.noiseFloor;typeof V=="number"&&k(V),y(!1)}else z==="speech-start"?K.current==="listening"&&(pe(),de()):z==="speech-end"&&K.current==="recording"&&(ke(),W())},[de,ke,pe,W]),Y=l.useCallback(()=>{pe(),g.current&&(g.current.pause(),g.current.onended=null,g.current.onerror=null,g.current=null);const M=N.current;M&&M.state!=="inactive"&&M.stop(),N.current=null,u.current=[],C.current&&(C.current.port.onmessage=null,C.current.disconnect(),C.current=null),j.current&&(j.current.disconnect(),j.current=null),p.current&&(p.current.close(),p.current=null),A.current&&(A.current.getTracks().forEach(_=>_.stop()),A.current=null),c(0),y(!1),k(0),r("idle")},[pe]),ge=l.useCallback(async()=>{if(K.current==="idle")try{const M=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0}});A.current=M;const _=new AudioContext;p.current=_,await _.audioWorklet.addModule(Za),C.current?.port&&(C.current.port.onmessage=null),y(!0),k(0);const z=new AudioWorkletNode(_,"vad-processor",{processorOptions:{speechThreshold:S.current.speechThreshold,silenceDuration:S.current.silenceDuration}});z.port.onmessage=Q,C.current=z;const V=_.createMediaStreamSource(M);j.current=V,V.connect(z),r("listening"),W(),window.dispatchEvent(new CustomEvent("profclaw:talk-mode",{detail:{state:"listening"}}))}catch{Y()}},[Q,W,Y]),Z=l.useCallback(()=>{K.current==="idle"?ge():Y()},[ge,Y]);return l.useEffect(()=>{const M=_=>{(rn()?_.metaKey:_.ctrlKey)&&_.shiftKey&&_.key.toLowerCase()==="v"&&(_.preventDefault(),Z())};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[Z]),l.useEffect(()=>{const M=()=>Z(),_=()=>Y();return window.addEventListener("profclaw:talk-mode-toggle",M),window.addEventListener("profclaw:talk-mode-stop",_),()=>{window.removeEventListener("profclaw:talk-mode-toggle",M),window.removeEventListener("profclaw:talk-mode-stop",_)}},[Z,Y]),l.useEffect(()=>{window.dispatchEvent(new CustomEvent("profclaw:talk-mode",{detail:{state:n}}))},[n]),l.useEffect(()=>()=>{Y()},[]),{state:n,energy:i,lastTranscription:m,isCalibrating:b,noiseFloor:T,selectedVoice:D,config:R,updateConfig:H,setSelectedVoice:qe,start:ge,stop:Y,toggle:Z,speakResponse:Ne}}const Vt={exec:ae,read_file:B,write_file:B,search_files:B,grep:B,git_status:B,git_commit:B,git_push:B,system_info:Ye,default:ae};function nn({approval:t,onDecision:s,isLoading:a=!1}){const[n,r]=l.useState(null),[i,c]=l.useState(null);l.useEffect(()=>{if(!t.expiresAt)return;const k=()=>{const E=Math.max(0,t.expiresAt-Date.now());r(E),E===0&&s(t.id,"deny")};k();const D=setInterval(k,1e3);return()=>clearInterval(D)},[t.expiresAt,t.id,s]);const m=k=>{c(k),s(t.id,k)},f=Vt[t.toolName]||Vt.default,b=t.securityLevel==="dangerous",y=k=>{const D=Math.floor(k/1e3),E=Math.floor(D/60),R=D%60;return`${E}:${R.toString().padStart(2,"0")}`},T=k=>Object.entries(k).map(([D,E])=>{const R=typeof E=="string"?E:JSON.stringify(E),F=R.length>100?R.slice(0,100)+"...":R;return`${D}: ${F}`}).join(`
7
+ `);return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"w-full max-w-lg mx-4 glass-heavy rounded-2xl shadow-2xl overflow-hidden",children:[e.jsxs("div",{className:d("px-6 py-4 border-b border-gray-200 dark:border-border flex items-center gap-3",b?"bg-red-50 dark:bg-red-500/10":"bg-yellow-50 dark:bg-yellow-500/10"),children:[b?e.jsx(Jt,{className:"h-6 w-6 text-red-500"}):e.jsx(mt,{className:"h-6 w-6 text-yellow-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-foreground",children:"Tool Approval Required"}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-muted-foreground",children:b?"This tool requires explicit approval":"Review before executing"})]}),n!==null&&e.jsxs("div",{className:"flex items-center gap-1.5 text-sm text-muted-foreground",children:[e.jsx(re,{className:"h-4 w-4"}),e.jsx("span",{className:d(n<3e4&&"text-red-500 font-medium"),children:y(n)})]})]}),e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:d("p-3 rounded-lg",b?"bg-red-100 dark:bg-red-500/10":"bg-yellow-100 dark:bg-yellow-500/10"),children:e.jsx(f,{className:d("h-6 w-6",b?"text-red-500":"text-yellow-500")})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-gray-900 dark:text-foreground",children:t.toolName}),e.jsx("span",{className:d("px-2 py-0.5 text-xs font-medium rounded-full",b?"bg-red-100 dark:bg-red-500/20 text-red-600 dark:text-red-500":"bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400"),children:t.securityLevel})]}),e.jsx("p",{className:"text-sm text-gray-600 dark:text-muted-foreground mt-1",children:b?"This tool can modify files, execute commands, or access sensitive data.":"This tool may access files or execute commands."})]})]}),(t.command||Object.keys(t.params).length>0)&&e.jsxs("div",{className:"bg-gray-100 dark:bg-muted/50 rounded-lg p-4 border border-gray-200 dark:border-border",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider mb-2",children:t.command?"Command":"Parameters"}),e.jsx("pre",{className:"text-sm font-mono whitespace-pre-wrap break-all text-gray-800 dark:text-foreground",children:t.command||T(t.params)})]}),b&&e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-50 dark:bg-red-500/10 rounded-lg border border-red-200 dark:border-red-500/20",children:[e.jsx(Bs,{className:"h-5 w-5 text-red-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm",children:[e.jsx("p",{className:"font-medium text-red-600 dark:text-red-500",children:"Security Warning"}),e.jsx("p",{className:"text-gray-600 dark:text-muted-foreground mt-1",children:"This operation could potentially harm your system or expose sensitive data. Only approve if you trust the source."})]})]})]}),e.jsxs("div",{className:"px-6 py-4 bg-gray-50 dark:bg-muted/30 border-t border-gray-200 dark:border-border flex items-center justify-between gap-3",children:[e.jsxs(P,{variant:"ghost",onClick:()=>m("deny"),disabled:a,className:"text-red-600 dark:text-red-500 hover:text-red-700 dark:hover:text-red-600 hover:bg-red-100 dark:hover:bg-red-500/10",children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Deny"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(P,{variant:"outline",onClick:()=>m("allow-always"),disabled:a,className:"border-green-300 dark:border-green-500/30 hover:bg-green-100 dark:hover:bg-green-500/10 text-green-700 dark:text-foreground",children:[e.jsx(Qt,{className:"h-4 w-4 mr-2 text-green-600 dark:text-green-500"}),"Allow Always"]}),e.jsx(P,{onClick:()=>m("allow-once"),disabled:a,className:d(b?"bg-red-500 hover:bg-red-600 text-white":"bg-yellow-500 hover:bg-yellow-600 text-gray-900"),children:a&&i==="allow-once"?e.jsx("span",{className:"animate-pulse",children:"Processing..."}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"h-4 w-4 mr-2"}),"Allow Once"]})})]})]})]})})}function Fn(){const t=Ws(),[s,a]=Ys(),n={model:"profclaw-chat-model",preset:"profclaw-chat-preset",sidebarOpen:"profclaw-chat-sidebar-open",agentMode:"profclaw-chat-agent-mode"},[r,i]=l.useState([]),[c,m]=l.useState(""),[f,b]=l.useState(()=>typeof window<"u"&&localStorage.getItem(n.model)||""),[y,T]=l.useState(()=>typeof window<"u"&&localStorage.getItem(n.preset)||"profclaw-assistant"),[k,D]=l.useState(!1),[E,R]=l.useState(!1),[F,p]=l.useState(null),[A,C]=l.useState(!1),[j,N]=l.useState([]),[u,v]=l.useState(null),[g,S]=l.useState([]),[K,U]=l.useState(()=>{if(typeof window<"u"){const o=localStorage.getItem(n.sidebarOpen);return o!==null?JSON.parse(o):!0}return!0}),[H,qe]=l.useState(()=>{if(typeof window<"u"){const o=localStorage.getItem(n.agentMode);return o!==null?JSON.parse(o):!1}return!1}),[W,pe]=l.useState("ask-dangerous"),[Ne,Re]=l.useState(!1),[de,ke]=l.useState([]),[Q,Y]=l.useState(!1),ge=l.useMemo(()=>{const o=new Map;for(const h of de){if(h.type==="tool:call"){const x=h.data,w=x.id??x.toolCallId??crypto.randomUUID(),I=x.name??x.toolName??"unknown";o.set(w,{id:w,toolName:I,status:"running",startedAt:Date.now()})}if(h.type==="tool:result"){const x=h.data,w=x.id??x.toolCallId??"",I=o.get(w);I&&(I.status=x.success===!1?"failed":"completed",I.completedAt=Date.now(),x.error&&(I.error=x.error))}}return Array.from(o.values())},[de]),Z=l.useRef(null),M=l.useRef(null),_=l.useRef([]),z=l.useRef(null),V=l.useCallback(o=>{v(o),Z.current=o,o?a({c:o},{replace:!0}):a({},{replace:!0})},[a]),{data:X}=se({queryKey:["chat","models"],queryFn:()=>J.chat.models(),staleTime:6e4}),{data:ue,refetch:fe}=se({queryKey:["chat","providers"],queryFn:()=>J.chat.providers(),refetchInterval:3e4,staleTime:25e3}),{data:Ce}=se({queryKey:["chat","presets"],queryFn:()=>J.chat.presets(),staleTime:6e4}),{data:ts}=se({queryKey:["chat","quickActions"],queryFn:()=>J.chat.quickActions(),staleTime:6e4}),{data:Ee,refetch:be}=se({queryKey:["chat","conversations","recent"],queryFn:()=>J.chat.conversations.recent(10),staleTime:1e4}),{data:ss}=se({queryKey:["chat","memory",u],queryFn:()=>J.chat.conversations.getMemoryStats(u,f),enabled:!!u,refetchInterval:6e4,staleTime:55e3}),{data:Ge}=se({queryKey:["model-capability",f],queryFn:async()=>{if(!f)return{capability:"reasoning",tier:"full",maxSchemaTokens:2e4};const o=await fetch(`/api/chat/model-capability?model=${encodeURIComponent(f)}`);return o.ok?o.json():{capability:"reasoning",tier:"full",maxSchemaTokens:2e4}},staleTime:3e5,enabled:!!f}),{data:ht}=se({queryKey:["voice-status"],queryFn:async()=>{const o=await fetch("/api/voice/status");return o.ok?o.json():{available:!1,stt:{provider:null},tts:{provider:null}}},staleTime:6e4,retry:1}),De=ht?.stt?.provider!=null,pt=ht?.tts?.provider!=null,rs=_e({mutationFn:({type:o,apiKey:h})=>J.chat.configure(o,{apiKey:h,enabled:!0}),onSuccess:()=>{O.success("Provider configured successfully"),fe(),t.invalidateQueries({queryKey:["chat","providers"]})},onError:o=>{O.error(o instanceof Error?o.message:"Failed to configure provider")}}),Le=_e({mutationFn:o=>J.chat.conversations.create(o),onSuccess:o=>{V(o.conversation.id),be()}}),oe=_e({mutationFn:({conversationId:o,content:h,model:x})=>J.chat.conversations.sendMessage(o,{content:h,model:x}),onSuccess:o=>{const h={id:o.assistantMessage.id,role:"assistant",content:o.assistantMessage.content,timestamp:o.assistantMessage.createdAt,usage:o.usage};i(x=>[...x.filter(I=>!I.isLoading),h]),be(),t.invalidateQueries({queryKey:["chat","memory"]}),o.compaction&&O.info(`Memory compacted: ${o.compaction.originalCount} → ${o.compaction.compactedCount} messages`,{duration:4e3})},onError:o=>{i(h=>{const x=h.filter(I=>!I.isLoading),w=x[x.length-1];return w&&w.role==="user"?[...x.slice(0,-1),{...w,error:o instanceof Error?o.message:"Failed to send message"}]:x}),O.error("Failed to send message")}}),me=_e({mutationFn:({conversationId:o,content:h,model:x})=>J.chat.conversations.sendMessageWithTools(o,{content:h,model:x,enableTools:!0}),onSuccess:o=>{const h={id:o.assistantMessage.id,role:"assistant",content:o.assistantMessage.content,timestamp:o.assistantMessage.createdAt,usage:o.usage,toolCalls:o.toolCalls};i(x=>[...x.filter(I=>!I.isLoading),h]),be(),t.invalidateQueries({queryKey:["chat","memory"]}),o.pendingApprovals&&o.pendingApprovals.length>0&&S(x=>{const w=o.pendingApprovals.filter(I=>!x.some($=>$.id===I.id));return[...x,...w]}),o.compaction&&O.info(`Memory compacted: ${o.compaction.originalCount} → ${o.compaction.compactedCount} messages`,{duration:4e3}),o.toolCalls&&o.toolCalls.length>0&&O.success(`Used ${o.toolCalls.length} tool(s)`,{duration:3e3}),o.toolSupport?.requested&&!o.toolSupport.supported&&O.warning(o.toolSupport.recommendation||"Model doesn't support tools. Using normal conversation mode.",{duration:6e3})},onError:o=>{i(h=>{const x=h.filter(I=>!I.isLoading),w=x[x.length-1];return w&&w.role==="user"?[...x.slice(0,-1),{...w,error:o instanceof Error?o.message:"Failed to send message"}]:x}),O.error("Failed to send message")}}),He=_e({mutationFn:({approvalId:o,decision:h})=>J.chat.tools.approve({conversationId:u,approvalId:o,decision:h}),onSuccess:(o,{approvalId:h,decision:x})=>{if(S(w=>w.filter(I=>I.id!==h)),x==="deny")O.info("Tool execution denied");else if(O.success(x==="allow-always"?"Tool allowed (always)":"Tool executed"),o.result){const w={id:crypto.randomUUID(),role:"assistant",content:typeof o.result=="string"?o.result:`Tool completed:
8
+ \`\`\`json
9
+ ${JSON.stringify(o.result,null,2)}
10
+ \`\`\``,timestamp:new Date().toISOString()};i(I=>[...I,w])}},onError:o=>{O.error(o instanceof Error?o.message:"Failed to process approval")}}),as=l.useCallback((o,h)=>{He.mutate({approvalId:o,decision:h})},[He]);l.useEffect(()=>{const o=s.get("c");o&&o!==Z.current&&(Z.current=o,Pe(o))},[s]),l.useEffect(()=>{if(!s.get("c")&&!u&&Ee?.conversations?.length){const h=Ee.conversations[0];h?.id&&Pe(h.id)}},[Ee]),l.useEffect(()=>{if(!ue?.providers||!X?.aliases)return;const o=X.aliases,x=ue.providers.filter(I=>I.healthy);if(!(f&&(I=>{const $=o.find(L=>L.alias===I);return $?x.some(L=>L.type===$.provider):!1})(f))&&x.length>0){const I={anthropic:"sonnet",openai:"gpt",google:"gemini",azure:"azure",groq:"groq",xai:"grok",ollama:"local"},$=x[0],L=I[$.type]||"local";b(L)}},[ue,X,f]);const ns=l.useCallback(o=>{b(o),localStorage.setItem(n.model,o)},[n.model]),os=l.useCallback(o=>{T(o),localStorage.setItem(n.preset,o)},[n.preset]),Pe=async o=>{try{const h=await J.chat.conversations.get(o);v(o),Z.current=o,T(h.conversation.presetId),i(h.messages.map(x=>({id:x.id,role:x.role,content:x.content,timestamp:x.createdAt,usage:x.tokenUsage?{promptTokens:x.tokenUsage.prompt,completionTokens:x.tokenUsage.completion,totalTokens:x.tokenUsage.total,cost:x.cost}:void 0,toolCalls:x.toolCalls?.map(w=>({id:w.id,name:w.name,arguments:w.arguments||{},result:w.result,status:w.status||"success",duration:w.duration}))}))),R(!1)}catch{O.error("Failed to load conversation")}},is=async()=>{const o=oe.isPending||me.isPending||Q;if(!c.trim()||o)return;const h={id:crypto.randomUUID(),role:"user",content:c.trim(),timestamp:new Date().toISOString(),images:j.length>0?[...j]:void 0},x={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};i($=>[...$,h,x]);const w=c.trim();if(m(""),N([]),H){ke([]),Y(!0);try{let $=u;$||($=(await Le.mutateAsync({presetId:y})).conversation.id);for await(const L of J.chat.agentic.sendMessage($,{content:w,model:f||void 0,showThinking:!0})){if(ke(G=>[...G,L]),L.type==="summary"){const G=L.data;i(te=>[...te.filter(Te=>!Te.isLoading),{id:crypto.randomUUID(),role:"assistant",content:G.summary,timestamp:new Date().toISOString()}])}if(L.type==="complete"){const G=L.data;O.success(`Task completed in ${G.totalSteps} step${G.totalSteps!==1?"s":""} with ${G.toolCalls?.length||0} tool call${(G.toolCalls?.length||0)!==1?"s":""}`,{duration:4e3})}if(L.type==="error"){const G=L.data;i(te=>{const xe=te.filter(Cs=>!Cs.isLoading),Te=xe[xe.length-1];return Te&&Te.role==="user"?[...xe.slice(0,-1),{...Te,error:G.message}]:xe}),O.error(G.message)}}be(),t.invalidateQueries({queryKey:["chat","memory"]})}catch($){i(L=>{const G=L.filter(xe=>!xe.isLoading),te=G[G.length-1];return te&&te.role==="user"?[...G.slice(0,-1),{...te,error:$ instanceof Error?$.message:"Agentic execution failed"}]:G}),O.error("Agentic execution failed")}finally{Y(!1)}return}const I=oe;if(u)I.mutate({conversationId:u,content:w,model:f||void 0});else{const $=await Le.mutateAsync({presetId:y});I.mutate({conversationId:$.conversation.id,content:w,model:f||void 0})}},ls=l.useCallback(async o=>{const h=oe.isPending||me.isPending||Q;if(!o.trim()||h)return;const x={id:crypto.randomUUID(),role:"user",content:o.trim(),timestamp:new Date().toISOString()},w={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};i($=>[...$,x,w]);const I=H?me:oe;if(u)I.mutate({conversationId:u,content:o.trim(),model:f||void 0});else{const $=await Le.mutateAsync({presetId:y});I.mutate({conversationId:$.conversation.id,content:o.trim(),model:f||void 0})}},[oe.isPending,me.isPending,Q,H,u,f,y,oe,me,Le]),q=an({onTranscription:l.useCallback(o=>{m(h=>h?`${h} ${o}`:o)},[]),onSend:ls});l.useEffect(()=>{if(q.state==="idle"||!q.config.autoTts)return;const o=r[r.length-1];o&&o.role==="assistant"&&!o.isLoading&&o.content&&o.id!==z.current&&(z.current=o.id,q.speakResponse(o.content))},[r,q.state,q.config.autoTts,q.speakResponse]);const cs=l.useCallback(()=>{if(!De&&q.state==="idle"){O.error("Talk Mode requires an STT provider. Go to Settings > Voice to configure.",{id:"voice-unavailable"});return}q.toggle()},[De,q.state,q.toggle]),Se=()=>{V(null),i([]),S([]),O.success("Started new chat")},ds=async(o,h)=>{await navigator.clipboard.writeText(o),p(h),setTimeout(()=>p(null),2e3)},us=o=>{const h=r.findIndex(L=>L.id===o);if(h===-1||!u)return;const x=r[h];let w;if(x.role==="assistant"&&x.error){for(let L=h-1;L>=0;L--)if(r[L].role==="user"){w=r[L];break}}else x.role==="user"&&x.error&&(w=x);if(!w){O.error("Could not find message to retry");return}const I={id:"loading",role:"assistant",content:"",isLoading:!0,timestamp:new Date().toISOString()};i(L=>{const G=L.findIndex(te=>te.id===w.id);return[...L.slice(0,G+1),I]}),(H?me:oe).mutate({conversationId:u,content:w.content,model:f||void 0}),O.info("Retrying message...")},ms=o=>{m(o)},xs=l.useCallback(o=>{const x={deploy:"Run the deploy workflow for this project",review:"Run a code review on the recent changes",debug:"Help me debug the current issue",research:"Research this topic for me",test:"Run the test suite and analyze results",refactor:"Suggest refactoring improvements for the current code"}[o]||`Run the ${o} workflow`;m(x)},[]),hs=o=>{const h=o.target.files;h&&Array.from(h).forEach(x=>{const w=new FileReader;w.onload=()=>{N(I=>[...I,w.result])},w.readAsDataURL(x)})},ps=o=>{N(h=>h.filter((x,w)=>w!==o))},gs=async()=>{if(!De){O.error("Voice input requires an STT provider. Go to Settings > Voice to configure.",{id:"voice-unavailable"});return}try{const o=await navigator.mediaDevices.getUserMedia({audio:!0}),h=new MediaRecorder(o);M.current=h,_.current=[],h.ondataavailable=x=>{x.data.size>0&&_.current.push(x.data)},h.onstop=async()=>{o.getTracks().forEach(w=>w.stop());const x=new Blob(_.current,{type:"audio/webm"});if(x.size!==0)try{const w=new FormData;w.append("audio",x,"recording.webm");const I=await fetch("/api/voice/transcribe",{method:"POST",body:w});if(!I.ok)throw new Error("Transcription failed");const $=await I.json();$.text&&(m(L=>L?`${L} ${$.text}`:$.text??""),O.success("Voice transcribed"))}catch{O.error("Voice transcription failed")}},h.start(),C(!0),O.success("Recording started")}catch{O.error("Microphone access denied")}},fs=()=>{M.current&&A&&(M.current.stop(),C(!1))},bs=async(o,h)=>{await rs.mutateAsync({type:o,apiKey:h})},ys=l.useCallback(()=>{U(o=>{const h=!o;return localStorage.setItem(n.sidebarOpen,JSON.stringify(h)),h})},[n.sidebarOpen]),js=l.useCallback(()=>{qe(o=>{const h=!o;return localStorage.setItem(n.agentMode,JSON.stringify(h)),O.info(h?"Agent mode enabled (autonomous)":"Chat mode enabled (conversational)",{id:"agent-mode-toggle"}),h})},[n.agentMode]),vs=l.useCallback(()=>{Re(o=>{const h=!o;return h?document.documentElement.classList.add("chat-fullscreen"):document.documentElement.classList.remove("chat-fullscreen"),h})},[]);l.useEffect(()=>()=>{document.documentElement.classList.remove("chat-fullscreen")},[]);const ws=l.useCallback(async o=>{try{await J.chat.conversations.delete(o),be(),u===o&&Se(),O.success("Conversation deleted")}catch{O.error("Failed to delete conversation")}},[u,be]),Ns=X?.aliases||[],Je=ue?.providers||[],ye=Je.filter(o=>o.healthy),gt=Ce?.presets||[],ks=ts?.actions||[],ft=Ee?.conversations||[],bt=gt.find(o=>o.id===y),yt=oe.isPending||me.isPending||Q,jt=g[0];return e.jsxs("div",{className:d("flex overflow-hidden transition-all duration-300",Ne?"h-screen rounded-none border-0 shadow-none mx-0 my-0 bg-background":"rounded-2xl border border-border/30 bg-card/40 backdrop-blur-xl shadow-[0_8px_30px_rgba(0,0,0,0.12)] dark:shadow-[0_8px_30px_rgba(0,0,0,0.3)] -mx-2 -my-2 sm:-mx-4 sm:-my-3 h-[calc(100vh-6.5rem)]"),children:[!Ne&&e.jsx("aside",{className:"shrink-0",children:e.jsx(Da,{isOpen:K,onToggle:ys,conversations:ft,currentConversationId:u,onSelectConversation:Pe,onNewChat:Se,onDeleteConversation:ws,width:260})}),e.jsxs("main",{className:"flex-1 flex flex-col min-w-0 bg-background/30",role:"main",children:[e.jsx("header",{className:"border-b border-border/20 bg-card/30",role:"banner",children:e.jsx(Xr,{currentPreset:bt,presets:gt,selectedPreset:y,selectedModel:f,aliases:Ns,providers:Je,healthyProviders:ye,memoryStats:ss,conversationId:u,onPresetChange:os,onModelChange:ns,onNewChat:Se,onOpenHistory:()=>R(!0),onOpenProviderSetup:()=>D(!0),onClearChat:Se,focusedView:Ne,onToggleFocusedView:vs,modelCapability:Ge?{toolTier:Ge.tier,capabilityLevel:Ge.capability}:void 0})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden px-3 py-2",children:[ye.length===0&&e.jsxs("div",{className:"mb-4 p-4 rounded-2xl bg-amber-500/10 border border-amber-500/20 flex items-start gap-3",children:[e.jsx(ut,{className:"h-5 w-5 text-amber-500 shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium text-amber-200",children:"No AI providers connected"}),e.jsx("p",{className:"text-sm text-amber-300/80 mt-1",children:"Connect at least one provider to start chatting."})]}),e.jsxs(P,{variant:"outline",size:"sm",className:"border-amber-500/30 hover:bg-amber-500/10",onClick:()=>D(!0),children:[e.jsx(Ut,{className:"h-4 w-4 mr-1"}),"Setup"]})]}),H&&e.jsx(Qa,{level:W,onChange:pe,className:"mb-3"}),H&&(de.length>0||Q)&&e.jsx(Oa,{events:de,isActive:Q,className:"mb-3"}),H&&(ge.length>0||Q)&&e.jsx(Wa,{toolCalls:ge,isExecuting:Q,className:"mb-3"}),e.jsx(Ca,{messages:r,currentPreset:bt,quickActions:ks,healthyProviders:ye.length,copiedId:F,onCopy:ds,onRetry:us,onQuickAction:ms,onOpenProviderSetup:()=>D(!0)}),q.state!=="idle"&&e.jsx(Ka,{state:q.state,energy:q.energy,lastTranscription:q.lastTranscription,isCalibrating:q.isCalibrating,noiseFloor:q.noiseFloor,selectedVoice:q.selectedVoice,onVoiceChange:q.setSelectedVoice,onStop:q.stop,ttsAvailable:pt}),e.jsx(Ta,{value:c,onChange:m,onSend:is,isPending:yt,disabled:ye.length===0,placeholder:ye.length>0?H?"Give the agent a task...":"Type a message...":"Configure a provider to start chatting...",pendingImages:j,onImageSelect:hs,onImageRemove:ps,isRecording:A,onStartRecording:gs,onStopRecording:fs,agentMode:H,onToggleAgentMode:js,talkModeState:q.state,onToggleTalkMode:cs,voiceAvailable:{stt:De,tts:pt}}),H&&e.jsx(qa,{onWorkflowSelect:xs,disabled:yt||ye.length===0,className:"px-3 pb-2"})]}),e.jsx(_a,{open:E,onOpenChange:R,conversations:ft,currentConversationId:u,onSelectConversation:Pe,onNewChat:Se}),e.jsx(Pa,{open:k,onOpenChange:D,providers:Je,onSaveApiKey:bs}),jt&&e.jsx(nn,{approval:jt,onDecision:as,isLoading:He.isPending})]})]})}export{Fn as ChatView};
@@ -0,0 +1 @@
1
+ import{c as k,Z as C,M as f,j as e,b as c,ad as w,U as m,ak as $,u as h,m as g}from"./index-kb4AJXUB.js";import{S as x}from"./skeleton-CtkIA_MU.js";import{T as j}from"./trending-up-BGWxvlmZ.js";import{R as b,C as L,X as S,Y as A,T as N,a as F,L as T}from"./CartesianChart-B50bcUJi.js";import{A as D,a as q,P as I,b as M}from"./AreaChart-B5qMEGWj.js";const O=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],v=k("dollar-sign",O);function B({summary:a,analytics:l}){const s=a.taskCount>0?a.totalCost/a.taskCount:0,t=l&&l.daily.length>0?l.daily.slice(-7).reduce((n,i)=>n+i.cost,0)/7*30:a.totalCost*30,r=[{label:"Total Spend",value:`$${a.totalCost.toFixed(4)}`,icon:v,subtext:`${a.taskCount} tasks`,color:"text-green-500"},{label:"Total Tokens",value:a.totalTokens.toLocaleString(),icon:C,subtext:`${a.inputTokens.toLocaleString()} in / ${a.outputTokens.toLocaleString()} out`,color:"text-blue-500"},{label:"Avg Cost/Task",value:`$${s.toFixed(4)}`,icon:f,subtext:a.taskCount>0?"Per task average":"No tasks yet",color:"text-indigo-500"},{label:"Projected Monthly",value:`$${t.toFixed(2)}`,icon:j,subtext:"Based on recent usage",color:"text-orange-500"}];return e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:r.map(n=>e.jsx(c,{className:"glass p-6 rounded-2xl hover-lift transition-liquid",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-1",children:n.label}),e.jsx("p",{className:"text-2xl font-bold text-foreground mb-1",children:n.value}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n.subtext})]}),e.jsx("div",{className:`p-3 rounded-xl bg-muted/50 ${n.color}`,children:e.jsx(n.icon,{className:"w-5 h-5"})})]})},n.label))})}function P({data:a}){const l=a.map(s=>({...s,displayDate:new Date(s.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})}));return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 text-primary"}),"Daily Costs"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Cost trend over the last ",a.length," days"]})]}),e.jsx(b,{width:"100%",height:300,children:e.jsxs(D,{data:l,margin:{top:10,right:10,left:0,bottom:0},children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"costGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"5%",stopColor:"hsl(var(--primary))",stopOpacity:.3}),e.jsx("stop",{offset:"95%",stopColor:"hsl(var(--primary))",stopOpacity:0})]})}),e.jsx(L,{strokeDasharray:"3 3",stroke:"hsl(var(--border))",opacity:.3}),e.jsx(S,{dataKey:"displayDate",stroke:"hsl(var(--muted-foreground))",fontSize:12,tickLine:!1}),e.jsx(A,{stroke:"hsl(var(--muted-foreground))",fontSize:12,tickLine:!1,tickFormatter:s=>`$${s.toFixed(2)}`}),e.jsx(N,{content:({active:s,payload:t})=>s&&t&&t.length?e.jsxs("div",{className:"glass-heavy p-3 rounded-xl shadow-float border border-border/50",children:[e.jsx("p",{className:"text-sm font-semibold mb-1",children:t[0].payload.displayDate}),e.jsxs("p",{className:"text-sm text-primary font-medium",children:["$",t[0].value?.toFixed(4)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t[0].payload.tokens.toLocaleString()," tokens"]})]}):null}),e.jsx(q,{type:"monotone",dataKey:"cost",stroke:"hsl(var(--primary))",strokeWidth:2,fill:"url(#costGradient)"})]})})]})}const p=["hsl(var(--primary))","hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))","hsl(var(--chart-4))","hsl(var(--chart-5))"];function R({data:a}){const l=Object.entries(a).map(([s,t],r)=>({name:s,value:t.cost,tokens:t.tokens,color:p[r%p.length]})).sort((s,t)=>t.value-s.value);return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"mb-4",children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5 text-primary"}),"Costs by Agent"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Cost distribution across AI agents"})]}),e.jsx(b,{width:"100%",height:300,children:e.jsxs(I,{children:[e.jsx(M,{data:l,cx:"50%",cy:"50%",innerRadius:60,outerRadius:100,paddingAngle:2,dataKey:"value",children:l.map((s,t)=>e.jsx(F,{fill:s.color},`cell-${t}`))}),e.jsx(N,{content:({active:s,payload:t})=>s&&t&&t.length?e.jsxs("div",{className:"glass-heavy p-3 rounded-xl shadow-float border border-border/50",children:[e.jsx("p",{className:"text-sm font-semibold mb-1",children:t[0].payload.name}),e.jsxs("p",{className:"text-sm text-primary font-medium",children:["$",t[0].value?.toFixed(4)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t[0].payload.tokens.toLocaleString()," tokens"]})]}):null}),e.jsx(T,{verticalAlign:"bottom",height:36,iconType:"circle",formatter:(s,t)=>{const r=(t.payload.value/l.reduce((n,i)=>n+i.value,0)*100).toFixed(1);return e.jsxs("span",{className:"text-sm text-foreground",children:[s," (",r,"%)"]})}})]})}),e.jsx("div",{className:"mt-6 space-y-2",children:l.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg hover:bg-muted/50 transition-liquid",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:s.color}}),e.jsx("span",{className:"text-sm font-medium",children:s.name})]}),e.jsxs("span",{className:"text-sm text-primary font-semibold",children:["$",s.value.toFixed(4)]})]},s.name))})]})}function K({budget:a}){const l=a?.limit??0,s=a?.spent??0,t=a?.remaining??0,r=a?.percentage??0,n=()=>r>=100?"text-red-500":r>=80?"text-orange-500":r>=50?"text-yellow-500":"text-green-500",i=()=>r>=100?"bg-red-500":r>=80?"bg-orange-500":r>=50?"bg-yellow-500":"bg-green-500",d=r>=100?m:r>=80?m:$,u=n(),y=i();return e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-semibold flex items-center gap-2",children:[e.jsx(j,{className:"w-5 h-5 text-primary"}),"Budget Tracker"]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Current spending vs budget limit"})]}),e.jsx("div",{className:`p-2 rounded-lg bg-muted/50 ${u}`,children:e.jsx(d,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Budget Limit"}),e.jsxs("p",{className:"text-lg font-bold text-foreground",children:["$",l.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Spent"}),e.jsxs("p",{className:`text-lg font-bold ${u}`,children:["$",s.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-1",children:"Remaining"}),e.jsxs("p",{className:"text-lg font-bold text-foreground",children:["$",t.toFixed(2)]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Usage"}),e.jsxs("span",{className:`font-semibold ${u}`,children:[r.toFixed(1),"%"]})]}),e.jsx("div",{className:"w-full h-3 bg-muted rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full ${y} transition-all duration-500 ease-out rounded-full`,style:{width:`${Math.min(r,100)}%`}})})]}),r>=100&&e.jsx("div",{className:"mt-4 p-3 rounded-xl bg-red-500/10 border border-red-500/20",children:e.jsxs("p",{className:"text-sm text-red-500 font-medium flex items-center gap-2",children:[e.jsx(m,{className:"w-4 h-4"}),"Budget exceeded! Consider increasing the limit or pausing tasks."]})}),r>=80&&r<100&&e.jsx("div",{className:"mt-4 p-3 rounded-xl bg-orange-500/10 border border-orange-500/20",children:e.jsxs("p",{className:"text-sm text-orange-500 font-medium flex items-center gap-2",children:[e.jsx(m,{className:"w-4 h-4"}),"Approaching budget limit. ",r.toFixed(0),"% used."]})})]})}function X(){const{data:a,isLoading:l}=h({queryKey:["costs","summary"],queryFn:g.costs.summary,refetchInterval:3e4}),{data:s,isLoading:t}=h({queryKey:["costs","analytics"],queryFn:g.costs.analytics,refetchInterval:3e4}),{data:r,isLoading:n}=h({queryKey:["costs","budget"],queryFn:g.costs.budget,refetchInterval:3e4});return l||t||n?e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{children:[e.jsx(x,{className:"h-8 w-48 mb-2"}),e.jsx(x,{className:"h-4 w-64"})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[1,2,3,4].map(o=>e.jsx(x,{className:"h-32 rounded-2xl"},o))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsx(x,{className:"h-80 rounded-2xl"}),e.jsx(x,{className:"h-80 rounded-2xl"})]})]}):e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-foreground mb-2",children:"Cost Analytics"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Track token usage, costs, and budget across all AI agents"})]}),a&&e.jsx(B,{summary:a,analytics:s}),r&&e.jsx(K,{budget:r}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[s&&s.daily.length>0&&e.jsx(P,{data:s.daily}),s&&Object.keys(s.byAgent).length>0&&e.jsx(R,{data:s.byAgent})]}),s&&Object.keys(s.byModel).length>0&&e.jsxs(c,{className:"glass p-6 rounded-2xl",children:[e.jsxs("h3",{className:"text-lg font-semibold mb-4 flex items-center gap-2",children:[e.jsx(f,{className:"w-5 h-5 text-primary"}),"Costs by Model"]}),e.jsx("div",{className:"space-y-3",children:Object.entries(s.byModel).sort(([,o],[,d])=>d.cost-o.cost).map(([o,d])=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-xl bg-muted/50 hover:bg-muted/70 transition-liquid",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:o}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[d.tokens.toLocaleString()," tokens"]})]}),e.jsx("div",{className:"text-right",children:e.jsxs("div",{className:"font-semibold text-primary",children:["$",d.cost.toFixed(4)]})})]},o))})]}),(!s||s.daily.length===0)&&e.jsxs(c,{className:"glass p-12 rounded-2xl text-center",children:[e.jsx(v,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground opacity-50"}),e.jsx("h3",{className:"text-lg font-semibold mb-2",children:"No Cost Data Yet"}),e.jsx("p",{className:"text-sm text-muted-foreground max-w-md mx-auto",children:"Cost analytics will appear here once AI agents start processing tasks. Create a task to get started!"})]})]})}export{X as CostsDashboard};
@@ -0,0 +1 @@
1
+ import{j as r,i as n}from"./index-kb4AJXUB.js";import{S as f,a as h,b,c as o,d as x}from"./select-LsO16slr.js";import{H as l}from"./hash-g3102kPC.js";const j=[0,1,2,3,5,8,13,21];function w({value:t,onChange:s,disabled:c=!1,className:d,compact:i=!1,placeholder:a="Estimate"}){const m=e=>{s(e==="__none__"?null:parseInt(e,10))},g=e=>e===0?"0 pts (trivial)":e===1?"1 pt (tiny)":e===2?"2 pts (small)":e===3?"3 pts (medium)":e===5?"5 pts (large)":e===8?"8 pts (x-large)":e===13?"13 pts (huge)":e===21?"21 pts (epic)":`${e} pts`,u=e=>e==null?null:`${e} pts`;return r.jsxs(f,{value:t!=null?String(t):"__none__",onValueChange:m,disabled:c,children:[r.jsx(h,{className:n("bg-white/5 border-white/10 rounded-xl",i&&"w-[100px]",d),children:r.jsx(b,{placeholder:a,children:t!=null?r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(l,{className:"h-3.5 w-3.5 text-muted-foreground"}),r.jsx("span",{children:u(t)})]}):r.jsxs("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[r.jsx(l,{className:"h-3.5 w-3.5"}),r.jsx("span",{children:a})]})})}),r.jsxs(o,{className:"glass-heavy rounded-xl border-white/10",children:[r.jsx(x,{value:"__none__",children:r.jsx("span",{className:"text-muted-foreground",children:"No estimate"})}),j.map(e=>r.jsx(x,{value:String(e),children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{className:n("w-5 h-5 rounded-md flex items-center justify-center text-xs font-medium",e===0&&"bg-zinc-500/20 text-zinc-400",e===1&&"bg-green-500/20 text-green-400",e===2&&"bg-emerald-500/20 text-emerald-400",e===3&&"bg-blue-500/20 text-blue-400",e===5&&"bg-yellow-500/20 text-yellow-400",e===8&&"bg-orange-500/20 text-orange-400",e===13&&"bg-red-500/20 text-red-400",e===21&&"bg-purple-500/20 text-purple-400"),children:e}),r.jsx("span",{children:g(e)})]})},e))]})]})}function S({value:t,className:s}){return t==null?null:r.jsxs("span",{className:n("inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-xs font-medium",t===0&&"bg-zinc-500/20 text-zinc-400",t===1&&"bg-green-500/20 text-green-400",t===2&&"bg-emerald-500/20 text-emerald-400",t===3&&"bg-blue-500/20 text-blue-400",t===5&&"bg-yellow-500/20 text-yellow-400",t===8&&"bg-orange-500/20 text-orange-400",t===13&&"bg-red-500/20 text-red-400",t>=21&&"bg-purple-500/20 text-purple-400",s),children:[r.jsx(l,{className:"h-3 w-3"}),t]})}export{S as E,w as a};
@@ -0,0 +1,2 @@
1
+ import{bN as Y,n as ce,r,u as M,o as U,j as e,S as W,D as de,x as me,i as x,a5 as pe,y as ue,aw as he,z as fe,k as I,X as xe,R as ge,B as ee,an as ye,L as te,T as Q,F as J,a as we,N as be,bO as ke,Z as je,V as ve,aj as Ne,U as Ce,g as Se,m as g,ak as Ae}from"./index-kb4AJXUB.js";import{M as Me,a as Ie,b as qe}from"./markdown-renderer-CjU6hBcW.js";import{C as X}from"./cpu-B41x1-vV.js";import{T as De}from"./trash-2-B4oAXsX-.js";import{S as ze}from"./send-BDYBZDUZ.js";import{M as He}from"./message-square-Bf2-CVbt.js";import{L as Te}from"./layout-dashboard-B07MFhBs.js";import{B as We}from"./brain-C53ElFLD.js";import{W as Ee}from"./wrench-ByZkjO6m.js";import{C as Le}from"./circle-x-BN89YhbS.js";import"./defineProperty-CoXUr7_6.js";const Z="profclaw_chatbot_conversation_";function Pe(i,a){return a?`${Z}${i}_${a}`:`${Z}${i}`}const o={dashboard:{type:"dashboard",name:"Dashboard",icon:Te,description:"Overview of your workspace with stats and recent activity",capabilities:["View workspace statistics and metrics","See recent tickets and tasks","Check team activity and progress","Get insights on productivity trends"],quickActions:[{label:"Status report",prompt:"Give me a status report of my workspace. What are the key metrics and any items needing attention?"},{label:"What's new?",prompt:"What's happened recently in my workspace? Any updates I should know about?"},{label:"Productivity tips",prompt:"Based on my current workload, what productivity tips do you have?"}]},tickets:{type:"tickets",name:"Tickets",icon:Q,description:"Manage and track your tickets",capabilities:["Create new tickets","Search and filter tickets","Update ticket status and priority","Add comments and checklists","Assign tickets to team members"],quickActions:[{label:"Create ticket",prompt:"Help me create a new ticket. Ask me what it should be about."},{label:"Find tickets",prompt:"Help me find tickets. What would you like to search for?"},{label:"Ticket overview",prompt:"Give me an overview of my tickets - how many are open, in progress, and done?"}]},ticketDetail:{type:"ticket-detail",name:"Ticket Details",icon:Q,description:"Viewing a specific ticket",capabilities:["Update this ticket (status, priority, description)","Add comments to this ticket","Create checklists and subtasks","Link related tickets","Generate AI summaries"],quickActions:[{label:"Summarize",prompt:"Summarize this ticket and its current status for me."},{label:"Suggest next steps",prompt:"Based on this ticket, what should be the next steps to resolve it?"},{label:"Draft comment",prompt:"Help me draft a status update comment for this ticket."}]},projects:{type:"projects",name:"Projects",icon:J,description:"Manage your projects and sprints",capabilities:["Create new projects","View project progress","Manage sprints and iterations","See project analytics"],quickActions:[{label:"Create project",prompt:"Help me create a new project. What should it be called and what prefix should it use?"},{label:"Project status",prompt:"Give me a status update on all my projects."},{label:"Sprint planning",prompt:"Help me plan a new sprint. What tickets should be included?"}]},projectDetail:{type:"project-detail",name:"Project Details",icon:J,description:"Viewing a specific project",capabilities:["View project metrics and progress","Manage sprints for this project","See all tickets in this project","Update project settings"],quickActions:[{label:"Project summary",prompt:"Give me a summary of this project - progress, blockers, and upcoming work."},{label:"Sprint status",prompt:"What's the status of the current sprint in this project?"},{label:"Create ticket",prompt:"Help me create a new ticket for this project."}]},tasks:{type:"tasks",name:"Tasks",icon:we,description:"View and manage AI agent tasks",capabilities:["View pending and completed tasks","Retry failed tasks","See task execution details","Monitor agent activity"],quickActions:[{label:"Task status",prompt:"Give me an overview of my task queue - pending, running, and completed."},{label:"Failed tasks",prompt:"Are there any failed tasks that need attention?"},{label:"Agent activity",prompt:"What are my AI agents currently working on?"}]},summaries:{type:"summaries",name:"Summaries",icon:be,description:"AI-generated session summaries",capabilities:["Browse past session summaries","Search for specific work","Review completed work history"],quickActions:[{label:"Recent work",prompt:"What work has been completed recently? Show me recent summaries."},{label:"Find summary",prompt:"Help me find a summary about a specific topic or task."}]},costs:{type:"costs",name:"Cost Dashboard",icon:ke,description:"Track AI usage and costs",capabilities:["View token usage statistics","Monitor cost trends","See cost breakdown by model","Set usage alerts"],quickActions:[{label:"Cost summary",prompt:"What's my AI usage and cost this month?"},{label:"Compare models",prompt:"Compare the costs between different AI models I use."}]},gateway:{type:"gateway",name:"AI Gateway",icon:je,description:"Manage AI agent workflows",capabilities:["Execute AI workflows","Configure agents","Monitor gateway status"],quickActions:[{label:"Run workflow",prompt:"Help me run an AI workflow. What task should I execute?"},{label:"Gateway status",prompt:"What's the status of the AI gateway?"}]},agents:{type:"agents",name:"Agents",icon:ee,description:"Configure AI agents",capabilities:["View available agents","Configure agent settings","Monitor agent health"],quickActions:[{label:"Agent status",prompt:"Show me the status of all AI agents."},{label:"Configure agent",prompt:"Help me configure an AI agent."}]},settings:{type:"settings",name:"Settings",icon:ve,description:"Configure profClaw settings",capabilities:["Configure AI providers","Manage integrations","Update preferences"],quickActions:[{label:"Setup help",prompt:"Help me set up and configure profClaw."},{label:"Provider config",prompt:"Help me configure an AI provider."}]},webhooks:{type:"webhooks",name:"Webhooks",icon:Ne,description:"Manage webhook integrations",capabilities:["View webhook status","Test webhook connections","Configure webhook endpoints"],quickActions:[{label:"Webhook status",prompt:"Show me the status of all webhooks."},{label:"Setup webhook",prompt:"Help me set up a new webhook integration."}]},failed:{type:"failed",name:"Failed Tasks",icon:Ce,description:"Review and retry failed tasks",capabilities:["View failed task details","Retry failed tasks","Analyze failure patterns"],quickActions:[{label:"Analyze failures",prompt:"Analyze the failed tasks and tell me what went wrong."},{label:"Retry all",prompt:"Help me retry the failed tasks."}]},memory:{type:"memory",name:"Memory",icon:We,description:"AI memory and context",capabilities:["Search memory for past context","View memory statistics","Manage memory files"],quickActions:[{label:"Search memory",prompt:"Search my memory for information about..."},{label:"Memory stats",prompt:"What's stored in my AI memory?"}]},cron:{type:"cron",name:"Scheduled Jobs",icon:Se,description:"Manage automated scheduled tasks",capabilities:["Create new scheduled jobs","View job status and history","Trigger jobs manually","Pause and resume jobs","Monitor execution logs"],quickActions:[{label:"Job status",prompt:"Show me the status of all my scheduled jobs. How many are active, paused, or failed?"},{label:"Recent failures",prompt:"Are there any failed scheduled jobs? Show me the recent failures and what went wrong."},{label:"Create job",prompt:"Help me create a new scheduled job. What task should it automate and how often should it run?"},{label:"Job history",prompt:"Show me the execution history of my scheduled jobs. Which ones ran recently?"}]},default:{type:"default",name:"profClaw",icon:W,description:"AI-powered task management",capabilities:["Answer questions about profClaw","Help with navigation","Provide general assistance"],quickActions:[{label:"Help",prompt:"What can you help me with in profClaw?"},{label:"Navigate",prompt:"Help me find what I need in profClaw."}]}};function Re(){const a=Y().pathname;return r.useMemo(()=>{if(a==="/"||a==="/chat")return{context:o.default};if(a==="/analytics")return{context:o.dashboard};const n=a.match(/^\/tickets\/([^/]+)$/);if(n&&n[1]!=="board")return{context:o.ticketDetail,entityId:n[1]};if(a==="/tickets"||a==="/tickets/board")return{context:o.tickets};const m=a.match(/^\/projects\/([^/]+)$/);if(m)return{context:o.projectDetail,entityId:m[1]};if(a==="/projects")return{context:o.projects};const p=a.match(/^\/tasks\/([^/]+)$/);return p?{context:o.tasks,entityId:p[1]}:a==="/tasks"?{context:o.tasks}:a.startsWith("/summaries")?{context:o.summaries}:a==="/costs"?{context:o.costs}:a==="/gateway"?{context:o.gateway}:a==="/agents"?{context:o.agents}:a.startsWith("/settings")?{context:o.settings}:a==="/webhooks"?{context:o.webhooks}:a==="/failed"?{context:o.failed}:a==="/memory"?{context:o.memory}:a==="/cron"?{context:o.cron}:{context:o.default}},[a])}function Fe({toolCall:i}){const[a,n]=r.useState(!1);return e.jsxs("div",{className:"mt-2 p-2 rounded-lg bg-muted/50 border border-border/50 text-xs",children:[e.jsxs("button",{onClick:()=>n(!a),className:"flex items-center gap-2 w-full text-left",children:[e.jsx(Ee,{className:"h-3 w-3 text-blue-500"}),e.jsx("span",{className:"font-medium",children:i.name}),i.status==="success"&&e.jsx(Ae,{className:"h-3 w-3 text-green-500 ml-auto"}),i.status==="error"&&e.jsx(Le,{className:"h-3 w-3 text-red-500 ml-auto"}),i.status==="pending"&&e.jsx(te,{className:"h-3 w-3 animate-spin text-yellow-500 ml-auto"})]}),a&&e.jsxs("div",{className:"mt-2 space-y-1",children:[e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Args:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto",children:JSON.stringify(i.arguments,null,2)})]}),i.result!==void 0&&i.result!==null&&e.jsxs("div",{className:"text-muted-foreground",children:[e.jsx("span",{className:"font-medium",children:"Result:"}),e.jsx("pre",{className:"mt-1 p-1 bg-background rounded text-[10px] overflow-x-auto max-h-24 overflow-y-auto",children:typeof i.result=="string"?i.result:JSON.stringify(i.result,null,2)})]})]})]})}function Ze(){const i=Y(),a=ce(),{context:n,entityId:m}=Re(),[p,E]=r.useState(!1),[C,se]=r.useState(!1),[w,f]=r.useState([]),[b,q]=r.useState(""),[D,k]=r.useState(null),[L,z]=r.useState(null),[j,P]=r.useState(!1),R=r.useRef(null),H=r.useRef(null),ae=i.pathname==="/"||i.pathname==="/chat"||i.pathname.startsWith("/chat/"),{data:F}=M({queryKey:["ticket",m],queryFn:()=>g.tickets.get(m,!1),enabled:n.type==="ticket-detail"&&!!m}),{data:V}=M({queryKey:["project",m],queryFn:()=>g.projects.get(m),enabled:n.type==="project-detail"&&!!m}),{data:S}=M({queryKey:["chat-providers"],queryFn:()=>g.chat.providers(),staleTime:6e4}),{data:$}=M({queryKey:["chat","models"],queryFn:()=>g.chat.models(),staleTime:6e4}),[y,K]=r.useState(()=>typeof window<"u"&&localStorage.getItem("profclaw-floating-chat-model")||""),re=t=>{K(t),localStorage.setItem("profclaw-floating-chat-model",t)},T=r.useMemo(()=>$?.aliases||[],[$]),h=r.useMemo(()=>S?.providers||[],[S]),_=r.useMemo(()=>new Set(h.map(t=>t.type)),[h]),G=r.useMemo(()=>T.filter(t=>_.has(t.provider)).reduce((t,s)=>{const c=s.provider;return(!t[c]||s.alias.length<t[c].alias.length)&&(t[c]=s),t},{}),[T,_]),v=r.useMemo(()=>Object.values(G).sort((t,s)=>{const c=h.find(u=>u.type===t.provider)?.healthy?1:0;return(h.find(u=>u.type===s.provider)?.healthy?1:0)-c||t.provider.localeCompare(s.provider)}),[G,h]);r.useEffect(()=>{if(!y&&v.length>0){const t=v.find(s=>h.find(c=>c.type===s.provider)?.healthy);t&&K(t.alias)}},[y,v,h]);const N=Pe(n.type,m);r.useEffect(()=>{p&&(async()=>{const s=localStorage.getItem(N);if(s){P(!0);try{const c=await g.chat.conversations.get(s);k(s);const d=c.messages.filter(l=>l.role!=="system").map(l=>({id:l.id,role:l.role,content:l.content,timestamp:new Date(l.createdAt),model:l.model,provider:l.provider,toolCalls:l.toolCalls?.map(le=>({...le,status:"success"}))}));f(d);const u=d.filter(l=>l.role==="assistant").pop();u?.model&&z(u.model)}catch{localStorage.removeItem(N),k(null),f([])}finally{P(!1)}}else k(null),f([])})()},[N,p]),r.useEffect(()=>{R.current?.scrollIntoView({behavior:"smooth"})},[w]),r.useEffect(()=>{p&&!j&&setTimeout(()=>H.current?.focus(),100)},[p,j]);const ne=U({mutationFn:async()=>{const t=`${n.name} Chat`;return(await g.chat.conversations.create({title:t,presetId:"profclaw-assistant",ticketId:n.type==="ticket-detail"?m:void 0,projectId:n.type==="project-detail"?m:void 0})).conversation.id},onSuccess:t=>{k(t),localStorage.setItem(N,t)}}),A=U({mutationFn:async t=>{let s=D;s||(s=await ne.mutateAsync());const c={id:`user-${Date.now()}`,role:"user",content:t,timestamp:new Date};f(l=>[...l,c]);const d=`assistant-${Date.now()}`;f(l=>[...l,{id:d,role:"assistant",content:"",timestamp:new Date,isLoading:!0}]);const u=await g.chat.conversations.sendMessageWithTools(s,{content:t,enableTools:!0,model:y||void 0});return{loadingId:d,response:u}},onSuccess:({loadingId:t,response:s})=>{s.assistantMessage.model&&z(s.assistantMessage.model),f(c=>c.map(d=>d.id===t?{...d,id:s.assistantMessage.id,content:s.assistantMessage.content,isLoading:!1,model:s.assistantMessage.model,provider:s.assistantMessage.provider,toolCalls:s.assistantMessage.toolCalls?.map(u=>({...u,status:"success"}))}:d)),s.assistantMessage.toolCalls?.length&&(a.invalidateQueries({queryKey:["tickets"]}),a.invalidateQueries({queryKey:["projects"]}),a.invalidateQueries({queryKey:["tasks"]}))},onError:t=>{f(s=>[...s.filter(d=>!d.isLoading),{id:`error-${Date.now()}`,role:"assistant",content:`Sorry, I encountered an error: ${t instanceof Error?t.message:"Unknown error"}`,timestamp:new Date}])}}),O=()=>{if(!b.trim()||A.isPending)return;const t=b.trim();q(""),A.mutate(t)},ie=t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),O())},oe=async()=>{if(D){try{await g.chat.conversations.delete(D)}catch{}localStorage.removeItem(N),k(null)}f([]),z(null)},B=n.icon;return ae?null:e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{className:x("fixed z-50 flex flex-col overflow-hidden transition-all duration-300 ease-out","bottom-24 right-4 sm:right-6","glass-heavy","rounded-[2rem] shadow-2xl shadow-primary/10",C?"w-[calc(100vw-2rem)] sm:w-130 md:w-150 lg:w-170 h-[72vh] sm:h-155 md:h-180":"w-[calc(100vw-2rem)] sm:w-105 md:w-120 h-[62vh] sm:h-140 md:h-155"),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative h-9 w-9 rounded-xl glass-heavy flex items-center justify-center shadow-lg shadow-primary/5",children:[e.jsx(W,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"absolute -top-1.5 -right-1.5 px-1.5 py-0.5 text-[8px] font-black uppercase rounded-lg bg-primary text-primary-foreground leading-none shadow-sm",children:"Beta"})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-black tracking-tight uppercase tracking-[0.1em]",children:"profClaw Assistant"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-muted-foreground font-semibold",children:[e.jsx(B,{className:"h-3 w-3"}),e.jsx("span",{className:"uppercase tracking-widest",children:n.name}),m&&F&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",F.sequence]}),m&&V&&e.jsxs("span",{className:"text-sky-600 dark:text-sky-400",children:["• ",V.key]})]})]})]}),v.length>0&&e.jsxs(de,{children:[e.jsx(me,{asChild:!0,children:e.jsxs("button",{className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-xl text-[10px] font-bold bg-primary/10 hover:bg-primary/20 transition-all shadow-sm",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",h.find(t=>t.type===T.find(s=>s.alias===y)?.provider)?.healthy?"bg-emerald-500 shadow-[0_0_8px_var(--success)]":"bg-amber-400 shadow-[0_0_8px_var(--warning)]")}),e.jsx(X,{className:"h-3.5 w-3.5 text-primary"}),e.jsx("span",{className:"capitalize max-w-20 truncate text-primary font-black",children:y||L||"Model"}),e.jsx(pe,{className:"h-3 w-3 text-primary opacity-50"})]})}),e.jsxs(ue,{align:"end",className:"w-52 glass-heavy shadow-2xl",children:[e.jsx("div",{className:"px-2 py-1.5 text-[9px] font-medium text-muted-foreground uppercase tracking-wider",children:"Select Model"}),e.jsx(he,{}),v.map(t=>{const c=h.find(l=>l.type===t.provider)?.healthy,d=(y||L)===t.alias,u=t.provider==="ollama";return e.jsxs(fe,{onClick:()=>re(t.alias),className:x("flex items-center justify-between cursor-pointer text-xs py-2",d&&"bg-primary/20"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:x("h-1.5 w-1.5 rounded-full",c?"bg-emerald-500":"bg-amber-400")}),e.jsx("span",{className:x("capitalize font-bold",d&&"text-primary"),children:t.alias})]}),e.jsx("span",{className:"text-[9px] text-muted-foreground",children:u?"Local":t.provider})]},t.alias)})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[w.length>0&&e.jsx(I,{variant:"ghost",size:"sm",onClick:oe,className:"h-7 w-7 p-0",title:"Clear chat",children:e.jsx(De,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>se(!C),className:"h-7 w-7 p-0",title:C?"Minimize":"Expand",children:C?e.jsx(Me,{className:"h-3.5 w-3.5"}):e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>E(!1),className:"h-7 w-7 p-0",title:"Close",children:e.jsx(xe,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3.5 scrollbar-none liquid-fade-y",children:[j?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full",children:[e.jsx(ge,{className:"h-6 w-6 animate-spin text-sky-500 mb-2"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading conversation..."})]}):w.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center px-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-xl bg-sky-500/10 flex items-center justify-center mb-3",children:e.jsx(B,{className:"h-6 w-6 text-sky-500"})}),e.jsxs("h4",{className:"text-sm font-medium mb-1",children:[n.name," Assistant"]}),e.jsxs("p",{className:"text-xs text-muted-foreground mb-4 max-w-70",children:[n.description,". How can I help?"]}),e.jsxs("div",{className:"w-full space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide",children:"Quick Actions"}),e.jsx("div",{className:"flex flex-col gap-2",children:n.quickActions.map(t=>e.jsx("button",{onClick:()=>{q(t.prompt),setTimeout(()=>H.current?.focus(),0)},className:"px-3 py-2 text-xs text-left rounded-lg bg-muted/50 hover:bg-muted transition-colors border border-transparent hover:border-border",children:t.label},t.label))})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border w-full",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-wide mb-2",children:"I can help you"}),e.jsx("ul",{className:"text-[11px] text-muted-foreground text-left space-y-1",children:n.capabilities.slice(0,3).map((t,s)=>e.jsxs("li",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-sky-500 mt-0.5",children:"•"}),t]},s))})]}),S?.default&&e.jsxs("div",{className:"mt-4 pt-2 text-[10px] text-muted-foreground/70 flex items-center gap-1",children:[e.jsx(X,{className:"h-3 w-3"}),e.jsxs("span",{children:["Powered by ",S.default]})]})]}):w.map(t=>e.jsxs("div",{className:x("flex gap-3",t.role==="user"?"justify-end":"justify-start"),children:[t.role==="assistant"&&e.jsx("div",{className:"h-7 w-7 rounded-full bg-zinc-100 dark:bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx(ee,{className:"h-4 w-4 text-zinc-500"})}),e.jsx("div",{className:x("max-w-[85%] rounded-[1.5rem] px-5 py-3.5 text-[14px] leading-relaxed shadow-lg transition-all",t.role==="user"?"bg-primary text-primary-foreground rounded-tr-sm ml-auto shadow-primary/10":"glass text-foreground rounded-tl-sm shadow-sm",t.role==="assistant"&&"mr-auto"),children:t.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-0"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-150"}),e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-zinc-400 dark:bg-zinc-600 animate-bounce delay-300"})]}):t.role==="assistant"?e.jsxs(e.Fragment,{children:[e.jsx(qe,{content:t.content}),t.toolCalls&&t.toolCalls.length>0&&e.jsx("div",{className:"mt-2 space-y-1",children:t.toolCalls.map(s=>e.jsx(Fe,{toolCall:s},s.id))})]}):e.jsx("p",{className:"whitespace-pre-wrap",children:t.content})}),t.role==="user"&&e.jsx("div",{className:"h-8 w-8 rounded-xl glass-heavy flex items-center justify-center shrink-0 shadow-lg",children:e.jsx(ye,{className:"h-4.5 w-4.5 text-primary"})})]},t.id)),e.jsx("div",{ref:R})]}),e.jsxs("div",{className:"p-4 bg-primary/5",children:[e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{ref:H,value:b,onChange:t=>q(t.target.value),onKeyDown:ie,placeholder:`Ask about ${n.name.toLowerCase()}...`,rows:1,disabled:j,className:"flex-1 px-4 py-3 text-sm glass rounded-[1.5rem] resize-none focus:outline-none focus:ring-1 focus:ring-primary/20 focus:bg-white/50 dark:focus:bg-black/50 min-h-11 max-h-32 placeholder:text-muted-foreground/50 disabled:opacity-50 transition-all font-medium",style:{height:"auto",overflow:b.split(`
2
+ `).length>3?"auto":"hidden"},onInput:t=>{const s=t.target;s.style.height="auto",s.style.height=Math.min(s.scrollHeight,120)+"px"}}),e.jsx(I,{onClick:O,disabled:!b.trim()||A.isPending||j,size:"sm",className:"h-11 w-11 p-0 rounded-2xl bg-primary hover:bg-primary-hover text-primary-foreground shadow-xl shadow-primary/20 hover:scale-110 active:scale-95 transition-all",children:A.isPending?e.jsx(te,{className:"h-4 w-4 animate-spin"}):e.jsx(ze,{className:"h-4 w-4"})})]}),e.jsxs("p",{className:"text-[10px] text-muted-foreground text-center mt-2 font-medium opacity-60",children:["Press Enter to send • Shift+Enter for new line",w.length>0&&" • Session auto-saved"]})]})]}),e.jsx("button",{onClick:()=>E(!p),className:x("fixed bottom-6 right-6 z-50 h-[60px] w-[60px] rounded-[1.5rem] flex items-center justify-center transition-all duration-300 ease-out hover:scale-110 active:scale-90 shadow-2xl",p?"glass-heavy text-primary shadow-primary/10":"bg-primary text-primary-foreground shadow-primary/30"),title:p?"Close chat":`Open profClaw Assistant (${n.name})`,children:p?e.jsx(He,{className:"h-6 w-6"}):e.jsx(W,{className:"h-6 w-6"})})]})}export{Ze as FloatingChatbot,Ze as default};
@@ -0,0 +1,2 @@
1
+ import{c as pe,n as je,r as a,u as q,o as C,t as r,j as e,U as O,af as fe,k as n,R as Ne,i as Q,P as B,L as D,w as we,g as ve,D as be,x as ye,y as Ce,bo as De,aw as F,z as $,Q as k,C as S,O as K}from"./index-kb4AJXUB.js";import{A as U,a as H,b as _,c as J,d as V,e as X,f as Y,g as W}from"./alert-dialog-BOmnTkN-.js";import{G as Z}from"./globe-CCspjvus.js";import{E as ke}from"./ellipsis-NuUWekvu.js";import{T as Se}from"./trash-2-B4oAXsX-.js";import{C as Ae}from"./circle-x-BN89YhbS.js";const Me=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],ee=pe("lock",Me),Te="http://localhost:3000";async function x(t,l={}){const i=await fetch(`${Te}/api/users${t}`,{...l,headers:{"Content-Type":"application/json",...l.headers},credentials:"include"});if(!i.ok){const g=await i.json().catch(()=>({error:"Unknown error"}));throw new Error(g.error||`HTTP ${i.status}`)}return i.json()}const m={list:()=>x("/admin/invites"),generate:t=>x("/admin/invites",{method:"POST",body:JSON.stringify(t)}),delete:t=>x(`/admin/invites/${t}`,{method:"DELETE"}),getRegistrationMode:()=>x("/admin/registration-mode"),setRegistrationMode:t=>x("/admin/registration-mode",{method:"PATCH",body:JSON.stringify({mode:t})})};function Pe(){const t=je(),[l,i]=a.useState(""),[g,p]=a.useState(!1),[se,A]=a.useState(!1),[u,te]=a.useState([]),[M,T]=a.useState(1),[I,L]=a.useState(""),[j,E]=a.useState(""),[G,R]=a.useState(null),[f,N]=a.useState(null),[ae,w]=a.useState(!1),{data:c,isLoading:v,error:z,refetch:ne}=q({queryKey:["admin","inviteCodes"],queryFn:()=>m.list()}),{data:d}=q({queryKey:["admin","registrationMode"],queryFn:()=>m.getRegistrationMode()}),b=C({mutationFn:m.generate,onSuccess:s=>{te(s.codes),p(!1),A(!0),T(1),L(""),E(""),t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success(`Generated ${s.codes.length} invite code(s)`)},onError:s=>r.error(s.message)}),le=C({mutationFn:m.delete,onSuccess:()=>{t.invalidateQueries({queryKey:["admin","inviteCodes"]}),r.success("Invite code deleted")},onError:s=>r.error(s.message)}),h=C({mutationFn:s=>m.setRegistrationMode(s),onSuccess:s=>{t.invalidateQueries({queryKey:["admin","registrationMode"]}),r.success(`Registration mode set to ${s.mode}`)},onError:s=>r.error(s.message)}),y=(s,o)=>{navigator.clipboard.writeText(s),R(o),setTimeout(()=>R(null),2e3),r.success(`${o} copied`)},re=s=>s.usedBy?{label:"Used",color:"bg-zinc-500/10 text-zinc-500",icon:S}:s.expiresAt&&new Date>new Date(s.expiresAt)?{label:"Expired",color:"bg-red-500/10 text-red-500",icon:Ae}:{label:"Available",color:"bg-green-500/10 text-green-500",icon:S},P=c?.invites?.filter(s=>(s.label||"").toLowerCase().includes(l.toLowerCase())||s.id.toLowerCase().includes(l.toLowerCase())||(s.createdBy||"").toLowerCase().includes(l.toLowerCase()))||[],ie=()=>{b.mutate({count:M,label:I||void 0,expiresInDays:j?parseInt(j,10):void 0})},de=s=>{N(s)},oe=()=>{f&&(le.mutate(f.id),N(null))},ce=()=>{const s=d?.mode==="invite"?"open":"invite";if(s==="open"){w(!0);return}h.mutate(s)},xe=()=>{h.mutate("open"),w(!1)},me=c?.invites?.filter(s=>!s.usedBy&&(!s.expiresAt||new Date<=new Date(s.expiresAt))).length||0,ue=c?.invites?.filter(s=>s.usedBy).length||0,he=c?.invites?.filter(s=>!s.usedBy&&s.expiresAt&&new Date>new Date(s.expiresAt)).length||0;return z?e.jsx("div",{className:"p-6",children:e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx(O,{className:"h-12 w-12 text-destructive mb-4"}),e.jsx("h2",{className:"text-xl font-semibold mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-muted-foreground",children:z.message})]})}):e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-3",children:[e.jsx(fe,{className:"h-6 w-6"}),"Invite Codes"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Generate and manage invite codes for user registration"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(n,{variant:"outline",onClick:()=>ne(),disabled:v,className:"rounded-xl",children:[e.jsx(Ne,{className:Q("h-4 w-4 mr-2",v&&"animate-spin")}),"Refresh"]}),e.jsxs(n,{onClick:()=>p(!0),className:"rounded-xl",children:[e.jsx(B,{className:"h-4 w-4 mr-2"}),"Generate Codes"]})]})]}),e.jsxs("div",{className:"rounded-2xl glass shadow-lg p-4 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[d?.mode==="invite"?e.jsx("div",{className:"h-10 w-10 rounded-full bg-amber-500/10 flex items-center justify-center",children:e.jsx(ee,{className:"h-5 w-5 text-amber-500"})}):e.jsx("div",{className:"h-10 w-10 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(Z,{className:"h-5 w-5 text-green-500"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium",children:["Registration Mode: ",e.jsx("span",{className:"capitalize",children:d?.mode||"..."})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:d?.mode==="invite"?"New users need an invite code to sign up":"Anyone can sign up without an invite code"})]})]}),e.jsxs(n,{variant:"outline",onClick:ce,disabled:h.isPending,className:"rounded-xl",children:[h.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin mr-2"}):d?.mode==="invite"?e.jsx(Z,{className:"h-4 w-4 mr-2"}):e.jsx(ee,{className:"h-4 w-4 mr-2"}),"Switch to ",d?.mode==="invite"?"Open":"Invite"]})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(we,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx("input",{type:"text",placeholder:"Search by label or ID...",value:l,onChange:s=>i(s.target.value),className:"w-full pl-10 pr-4 py-2 field-lg"})]}),e.jsx("div",{className:"rounded-2xl glass shadow-lg overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/5 bg-muted/30",children:[e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Label"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Status"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Expires"}),e.jsx("th",{className:"text-left p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Created"}),e.jsx("th",{className:"text-right p-4 text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Actions"})]})}),e.jsx("tbody",{children:v?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center",children:e.jsx(D,{className:"h-6 w-6 animate-spin mx-auto text-muted-foreground"})})}):P.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"p-8 text-center text-muted-foreground",children:l?"No matching invite codes":"No invite codes yet. Generate some to get started."})}):P.map(s=>{const o=re(s),ge=o.icon;return e.jsxs("tr",{className:"border-b border-white/5 last:border-0 hover:bg-muted/20 transition-colors",children:[e.jsx("td",{className:"p-4",children:e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.label||e.jsx("span",{className:"text-muted-foreground",children:"No label"})}),e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:[s.id.slice(0,8),"..."]})]})}),e.jsx("td",{className:"p-4",children:e.jsxs("span",{className:Q("inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold",o.color),children:[e.jsx(ge,{className:"h-3 w-3"}),o.label]})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.expiresAt?e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(ve,{className:"h-3.5 w-3.5"}),new Date(s.expiresAt).toLocaleDateString()]}):e.jsx("span",{className:"text-muted-foreground/50",children:"Never"})}),e.jsx("td",{className:"p-4 text-sm text-muted-foreground",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"-"}),e.jsx("td",{className:"p-4",children:e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs(be,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(n,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-lg",children:e.jsx(ke,{className:"h-4 w-4"})})}),e.jsxs(Ce,{align:"end",className:"w-48",children:[e.jsx(De,{children:"Actions"}),e.jsx(F,{}),e.jsxs($,{onClick:()=>y(s.id,"ID"),children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy ID"]}),e.jsx(F,{}),e.jsxs($,{onClick:()=>de(s),className:"text-destructive focus:text-destructive",children:[e.jsx(Se,{className:"h-4 w-4 mr-2"}),"Delete"]})]})]})})})]},s.id)})})]})})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total"}),e.jsx("p",{className:"text-2xl font-bold",children:c?.total||0})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Available"}),e.jsx("p",{className:"text-2xl font-bold text-green-500",children:me})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Used"}),e.jsx("p",{className:"text-2xl font-bold text-zinc-500",children:ue})]}),e.jsxs("div",{className:"p-4 rounded-2xl glass shadow-lg",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Expired"}),e.jsx("p",{className:"text-2xl font-bold text-red-500",children:he})]})]}),g&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(B,{className:"h-6 w-6 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Generate Invite Codes"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create new codes for user registration"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Number of codes"}),e.jsx("input",{type:"number",min:1,max:50,value:M,onChange:s=>T(Math.min(50,Math.max(1,parseInt(s.target.value,10)||1))),className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Label (optional)"}),e.jsx("input",{type:"text",value:I,onChange:s=>L(s.target.value),placeholder:'e.g., "For onboarding batch 2"',className:"w-full field-lg"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium mb-1 block",children:"Expires in (days, optional)"}),e.jsx("input",{type:"number",min:1,max:365,value:j,onChange:s=>E(s.target.value),placeholder:"e.g., 7",className:"w-full field-lg"})]}),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsx(n,{variant:"outline",className:"flex-1 rounded-xl",onClick:()=>p(!1),children:"Cancel"}),e.jsx(n,{className:"flex-1 rounded-xl",onClick:ie,disabled:b.isPending,children:b.isPending?e.jsx(D,{className:"h-4 w-4 animate-spin"}):"Generate"})]})]})]})}),e.jsx(U,{open:!!f,onOpenChange:s=>!s&&N(null),children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Delete Invite Code"}),e.jsx(V,{children:"Are you sure you want to delete this invite code? This action cannot be undone."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:oe,className:"rounded-xl bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),e.jsx(U,{open:ae,onOpenChange:w,children:e.jsxs(H,{children:[e.jsxs(_,{children:[e.jsx(J,{children:"Switch to Open Registration?"}),e.jsx(V,{children:"Anyone will be able to sign up without an invite code. You can switch back to invite-only at any time."})]}),e.jsxs(X,{children:[e.jsx(Y,{className:"rounded-xl",children:"Cancel"}),e.jsx(W,{onClick:xe,className:"rounded-xl",children:"Switch to Open"})]})]})}),se&&u.length>0&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 backdrop-blur-sm",children:e.jsxs("div",{className:"glass-heavy rounded-2xl shadow-2xl w-full max-w-md mx-4 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-12 w-12 rounded-full bg-green-500/10 flex items-center justify-center",children:e.jsx(S,{className:"h-6 w-6 text-green-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold",children:"Invite Codes Generated"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[u.length," code(s) ready to share"]})]})]}),e.jsx("div",{className:"space-y-2 max-h-64 overflow-y-auto",children:u.map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-xl bg-muted/30",children:[e.jsx("code",{className:"flex-1 font-mono text-sm font-semibold",children:s.code}),e.jsx(n,{size:"sm",variant:"ghost",className:"h-8 w-8 p-0",onClick:()=>y(s.code,s.id),children:G===s.id?e.jsx(K,{className:"h-4 w-4 text-green-500"}):e.jsx(k,{className:"h-4 w-4"})})]},s.id))}),e.jsxs(n,{size:"sm",variant:"outline",className:"w-full mt-3 rounded-xl",onClick:()=>y(u.map(s=>s.code).join(`
2
+ `),"all-codes"),children:[G==="all-codes"?e.jsx(K,{className:"h-4 w-4 mr-2 text-green-500"}):e.jsx(k,{className:"h-4 w-4 mr-2"}),"Copy All"]}),e.jsxs("p",{className:"text-xs text-amber-500 flex items-start gap-2 mt-3",children:[e.jsx(O,{className:"h-4 w-4 flex-shrink-0 mt-0.5"}),"Save these codes now. They cannot be retrieved later."]}),e.jsx(n,{className:"w-full rounded-xl mt-3",onClick:()=>A(!1),children:"Done"})]})})]})}export{Pe as InviteCodeManagement};