@lovelybunch/api 1.0.75-alpha.8 → 1.0.75

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 (188) hide show
  1. package/dist/lib/jobs/job-runner.js +10 -2
  2. package/dist/lib/jobs/job-scheduler.js +21 -0
  3. package/dist/lib/mail/mail-runner.d.ts +51 -0
  4. package/dist/lib/mail/mail-runner.js +342 -0
  5. package/dist/lib/slack/slack-service.d.ts +2 -0
  6. package/dist/lib/slack/slack-service.js +3 -0
  7. package/dist/lib/storage/file-storage.d.ts +16 -16
  8. package/dist/lib/storage/file-storage.js +59 -64
  9. package/dist/lib/terminal/terminal-manager.d.ts +3 -5
  10. package/dist/lib/terminal/terminal-manager.js +10 -61
  11. package/dist/routes/api/v1/ai/route.js +361 -20
  12. package/dist/routes/api/v1/chats/[id]/index.js +2 -1
  13. package/dist/routes/api/v1/chats/[id]/route.d.ts +7 -0
  14. package/dist/routes/api/v1/chats/[id]/route.js +30 -1
  15. package/dist/routes/api/v1/context/index.js +0 -2
  16. package/dist/routes/api/v1/git/index.js +23 -0
  17. package/dist/routes/api/v1/knowledge/[filename]/index.d.ts +1 -0
  18. package/dist/routes/api/v1/knowledge/[filename]/index.js +1 -0
  19. package/dist/routes/api/v1/knowledge/[filename]/route.d.ts +3 -0
  20. package/dist/routes/api/v1/knowledge/[filename]/route.js +254 -0
  21. package/dist/routes/api/v1/knowledge/index.d.ts +1 -0
  22. package/dist/routes/api/v1/knowledge/index.js +1 -0
  23. package/dist/routes/api/v1/knowledge/route.d.ts +3 -0
  24. package/dist/routes/api/v1/knowledge/route.js +176 -0
  25. package/dist/routes/api/v1/mail/index.d.ts +3 -0
  26. package/dist/routes/api/v1/mail/index.js +23 -0
  27. package/dist/routes/api/v1/mail/route.d.ts +294 -0
  28. package/dist/routes/api/v1/mail/route.js +344 -0
  29. package/dist/routes/api/v1/mcp/index.js +109 -34
  30. package/dist/routes/api/v1/slack/index.d.ts +3 -0
  31. package/dist/routes/api/v1/slack/index.js +15 -0
  32. package/dist/routes/api/v1/slack/route.d.ts +124 -0
  33. package/dist/routes/api/v1/slack/route.js +192 -0
  34. package/dist/routes/api/v1/tasks/[id]/route.d.ts +117 -0
  35. package/dist/routes/api/v1/tasks/[id]/route.js +166 -0
  36. package/dist/routes/api/v1/tasks/index.d.ts +3 -0
  37. package/dist/routes/api/v1/tasks/index.js +10 -0
  38. package/dist/routes/api/v1/tasks/route.d.ts +96 -0
  39. package/dist/routes/api/v1/tasks/route.js +136 -0
  40. package/dist/routes/api/v1/terminal/[proposalId]/create/route.js +2 -2
  41. package/dist/routes/api/v1/terminal/[taskId]/create/index.d.ts +3 -0
  42. package/dist/routes/api/v1/terminal/[taskId]/create/index.js +5 -0
  43. package/dist/routes/api/v1/terminal/[taskId]/create/route.d.ts +10 -0
  44. package/dist/routes/api/v1/terminal/[taskId]/create/route.js +27 -0
  45. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.d.ts +3 -0
  46. package/dist/routes/api/v1/terminal/[taskId]/destroy/index.js +5 -0
  47. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.d.ts +10 -0
  48. package/dist/routes/api/v1/terminal/[taskId]/destroy/route.js +21 -0
  49. package/dist/routes/api/v1/terminal/[taskId]/resize/index.d.ts +3 -0
  50. package/dist/routes/api/v1/terminal/[taskId]/resize/index.js +5 -0
  51. package/dist/routes/api/v1/terminal/[taskId]/resize/route.d.ts +10 -0
  52. package/dist/routes/api/v1/terminal/[taskId]/resize/route.js +21 -0
  53. package/dist/routes/api/v1/terminal/sessions/route.js +4 -4
  54. package/dist/server-with-static.js +14 -8
  55. package/dist/server.js +14 -8
  56. package/package.json +4 -4
  57. package/static/assets/{ActivityPage-DSSML9J-.js → ActivityPage-k4I7Q53O.js} +1 -1
  58. package/static/assets/ApiKeysSettingsPage-B1YvVdmg.js +2 -0
  59. package/static/assets/{ArchitectureEditPage-CIjqkpMz.js → ArchitectureEditPage-CpowsIx2.js} +1 -1
  60. package/static/assets/{ArchitecturePage-Db__w054.js → ArchitecturePage-DYxC_aMR.js} +1 -1
  61. package/static/assets/{AuthSettingsPage-Bpooi8Z0.js → AuthSettingsPage-DtSo78Y_.js} +2 -2
  62. package/static/assets/{CallbackPage-BGLKeyjv.js → CallbackPage-bROCGapx.js} +1 -1
  63. package/static/assets/CodePage-CPCj64rX.js +2 -0
  64. package/static/assets/{CollapsibleSection-B6RO5o5R.js → CollapsibleSection-M5cXbl92.js} +1 -1
  65. package/static/assets/DashboardPage-B9BZZfw6.js +51 -0
  66. package/static/assets/{GitPage-DxjLaRWe.js → GitPage-BiDtdSK1.js} +2 -2
  67. package/static/assets/GitSettingsPage-THm6wDjs.js +6 -0
  68. package/static/assets/IdentityPage-BC16skg6.js +6 -0
  69. package/static/assets/{ImplementationStepsEditor-DWjDyZzP.js → ImplementationStepsEditor-HliLQav5.js} +2 -2
  70. package/static/assets/IntegrationsSettingsPage-CC_VKIQa.js +1 -0
  71. package/static/assets/JobDetailPage-z1QQYvmU.js +1 -0
  72. package/static/assets/KnowledgeDetailPage-DzHXBS7Q.js +1 -0
  73. package/static/assets/KnowledgeEditPage-BwGnUH_m.js +1 -0
  74. package/static/assets/KnowledgePage-CGIVMS02.js +3 -0
  75. package/static/assets/{LoginPage-DptfKsWo.js → LoginPage-VQ3lcfLV.js} +1 -1
  76. package/static/assets/MailInboxPage-DiZKqwdU.js +1 -0
  77. package/static/assets/MailProcessingModal-DIeSQBoR.js +6 -0
  78. package/static/assets/MailReadPage-C8AACmZQ.js +1 -0
  79. package/static/assets/MailSentPage-C_5yFly_.js +1 -0
  80. package/static/assets/McpSettingsPage-i9YHcu1s.js +1 -0
  81. package/static/assets/NewKnowledgePage-BnVY7WUD.js +9 -0
  82. package/static/assets/{NewSkillPage-Cwy2MSr9.js → NewSkillPage-DwniHD6D.js} +1 -1
  83. package/static/assets/NewTaskPage-F5UX2WMc.js +90 -0
  84. package/static/assets/NotFoundPage-BbSZX_4L.js +6 -0
  85. package/static/assets/NotificationsSettingsPage-C8kjcift.js +1 -0
  86. package/static/assets/ProjectEditPage-DUUlIEqI.js +11 -0
  87. package/static/assets/{ProjectPage-DgUr4bVU.js → ProjectPage-Unz9PQpA.js} +1 -1
  88. package/static/assets/PromptsSettingsPage-DVpIuRKI.js +1 -0
  89. package/static/assets/ResourceDetailPage-DqHZ2KYD.js +1 -0
  90. package/static/assets/ResourcesPage-BP5tuAi-.js +41 -0
  91. package/static/assets/RoleEditPage-BgKu8S0-.js +13 -0
  92. package/static/assets/{RolePage-Sc-GFiL2.js → RolePage-Fed52Ov5.js} +1 -1
  93. package/static/assets/{RulesSettingsPage-DdMCzh9j.js → RulesSettingsPage-BQ2O0u66.js} +2 -2
  94. package/static/assets/SchedulePage-jkxjuzBx.js +4 -0
  95. package/static/assets/SkillDetailPage-k3Q2-NFd.js +1 -0
  96. package/static/assets/{SkillEditPage-BDd2CtAS.js → SkillEditPage-urF4snjo.js} +1 -1
  97. package/static/assets/SkillsPage-DlWDhEjR.js +8 -0
  98. package/static/assets/{SkillsSettingsPage-1N0JQOYc.js → SkillsSettingsPage-BViFgckG.js} +1 -1
  99. package/static/assets/SourceInput-CAFKTHw-.js +1 -0
  100. package/static/assets/{TagInput-D_SdcypZ.js → TagInput-C6lI-ePr.js} +1 -1
  101. package/static/assets/TaskDetailPage-DpbRHnW_.js +16 -0
  102. package/static/assets/TaskEditPage-DssRbW0h.js +1 -0
  103. package/static/assets/TasksPage-CD_eo0Bj.js +17 -0
  104. package/static/assets/TerminalPage-BG_wlccr.js +1 -0
  105. package/static/assets/TerminalSessionPage-CsK-LznK.js +8 -0
  106. package/static/assets/UserPreferencesPage-CWUq3efu.js +1 -0
  107. package/static/assets/UserSettingsPage-CduI_MGS.js +1 -0
  108. package/static/assets/UtilitiesPage-BAxokhLh.js +1 -0
  109. package/static/assets/{alert-BD5jo3SI.js → alert-BXsc6_qu.js} +1 -1
  110. package/static/assets/{arrow-down-BxcoVp6S.js → arrow-down-DmW_3gE8.js} +1 -1
  111. package/static/assets/{arrow-left-CdM_IPng.js → arrow-left-1S-835kP.js} +1 -1
  112. package/static/assets/{arrow-up-BOJ6ob9X.js → arrow-up-BYism_o1.js} +1 -1
  113. package/static/assets/arrow-up-down-Dw3J0a4i.js +6 -0
  114. package/static/assets/{badge-DEiQk9C9.js → badge-BUEY53dV.js} +1 -1
  115. package/static/assets/{browser-modal-Dp1eMxt6.js → browser-modal-DCNdI4NT.js} +2 -2
  116. package/static/assets/{card-BCFxXzRk.js → card-BcPlIAH5.js} +1 -1
  117. package/static/assets/{chevron-left-C25izNzZ.js → chevron-left-FMmNe7yP.js} +1 -1
  118. package/static/assets/{plus-iamYJu5V.js → chevron-up-CqM3won3.js} +2 -2
  119. package/static/assets/{chevrons-up-DqbWMOjv.js → chevrons-up-DTvCkIHc.js} +1 -1
  120. package/static/assets/{circle-alert-CMRMPnbY.js → circle-alert-dseM-Ib7.js} +1 -1
  121. package/static/assets/{circle-check-big-NI18oHuP.js → circle-check-big-jKg34xC-.js} +1 -1
  122. package/static/assets/{circle-check-D5wZZPvj.js → circle-check-eyo6pBP1.js} +1 -1
  123. package/static/assets/{circle-play-BhVU869u.js → circle-play-BrY_lNiH.js} +1 -1
  124. package/static/assets/{circle-x-BXDB-G_q.js → circle-x-uqmzEce1.js} +1 -1
  125. package/static/assets/{clipboard-DC2xmNVx.js → clipboard-tzPFoieb.js} +1 -1
  126. package/static/assets/{clock-CeCp7Pz1.js → clock-Bjc06QBM.js} +1 -1
  127. package/static/assets/code-DrYqPukx.js +6 -0
  128. package/static/assets/{download-ZF_XbTIA.js → download-Bg__QCLT.js} +1 -1
  129. package/static/assets/{external-link-CYBz87-P.js → external-link-CNDy2UUo.js} +1 -1
  130. package/static/assets/{eye-BT8MAvKY.js → eye-DLFBnC8t.js} +1 -1
  131. package/static/assets/{folder-git-2-BE9AIPnj.js → folder-git-2-DUqd0WRi.js} +1 -1
  132. package/static/assets/index-CHdBxVyk.css +2 -0
  133. package/static/assets/index-DFcWlnzl.js +487 -0
  134. package/static/assets/{info-DunFSp-x.js → info-D6jxZC5X.js} +1 -1
  135. package/static/assets/kiro-CX1mOsRO.js +17 -0
  136. package/static/assets/{label-vYhfrPMD.js → label-DBuh-ke5.js} +1 -1
  137. package/static/assets/{markdown-editor-BzZ8tCto.js → markdown-editor-B4YNQFT2.js} +1 -1
  138. package/static/assets/message-square-B5RWz_ff.js +6 -0
  139. package/static/assets/paperclip-4A_3MaPx.js +6 -0
  140. package/static/assets/{pause-BHonpdnw.js → pause-BzhKXHtR.js} +1 -1
  141. package/static/assets/{play-CCo7tau2.js → play-CHIf-Rcz.js} +1 -1
  142. package/static/assets/{radio-group-Db-pBuyW.js → radio-group-C1ct-VsJ.js} +1 -1
  143. package/static/assets/{refresh-cw-Bg7vQzOw.js → refresh-cw-B3OwrDUf.js} +1 -1
  144. package/static/assets/{search-CH2zaibZ.js → search-Cq1ksEdp.js} +1 -1
  145. package/static/assets/select-44mcS2_G.js +1 -0
  146. package/static/assets/{status-utils-BDOyevaX.js → status-utils-CDkPeVfP.js} +1 -1
  147. package/static/assets/{switch-CH-VOgPo.js → switch-CIwjYvCt.js} +1 -1
  148. package/static/assets/{tabs-XeRAjZYR.js → tabs-DTV6Su-h.js} +1 -1
  149. package/static/assets/{tag-CRP5nL5-.js → tag-p6yeowCW.js} +1 -1
  150. package/static/assets/{terminal-preview-DMJMuORo.js → terminal-preview-DN38x9Jm.js} +1 -1
  151. package/static/assets/use-terminal-BXJqOeJe.js +1 -0
  152. package/static/assets/video-BH5ChaoS.js +36 -0
  153. package/static/index.html +2 -2
  154. package/static/assets/ApiKeysSettingsPage-Chw9PNL5.js +0 -2
  155. package/static/assets/CodePage-CrokcH-S.js +0 -2
  156. package/static/assets/DashboardPage-BaSQQ8Nv.js +0 -41
  157. package/static/assets/GitSettingsPage-tKBXYAFm.js +0 -6
  158. package/static/assets/IdentityPage-D2yBjeYn.js +0 -11
  159. package/static/assets/IntegrationsSettingsPage-Bx8-0Ig4.js +0 -1
  160. package/static/assets/JobDetailPage-BQmTHled.js +0 -1
  161. package/static/assets/KnowledgeDetailPage-QMU2bC3L.js +0 -1
  162. package/static/assets/KnowledgeEditPage-DbMJVcLc.js +0 -1
  163. package/static/assets/KnowledgePage-aU1GxZSZ.js +0 -8
  164. package/static/assets/McpSettingsPage-C3WxFwRB.js +0 -1
  165. package/static/assets/NewKnowledgePage-Cbiswrw_.js +0 -9
  166. package/static/assets/NewProposalPage-B_sDMBTK.js +0 -90
  167. package/static/assets/ProjectEditPage-BznWiBBc.js +0 -11
  168. package/static/assets/PromptsSettingsPage-CY0-870a.js +0 -1
  169. package/static/assets/ProposalDetailPage-K4iMXHEg.js +0 -1
  170. package/static/assets/ProposalEditPage-jZOtCMqP.js +0 -1
  171. package/static/assets/ProposalsPage-C7n4-G05.js +0 -17
  172. package/static/assets/ResourcesPage-vB5-XkUv.js +0 -71
  173. package/static/assets/RoleEditPage-Cu7ZB3yj.js +0 -13
  174. package/static/assets/SchedulePage-Bkkf2wA0.js +0 -4
  175. package/static/assets/SkillDetailPage-5sDxf3Of.js +0 -1
  176. package/static/assets/SkillsPage-D2G7EfK8.js +0 -8
  177. package/static/assets/SourceInput-DlC0zwva.js +0 -1
  178. package/static/assets/TerminalPage--KZ7azvP.js +0 -1
  179. package/static/assets/TerminalSessionPage-ClvxK9ia.js +0 -13
  180. package/static/assets/UserPreferencesPage-CheOH7jZ.js +0 -1
  181. package/static/assets/UserSettingsPage-C8STDvfQ.js +0 -1
  182. package/static/assets/UtilitiesPage-9rTxR2md.js +0 -1
  183. package/static/assets/calendar-Cx5r9R7A.js +0 -6
  184. package/static/assets/droid-DqWsM2dp.js +0 -17
  185. package/static/assets/index-DVTgTsDa.css +0 -2
  186. package/static/assets/index-hqVgTgRB.js +0 -462
  187. package/static/assets/use-terminal-DuGZuvd2.js +0 -1
  188. package/static/assets/zap-BlzMp7dY.js +0 -6
@@ -1,71 +0,0 @@
1
- import{c as oe,r as t,j as e,D as pe,b as ge,d as ve,f as je,H as le,S as is,B as R,al as os,n as Ee,a as $e,A as ae,w as ye,h as W,i as B,k as $,l as U,m as G,ag as Oe,x as me,an as ca,ao as da,ap as ua,aq as be,ar as Fe,as as _e,at as ma,au as Bs,av as ha,aw as xa,e as fa,I as We,am as Xe,X as cs,C as $s,F as we,ax as Ze,ay as pa,az as ga,aA as va,a9 as ja,aa as ya,v as ba,ab as wa,ae as Je,g as ds,V as us,aB as Na}from"./index-hqVgTgRB.js";import{C as Ye,b as ms,a as Qe,c as _a,d as Sa}from"./card-BCFxXzRk.js";import{L as C}from"./label-vYhfrPMD.js";import{B as Me}from"./badge-DEiQk9C9.js";import{c as Ca}from"./clipboard-B9ndUJKl.js";import{R as Us}from"./registry-ANRa5WBi.js";import{D as es}from"./download-ZF_XbTIA.js";import{C as zs}from"./chevron-left-C25izNzZ.js";import{C as ka}from"./calendar-Cx5r9R7A.js";import{T as Pa}from"./tag-CRP5nL5-.js";import{P as hs}from"./plus-iamYJu5V.js";import{S as Ea}from"./search-CH2zaibZ.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Ma=[["path",{d:"M17.5 22h.5a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v3",key:"rslqgf"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M2 19a2 2 0 1 1 4 0v1a2 2 0 1 1-4 0v-4a6 6 0 0 1 12 0v4a2 2 0 1 1-4 0v-1a2 2 0 1 1 4 0",key:"9f7x3i"}]],xs=oe("file-audio",Ma);/**
7
- * @license lucide-react v0.542.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Fa=[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]],ss=oe("file-code",Fa);/**
12
- * @license lucide-react v0.542.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Ia=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]],fs=oe("file-image",Ia);/**
17
- * @license lucide-react v0.542.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const Ra=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ps=oe("file-json",Ra);/**
22
- * @license lucide-react v0.542.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Ta=[["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}],["path",{d:"M15.033 13.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56v-4.704a.645.645 0 0 1 .967-.56z",key:"1tzo1f"}]],gs=oe("file-play",Ta);/**
27
- * @license lucide-react v0.542.0 - ISC
28
- *
29
- * This source code is licensed under the ISC license.
30
- * See the LICENSE file in the root directory of this source tree.
31
- */const Da=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M8 13h2",key:"yr2amv"}],["path",{d:"M14 13h2",key:"un5t4a"}],["path",{d:"M8 17h2",key:"2yhykz"}],["path",{d:"M14 17h2",key:"10kma7"}]],vs=oe("file-spreadsheet",Da);/**
32
- * @license lucide-react v0.542.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */const Ga=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M9 13v-1h6v1",key:"1bb014"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M11 18h2",key:"12mj7e"}]],js=oe("file-type",Ga);/**
37
- * @license lucide-react v0.542.0 - ISC
38
- *
39
- * This source code is licensed under the ISC license.
40
- * See the LICENSE file in the root directory of this source tree.
41
- */const Aa=[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]],La=oe("hard-drive",Aa);/**
42
- * @license lucide-react v0.542.0 - ISC
43
- *
44
- * This source code is licensed under the ISC license.
45
- * See the LICENSE file in the root directory of this source tree.
46
- */const Ka=[["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"}]],Ne=oe("image",Ka);/**
47
- * @license lucide-react v0.542.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */const Va=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],ys=oe("maximize-2",Va);/**
52
- * @license lucide-react v0.542.0 - ISC
53
- *
54
- * This source code is licensed under the ISC license.
55
- * See the LICENSE file in the root directory of this source tree.
56
- */const Oa=[["path",{d:"M9 18V5l12-2v13",key:"1jmyc2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["circle",{cx:"18",cy:"16",r:"3",key:"1hluhg"}]],fe=oe("music",Oa);/**
57
- * @license lucide-react v0.542.0 - ISC
58
- *
59
- * This source code is licensed under the ISC license.
60
- * See the LICENSE file in the root directory of this source tree.
61
- */const Wa=[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]],bs=oe("presentation",Wa);/**
62
- * @license lucide-react v0.542.0 - ISC
63
- *
64
- * This source code is licensed under the ISC license.
65
- * See the LICENSE file in the root directory of this source tree.
66
- */const Ba=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],$a=oe("upload",Ba);/**
67
- * @license lucide-react v0.542.0 - ISC
68
- *
69
- * This source code is licensed under the ISC license.
70
- * See the LICENSE file in the root directory of this source tree.
71
- */const Ua=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Be=oe("video",Ua);async function qs(l){const c=l.startsWith("http")?l:`${Us}${l}`,n=await fetch(c,{headers:{Accept:"application/json","User-Agent":"coconut-frontend"}});if(!n.ok)throw new Error(`Failed to fetch registry resource: ${n.status}`);return n.json()}async function za(){return qs("/registry/resources/root.json")}async function ws(l){return qs(l)}function Ke(l){if(l)return l.startsWith("http")?l:`${Us}${l}`}function qa({open:l,onOpenChange:c,onSelectExample:n,onCustomizeInAssistant:p}){const[m,u]=t.useState([]),[j,h]=t.useState(!1),[N,P]=t.useState(null),[S,d]=t.useState(null),[x,y]=t.useState(null),[E,w]=t.useState(!1),[b,_]=t.useState(null);t.useEffect(()=>{l&&(h(!0),P(null),d(null),y(null),_(null),za().then(v=>{u(v.elements??[]),v.elements&&v.elements.length>0&&z(v.elements[0])}).catch(v=>{console.error("Failed to load registry resources",v),u([]),P("Failed to load examples from registry")}).finally(()=>h(!1)))},[l]);const z=async v=>{d(v.id),_(null),y(null),w(!0);try{const k=await ws(v.endpoint);y(k)}catch(k){console.error("Failed to load resource detail",k),_("Unable to load details for this example")}finally{w(!1)}},M=()=>{x?.prompt&&(n(x.prompt),c(!1))},T=()=>{x?.prompt&&p&&(p(x.prompt),c(!1))},A=async v=>{if(S===v.id&&x?.prompt){n(x.prompt),c(!1);return}try{const k=await ws(v.endpoint);k.prompt&&(n(k.prompt),c(!1))}catch(k){console.error("Failed to load resource detail",k)}};return e.jsx(pe,{open:l,onOpenChange:c,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Example Prompts"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden relative",children:[e.jsx("div",{className:"h-[40%] min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:E?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading..."]}):b?e.jsx("p",{className:"text-sm text-muted-foreground",children:b}):x?e.jsx("img",{src:Ke(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example"})}),e.jsxs("div",{className:"flex-1 min-h-0 border-t flex flex-col",children:[j?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):N?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:N}):m.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(is,{className:"flex-1",children:e.jsx("div",{className:"p-3 space-y-2",children:m.map(v=>e.jsxs("button",{onClick:()=>z(v),onDoubleClick:()=>A(v),className:`w-full text-left p-2 rounded-lg border-2 transition-all flex gap-3 ${S===v.id?"border-primary bg-primary/5":"border-transparent bg-muted/50 hover:bg-muted"}`,children:[v.thumbnailUrl&&e.jsx("img",{src:Ke(v.thumbnailUrl),alt:"",className:"w-12 h-12 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:v.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:v.description})]})]},v.id))})}),e.jsx("div",{className:"p-3 border-t flex-shrink-0",children:e.jsxs(R,{onClick:M,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),x&&p&&e.jsx("div",{className:"absolute bottom-16 right-3 z-10",children:e.jsxs(R,{size:"sm",variant:"secondary",onClick:T,children:[e.jsx(Ee,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize"]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsxs("div",{className:"w-[35%] border-r flex flex-col",children:[j?e.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading examples..."]}):N?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:N}):m.length===0?e.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-muted-foreground",children:"No examples available"}):e.jsx(is,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-3",children:m.map(v=>e.jsxs("button",{onClick:()=>z(v),onDoubleClick:()=>A(v),className:`w-full text-left p-3 rounded-lg border-2 transition-all flex gap-3 ${S===v.id?"border-primary bg-primary/5 shadow-sm":"border-transparent bg-muted/50 hover:bg-muted hover:border-muted-foreground/20"}`,children:[v.thumbnailUrl&&e.jsx("img",{src:Ke(v.thumbnailUrl),alt:"",className:"w-16 h-16 rounded object-cover flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium",children:v.name}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 mt-1",children:v.description}),v.tags&&v.tags.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mt-2",children:[v.tags.slice(0,3).map(k=>e.jsx(Me,{variant:"secondary",className:"text-[10px]",children:k},k)),v.tags.length>3&&e.jsxs(Me,{variant:"outline",className:"text-[10px]",children:["+",v.tags.length-3]})]})]})]},v.id))})}),e.jsx("div",{className:"p-4 border-t flex-shrink-0",children:e.jsxs(R,{onClick:M,disabled:!x?.prompt||E,className:"w-full",children:[e.jsx(os,{className:"mr-2 h-4 w-4"}),"Use This Prompt"]})})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden relative",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:E?e.jsxs("div",{className:"flex items-center text-muted-foreground",children:[e.jsx(le,{className:"h-5 w-5 animate-spin mr-2"}),"Loading details..."]}):b?e.jsx("p",{className:"text-sm text-muted-foreground",children:b}):x?e.jsx("img",{src:Ke(x.imageUrl),alt:x.title,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Select an example to preview"})}),x&&e.jsxs("div",{className:"border-t p-4 bg-background flex-shrink-0 max-h-[30%] overflow-y-auto",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-2 font-medium",children:"Full Prompt:"}),e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:x.prompt})]}),x&&p&&e.jsx("div",{className:"absolute bottom-4 right-4 z-10",children:e.jsxs(R,{size:"sm",variant:"secondary",onClick:T,children:[e.jsx(Ee,{className:"mr-1.5 h-3.5 w-3.5"}),"Customize in Assistant"]})})]})]})]})})}const Ns="image-generator-settings";function _s(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Ve={"nano-banana-pro":{id:"nano-banana-pro",label:"Nano Banana Pro",replicateId:"google/nano-banana-pro",features:{resolution:!0,outputQuality:!1,quality:!1,goFast:!1,safetyTolerance:!1,matchInputImage:!1,background:!1},resolutionOptions:[{value:"1K",label:"1K"},{value:"2K",label:"2K"},{value:"4K",label:"4K"}],defaults:{resolution:"2K"}},"flux-2-dev":{id:"flux-2-dev",label:"FLUX.2 Dev",replicateId:"black-forest-labs/flux-2-dev",features:{resolution:!1,outputQuality:!0,quality:!1,goFast:!0,safetyTolerance:!1,matchInputImage:!0,background:!1},defaults:{outputQuality:80,goFast:!0}},"flux-2-pro":{id:"flux-2-pro",label:"FLUX.2 Pro",replicateId:"black-forest-labs/flux-2-pro",features:{resolution:!0,outputQuality:!0,quality:!1,goFast:!1,safetyTolerance:!0,matchInputImage:!1,background:!1},resolutionOptions:[{value:"0.5 MP",label:"0.5 MP"},{value:"1 MP",label:"1 MP"},{value:"2 MP",label:"2 MP"},{value:"4 MP",label:"4 MP"}],defaults:{resolution:"2 MP",outputQuality:80,safetyTolerance:2}},"gpt-image-1.5":{id:"gpt-image-1.5",label:"GPT Image 1.5",replicateId:"openai/gpt-image-1.5",features:{resolution:!1,outputQuality:!1,quality:!0,goFast:!1,safetyTolerance:!1,matchInputImage:!1,background:!0},aspectRatioOptions:[{value:"1:1",label:"1:1"},{value:"3:2",label:"3:2"},{value:"2:3",label:"2:3"}],defaults:{aspectRatio:"1:1",quality:"high",background:"auto"}}},Ss=Object.values(Ve).map(l=>({value:l.id,label:l.label})),Cs=[{value:"1:1",label:"1:1"},{value:"2:3",label:"2:3"},{value:"3:2",label:"3:2"},{value:"3:4",label:"3:4"},{value:"4:3",label:"4:3"},{value:"4:5",label:"4:5"},{value:"5:4",label:"5:4"},{value:"9:16",label:"9:16"},{value:"16:9",label:"16:9"},{value:"21:9",label:"21:9"}],Ha={value:"match_input_image",label:"Match Input"},ks=[{value:"png",label:"PNG"},{value:"jpg",label:"JPG"},{value:"webp",label:"WebP"}],Ps=[{value:"60",label:"60"},{value:"70",label:"70"},{value:"80",label:"80"},{value:"90",label:"90"},{value:"100",label:"100"}],Es=[{value:"low",label:"Low"},{value:"medium",label:"Medium"},{value:"high",label:"High"}],Ms=[{value:"auto",label:"Auto"},{value:"transparent",label:"Transparent"},{value:"opaque",label:"Opaque"}],Fs=[{value:"1",label:"1 (Strict)"},{value:"2",label:"2"},{value:"3",label:"3"},{value:"4",label:"4"},{value:"5",label:"5"},{value:"6",label:"6 (Relaxed)"}];function Ja({open:l,onOpenChange:c,onSave:n,onCustomizeInAssistant:p}){const m=a=>a.aspectRatioOptions?a.aspectRatioOptions:a.features.matchInputImage?[Ha,...Cs]:Cs,u=(a,s)=>typeof s!="string"?!1:new Set(m(a).map(f=>f.value)).has(s),h=(()=>{if(typeof window>"u")return null;try{const a=localStorage.getItem(Ns);return a?JSON.parse(a):null}catch{return null}})(),N=h?.model||"nano-banana-pro",P=Ve[N],S=u(P,h?.aspectRatio)?h?.aspectRatio:P.defaults.aspectRatio||"16:9",[d,x]=t.useState(""),[y,E]=t.useState(N),[w,b]=t.useState(S),[_,z]=t.useState(h?.resolution||"2K"),[M,T]=t.useState(h?.outputFormat||"png"),[A,v]=t.useState(h?.outputQuality||"80"),[k,q]=t.useState(h?.quality||"high"),[L,D]=t.useState(h?.goFast??!0),[I,g]=t.useState(h?.safetyTolerance||"2"),[K,Y]=t.useState(h?.background||"auto"),[H,ee]=t.useState(null),[V,O]=t.useState(!1),[Q,o]=t.useState(!1),[te,i]=t.useState([]),[F,se]=t.useState([]),[X,re]=t.useState(!0),[ue,he]=t.useState(!1),[Ie,Re]=t.useState(0),xe=t.useRef(null),{toast:ie}=$e();t.useEffect(()=>{const a={model:y,aspectRatio:w,resolution:_,outputFormat:M,outputQuality:A,quality:k,goFast:L,safetyTolerance:I,background:K};localStorage.setItem(Ns,JSON.stringify(a))},[y,w,_,M,A,k,L,I,K]),t.useEffect(()=>(V?(Re(0),xe.current=setInterval(()=>{Re(a=>a+1)},1e3)):xe.current&&(clearInterval(xe.current),xe.current=null),()=>{xe.current&&clearInterval(xe.current)}),[V]);const J=Ve[y],Ce=m(J),Te=J.resolutionOptions||[];t.useEffect(()=>{const a=Ve[y];a.defaults.resolution&&a.features.resolution&&z(a.defaults.resolution),a.defaults.outputQuality!==void 0&&v(String(a.defaults.outputQuality)),a.defaults.quality!==void 0&&a.features.quality&&q(String(a.defaults.quality)),a.defaults.goFast!==void 0&&D(a.defaults.goFast),a.defaults.safetyTolerance!==void 0&&g(String(a.defaults.safetyTolerance)),a.defaults.background!==void 0&&a.features.background&&Y(String(a.defaults.background)),b(s=>{const r=m(a).map(f=>f.value);return r.includes(s)?s:a.defaults.aspectRatio||r[0]||"16:9"})},[y]),t.useEffect(()=>{l&&ze()},[l]);const ze=async()=>{try{const s=await(await fetch(`${ae}/api/v1/resources`)).json();if(s.success){const r=(s.data||[]).filter(f=>{const Z=f.type==="image/jpeg"||f.name.toLowerCase().endsWith(".jpg")||f.name.toLowerCase().endsWith(".jpeg"),ne=f.type==="image/png"||f.name.toLowerCase().endsWith(".png");return(Z||ne)&&f.thumbnailPath});i(r)}}catch(a){console.error("Failed to fetch image resources:",a)}},ke=async()=>{if(!d.trim()){ie({title:"Prompt required",description:"Please enter a prompt to generate an image",variant:"destructive"});return}O(!0),ee(null);try{const a=X||F.length===0?[]:[...F],s=new AbortController,r=setTimeout(()=>s.abort(),3e5),f=await fetch(`${ae}/api/v1/resources/generate`,{method:"POST",headers:{"Content-Type":"application/json"},signal:s.signal,body:JSON.stringify({prompt:d,model:y,dimensions:w,resolution:J.features.resolution?_:void 0,output_format:M,output_quality:J.features.outputQuality?parseInt(A):void 0,quality:J.features.quality?k:void 0,go_fast:J.features.goFast?L:void 0,safety_tolerance:J.features.safetyTolerance?parseInt(I):void 0,background:J.features.background?K:void 0,image_input:a})});if(clearTimeout(r),f.status===504||f.status===502||f.status===408)throw new Error("Request timed out. The image model may be warming up - please try again.");const Z=f.headers.get("content-type");if(!Z||!Z.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const ne=await f.json();if(!f.ok||!ne.success){const de=ne.error?.message||"Failed to generate image",ce=ne.error?.code==="MISSING_API_TOKEN";throw new Error(ce?"Replicate API token not configured. Please add it in Settings → Integrations.":de)}ee(ne.data.imageUrl),ie({title:"Image generated",description:"Your image has been generated successfully"})}catch(a){console.error("Generation error:",a);const s=a instanceof Error&&a.name==="AbortError",r=s?"Request timed out after 5 minutes. The model may be overloaded - please try again.":a instanceof Error?a.message:"Failed to generate image.",f=s||r.toLowerCase().includes("timeout")||r.toLowerCase().includes("timed out");ie({title:f?"Generation timed out":"Generation failed",description:r,variant:"destructive"})}finally{O(!1)}};t.useEffect(()=>{const a=s=>{l&&(s.metaKey||s.ctrlKey)&&s.key==="Enter"&&(s.preventDefault(),d.trim()&&!V&&!Q&&ke())};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[l,d,V,Q]);const De=async()=>{if(H){o(!0);try{await n(H,{prompt:d,model:y}),x(""),E("nano-banana-pro"),b("16:9"),z("2K"),T("png"),v("80"),q("high"),D(!0),g("2"),Y("auto"),ee(null),re(!0),se([]),c(!1)}catch(a){ie({title:"Save failed",description:a instanceof Error?a.message:"Failed to save image. Please try again.",variant:"destructive"})}finally{o(!1)}}},Ge=()=>{!V&&!Q&&c(!1)},Ae=()=>{re(!0),se([])},Le=a=>{X&&re(!1),F.includes(a)?(se(F.filter(s=>s!==a)),F.length===1&&re(!0)):F.length<3?se([...F,a]):ie({title:"Maximum selection",description:"You can only select up to 3 images",variant:"destructive"})},qe=a=>{x(a)},He=a=>{p&&(he(!1),c(!1),p(`"${a}" Please customize this (and respond back just the updated markdown):`))};return e.jsxs(pe,{open:l,onOpenChange:Ge,children:[e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Image"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:V?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):H?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:H,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Ne,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"}),e.jsxs(R,{size:"sm",onClick:()=>he(!0),className:"mt-2",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-2 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:Ae,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${X?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),te.map(a=>{const s=F.includes(a.id);return e.jsx("button",{onClick:()=>Le(a.id),className:`flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${s?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${ae}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[45vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(ye,{id:"prompt-mobile",placeholder:"Describe the image...",value:d,onChange:a=>x(a.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"model-mobile",className:"text-xs",children:"Model"}),e.jsxs(W,{value:y,onValueChange:a=>E(a),children:[e.jsx(B,{id:"model-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ss.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"outputFormat-mobile",className:"text-xs",children:"Format"}),e.jsxs(W,{value:M,onValueChange:T,children:[e.jsx(B,{id:"outputFormat-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:ks.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.background&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"background-mobile",className:"text-xs",children:"Background"}),e.jsxs(W,{value:K,onValueChange:Y,children:[e.jsx(B,{id:"background-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ms.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.goFast&&e.jsx("div",{className:"space-y-1 flex flex-col justify-end",children:e.jsxs("div",{className:"flex items-center space-x-2 h-8",children:[e.jsx(Oe,{id:"goFast-mobile",checked:L,onCheckedChange:a=>D(a===!0)}),e.jsx(C,{htmlFor:"goFast-mobile",className:"text-xs cursor-pointer",children:"Go Fast"})]})}),J.features.safetyTolerance&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"safetyTolerance-mobile",className:"text-xs",children:"Safety"}),e.jsxs(W,{value:I,onValueChange:g,children:[e.jsx(B,{id:"safetyTolerance-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Fs.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[J.features.resolution&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"resolution-mobile",className:"text-xs",children:"Resolution"}),e.jsxs(W,{value:_,onValueChange:z,children:[e.jsx(B,{id:"resolution-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Te.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"aspectRatio-mobile",className:"text-xs",children:"Ratio"}),e.jsxs(W,{value:w,onValueChange:b,children:[e.jsx(B,{id:"aspectRatio-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ce.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.outputQuality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"outputQuality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(W,{value:A,onValueChange:v,children:[e.jsx(B,{id:"outputQuality-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ps.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.quality&&e.jsxs("div",{className:"space-y-1 flex-1 min-w-[80px]",children:[e.jsx(C,{htmlFor:"quality-mobile",className:"text-xs",children:"Quality"}),e.jsxs(W,{value:k,onValueChange:q,children:[e.jsx(B,{id:"quality-mobile",className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Es.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:ke,disabled:!d.trim()||V||Q,className:"flex-1 h-9",size:"sm",children:V?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_s,{}),e.jsxs("span",{children:[Ie,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:De,disabled:!H||V||Q,variant:"outline",className:"flex-1 h-9",size:"sm",children:Q?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(ye,{id:"prompt",placeholder:"Describe the image you want to generate...",value:d,onChange:a=>x(a.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"model",children:"Model"}),e.jsxs(W,{value:y,onValueChange:a=>E(a),children:[e.jsx(B,{id:"model",children:e.jsx($,{})}),e.jsx(U,{children:Ss.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(W,{value:w,onValueChange:b,children:[e.jsx(B,{id:"aspectRatio",children:e.jsx($,{})}),e.jsx(U,{children:Ce.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.resolution&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(W,{value:_,onValueChange:z,children:[e.jsx(B,{id:"resolution",children:e.jsx($,{})}),e.jsx(U,{children:Te.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputFormat",children:"Output Format"}),e.jsxs(W,{value:M,onValueChange:T,children:[e.jsx(B,{id:"outputFormat",children:e.jsx($,{})}),e.jsx(U,{children:ks.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.background&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"background",children:"Background"}),e.jsxs(W,{value:K,onValueChange:Y,children:[e.jsx(B,{id:"background",children:e.jsx($,{})}),e.jsx(U,{children:Ms.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.outputQuality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"outputQuality",children:"Output Quality"}),e.jsxs(W,{value:A,onValueChange:v,children:[e.jsx(B,{id:"outputQuality",children:e.jsx($,{})}),e.jsx(U,{children:Ps.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.quality&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"quality",children:"Quality"}),e.jsxs(W,{value:k,onValueChange:q,children:[e.jsx(B,{id:"quality",children:e.jsx($,{})}),e.jsx(U,{children:Es.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),J.features.goFast&&e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oe,{id:"goFast",checked:L,onCheckedChange:a=>D(a===!0)}),e.jsx(C,{htmlFor:"goFast",className:"cursor-pointer",children:"Go Fast"})]}),J.features.safetyTolerance&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"safetyTolerance",children:"Safety Tolerance"}),e.jsxs(W,{value:I,onValueChange:g,children:[e.jsx(B,{id:"safetyTolerance",children:e.jsx($,{})}),e.jsx(U,{children:Fs.map(a=>e.jsx(G,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:ke,disabled:!d.trim()||V||Q,className:"w-full",children:V?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(_s,{}),e.jsxs("span",{children:["Generating... ",Ie,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:De,disabled:!H||V||Q,variant:"outline",className:"w-full",children:Q?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:V?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating image..."})]}):H?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("img",{src:H,alt:"Generated",className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Ne,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated image will appear here"}),e.jsxs(R,{onClick:()=>he(!0),className:"mt-2",children:[e.jsx(Ee,{className:"mr-2 h-4 w-4"}),"View Examples"]})]})}),e.jsx("div",{className:"border-t bg-background p-4 flex-shrink-0",children:e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:Ae,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${X?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),te.map(a=>{const s=F.includes(a.id);return e.jsx("button",{onClick:()=>Le(a.id),className:`flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${s?"border-primary ring-2 ring-primary":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("img",{src:`${ae}/api/v1/resources/${a.id}/thumbnail`,alt:a.name,className:"w-full h-full object-cover"})},a.id)})]})})]})]})]}),e.jsx(qa,{open:ue,onOpenChange:he,onSelectExample:qe,onCustomizeInAssistant:p?He:void 0})]})}var Hs=["PageUp","PageDown"],Js=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Ys={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},Se="Slider",[as,Ya,Qa]=ua(Se),[Qs,Et]=da(Se,[Qa]),[Xa,Ue]=Qs(Se),Xs=t.forwardRef((l,c)=>{const{name:n,min:p=0,max:m=100,step:u=1,orientation:j="horizontal",disabled:h=!1,minStepsBetweenThumbs:N=0,defaultValue:P=[p],value:S,onValueChange:d=()=>{},onValueCommit:x=()=>{},inverted:y=!1,form:E,...w}=l,b=t.useRef(new Set),_=t.useRef(0),M=j==="horizontal"?Za:et,[T=[],A]=ca({prop:S,defaultProp:P,onChange:I=>{[...b.current][_.current]?.focus(),d(I)}}),v=t.useRef(T);function k(I){const g=lt(T,I);D(I,g)}function q(I){D(I,_.current)}function L(){const I=v.current[_.current];T[_.current]!==I&&x(T)}function D(I,g,{commit:K}={commit:!1}){const Y=ct(u),H=dt(Math.round((I-p)/u)*u+p,Y),ee=Bs(H,[p,m]);A((V=[])=>{const O=tt(V,ee,g);if(ot(O,N*u)){_.current=O.indexOf(ee);const Q=String(O)!==String(V);return Q&&K&&x(O),Q?O:V}else return V})}return e.jsx(Xa,{scope:l.__scopeSlider,name:n,disabled:h,min:p,max:m,valueIndexToChangeRef:_,thumbs:b.current,values:T,orientation:j,form:E,children:e.jsx(as.Provider,{scope:l.__scopeSlider,children:e.jsx(as.Slot,{scope:l.__scopeSlider,children:e.jsx(M,{"aria-disabled":h,"data-disabled":h?"":void 0,...w,ref:c,onPointerDown:be(w.onPointerDown,()=>{h||(v.current=T)}),min:p,max:m,inverted:y,onSlideStart:h?void 0:k,onSlideMove:h?void 0:q,onSlideEnd:h?void 0:L,onHomeKeyDown:()=>!h&&D(p,0,{commit:!0}),onEndKeyDown:()=>!h&&D(m,T.length-1,{commit:!0}),onStepKeyDown:({event:I,direction:g})=>{if(!h){const H=Hs.includes(I.key)||I.shiftKey&&Js.includes(I.key)?10:1,ee=_.current,V=T[ee],O=u*H*g;D(V+O,ee,{commit:!0})}}})})})})});Xs.displayName=Se;var[Zs,ea]=Qs(Se,{startEdge:"left",endEdge:"right",size:"width",direction:1}),Za=t.forwardRef((l,c)=>{const{min:n,max:p,dir:m,inverted:u,onSlideStart:j,onSlideMove:h,onSlideEnd:N,onStepKeyDown:P,...S}=l,[d,x]=t.useState(null),y=_e(c,M=>x(M)),E=t.useRef(void 0),w=ma(m),b=w==="ltr",_=b&&!u||!b&&u;function z(M){const T=E.current||d.getBoundingClientRect(),A=[0,T.width],k=ls(A,_?[n,p]:[p,n]);return E.current=T,k(M-T.left)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:_?"left":"right",endEdge:_?"right":"left",direction:_?1:-1,size:"width",children:e.jsx(sa,{dir:w,"data-orientation":"horizontal",...S,ref:y,style:{...S.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:M=>{const T=z(M.clientX);j?.(T)},onSlideMove:M=>{const T=z(M.clientX);h?.(T)},onSlideEnd:()=>{E.current=void 0,N?.()},onStepKeyDown:M=>{const A=Ys[_?"from-left":"from-right"].includes(M.key);P?.({event:M,direction:A?-1:1})}})})}),et=t.forwardRef((l,c)=>{const{min:n,max:p,inverted:m,onSlideStart:u,onSlideMove:j,onSlideEnd:h,onStepKeyDown:N,...P}=l,S=t.useRef(null),d=_e(c,S),x=t.useRef(void 0),y=!m;function E(w){const b=x.current||S.current.getBoundingClientRect(),_=[0,b.height],M=ls(_,y?[p,n]:[n,p]);return x.current=b,M(w-b.top)}return e.jsx(Zs,{scope:l.__scopeSlider,startEdge:y?"bottom":"top",endEdge:y?"top":"bottom",size:"height",direction:y?1:-1,children:e.jsx(sa,{"data-orientation":"vertical",...P,ref:d,style:{...P.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:w=>{const b=E(w.clientY);u?.(b)},onSlideMove:w=>{const b=E(w.clientY);j?.(b)},onSlideEnd:()=>{x.current=void 0,h?.()},onStepKeyDown:w=>{const _=Ys[y?"from-bottom":"from-top"].includes(w.key);N?.({event:w,direction:_?-1:1})}})})}),sa=t.forwardRef((l,c)=>{const{__scopeSlider:n,onSlideStart:p,onSlideMove:m,onSlideEnd:u,onHomeKeyDown:j,onEndKeyDown:h,onStepKeyDown:N,...P}=l,S=Ue(Se,n);return e.jsx(Fe.span,{...P,ref:c,onKeyDown:be(l.onKeyDown,d=>{d.key==="Home"?(j(d),d.preventDefault()):d.key==="End"?(h(d),d.preventDefault()):Hs.concat(Js).includes(d.key)&&(N(d),d.preventDefault())}),onPointerDown:be(l.onPointerDown,d=>{const x=d.target;x.setPointerCapture(d.pointerId),d.preventDefault(),S.thumbs.has(x)?x.focus():p(d)}),onPointerMove:be(l.onPointerMove,d=>{d.target.hasPointerCapture(d.pointerId)&&m(d)}),onPointerUp:be(l.onPointerUp,d=>{const x=d.target;x.hasPointerCapture(d.pointerId)&&(x.releasePointerCapture(d.pointerId),u(d))})})}),aa="SliderTrack",ta=t.forwardRef((l,c)=>{const{__scopeSlider:n,...p}=l,m=Ue(aa,n);return e.jsx(Fe.span,{"data-disabled":m.disabled?"":void 0,"data-orientation":m.orientation,...p,ref:c})});ta.displayName=aa;var ts="SliderRange",na=t.forwardRef((l,c)=>{const{__scopeSlider:n,...p}=l,m=Ue(ts,n),u=ea(ts,n),j=t.useRef(null),h=_e(c,j),N=m.values.length,P=m.values.map(x=>ia(x,m.min,m.max)),S=N>1?Math.min(...P):0,d=100-Math.max(...P);return e.jsx(Fe.span,{"data-orientation":m.orientation,"data-disabled":m.disabled?"":void 0,...p,ref:h,style:{...l.style,[u.startEdge]:S+"%",[u.endEdge]:d+"%"}})});na.displayName=ts;var ns="SliderThumb",la=t.forwardRef((l,c)=>{const n=Ya(l.__scopeSlider),[p,m]=t.useState(null),u=_e(c,h=>m(h)),j=t.useMemo(()=>p?n().findIndex(h=>h.ref.current===p):-1,[n,p]);return e.jsx(st,{...l,ref:u,index:j})}),st=t.forwardRef((l,c)=>{const{__scopeSlider:n,index:p,name:m,...u}=l,j=Ue(ns,n),h=ea(ns,n),[N,P]=t.useState(null),S=_e(c,z=>P(z)),d=N?j.form||!!N.closest("form"):!0,x=ha(N),y=j.values[p],E=y===void 0?0:ia(y,j.min,j.max),w=nt(p,j.values.length),b=x?.[h.size],_=b?rt(b,E,h.direction):0;return t.useEffect(()=>{if(N)return j.thumbs.add(N),()=>{j.thumbs.delete(N)}},[N,j.thumbs]),e.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[h.startEdge]:`calc(${E}% + ${_}px)`},children:[e.jsx(as.ItemSlot,{scope:l.__scopeSlider,children:e.jsx(Fe.span,{role:"slider","aria-label":l["aria-label"]||w,"aria-valuemin":j.min,"aria-valuenow":y,"aria-valuemax":j.max,"aria-orientation":j.orientation,"data-orientation":j.orientation,"data-disabled":j.disabled?"":void 0,tabIndex:j.disabled?void 0:0,...u,ref:S,style:y===void 0?{display:"none"}:l.style,onFocus:be(l.onFocus,()=>{j.valueIndexToChangeRef.current=p})})}),d&&e.jsx(ra,{name:m??(j.name?j.name+(j.values.length>1?"[]":""):void 0),form:j.form,value:y},p)]})});la.displayName=ns;var at="RadioBubbleInput",ra=t.forwardRef(({__scopeSlider:l,value:c,...n},p)=>{const m=t.useRef(null),u=_e(m,p),j=xa(c);return t.useEffect(()=>{const h=m.current;if(!h)return;const N=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(N,"value").set;if(j!==c&&S){const d=new Event("input",{bubbles:!0});S.call(h,c),h.dispatchEvent(d)}},[j,c]),e.jsx(Fe.input,{style:{display:"none"},...n,ref:u,defaultValue:c})});ra.displayName=at;function tt(l=[],c,n){const p=[...l];return p[n]=c,p.sort((m,u)=>m-u)}function ia(l,c,n){const u=100/(n-c)*(l-c);return Bs(u,[0,100])}function nt(l,c){return c>2?`Value ${l+1} of ${c}`:c===2?["Minimum","Maximum"][l]:void 0}function lt(l,c){if(l.length===1)return 0;const n=l.map(m=>Math.abs(m-c)),p=Math.min(...n);return n.indexOf(p)}function rt(l,c,n){const p=l/2,u=ls([0,50],[0,p]);return(p-u(c)*n)*n}function it(l){return l.slice(0,-1).map((c,n)=>l[n+1]-c)}function ot(l,c){if(c>0){const n=it(l);return Math.min(...n)>=c}return!0}function ls(l,c){return n=>{if(l[0]===l[1]||c[0]===c[1])return c[0];const p=(c[1]-c[0])/(l[1]-l[0]);return c[0]+p*(n-l[0])}}function ct(l){return(String(l).split(".")[1]||"").length}function dt(l,c){const n=Math.pow(10,c);return Math.round(l*n)/n}var oa=Xs,ut=ta,mt=na,ht=la;const Pe=t.forwardRef(({className:l,...c},n)=>e.jsxs(oa,{ref:n,className:fa("relative flex w-full touch-none select-none items-center",l),...c,children:[e.jsx(ut,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:e.jsx(mt,{className:"absolute h-full bg-primary"})}),e.jsx(ht,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}));Pe.displayName=oa.displayName;const Is="audio-generator-settings";function Rs(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Ts=["English_Trustworth_Man","English_Aussie_Bloke","English_CalmWoman","English_UpsetGirl","English_Gentle-voiced_man","English_Whispering_girl","English_Diligent_Man","English_Graceful_Lady","English_ReservedYoungMan","English_PlayfulGirl","English_ManWithDeepVoice","English_MaturePartner","English_FriendlyPerson","English_MatureBoss","English_Debator","English_LovelyGirl","English_Steadymentor","English_Deep-VoicedGentleman","English_Wiselady","English_CaptivatingStoryteller","English_DecentYoungMan","English_SentimentalLady","English_ImposingManner","English_SadTeen","English_PassionateWarrior","English_WiseScholar","English_Soft-spokenGirl","English_SereneWoman","English_ConfidentWoman","English_PatientMan","English_Comedian","English_BossyLeader","English_Strong-WilledBoy","English_StressedLady","English_AssertiveQueen","English_AnimeCharacter","English_Jovialman","English_WhimsicalGirl","English_Kind-heartedGirl","Chinese (Mandarin)_Reliable_Executive","Chinese (Mandarin)_News_Anchor","Chinese (Mandarin)_Unrestrained_Young_Man","Chinese (Mandarin)_Mature_Woman","Arrogant_Miss","Robot_Armor","Chinese (Mandarin)_Kind-hearted_Antie","Chinese (Mandarin)_Refreshing_Young_Man","Chinese (Mandarin)_HK_Flight_Attendant","Chinese (Mandarin)_Humorous_Elder","Chinese (Mandarin)_Gentleman","Chinese (Mandarin)_Warm_Bestie","Chinese (Mandarin)_Stubborn_Friend","Chinese (Mandarin)_Sweet_Lady","Chinese (Mandarin)_Southern_Young_Man","Chinese (Mandarin)_Wise_Women","Chinese (Mandarin)_Gentle_Youth","Chinese (Mandarin)_Warm_Girl","Chinese (Mandarin)_Male_Announcer","Chinese (Mandarin)_Kind-hearted_Elder","Chinese (Mandarin)_Cute_Spirit","Chinese (Mandarin)_Radio_Host","Chinese (Mandarin)_Lyrical_Voice","Chinese (Mandarin)_Straightforward_Boy","Chinese (Mandarin)_Sincere_Adult","Chinese (Mandarin)_Gentle_Senior","Chinese (Mandarin)_Crisp_Girl","Chinese (Mandarin)_Pure-hearted_Boy","Chinese (Mandarin)_Soft_Girl","Chinese (Mandarin)_IntellectualGirl","Chinese (Mandarin)_Warm_HeartedGirl","Chinese (Mandarin)_Laid_BackGirl","Chinese (Mandarin)_ExplorativeGirl","Chinese (Mandarin)_Warm-HeartedAunt","Chinese (Mandarin)_BashfulGirl","Japanese_IntellectualSenior","Japanese_DecisivePrincess","Japanese_LoyalKnight","Japanese_DominantMan","Japanese_SeriousCommander","Japanese_ColdQueen","Japanese_DependableWoman","Japanese_GentleButler","Japanese_KindLady","Japanese_CalmLady","Japanese_OptimisticYouth","Japanese_GenerousIzakayaOwner","Japanese_SportyStudent","Japanese_InnocentBoy","Japanese_GracefulMaiden","Cantonese_ProfessionalHost(F)","Cantonese_GentleLady","Cantonese_ProfessionalHost(M)","Cantonese_PlayfulMan","Cantonese_CuteGirl","Cantonese_KindWoman","Korean_SweetGirl","Korean_CheerfulBoyfriend","Korean_EnchantingSister","Korean_ShyGirl","Korean_ReliableSister","Korean_StrictBoss","Korean_SassyGirl","Korean_ChildhoodFriendGirl","Korean_PlayboyCharmer","Korean_ElegantPrincess","Korean_BraveFemaleWarrior","Korean_BraveYouth","Korean_CalmLady","Korean_EnthusiasticTeen","Korean_SoothingLady","Korean_IntellectualSenior","Korean_LonelyWarrior","Korean_MatureLady","Korean_InnocentBoy","Korean_CharmingSister","Korean_AthleticStudent","Korean_BraveAdventurer","Korean_CalmGentleman","Korean_WiseElf","Korean_CheerfulCoolJunior","Korean_DecisiveQueen","Korean_ColdYoungMan","Korean_MysteriousGirl","Korean_QuirkyGirl","Korean_ConsiderateSenior","Korean_CheerfulLittleSister","Korean_DominantMan","Korean_AirheadedGirl","Korean_ReliableYouth","Korean_FriendlyBigSister","Korean_GentleBoss","Korean_ColdGirl","Korean_HaughtyLady","Korean_CharmingElderSister","Korean_IntellectualMan","Korean_CaringWoman","Korean_WiseTeacher","Korean_ConfidentBoss","Korean_AthleticGirl","Korean_PossessiveMan","Korean_GentleWoman","Korean_CockyGuy","Korean_ThoughtfulWoman","Korean_OptimisticYouth","Spanish_SereneWoman","Spanish_MaturePartner","Spanish_CaptivatingStoryteller","Spanish_Narrator","Spanish_WiseScholar","Spanish_Kind-heartedGirl","Spanish_DeterminedManager","Spanish_BossyLeader","Spanish_ReservedYoungMan","Spanish_ConfidentWoman","Spanish_ThoughtfulMan","Spanish_Strong-WilledBoy","Spanish_SophisticatedLady","Spanish_RationalMan","Spanish_AnimeCharacter","Spanish_Deep-tonedMan","Spanish_Fussyhostess","Spanish_SincereTeen","Spanish_FrankLady","Spanish_Comedian","Spanish_Debator","Spanish_ToughBoss","Spanish_Wiselady","Spanish_Steadymentor","Spanish_Jovialman","Spanish_SantaClaus","Spanish_Rudolph","Spanish_Intonategirl","Spanish_Arnold","Spanish_Ghost","Spanish_HumorousElder","Spanish_EnergeticBoy","Spanish_WhimsicalGirl","Spanish_StrictBoss","Spanish_ReliableMan","Spanish_SereneElder","Spanish_AngryMan","Spanish_AssertiveQueen","Spanish_CaringGirlfriend","Spanish_PowerfulSoldier","Spanish_PassionateWarrior","Spanish_ChattyGirl","Spanish_RomanticHusband","Spanish_CompellingGirl","Spanish_PowerfulVeteran","Spanish_SensibleManager","Spanish_ThoughtfulLady","Portuguese_SentimentalLady","Portuguese_BossyLeader","Portuguese_Wiselady","Portuguese_Strong-WilledBoy","Portuguese_Deep-VoicedGentleman","Portuguese_UpsetGirl","Portuguese_PassionateWarrior","Portuguese_AnimeCharacter","Portuguese_ConfidentWoman","Portuguese_AngryMan","Portuguese_CaptivatingStoryteller","Portuguese_Godfather","Portuguese_ReservedYoungMan","Portuguese_SmartYoungGirl","Portuguese_Kind-heartedGirl","Portuguese_Pompouslady","Portuguese_Grinch","Portuguese_Debator","Portuguese_SweetGirl","Portuguese_AttractiveGirl","Portuguese_ThoughtfulMan","Portuguese_PlayfulGirl","Portuguese_GorgeousLady","Portuguese_LovelyLady","Portuguese_SereneWoman","Portuguese_SadTeen","Portuguese_MaturePartner","Portuguese_Comedian","Portuguese_NaughtySchoolgirl","Portuguese_Narrator","Portuguese_ToughBoss","Portuguese_Fussyhostess","Portuguese_Dramatist","Portuguese_Steadymentor","Portuguese_Jovialman","Portuguese_CharmingQueen","Portuguese_SantaClaus","Portuguese_Rudolph","Portuguese_Arnold","Portuguese_CharmingSanta","Portuguese_CharmingLady","Portuguese_Ghost","Portuguese_HumorousElder","Portuguese_CalmLeader","Portuguese_GentleTeacher","Portuguese_EnergeticBoy","Portuguese_ReliableMan","Portuguese_SereneElder","Portuguese_GrimReaper","Portuguese_AssertiveQueen","Portuguese_WhimsicalGirl","Portuguese_StressedLady","Portuguese_FriendlyNeighbor","Portuguese_CaringGirlfriend","Portuguese_PowerfulSoldier","Portuguese_FascinatingBoy","Portuguese_RomanticHusband","Portuguese_StrictBoss","Portuguese_InspiringLady","Portuguese_PlayfulSpirit","Portuguese_ElegantGirl","Portuguese_CompellingGirl","Portuguese_PowerfulVeteran","Portuguese_SensibleManager","Portuguese_ThoughtfulLady","Portuguese_TheatricalActor","Portuguese_FragileBoy","Portuguese_ChattyGirl","Portuguese_Conscientiousinstructor","Portuguese_RationalMan","Portuguese_WiseScholar","Portuguese_FrankLady","Portuguese_DeterminedManager","French_Male_Speech_New","French_Female_News Anchor","French_CasualMan","French_MovieLeadFemale","French_FemaleAnchor","French_MaleNarrator","Indonesian_SweetGirl","Indonesian_ReservedYoungMan","Indonesian_CharmingGirl","Indonesian_CalmWoman","Indonesian_ConfidentWoman","Indonesian_CaringMan","Indonesian_BossyLeader","Indonesian_DeterminedBoy","Indonesian_GentleGirl","German_FriendlyMan","German_SweetLady","German_PlayfulMan","Russian_HandsomeChildhoodFriend","Russian_BrightHeroine","Russian_AmbitiousWoman","Russian_ReliableMan","Russian_CrazyQueen","Russian_PessimisticGirl","Russian_AttractiveGuy","Russian_Bad-temperedBoy","Italian_BraveHeroine","Italian_Narrator","Italian_WanderingSorcerer","Italian_DiligentLeader","Dutch_kindhearted_girl","Dutch_bossy_leader","Vietnamese_kindhearted_girl","Arabic_CalmWoman","Arabic_FriendlyGuy","Turkish_CalmWoman","Turkish_Trustworthyman","Ukrainian_CalmWoman"],Ds=[{value:"auto",label:"Auto"},{value:"happy",label:"Happy"},{value:"sad",label:"Sad"},{value:"angry",label:"Angry"},{value:"fearful",label:"Fearful"},{value:"disgusted",label:"Disgusted"},{value:"surprised",label:"Surprised"},{value:"neutral",label:"Neutral"}],Gs=[{value:"English",label:"English"},{value:"Chinese",label:"Chinese"},{value:"Japanese",label:"Japanese"},{value:"Korean",label:"Korean"},{value:"Spanish",label:"Spanish"},{value:"Portuguese",label:"Portuguese"},{value:"French",label:"French"},{value:"Indonesian",label:"Indonesian"},{value:"German",label:"German"},{value:"Russian",label:"Russian"},{value:"Italian",label:"Italian"},{value:"Dutch",label:"Dutch"},{value:"Vietnamese",label:"Vietnamese"},{value:"Arabic",label:"Arabic"},{value:"Turkish",label:"Turkish"},{value:"Ukrainian",label:"Ukrainian"},{value:"Cantonese",label:"Cantonese"}],As=[{value:"mp3",label:"MP3"},{value:"wav",label:"WAV"},{value:"flac",label:"FLAC"}];function xt({open:l,onOpenChange:c,onSave:n}){const m=(()=>{if(typeof window>"u")return null;try{const o=localStorage.getItem(Is);return o?JSON.parse(o):null}catch{return null}})(),[u,j]=t.useState(""),[h,N]=t.useState(m?.voiceId||"English_Trustworth_Man"),[P,S]=t.useState(m?.useCustomVoice||!1),[d,x]=t.useState(m?.customVoiceId||""),[y,E]=t.useState(m?.speed??1),[w,b]=t.useState(m?.pitch??0),[_,z]=t.useState(m?.emotion||"auto"),[M,T]=t.useState(m?.languageBoost||"English"),[A,v]=t.useState(m?.audioFormat||"mp3"),[k,q]=t.useState(null),[L,D]=t.useState(!1),[I,g]=t.useState(!1),[K,Y]=t.useState(0),H=t.useRef(null),{toast:ee}=$e();t.useEffect(()=>{const o={voiceId:h,useCustomVoice:P,customVoiceId:d,speed:y,pitch:w,emotion:_,languageBoost:M,audioFormat:A};localStorage.setItem(Is,JSON.stringify(o))},[h,P,d,y,w,_,M,A]),t.useEffect(()=>(L?(Y(0),H.current=setInterval(()=>{Y(o=>o+1)},1e3)):H.current&&(clearInterval(H.current),H.current=null),()=>{H.current&&clearInterval(H.current)}),[L]);const V=async()=>{if(!u.trim()){ee({title:"Text required",description:"Please enter text to generate audio",variant:"destructive"});return}D(!0),q(null);try{const o=P?d:h,te=new AbortController,i=setTimeout(()=>te.abort(),3e5),F=await fetch(`${ae}/api/v1/resources/generate-audio`,{method:"POST",headers:{"Content-Type":"application/json"},signal:te.signal,body:JSON.stringify({text:u,voice_id:o,speed:y,pitch:w,emotion:_,language_boost:M,audio_format:A})});if(clearTimeout(i),F.status===504||F.status===502||F.status===408)throw new Error("Request timed out. The audio model may be warming up - please try again.");const se=F.headers.get("content-type");if(!se||!se.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const X=await F.json();if(!F.ok||!X.success){const re=X.error?.message||"Failed to generate audio",ue=X.error?.code==="MISSING_API_TOKEN";throw new Error(ue?"Replicate API token not configured. Please add it in Settings → Integrations.":re)}q(X.data.audioUrl),ee({title:"Audio generated",description:"Your audio has been generated successfully"})}catch(o){console.error("Generation error:",o);const te=o instanceof Error&&o.name==="AbortError",i=te?"Request timed out after 5 minutes. The model may be overloaded - please try again.":o instanceof Error?o.message:"Failed to generate audio.",F=te||i.toLowerCase().includes("timeout")||i.toLowerCase().includes("timed out");ee({title:F?"Generation timed out":"Generation failed",description:i,variant:"destructive"})}finally{D(!1)}};t.useEffect(()=>{const o=te=>{l&&(te.metaKey||te.ctrlKey)&&te.key==="Enter"&&(te.preventDefault(),u.trim()&&!L&&!I&&V())};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[l,u,L,I]);const O=async()=>{if(k){g(!0);try{await n(k),j(""),N("English_Trustworth_Man"),S(!1),x(""),E(1),b(0),z("auto"),T("English"),v("mp3"),q(null),c(!1)}catch(o){ee({title:"Save failed",description:o instanceof Error?o.message:"Failed to save audio. Please try again.",variant:"destructive"})}finally{g(!1)}}},Q=()=>{!L&&!I&&c(!1)};return e.jsx(pe,{open:l,onOpenChange:Q,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Audio"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:L?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):k?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-16 w-16 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-4 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:k,controls:!0,className:"w-full max-w-[90%]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(fe,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[55vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"text-mobile",className:"text-xs",children:"Text"}),e.jsx(ye,{id:"text-mobile",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>j(o.target.value),rows:3,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Voice"}),e.jsxs(W,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),N(o))},children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsxs(U,{className:"max-h-60",children:[Ts.map(o=>e.jsx(G,{value:o,className:"text-xs",children:o.replace(/_/g," ")},o)),e.jsx(G,{value:"__custom__",className:"text-xs font-medium",children:"Custom Voice ID..."})]})]}),P&&e.jsx(We,{placeholder:"Enter custom voice ID",value:d,onChange:o=>x(o.target.value),className:"h-8 text-xs mt-1"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Speed: ",y.toFixed(1),"x"]}),e.jsx(Pe,{value:[y],onValueChange:([o])=>E(o),min:.5,max:2,step:.1,className:"w-full"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(C,{className:"text-xs",children:["Pitch: ",w>0?"+":"",w]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>b(o),min:-12,max:12,step:1,className:"w-full"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Emotion"}),e.jsxs(W,{value:_,onValueChange:z,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ds.map(o=>e.jsx(G,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Language"}),e.jsxs(W,{value:M,onValueChange:T,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Gs.map(o=>e.jsx(G,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Format"}),e.jsxs(W,{value:A,onValueChange:v,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:As.map(o=>e.jsx(G,{value:o.value,className:"text-xs",children:o.label},o.value))})]})]})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:V,disabled:!u.trim()||L||I,className:"flex-1 h-9",size:"sm",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Rs,{}),e.jsxs("span",{children:[K,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:O,disabled:!k||L||I,variant:"outline",className:"flex-1 h-9",size:"sm",children:I?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[30%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"text",children:"Text"}),e.jsx(ye,{id:"text",placeholder:"Enter text to convert to speech...",value:u,onChange:o=>j(o.target.value),rows:6,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Voice"}),e.jsxs(W,{value:P?"__custom__":h,onValueChange:o=>{o==="__custom__"?S(!0):(S(!1),N(o))},children:[e.jsx(B,{children:e.jsx($,{})}),e.jsxs(U,{className:"max-h-80",children:[Ts.map(o=>e.jsx(G,{value:o,children:o.replace(/_/g," ")},o)),e.jsx(G,{value:"__custom__",className:"font-medium",children:"Custom Voice ID..."})]})]}),P&&e.jsx(We,{placeholder:"Enter custom voice ID",value:d,onChange:o=>x(o.target.value),className:"mt-2"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Speed: ",y.toFixed(1),"x"]}),e.jsx(Pe,{value:[y],onValueChange:([o])=>E(o),min:.5,max:2,step:.1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"0.5x"}),e.jsx("span",{children:"2x"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Pitch: ",w>0?"+":"",w]}),e.jsx(Pe,{value:[w],onValueChange:([o])=>b(o),min:-12,max:12,step:1,className:"w-full"}),e.jsxs("div",{className:"flex justify-between text-xs text-muted-foreground",children:[e.jsx("span",{children:"-12"}),e.jsx("span",{children:"+12"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Emotion"}),e.jsxs(W,{value:_,onValueChange:z,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:Ds.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Language Boost"}),e.jsxs(W,{value:M,onValueChange:T,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:Gs.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{children:"Audio Format"}),e.jsxs(W,{value:A,onValueChange:v,children:[e.jsx(B,{children:e.jsx($,{})}),e.jsx(U,{children:As.map(o=>e.jsx(G,{value:o.value,children:o.label},o.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:V,disabled:!u.trim()||L||I,className:"w-full",children:L?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Rs,{}),e.jsxs("span",{children:["Generating... ",K,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:O,disabled:!k||L||I,variant:"outline",className:"w-full",children:I?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:L?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating audio..."})]}):k?e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/50 flex justify-center",children:e.jsx("audio",{src:k,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(fe,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated audio will appear here"})]})})})]})]})})}const Ls="video-generator-settings";function Ks(){return e.jsxs("div",{className:"relative h-4 w-4",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-primary/30"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent border-t-primary animate-spin"}),e.jsx("div",{className:"absolute inset-[3px] rounded-full border border-transparent border-t-primary/60 animate-spin",style:{animationDirection:"reverse",animationDuration:"0.6s"}})]})}const Vs=[{value:"5",label:"5 seconds"},{value:"8",label:"8 seconds"},{value:"10",label:"10 seconds"}],Os=[{value:"480p",label:"480p"},{value:"720p",label:"720p"},{value:"1080p",label:"1080p"}],Ws=[{value:"16:9",label:"16:9 (Landscape)"},{value:"9:16",label:"9:16 (Portrait)"},{value:"1:1",label:"1:1 (Square)"}];function ft({open:l,onOpenChange:c,onSave:n}){const m=(()=>{if(typeof window>"u")return null;try{const i=localStorage.getItem(Ls);return i?JSON.parse(i):null}catch{return null}})(),[u,j]=t.useState(""),[h,N]=t.useState(m?.duration||"8"),[P,S]=t.useState(m?.resolution||"720p"),[d,x]=t.useState(m?.aspectRatio||"16:9"),[y,E]=t.useState(m?.generateAudio??!0),[w,b]=t.useState(null),[_,z]=t.useState(null),[M,T]=t.useState(null),[A,v]=t.useState(0),k=t.useRef(null),[q,L]=t.useState(!1),[D,I]=t.useState(!1),[g,K]=t.useState([]),{toast:Y}=$e();t.useEffect(()=>{const i={duration:h,resolution:P,aspectRatio:d,generateAudio:y};localStorage.setItem(Ls,JSON.stringify(i))},[h,P,d,y]),t.useEffect(()=>(q?(v(0),k.current=setInterval(()=>{v(i=>i+1)},1e3)):k.current&&(clearInterval(k.current),k.current=null),()=>{k.current&&clearInterval(k.current)}),[q]),t.useEffect(()=>{l&&H()},[l]);const H=async()=>{try{const F=await(await fetch(`${ae}/api/v1/resources`)).json();if(F.success){const se=(F.data||[]).filter(X=>{const re=X.type==="image/jpeg"||X.name.toLowerCase().endsWith(".jpg")||X.name.toLowerCase().endsWith(".jpeg"),ue=X.type==="image/png"||X.name.toLowerCase().endsWith(".png");return(re||ue)&&X.thumbnailPath});K(se)}}catch(i){console.error("Failed to fetch image resources:",i)}},ee=i=>{i===_?z(null):i===w?(b(null),z(i)):w?z(i):b(i)},V=()=>{b(null),z(null)},O=async()=>{if(!u.trim()){Y({title:"Prompt required",description:"Please enter a prompt to generate a video",variant:"destructive"});return}L(!0),T(null);try{const i=new AbortController,F=setTimeout(()=>i.abort(),3e5),se=await fetch(`${ae}/api/v1/resources/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},signal:i.signal,body:JSON.stringify({prompt:u,image:w||void 0,last_frame:_||void 0,duration:parseInt(h),resolution:P,aspect_ratio:d,generate_audio:y})});if(clearTimeout(F),se.status===504||se.status===502||se.status===408)throw new Error("Request timed out. The video model may be warming up - please try again.");const X=se.headers.get("content-type");if(!X||!X.includes("application/json"))throw new Error("Request timed out or server error. Please try again.");const re=await se.json();if(!se.ok||!re.success){const ue=re.error?.message||"Failed to generate video",he=re.error?.code==="MISSING_API_TOKEN";throw new Error(he?"Replicate API token not configured. Please add it in Settings → Integrations.":ue)}T(re.data.videoUrl),Y({title:"Video generated",description:"Your video has been generated successfully"})}catch(i){console.error("Generation error:",i);const F=i instanceof Error&&i.name==="AbortError",se=F?"Request timed out after 5 minutes. The model may be overloaded - please try again.":i instanceof Error?i.message:"Failed to generate video.",X=F||se.toLowerCase().includes("timeout")||se.toLowerCase().includes("timed out");Y({title:X?"Generation timed out":"Generation failed",description:se,variant:"destructive"})}finally{L(!1)}};t.useEffect(()=>{const i=F=>{l&&(F.metaKey||F.ctrlKey)&&F.key==="Enter"&&(F.preventDefault(),u.trim()&&!q&&!D&&O())};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[l,u,q,D]);const Q=async()=>{if(M){I(!0);try{await n(M),j(""),N("8"),S("720p"),x("16:9"),E(!0),b(null),z(null),T(null),c(!1)}catch(i){Y({title:"Save failed",description:i instanceof Error?i.message:"Failed to save video. Please try again.",variant:"destructive"})}finally{I(!1)}}},o=()=>{!q&&!D&&c(!1)},te=i=>i===w?"start":i===_?"end":null;return e.jsx(pe,{open:l,onOpenChange:o,children:e.jsxs(ge,{className:"max-w-[95vw] sm:max-w-[90vw] w-full sm:w-[90vw] max-h-[95vh] sm:max-h-[90vh] h-[95vh] sm:h-[90vh] p-0 gap-0 flex flex-col",children:[e.jsx(ve,{className:"px-4 sm:px-6 pt-4 sm:pt-6 pb-3 sm:pb-4 border-b flex-shrink-0",children:e.jsx(je,{className:"text-base sm:text-lg",children:"Generate Video"})}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden md:hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-3 flex items-center justify-center bg-muted/30 overflow-hidden",children:q?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3",children:[e.jsx(le,{className:"h-10 w-10 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Generating..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:M,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 text-muted-foreground",children:[e.jsx(Be,{className:"h-12 w-12"}),e.jsx("p",{className:"text-xs",children:"Preview"})]})}),e.jsxs("div",{className:"border-t bg-background p-2 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2 px-1",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-1.5 overflow-x-auto pb-1",children:[e.jsx("button",{onClick:V,className:`flex-shrink-0 h-16 w-16 flex items-center justify-center border-2 rounded-md transition-colors text-xs ${!w&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:"None"}),g.map(i=>{const F=te(i.id);return e.jsxs("button",{onClick:()=>ee(i.id),className:`relative flex-shrink-0 h-16 w-16 border-2 rounded-md overflow-hidden transition-colors ${F?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${ae}/api/v1/resources/${i.id}/thumbnail`,alt:i.name,className:"w-full h-full object-cover"}),F&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-[10px] font-medium text-center py-0.5",children:F==="start"?"Start":"End"})]},i.id)})]})]}),e.jsx("div",{className:"border-t p-3 overflow-y-auto flex-shrink-0 max-h-[40vh]",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{htmlFor:"prompt-mobile",className:"text-xs",children:"Prompt"}),e.jsx(ye,{id:"prompt-mobile",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>j(i.target.value),rows:2,className:"resize-none text-sm"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Duration"}),e.jsxs(W,{value:h,onValueChange:N,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Vs.map(i=>e.jsx(G,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Resolution"}),e.jsxs(W,{value:P,onValueChange:S,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Os.map(i=>e.jsx(G,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(C,{className:"text-xs",children:"Ratio"}),e.jsxs(W,{value:d,onValueChange:x,children:[e.jsx(B,{className:"h-8 text-xs",children:e.jsx($,{})}),e.jsx(U,{children:Ws.map(i=>e.jsx(G,{value:i.value,className:"text-xs",children:i.label},i.value))})]})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oe,{id:"generateAudio-mobile",checked:y,onCheckedChange:i=>E(i===!0)}),e.jsx(C,{htmlFor:"generateAudio-mobile",className:"text-xs cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex gap-2 pt-1",children:[e.jsx(R,{onClick:O,disabled:!u.trim()||q||D,className:"flex-1 h-9",size:"sm",children:q?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:[A,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-1.5",children:["Generate",e.jsx(me,{className:"ml-1",children:"⌘↵"})]})}),e.jsx(R,{onClick:Q,disabled:!M||q||D,variant:"outline",className:"flex-1 h-9",size:"sm",children:D?e.jsx(le,{className:"h-4 w-4 animate-spin"}):"Save"})]})]})})]}),e.jsxs("div",{className:"flex-1 hidden md:flex overflow-hidden",children:[e.jsx("div",{className:"w-[22%] border-r p-6 overflow-y-auto",children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"prompt",children:"Prompt"}),e.jsx(ye,{id:"prompt",placeholder:"Describe the video you want to generate...",value:u,onChange:i=>j(i.target.value),rows:4,className:"resize-none"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"duration",children:"Duration"}),e.jsxs(W,{value:h,onValueChange:N,children:[e.jsx(B,{id:"duration",children:e.jsx($,{})}),e.jsx(U,{children:Vs.map(i=>e.jsx(G,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"resolution",children:"Resolution"}),e.jsxs(W,{value:P,onValueChange:S,children:[e.jsx(B,{id:"resolution",children:e.jsx($,{})}),e.jsx(U,{children:Os.map(i=>e.jsx(G,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"aspectRatio",children:"Aspect Ratio"}),e.jsxs(W,{value:d,onValueChange:x,children:[e.jsx(B,{id:"aspectRatio",children:e.jsx($,{})}),e.jsx(U,{children:Ws.map(i=>e.jsx(G,{value:i.value,children:i.label},i.value))})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(Oe,{id:"generateAudio",checked:y,onCheckedChange:i=>E(i===!0)}),e.jsx(C,{htmlFor:"generateAudio",className:"cursor-pointer",children:"Generate audio"})]}),e.jsxs("div",{className:"flex flex-col gap-2 pt-4",children:[e.jsx(R,{onClick:O,disabled:!u.trim()||q||D,className:"w-full",children:q?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Ks,{}),e.jsxs("span",{children:["Generating... ",A,"s"]})]}):e.jsxs("span",{className:"flex items-center gap-2",children:["Generate",e.jsx(me,{children:"⌘"}),e.jsx(me,{children:"↵"})]})}),e.jsx(R,{onClick:Q,disabled:!M||q||D,variant:"outline",className:"w-full",children:D?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save"})]})]})}),e.jsxs("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"flex-1 min-h-0 p-6 flex items-center justify-center bg-muted/30 overflow-hidden",children:q?e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[e.jsx(le,{className:"h-12 w-12 animate-spin text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Generating video..."})]}):M?e.jsx("div",{className:"w-full h-full min-h-0 flex items-center justify-center overflow-hidden",children:e.jsx("video",{src:M,controls:!0,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg",children:"Your browser does not support the video tag."})}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[e.jsx(Be,{className:"h-16 w-16"}),e.jsx("p",{className:"text-sm",children:"Generated video will appear here"})]})}),e.jsxs("div",{className:"border-t bg-background p-4 flex-shrink-0",children:[e.jsx("p",{className:"text-xs text-muted-foreground mb-2",children:"Select start and end frames (optional)"}),e.jsxs("div",{className:"flex gap-2 overflow-x-auto",children:[e.jsx("button",{onClick:V,className:`flex-shrink-0 h-32 w-32 flex items-center justify-center border-2 rounded-md transition-colors ${!w&&!_?"border-primary bg-primary/10":"border-muted hover:border-muted-foreground/50"}`,children:e.jsx("span",{className:"text-sm font-medium",children:"None"})}),g.map(i=>{const F=te(i.id);return e.jsxs("button",{onClick:()=>ee(i.id),className:`relative flex-shrink-0 h-32 w-32 border-2 rounded-md overflow-hidden transition-colors ${F?"border-green-500 ring-2 ring-green-500":"border-muted hover:border-muted-foreground/50"}`,children:[e.jsx("img",{src:`${ae}/api/v1/resources/${i.id}/thumbnail`,alt:i.name,className:"w-full h-full object-cover"}),F&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-green-500 text-white text-xs font-medium text-center py-1",children:F==="start"?"Start":"End"})]},i.id)})]})]})]})]})]})})}function pt({open:l,onOpenChange:c,resource:n,onCopyPath:p,onDownload:m,onNavigate:u,canNavigatePrev:j,canNavigateNext:h}){const[N,P]=t.useState(null),[S,d]=t.useState(!1),[x,y]=t.useState(!1);t.useEffect(()=>{y(!1)},[n?.id,l]);const E=n?`${ae}/api/v1/resources/${n.id}`:"",w=n?.type.startsWith("image/")??!1,b=n?n.type==="image/svg+xml"||n.name.toLowerCase().endsWith(".svg"):!1,_=n?n.type==="application/pdf"||n.name.toLowerCase().endsWith(".pdf"):!1,z=n?.type.startsWith("video/")??!1,M=n?.type.startsWith("audio/")??!1,T=n?n.type.startsWith("text/")||n.type==="application/json"||n.type.includes("javascript")||n.type.includes("typescript")||n.type.includes("xml")||n.name.toLowerCase().match(/\.(txt|md|json|js|ts|jsx|tsx|css|html|xml|yaml|yml|log|sh|bash|zsh|fish)$/)!==null:!1,A=n?n.name.toLowerCase().endsWith(".md")||n.name.toLowerCase().endsWith(".markdown"):!1,v=n?n.type==="application/json"||n.name.toLowerCase().endsWith(".json"):!1,k=n?n.type==="text/html"||n.name.toLowerCase().endsWith(".html"):!1;if(t.useEffect(()=>{const g=K=>{if(l){if(K.key==="Escape"){x?y(!1):c(!1);return}if(!x){if(K.key==="ArrowLeft"&&j){K.preventDefault(),u("prev");return}K.key==="ArrowRight"&&h&&(K.preventDefault(),u("next"))}}};if(l)return document.addEventListener("keydown",g),()=>document.removeEventListener("keydown",g)},[l,c,u,j,h,x]),t.useEffect(()=>{l&&n&&(T||A||v||k)?(d(!0),fetch(E).then(g=>{if(g.ok)return g.text();throw new Error("Failed to load file")}).then(g=>{P(g)}).catch(g=>{console.error("Failed to load text content:",g),P(null)}).finally(()=>{d(!1)})):P(null)},[l,n?.id,T,A,v,k,E]),!n)return null;const q=g=>{if(g===0)return"0 B";const K=1024,Y=["B","KB","MB","GB"],H=Math.floor(Math.log(g)/Math.log(K));return parseFloat((g/Math.pow(K,H)).toFixed(2))+" "+Y[H]},L=g=>new Date(g).toLocaleString(),D=g=>g.startsWith("image/")?e.jsx(Ne,{className:"h-6 w-6"}):g.startsWith("video/")?e.jsx(Be,{className:"h-6 w-6"}):g.startsWith("audio/")?e.jsx(fe,{className:"h-6 w-6"}):g.includes("text")||g.includes("document")||g.includes("code")?e.jsx(we,{className:"h-6 w-6"}):g.includes("json")||g.includes("javascript")||g.includes("typescript")?e.jsx(ss,{className:"h-6 w-6"}):e.jsx(Ze,{className:"h-6 w-6"}),I=()=>{if(b)return e.jsxs(e.Fragment,{children:[e.jsx("img",{src:E,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>y(!0),children:e.jsx(ys,{className:"h-4 w-4"})})]});if(_)return e.jsx("iframe",{src:E,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name});if(z)return e.jsx("video",{src:E,controls:!0,className:"max-w-full max-h-full rounded-lg shadow-lg",children:"Your browser does not support the video tag."});if(M)return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsx(fe,{className:"h-24 w-24 text-muted-foreground/50"})}),e.jsx("div",{className:"flex-shrink-0 p-6 bg-muted/30 flex justify-center",children:e.jsx("audio",{src:E,controls:!0,className:"w-3/4 min-w-[300px]",children:"Your browser does not support the audio tag."})})]});if(A&&N!==null)return S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6 prose prose-sm dark:prose-invert max-w-none",children:e.jsx(pa,{remarkPlugins:[va],rehypePlugins:[ga],children:N})});if(k&&N!==null)return S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("iframe",{srcDoc:N,className:"w-full h-full min-h-[600px] rounded-lg border",title:n.name,sandbox:"allow-same-origin"});if(v&&N!==null){if(S)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})});let g=N;try{const K=JSON.parse(N);g=JSON.stringify(K,null,2)}catch{}return e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto",children:e.jsx("code",{children:g})})})}return T&&N!==null?S?e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-sm text-muted-foreground",children:"Loading..."})}):e.jsx("div",{className:"w-full h-full overflow-auto p-6",children:e.jsx("pre",{className:"text-xs bg-muted p-4 rounded-lg overflow-auto whitespace-pre-wrap",children:e.jsx("code",{children:N})})}):w?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:E,alt:n.name,className:"max-w-full max-h-full object-contain rounded-lg shadow-lg"}),e.jsx(R,{variant:"secondary",size:"icon",className:"absolute bottom-3 right-3 h-8 w-8 opacity-70 hover:opacity-100 transition-opacity",onClick:()=>y(!0),children:e.jsx(ys,{className:"h-4 w-4"})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4 text-muted-foreground",children:[D(n.type),e.jsx("p",{className:"text-sm",children:"Preview not available for this file type"}),e.jsxs(R,{variant:"outline",onClick:()=>m(n),children:[e.jsx(es,{className:"mr-2 h-4 w-4"}),"Download to view"]})]})};return e.jsxs(e.Fragment,{children:[e.jsx(pe,{open:l,onOpenChange:c,children:e.jsxs(ge,{className:"max-w-[90vw] w-[90vw] max-h-[90vh] h-[90vh] p-0 gap-0 flex flex-col [&>button]:hidden",children:[e.jsx(ve,{className:"px-6 pt-6 pb-4 border-b flex-shrink-0",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[D(n.type),e.jsxs("div",{className:"flex-1 min-w-0 flex items-baseline gap-3",children:[e.jsx(je,{className:"text-xl truncate",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground flex-shrink-0",children:n.type})]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>p(n),title:"Copy path to clipboard",children:e.jsx(Xe,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>m(n),title:"Download",children:e.jsx(es,{className:"h-4 w-4"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>c(!1),title:"Close",children:e.jsx(cs,{className:"h-4 w-4"})})]})]})}),e.jsx("div",{className:"flex-1 flex overflow-hidden",children:e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 relative flex items-center justify-center bg-muted/30 p-6 overflow-hidden",children:[j&&e.jsx("button",{type:"button",onClick:()=>u("prev"),className:"absolute left-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Previous resource",children:e.jsx(zs,{className:"h-5 w-5"})}),h&&e.jsx("button",{type:"button",onClick:()=>u("next"),className:"absolute right-4 top-1/2 -translate-y-1/2 rounded-full border bg-background/80 p-2 shadow-sm hover:bg-background transition-colors","aria-label":"Next resource",children:e.jsx($s,{className:"h-5 w-5"})}),I()]}),e.jsx("div",{className:"border-t p-6 flex-shrink-0 bg-background",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"grid gap-x-6 gap-y-2 md:grid-cols-2 text-sm",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(La,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Size:"}),e.jsx("span",{children:q(n.size)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ka,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Uploaded:"}),e.jsx("span",{children:L(n.uploadedAt)})]})]}),e.jsx("div",{className:"space-y-2",children:n.metadata.tags&&n.metadata.tags.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Pa,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1",children:n.metadata.tags.map(g=>e.jsx(Me,{variant:"secondary",className:"text-xs",children:g},g))})]})})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[n.metadata.description?e.jsxs(e.Fragment,{children:[e.jsx(we,{className:"h-4 w-4 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"text-muted-foreground",children:"Description:"}),e.jsx("span",{className:"truncate flex-1",title:n.metadata.description,children:n.metadata.description})]}):e.jsx("div",{className:"flex-1"}),n.metadata.generationPrompt&&e.jsxs(R,{size:"sm",className:"h-6 text-xs px-2 flex-shrink-0",onClick:()=>{navigator.clipboard.writeText(n.metadata.generationPrompt||"")},children:[e.jsx(Xe,{className:"h-2.5 w-2.5 mr-1"}),"Copy Prompt"]})]})]})})]})})]})}),x&&(w||b)&&e.jsxs("div",{className:"fixed inset-0 z-[100] bg-black/95 flex items-center justify-center",onClick:()=>y(!1),children:[e.jsx(R,{variant:"ghost",size:"icon",className:"absolute top-4 right-4 h-10 w-10 text-white hover:bg-white/20",onClick:()=>y(!1),children:e.jsx(cs,{className:"h-6 w-6"})}),e.jsx("img",{src:E,alt:n.name,className:"max-w-[95vw] max-h-[95vh] object-contain",onClick:g=>g.stopPropagation()})]})]})}function Mt(){const[l,c]=t.useState([]),[n,p]=t.useState(!0),[m,u]=t.useState(!1),[j,h]=t.useState(""),[N,P]=t.useState(!1),[S,d]=t.useState([]),[x,y]=t.useState(""),[E,w]=t.useState(""),[b,_]=t.useState([]),[z,M]=t.useState(!1),[T,A]=t.useState(!1),[v,k]=t.useState(!1),[q,L]=t.useState(null),[D,I]=t.useState(null),[g,K]=t.useState(null),[Y,H]=t.useState(1),ee=12,V=t.useRef(null),{toast:O}=$e();t.useEffect(()=>{Q()},[]);const Q=async()=>{try{p(!0);const r=await(await fetch(`${ae}/api/v1/resources`)).json();r.success&&c(r.data||[])}catch(s){console.error("Failed to fetch resources:",s)}finally{p(!1)}},o=s=>{s.length!==0&&_(Array.from(s))},te=async()=>{if(b.length!==0){u(!0);try{for(const s of b){const r=new FormData;if(r.append("file",s),r.append("tags",S.join(", ")),r.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:r})).ok)throw new Error("Upload failed")}d([]),y(""),w(""),_([]),P(!1),await Q(),O({title:"Upload successful",description:`${b.length} file(s) uploaded successfully`})}catch(s){console.error("Upload failed:",s),O({title:"Upload failed",description:"Failed to upload files. Please try again.",variant:"destructive"})}finally{u(!1)}}},i=()=>{d([]),y(""),w(""),_([]),P(!1)},F=s=>{if(s.key==="Enter"){s.preventDefault();const r=x.trim();r&&!S.includes(r)&&(d([...S,r]),y(""))}},se=s=>{d(S.filter(r=>r!==s))},X=s=>{_(b.filter((r,f)=>f!==s))},re=async()=>{if(g)try{if((await fetch(`${ae}/api/v1/resources/${g.id}`,{method:"DELETE"})).ok)await Q(),O({title:"Resource deleted",description:`${g.name} has been deleted`});else throw new Error("Delete failed")}catch(s){console.error("Failed to delete resource:",s),O({title:"Delete failed",description:"Failed to delete resource. Please try again.",variant:"destructive"})}finally{K(null)}},ue=async s=>{try{const r=`.nut/resources/files/${s.path}`;await Ca(r),O({title:"Path copied!",description:`Copied ${r} to clipboard`})}catch(r){console.error("Failed to copy path:",r),O({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},he=s=>{if(s===0)return"0 B";const r=1024,f=["B","KB","MB","GB"],Z=Math.floor(Math.log(s)/Math.log(r));return parseFloat((s/Math.pow(r,Z)).toFixed(2))+" "+f[Z]},Ie=(s,r)=>{const f=r.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||f.endsWith(".svg")?e.jsx(fs,{className:"h-4 w-4"}):e.jsx(Ne,{className:"h-4 w-4"}):s.startsWith("video/")?e.jsx(gs,{className:"h-4 w-4"}):s.startsWith("audio/")?e.jsx(xs,{className:"h-4 w-4"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(we,{className:"h-4 w-4"}):f.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(ss,{className:"h-4 w-4"}):s==="application/json"||f.endsWith(".json")?e.jsx(ps,{className:"h-4 w-4"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(vs,{className:"h-4 w-4"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(bs,{className:"h-4 w-4"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(we,{className:"h-4 w-4"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(js,{className:"h-4 w-4"}):e.jsx(Ze,{className:"h-4 w-4"})},Re=(s,r)=>{const f=r.toLowerCase();return s.startsWith("image/")?s==="image/svg+xml"||f.endsWith(".svg")?e.jsx(fs,{className:"h-16 w-16"}):e.jsx(Ne,{className:"h-16 w-16"}):s.startsWith("video/")?e.jsx(gs,{className:"h-16 w-16"}):s.startsWith("audio/")?e.jsx(xs,{className:"h-16 w-16"}):s==="application/pdf"||f.endsWith(".pdf")?e.jsx(we,{className:"h-16 w-16"}):f.match(/\.(js|jsx|ts|tsx|py|java|cpp|c|h|hpp|cs|go|rs|rb|php|swift|kt|scala|r|m|mm)$/)?e.jsx(ss,{className:"h-16 w-16"}):s==="application/json"||f.endsWith(".json")?e.jsx(ps,{className:"h-16 w-16"}):s.includes("spreadsheet")||s.includes("excel")||f.match(/\.(xls|xlsx|csv)$/)?e.jsx(vs,{className:"h-16 w-16"}):s.includes("presentation")||s.includes("powerpoint")||f.match(/\.(ppt|pptx)$/)?e.jsx(bs,{className:"h-16 w-16"}):s.startsWith("text/")||s.includes("document")||s.includes("word")?e.jsx(we,{className:"h-16 w-16"}):s.includes("font")||f.match(/\.(ttf|otf|woff|woff2|eot)$/)?e.jsx(js,{className:"h-16 w-16"}):e.jsx(Ze,{className:"h-16 w-16"})},xe=s=>{const r=s.name.toLowerCase(),f=s.type.startsWith("image/");return s.type==="image/svg+xml"||r.endsWith(".svg")?e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/30 rounded-md border overflow-hidden p-2",children:e.jsx("img",{src:`${ae}/api/v1/resources/${s.id}`,alt:s.name,className:"w-full h-full object-contain"})}):f&&s.thumbnailPath?e.jsx("img",{src:`${ae}/api/v1/resources/${s.id}/thumbnail`,alt:s.name,className:"w-full h-32 object-cover rounded-md border",onError:ne=>{ne.currentTarget.style.display="none"}}):e.jsx("div",{className:"w-full h-32 flex items-center justify-center bg-muted/50 rounded-md border",children:e.jsx("div",{className:"text-muted-foreground",children:Re(s.type,s.name)})})},ie=l.filter(s=>{if(!j)return!0;const r=j.toLowerCase();return s.name.toLowerCase().includes(r)||s.metadata.description?.toLowerCase().includes(r)||s.metadata.tags?.some(f=>f.toLowerCase().includes(r))}),J=Math.ceil(ie.length/ee),Ce=(Y-1)*ee,Te=ie.slice(Ce,Ce+ee);t.useEffect(()=>{H(1)},[j]);const ze=s=>{s.preventDefault(),s.stopPropagation()},ke=s=>{s.preventDefault(),s.stopPropagation(),s.dataTransfer.files&&s.dataTransfer.files.length>0&&o(s.dataTransfer.files)},De=(s,r)=>{if(r.target.closest("button"))return;L(s);const Z=ie.findIndex(ne=>ne.id===s.id);I(Z>=0?Z:null)},Ge=s=>{window.open(`${ae}/api/v1/resources/${s.id}?download=true`)},Ae=async(s,r)=>{u(!0);try{const f=await fetch(s);if(!f.ok)throw new Error("Failed to download generated image");const Z=await f.blob(),ne=`generated-image-${Date.now()}.png`,de=new FormData;de.append("file",Z,ne),de.append("tags",S.join(","));const ce=r?.prompt?`Generated with: "${r.prompt}"${r.model?` (${r.model})`:""}`:E;if(de.append("description",ce),r?.prompt&&de.append("generationPrompt",r.prompt),r?.model&&de.append("generationModel",r.model),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:de})).ok)throw new Error("Upload failed");await Q(),O({title:"Image saved",description:"Generated image has been saved to resources"})}catch(f){throw console.error("Failed to save generated image:",f),O({title:"Save failed",description:f instanceof Error?f.message:"Failed to save generated image",variant:"destructive"}),f}finally{u(!1)}},Le=s=>{window.dispatchEvent(new CustomEvent("customize-prompt-in-assistant",{detail:{prompt:s}}))},qe=async s=>{u(!0);try{const r=await fetch(s);if(!r.ok)throw new Error("Failed to download generated audio");const f=await r.blob();let Z="mp3";const ne=r.headers.get("content-type");ne?.includes("wav")?Z="wav":ne?.includes("flac")?Z="flac":s.includes(".wav")?Z="wav":s.includes(".flac")&&(Z="flac");const de=`generated-audio-${Date.now()}.${Z}`,ce=new FormData;if(ce.append("file",f,de),ce.append("tags",S.join(",")),ce.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await Q(),O({title:"Audio saved",description:"Generated audio has been saved to resources"})}catch(r){throw console.error("Failed to save generated audio:",r),O({title:"Save failed",description:r instanceof Error?r.message:"Failed to save generated audio",variant:"destructive"}),r}finally{u(!1)}},He=async s=>{u(!0);try{const r=await fetch(s);if(!r.ok)throw new Error("Failed to download generated video");const f=await r.blob();let Z="mp4";(r.headers.get("content-type")?.includes("webm")||s.includes(".webm"))&&(Z="webm");const de=`generated-video-${Date.now()}.${Z}`,ce=new FormData;if(ce.append("file",f,de),ce.append("tags",S.join(",")),ce.append("description",E),!(await fetch(`${ae}/api/v1/resources`,{method:"POST",body:ce})).ok)throw new Error("Upload failed");await Q(),O({title:"Video saved",description:"Generated video has been saved to resources"})}catch(r){throw console.error("Failed to save generated video:",r),O({title:"Save failed",description:r instanceof Error?r.message:"Failed to save generated video",variant:"destructive"}),r}finally{u(!1)}},a=s=>{if(D===null)return;const r=s==="next"?D+1:D-1;if(r<0||r>=ie.length)return;const f=ie[r];I(r),L(f)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Resources"}),e.jsx("p",{className:"text-muted-foreground",children:"Upload and generate media assets for your project"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs(ja,{children:[e.jsx(ya,{asChild:!0,children:e.jsxs(R,{variant:"outline",size:"sm",children:[e.jsx(Ee,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Generate"}),e.jsx(ba,{className:"h-3 w-3 ml-1 opacity-50"})]})}),e.jsxs(wa,{align:"end",className:"min-w-[var(--radix-dropdown-menu-trigger-width)]",children:[e.jsxs(Je,{onClick:()=>M(!0),children:[e.jsx(Ne,{className:"h-4 w-4 mr-2"}),"Image"]}),e.jsxs(Je,{onClick:()=>A(!0),children:[e.jsx(fe,{className:"h-4 w-4 mr-2"}),"Audio"]}),e.jsxs(Je,{onClick:()=>k(!0),children:[e.jsx(Be,{className:"h-4 w-4 mr-2"}),"Video"]})]})]}),e.jsxs(R,{size:"sm",onClick:()=>P(!N),children:[e.jsx(hs,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Upload Resources"})]})]})]}),e.jsx(pe,{open:N,onOpenChange:s=>!s&&i(),children:e.jsxs(ge,{className:"max-w-2xl",children:[e.jsxs(ve,{children:[e.jsx(je,{children:"Upload Resource"}),e.jsx(ds,{children:"Add files to your project resources"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"border-2 border-dashed border-muted-foreground/25 rounded-lg p-8 text-center cursor-pointer hover:border-muted-foreground/50 transition-colors",onDragOver:ze,onDrop:ke,onClick:()=>V.current?.click(),children:[e.jsx($a,{className:"mx-auto h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"mt-2 text-sm font-medium",children:"Drop files here or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Support for images, documents, and other files"})]}),e.jsx("input",{ref:V,type:"file",multiple:!0,className:"hidden",onChange:s=>s.target.files&&o(s.target.files)}),b.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs(C,{children:["Selected Files (",b.length,")"]}),e.jsx("div",{className:"border rounded-lg p-3 max-h-40 overflow-y-auto space-y-2",children:b.map((s,r)=>e.jsxs("div",{className:"flex items-center justify-between text-sm bg-muted/50 rounded px-3 py-2",children:[e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx(R,{variant:"ghost",size:"sm",onClick:()=>X(r),className:"h-6 w-6 p-0 ml-2",children:e.jsx(us,{className:"h-3 w-3"})})]},r))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"tags",children:"Tags"}),e.jsx(We,{id:"tags",placeholder:"Type a tag and press Enter",value:x,onChange:s=>y(s.target.value),onKeyDown:F}),S.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:S.map(s=>e.jsxs(Me,{variant:"secondary",className:"text-xs",children:[s,e.jsx("button",{type:"button",onClick:()=>se(s),className:"ml-1 hover:text-destructive",children:"×"})]},s))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(C,{htmlFor:"description",children:"Description"}),e.jsx(ye,{id:"description",placeholder:"Brief description of this resource...",value:E,onChange:s=>w(s.target.value),rows:3})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:i,disabled:m,children:"Cancel"}),e.jsx(R,{onClick:te,disabled:b.length===0||m,children:m?"Uploading...":`Upload ${b.length>0?`(${b.length})`:""}`})]})]})]})}),e.jsx("div",{className:"flex items-center space-x-2",children:e.jsxs("div",{className:"relative flex-1 w-full",children:[e.jsx(Ea,{className:"absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(We,{placeholder:"Search resources...",value:j,onChange:s=>h(s.target.value),className:"pl-8"})]})}),e.jsx("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:n?Array.from({length:6}).map((s,r)=>e.jsxs(Ye,{className:"animate-pulse",children:[e.jsxs(ms,{children:[e.jsx("div",{className:"h-4 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]}),e.jsx(Qe,{children:e.jsx("div",{className:"h-20 bg-muted rounded"})})]},r)):ie.length>0?Te.map(s=>e.jsxs(Ye,{className:"hover:shadow-lg hover:bg-muted transition-all cursor-pointer",onClick:r=>De(s,r),children:[e.jsxs(ms,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[Ie(s.type,s.name),e.jsx(_a,{className:"text-sm font-medium truncate",children:s.name})]}),e.jsxs(Sa,{className:"text-xs",children:[he(s.size)," • ",new Date(s.uploadedAt).toLocaleDateString()]}),e.jsxs("div",{className:"flex justify-end space-x-1 mt-2",children:[e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),ue(s)},title:"Copy path to clipboard",children:e.jsx(Xe,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),Ge(s)},children:e.jsx(es,{className:"h-3 w-3"})}),e.jsx(R,{variant:"ghost",size:"sm",onClick:r=>{r.stopPropagation(),K(s)},children:e.jsx(us,{className:"h-3 w-3"})})]})]}),e.jsxs(Qe,{className:"pt-0",children:[e.jsx("div",{className:"mb-3",children:xe(s)}),s.metadata.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-2 line-clamp-2",children:s.metadata.description}),s.metadata.tags&&s.metadata.tags.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1",children:s.metadata.tags.map(r=>e.jsx(Me,{variant:"secondary",className:"text-xs",children:r},r))})]})]},s.id)):e.jsx("div",{className:"col-span-full",children:e.jsx(Ye,{children:e.jsxs(Qe,{className:"flex flex-col items-center justify-center py-12",children:[e.jsx(Na,{className:"h-12 w-12 text-muted-foreground/50"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No resources yet"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground text-center max-w-sm",children:"Upload files to get started. Resources can be referenced by LLMs and team members for enhanced context."}),e.jsxs(R,{className:"mt-4",onClick:()=>P(!0),children:[e.jsx(hs,{className:"mr-2 h-4 w-4"}),"Add First Resource"]})]})})})}),ie.length>ee&&e.jsxs("div",{className:"flex items-center justify-center gap-4 pt-4 pb-8",children:[e.jsxs(R,{variant:Y===1?"outline":"default",size:"sm",onClick:()=>H(s=>Math.max(1,s-1)),disabled:Y===1,children:[e.jsx(zs,{className:"h-4 w-4 mr-1"}),"Previous"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Page ",Y," of ",J]}),e.jsxs(R,{variant:Y===J?"outline":"default",size:"sm",onClick:()=>H(s=>Math.min(J,s+1)),disabled:Y===J,children:["Next",e.jsx($s,{className:"h-4 w-4 ml-1"})]})]}),m&&e.jsx("div",{className:"fixed bottom-4 right-4 bg-background border rounded-lg shadow-lg p-4",children:e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),e.jsx("span",{className:"text-sm",children:"Uploading files..."})]})}),e.jsx(Ja,{open:z,onOpenChange:M,onSave:Ae,onCustomizeInAssistant:Le}),e.jsx(xt,{open:T,onOpenChange:A,onSave:qe}),e.jsx(ft,{open:v,onOpenChange:k,onSave:He}),e.jsx(pt,{open:!!q,onOpenChange:s=>{s||L(null),s||I(null)},resource:q,onCopyPath:ue,onDownload:Ge,onNavigate:a,canNavigatePrev:D!==null&&D>0,canNavigateNext:D!==null&&D<ie.length-1}),e.jsx(pe,{open:!!g,onOpenChange:s=>!s&&K(null),children:e.jsxs(ge,{className:"max-w-md",children:[e.jsxs(ve,{children:[e.jsx(je,{children:"Delete Resource"}),e.jsxs(ds,{children:["Are you sure you want to delete ",e.jsx("strong",{children:g?.name}),"? This action cannot be undone."]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4",children:[e.jsx(R,{variant:"outline",onClick:()=>K(null),children:"Cancel"}),e.jsx(R,{variant:"destructive",onClick:re,children:"Delete"})]})]})})]})}export{Mt as default};
@@ -1,13 +0,0 @@
1
- import{u as j,a as v,r as n,A as d,j as e,B as h,L as g,a7 as y}from"./index-hqVgTgRB.js";import{C as m,a as x,b as N,c as C}from"./card-BCFxXzRk.js";import{M as w}from"./markdown-editor-BzZ8tCto.js";import{A as S}from"./arrow-left-CdM_IPng.js";import{C as b}from"./circle-check-big-NI18oHuP.js";function B(){const u=j(),{toast:t}=v(),[i,a]=n.useState(""),[f,r]=n.useState(!0),[o,l]=n.useState(!1);n.useEffect(()=>{fetch(`${d}/api/v1/context/role`).then(s=>s.json()).then(s=>{s.success&&a(s.document.content.trim()),r(!1)}).catch(s=>{console.error("Failed to load context:",s),t({title:"Error",description:"Failed to load role definition",variant:"destructive"}),r(!1)})},[t]);const p=async()=>{l(!0);try{const c=await(await fetch(`${d}/api/v1/context/role`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:i,metadata:{}})})).json();if(c.success)t({title:"Success",description:"Role definition saved successfully",action:e.jsx(b,{className:"h-4 w-4"})}),u("/context/role");else throw new Error(c.error||"Failed to save context")}catch(s){console.error("Save error:",s),t({title:"Error",description:"Failed to save role definition",variant:"destructive"})}finally{l(!1)}};return f?e.jsx("div",{className:"space-y-6",children:e.jsx(m,{children:e.jsx(x,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{children:"Loading..."})})})})}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:"Edit Role Definition"}),e.jsx("p",{className:"text-muted-foreground text-sm hidden sm:block",children:"Define your role, responsibilities, and guidelines"})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(h,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(g,{to:"/context/role",className:"text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(S,{className:"w-4 h-4"})})}),e.jsxs(h,{onClick:p,disabled:o,size:"sm",children:[e.jsx(y,{className:"w-4 h-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:o?"Saving...":"Save"})]})]})]}),e.jsxs(m,{children:[e.jsx(N,{children:e.jsx(C,{children:"Role Documentation"})}),e.jsx(x,{children:e.jsx(w,{value:i,onChange:s=>a(s||""),placeholder:`Write your role definition in markdown...
2
-
3
- ## Your Role
4
-
5
- Describe your role and primary responsibilities.
6
-
7
- ## Guidelines
8
-
9
- Key guidelines and principles to follow.
10
-
11
- ## Constraints
12
-
13
- Any constraints or boundaries to be aware of.`,height:800})})]})]})}export{B as default};
@@ -1,4 +0,0 @@
1
- import{a as Qe,ak as Xe,r as m,j as e,B as u,H as O,bf as pe,R as q,U as ge,V as fe,W as V,Y,Z as G,_ as K,$ as Z,a0 as Q,a1 as X,L as ve,p as ee,ah as je,bg as es,C as ss,O as ts,v as se,D as Ne,b as be,d as ye,f as we,g as Se,I as te,h as as,i as rs,k as ns,l as is,m as ls,a9 as Ce,aa as ke,ab as Ae,ac as De,ad as Ie,ai as Te,w as ds,ag as cs,a5 as Fe,A as j}from"./index-hqVgTgRB.js";import{C as J,a as ae,c as re,b as Pe}from"./card-BCFxXzRk.js";import{B as F}from"./badge-DEiQk9C9.js";import{L as v}from"./label-vYhfrPMD.js";import{S as os}from"./switch-CH-VOgPo.js";import{T as ms,a as us,b as ne,c as ie}from"./tabs-XeRAjZYR.js";import{R as hs}from"./refresh-cw-Bg7vQzOw.js";import{P as $e}from"./plus-iamYJu5V.js";import{P as Me}from"./play-CCo7tau2.js";import{P as xs}from"./pause-BHonpdnw.js";import{C as ps}from"./clock-CeCp7Pz1.js";const ce=[{id:"claude",label:"Claude Code"},{id:"gemini",label:"Google Gemini"},{id:"codex",label:"OpenAI Codex"},{id:"droid",label:"Factory Droid"}],gs=[{label:"Monday",value:"monday"},{label:"Tuesday",value:"tuesday"},{label:"Wednesday",value:"wednesday"},{label:"Thursday",value:"thursday"},{label:"Friday",value:"friday"},{label:"Saturday",value:"saturday"},{label:"Sunday",value:"sunday"}],Ee=["monday","tuesday","wednesday","thursday","friday"],Oe=a=>{if(!a)return"—";try{return new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(new Date(a))}catch{return a}},H=a=>{if(!a)return"—";const x=new Date(a).getTime()-Date.now(),f=Math.round(x/(1e3*60));if(Number.isNaN(f))return Oe(a);if(Math.abs(f)<1)return"now";if(f>0){if(f<60)return`in ${f}m`;const b=Math.round(f/60);return b<24?`in ${b}h`:`in ${Math.round(b/24)}d`}const N=Math.abs(f);if(N<60)return`${N}m ago`;const T=Math.round(N/60);return T<24?`${T}h ago`:`${Math.round(T/24)}d ago`},fs=a=>{if(a.type==="interval"){const o=a.daysOfWeek.map(x=>x.slice(0,3).toUpperCase()).join(", ");return`Every ${a.hours}h (${o||"All days"})`}return a.description||`Cron: ${a.expression}`},vs=a=>{const o=ce.find(x=>x.id===a);return o?o.label:a},le=a=>{switch(a){case"active":case"succeeded":return"default";case"paused":case"running":return"secondary";case"failed":return"destructive";default:return"outline"}},de=()=>({name:"",model:"claude",prompt:"",hours:6,daysOfWeek:new Set(Ee),status:!0,anchorHour:"",agentIds:[],mcpServers:[]}),Re=a=>{if(a.schedule.type!=="interval")return de();const o=a.agentIds||(a.agentId?[a.agentId]:[]);return{name:a.name,model:ce.some(x=>x.id===a.model)?a.model:"claude",prompt:a.prompt,hours:a.schedule.hours,daysOfWeek:new Set(a.schedule.daysOfWeek),status:a.status==="active",anchorHour:a.schedule.anchorHour===void 0?"":String(a.schedule.anchorHour),agentIds:o,mcpServers:a.mcpServers||[]}},js=a=>a?Array.isArray(a)?a.filter(o=>typeof o=="string").map(o=>o.trim()).filter(Boolean):typeof a=="string"?a.split(",").map(o=>o.trim()).filter(Boolean):[]:[];function Fs(){const{toast:a}=Qe(),{refresh:o}=Xe(),[x,f]=m.useState([]),[N,T]=m.useState(!0),[L,b]=m.useState(!1),[P,y]=m.useState(!1),[n,p]=m.useState(()=>de()),[z,oe]=m.useState(!1),[w,S]=m.useState(null),[c,C]=m.useState(null),[g,$]=m.useState(null),[Je,M]=m.useState(!1),[R,He]=m.useState([]),[W,Le]=m.useState([]),[ze,We]=m.useState(new Set),[B,U]=m.useState({open:!1,serverToRemove:null}),k=async(s=!1)=>{try{N||b(!0);const t=await fetch(`${j}/api/v1/jobs`);if(!t.ok)throw new Error(`Failed to fetch jobs (${t.status})`);const r=await t.json();if(!r?.success)throw new Error(r?.error?.message||"Unknown error loading jobs");const i=r.data??[];if(f(i),c){const l=i.find(d=>d.id===c.id);l&&(C(l),l.schedule.type!=="cron"&&p(Re(l)))}if(g){const l=i.find(d=>d.id===g.id);l&&$(l)}s&&a({title:"Schedule refreshed",description:"Latest job information loaded."})}catch(t){console.error("Failed to load jobs:",t),a({title:"Failed to load schedule",description:t?.message??"Unknown error",variant:"destructive"})}finally{T(!1),b(!1)}};m.useEffect(()=>{k()},[]),m.useEffect(()=>{P&&(async()=>{try{const t=await fetch(`${j}/api/v1/agents`);if(t.ok){const i=await t.json(),d=(Array.isArray(i?.documents)?i.documents:[]).map(h=>({id:h.filename,name:h?.metadata?.name||h.title||h.filename,tools:js(h?.metadata?.tools)}));if(He(d),c){const D=(c.agentIds||(c.agentId?[c.agentId]:[])).filter(I=>!d.find(_=>_.id===I));D.length>0&&(a({title:"Some agents no longer available",description:`The following agents have been removed: ${D.join(", ")}`,variant:"destructive"}),p(I=>({...I,agentIds:I.agentIds.filter(_=>d.find(Ze=>Ze.id===_))})))}}const r=await fetch(`${j}/api/v1/mcp`);if(r.ok){const i=await r.json();if(i?.success&&Array.isArray(i.servers)&&(Le(i.servers),c?.mcpServers)){const l=c.mcpServers.filter(d=>!i.servers.includes(d));l.length>0&&(a({title:"Some MCP servers are no longer available",description:`The following servers have been removed: ${l.join(", ")}`,variant:"destructive"}),p(d=>({...d,mcpServers:d.mcpServers.filter(h=>i.servers.includes(h))})))}}}catch(t){console.error("Failed to load agents or MCP servers:",t)}})()},[P,c,a]);const A=s=>{p(t=>({...t,...s}))},Be=(s,t)=>{p(r=>{let i;if(t){i=[...r.agentIds,s];const l=R.find(d=>d.id===s);if(l&&l.tools.length>0){const d=new Set([...r.mcpServers,...l.tools]);return{...r,agentIds:i,mcpServers:Array.from(d).filter(h=>W.includes(h))}}}else i=r.agentIds.filter(l=>l!==s);return{...r,agentIds:i}})},Ue=(s,t)=>{if(!t&&R.filter(i=>n.agentIds.includes(i.id)&&i.tools.includes(s)).length>0){U({open:!0,serverToRemove:s});return}p(r=>({...r,mcpServers:t?[...r.mcpServers,s]:r.mcpServers.filter(i=>i!==s)}))},_e=()=>{const s=B.serverToRemove;s&&p(t=>({...t,mcpServers:t.mcpServers.filter(r=>r!==s)})),U({open:!1,serverToRemove:null})},qe=(s,t)=>{p(r=>{const i=new Set(r.daysOfWeek);return t?i.add(s):i.delete(s),i.size===0&&Ee.forEach(l=>i.add(l)),{...r,daysOfWeek:i}})},E=()=>{p(de())},me=s=>{We(t=>{const r=new Set(t);return r.has(s)?r.delete(s):r.add(s),r})},ue=s=>{$(s),M(!0)},he=()=>{C(null),E(),y(!0)},Ve=s=>{if(s._error){a({title:"Cannot edit corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}if(s.schedule.type==="cron"){a({title:"Manual edit required",description:"Cron-based jobs can be edited directly in .nut/jobs/<id>.md for now.",variant:"destructive"});return}C(s),p(Re(s)),y(!0)},Ye=async s=>{if(s.preventDefault(),!n.name.trim()){a({title:"Job name required",description:"Please provide a name for the scheduled job.",variant:"destructive"});return}if(!n.prompt.trim()){a({title:"Prompt required",description:"Please provide instructions for the scheduled job.",variant:"destructive"});return}oe(!0);const t=!!c;try{const r=Number(n.anchorHour.trim()),i=n.anchorHour.trim()===""||Number.isNaN(r)?void 0:Math.min(23,Math.max(0,r)),l={name:n.name.trim(),prompt:n.prompt.trim(),model:n.model,status:n.status?"active":"paused",schedule:{type:"interval",hours:Math.max(1,Number(n.hours)||6),daysOfWeek:Array.from(n.daysOfWeek),anchorHour:i},agentIds:n.agentIds.length>0?n.agentIds:void 0,mcpServers:n.mcpServers.length>0?n.mcpServers:void 0},d=t?`${j}/api/v1/jobs/${c?.id}`:`${j}/api/v1/jobs`,D=await fetch(d,{method:t?"PATCH":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!D.ok){const I=await D.json().catch(()=>({}));throw new Error(I?.error?.message||`Failed to ${t?"update":"create"} job (${D.status})`)}a({title:t?"Scheduled job updated":"Scheduled job created",description:l.name}),y(!1),C(null),E(),await k()}catch(r){console.error("Failed to submit job:",r),a({title:`Failed to ${c?"update":"create"} job`,description:r?.message??"Unknown error",variant:"destructive"})}finally{oe(!1)}},Ge=async s=>{if(s._error){a({title:"Cannot run corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}/run`,{method:"POST"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to run job (${t.status})`)}a({title:"Run started",description:`${s.name} is executing.`}),await k(),await o()}catch(t){console.error("Failed to run job:",t),a({title:"Run failed to start",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},Ke=async s=>{if(s._error){a({title:"Cannot update corrupted job",description:"Please fix the job file manually at .nut/jobs/"+s.id+".md",variant:"destructive"});return}S(s.id);const t=s.status==="active"?"paused":"active";try{const r=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i?.error?.message||`Failed to update job (${r.status})`)}a({title:t==="active"?"Job resumed":"Job paused",description:s.name}),await k(),await o()}catch(r){console.error("Failed to update job status:",r),a({title:"Failed to update job",description:r?.message??"Unknown error",variant:"destructive"})}finally{S(null)}},xe=async s=>{S(s.id);try{const t=await fetch(`${j}/api/v1/jobs/${s.id}`,{method:"DELETE"});if(!t.ok){const r=await t.json().catch(()=>({}));throw new Error(r?.error?.message||`Failed to delete job (${t.status})`)}a({title:"Scheduled job deleted",description:s.name}),c?.id===s.id&&(y(!1),C(null),E()),g?.id===s.id&&(M(!1),$(null)),await k()}catch(t){console.error("Failed to delete job:",t),a({title:"Failed to delete job",description:t?.message??"Unknown error",variant:"destructive"})}finally{S(null)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col gap-2 md:flex-row md:items-center md:justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Schedule"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Automate recurring agent runs with prompts, preferred models, and guardrails."})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(u,{variant:"outline",onClick:()=>k(!0),disabled:N||L,children:[L?e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(hs,{className:"mr-2 h-4 w-4"}),"Refresh"]}),e.jsxs(u,{onClick:he,children:[e.jsx($e,{className:"mr-2 h-4 w-4"}),"New Scheduled Job"]})]})]}),N?e.jsx(J,{children:e.jsxs(ae,{className:"flex items-center justify-center py-12 text-muted-foreground",children:[e.jsx(O,{className:"mr-2 h-5 w-5 animate-spin"}),"Loading scheduled jobs..."]})}):x.length===0?e.jsx(J,{className:"border-dashed",children:e.jsxs(ae,{className:"flex flex-col items-center justify-center py-16 px-6 text-center",children:[e.jsx("div",{className:"rounded-full bg-muted p-6 mb-6",children:e.jsx(pe,{className:"h-12 w-12 text-muted-foreground"})}),e.jsx(re,{className:"text-2xl mb-3",children:"No scheduled jobs yet"}),e.jsx("p",{className:"text-muted-foreground max-w-md mb-6",children:"Automate recurring tasks by scheduling an agent to run on your behalf. Set up your first job to get started."}),e.jsxs("div",{className:"bg-accent/50 rounded-lg p-6 max-w-lg space-y-3 text-sm text-left",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"1"})}),e.jsx("p",{className:"text-muted-foreground",children:"Choose the days of the week and cadence that fit your workflow"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"2"})}),e.jsx("p",{className:"text-muted-foreground",children:"Provide detailed instructions so the agent can execute safely"})]}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"h-6 w-6 rounded-full bg-primary/10 flex items-center justify-center flex-shrink-0 mt-0.5",children:e.jsx("span",{className:"text-xs font-bold text-primary",children:"3"})}),e.jsx("p",{className:"text-muted-foreground",children:"All runs are logged under for review"})]})]}),e.jsxs(u,{onClick:he,className:"mt-8",size:"lg",children:[e.jsx($e,{className:"mr-2 h-5 w-5"}),"Create Your First Job"]})]})}):e.jsx("div",{className:"grid gap-4",children:x.map(s=>s._error?e.jsx(J,{className:"border-destructive/50 bg-destructive/5",children:e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsxs(re,{className:"text-lg truncate text-destructive",children:["Unable to load job: ",s.id]}),e.jsx(F,{variant:"destructive",className:"text-xs shrink-0",children:"Error"})]}),e.jsx("p",{className:"text-sm text-destructive/80 mt-1",children:s._error}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-2",children:["Please review the job file at ",e.jsxs("code",{className:"text-xs bg-muted px-1 py-0.5 rounded",children:[".nut/jobs/",s.id,".md"]})]})]}),e.jsx("div",{className:"flex items-center gap-1.5 shrink-0",children:e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete corrupted job?"}),e.jsxs(K,{children:["This will remove the corrupted job file ",e.jsx("strong",{children:s.id}),". This action cannot be undone."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})})]})})},s.id):e.jsxs(J,{className:"group relative overflow-hidden border-border hover:border-primary/50 transition-all hover:shadow-lg",children:[e.jsx(Pe,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[e.jsx(ve,{to:`/schedule/${s.id}`,className:"hover:underline",children:e.jsx(re,{className:"text-lg truncate",children:s.name})}),e.jsx(F,{variant:le(s.status),className:"capitalize text-xs shrink-0",children:s.status})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:s.description||s.prompt||"No description provided"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[e.jsx(u,{size:"sm",variant:"default",onClick:()=>Ge(s),disabled:w===s.id,className:"h-8 px-3",children:w===s.id?e.jsx(O,{className:"h-3.5 w-3.5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{className:"mr-1.5 h-3.5 w-3.5"}),"Run"]})}),e.jsx(u,{size:"sm",variant:"outline",asChild:!0,className:"h-8 px-3 text-xs",children:e.jsx(ve,{to:`/schedule/${s.id}`,children:"View"})}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ve(s),disabled:w===s.id,className:"h-8 px-3 text-xs",children:"Edit"}),e.jsx(u,{size:"sm",variant:"outline",onClick:()=>Ke(s),disabled:w===s.id,className:"h-8 px-2",children:s.status==="active"?e.jsx(xs,{className:"h-3.5 w-3.5"}):e.jsx(Me,{className:"h-3.5 w-3.5"})}),e.jsxs(q,{children:[e.jsx(ge,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"ghost",disabled:w===s.id,className:"h-8 px-2 text-destructive hover:text-destructive hover:bg-destructive/10",children:e.jsx(fe,{className:"h-3.5 w-3.5"})})}),e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Delete scheduled job?"}),e.jsxs(K,{children:["This will remove ",e.jsx("strong",{children:s.name}),". Existing run logs will remain in ",e.jsx("code",{children:".nut/jobs/logs"}),"."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:()=>xe(s),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]})}),e.jsxs(ae,{className:"space-y-3 pt-0",children:[e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2 lg:grid-cols-4 text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ps,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"min-w-0",children:e.jsx("div",{className:"font-semibold truncate",children:fs(s.schedule)})})]}),e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:[e.jsx(ee,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx("div",{className:"font-semibold",children:vs(s.model)})]}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Next"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.nextRunAt)})]})}),e.jsx("div",{className:"flex items-center gap-2 p-2 rounded-md bg-accent/30",children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[10px] text-muted-foreground uppercase font-bold",children:"Last"}),e.jsx("div",{className:"font-semibold truncate",children:H(s.metadata.lastRunAt)})]})})]}),(s.agentIds&&s.agentIds.length>0||s.agentId||s.mcpServers&&s.mcpServers.length>0)&&e.jsxs("div",{className:"flex flex-wrap gap-2 text-xs",children:[(s.agentIds||(s.agentId?[s.agentId]:[])).map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-blue-50 dark:bg-blue-950/20 border border-blue-200 dark:border-blue-800",children:[e.jsx(ee,{className:"h-3 w-3 text-blue-600 dark:text-blue-400"}),e.jsx("span",{className:"font-medium text-blue-900 dark:text-blue-100",children:t.replace(".md","")})]},t)),s.mcpServers&&s.mcpServers.length>0&&s.mcpServers.map(t=>e.jsxs("div",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-purple-50 dark:bg-purple-950/20 border border-purple-200 dark:border-purple-800",children:[e.jsx(je,{className:"h-3 w-3 text-purple-600 dark:text-purple-400"}),e.jsx("span",{className:"font-medium text-purple-900 dark:text-purple-100",children:t})]},t))]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider text-muted-foreground flex items-center gap-1.5",children:[e.jsx(es,{className:"h-3 w-3"}),"Recent Runs"]}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>ue(s),children:["View All (",s.runs.length,")",e.jsx(ss,{className:"ml-1 h-3 w-3"})]})]}),s.runs.length===0?e.jsx("div",{className:"rounded-md border border-dashed bg-muted/20 p-4 text-center text-xs text-muted-foreground",children:'No runs yet • Click "Run" to execute'}):e.jsxs("div",{className:"space-y-1.5",children:[s.runs.slice(0,1).map(t=>{const r=ze.has(t.id);return e.jsxs("div",{className:"rounded-md border bg-card/50 overflow-hidden transition-all",children:[e.jsxs("div",{className:"p-2.5 text-xs hover:bg-accent/50 transition-colors cursor-pointer",onClick:()=>me(t.id),children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(F,{variant:le(t.status),className:"capitalize text-[10px] h-5",children:t.status}),e.jsx("span",{className:"text-muted-foreground truncate",children:H(t.startedAt)})]}),t.trigger==="manual"&&e.jsx(F,{variant:"outline",className:"text-[10px] h-5",children:"manual"})]}),t.error&&e.jsx("p",{className:"text-destructive font-medium mt-1 line-clamp-1",children:t.error})]}),t.summary&&e.jsx("div",{className:"px-2.5 pb-2.5",children:e.jsxs("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground relative cursor-pointer hover:bg-muted/70 transition-colors",onClick:i=>{i.stopPropagation(),me(t.id)},children:[e.jsx("div",{className:r?"":"line-clamp-2",children:t.summary}),e.jsx("div",{className:"flex justify-center mt-1",children:e.jsx("div",{className:"text-muted-foreground p-0.5",children:r?e.jsx(ts,{className:"h-3 w-3"}):e.jsx(se,{className:"h-3 w-3"})})})]})})]},t.id)}),s.runs.length>1&&e.jsxs(u,{variant:"ghost",size:"sm",className:"w-full h-7 text-xs",onClick:()=>ue(s),children:["+",s.runs.length-1," more runs"]})]})]})]})]},s.id))}),e.jsx(Ne,{open:P,onOpenChange:s=>{y(s),s||(C(null),E())},children:e.jsxs(be,{className:"max-w-4xl h-[700px] overflow-hidden flex flex-col",children:[e.jsxs(ye,{className:"space-y-2 pb-4 shrink-0",children:[e.jsxs(we,{className:"text-xl flex items-center gap-2",children:[e.jsx(pe,{className:"h-5 w-5 text-primary"}),c?"Edit Scheduled Job":"Create New Scheduled Job"]}),e.jsx(Se,{className:"text-sm",children:c?"Update the prompt, cadence, or agent preference":"Automate recurring tasks by scheduling an agent"})]}),e.jsxs("form",{onSubmit:Ye,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs(ms,{defaultValue:"basics",className:"flex-1 flex flex-col min-h-0",children:[e.jsxs(us,{className:"grid w-full grid-cols-3 mb-4 shrink-0",children:[e.jsx(ne,{value:"basics",children:"Basics"}),e.jsx(ne,{value:"schedule",children:"Schedule"}),e.jsx(ne,{value:"advanced",children:"Advanced"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto pr-2 -mr-2 min-h-0",children:[e.jsxs(ie,{value:"basics",className:"space-y-5 mt-0",children:[e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-name",className:"text-sm font-medium flex items-center gap-1.5",children:["Job Name",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(te,{id:"job-name",placeholder:"e.g., Publish docs nightly",value:n.name,onChange:s=>A({name:s.target.value}),className:"h-11",required:!0})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-model",className:"text-sm font-medium",children:"AI Model"}),e.jsxs(as,{value:n.model,onValueChange:s=>A({model:s}),children:[e.jsx(rs,{id:"job-model",className:"h-11",children:e.jsx(ns,{placeholder:"Select a model"})}),e.jsx(is,{children:ce.map(s=>e.jsx(ls,{value:s.id,children:s.label},s.id))})]})]})]}),e.jsxs("div",{className:"grid gap-5 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(ee,{className:"h-4 w-4"}),"Custom Agent",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.agentIds.length===0?"No agents selected":`${n.agentIds.length} agent${n.agentIds.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available Agents"}),e.jsx(Ie,{}),R.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No agents configured"}):R.map(s=>e.jsx(Te,{checked:n.agentIds.includes(s.id),onCheckedChange:t=>Be(s.id,t),children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-medium",children:s.name}),s.tools.length>0&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["MCP: ",s.tools.join(", ")]})]})},s.id))]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{className:"text-sm font-medium flex items-center gap-1.5",children:[e.jsx(je,{className:"h-4 w-4"}),"MCP Servers",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs(Ce,{children:[e.jsx(ke,{asChild:!0,children:e.jsxs(u,{variant:"outline",className:"w-full h-11 justify-between font-normal",children:[n.mcpServers.length===0?"No MCP servers selected":`${n.mcpServers.length} server${n.mcpServers.length!==1?"s":""} selected`,e.jsx(se,{className:"h-4 w-4 opacity-50"})]})}),e.jsxs(Ae,{className:"w-full min-w-[--radix-dropdown-menu-trigger-width]",children:[e.jsx(De,{children:"Available MCP Servers"}),e.jsx(Ie,{}),W.length===0?e.jsx("div",{className:"px-2 py-1.5 text-sm text-muted-foreground",children:"No MCP servers configured"}):W.map(s=>e.jsx(Te,{checked:n.mcpServers.includes(s),onCheckedChange:t=>Ue(s,t),children:s},s))]})]})]})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-prompt",className:"text-sm font-medium flex items-center gap-1.5",children:[n.agentIds.length>0?"Custom Instructions":"Instructions",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(ds,{id:"job-prompt",placeholder:n.agentIds.length>0?`Additional instructions to supplement the agent's predefined behavior...
2
- Example: Focus on performance optimizations`:`Example:
3
- Run the following command and append the output to .nut/context/knowledge/runs.md:
4
- pnpm docs:publish`,rows:6,value:n.prompt,onChange:s=>A({prompt:s.target.value}),className:"resize-none font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground flex items-start gap-1.5",children:[e.jsx("span",{className:"text-amber-600 dark:text-amber-500",children:"⚠"}),e.jsx("span",{children:n.agentIds.length>0?"These custom instructions will be combined with the selected agents' predefined instructions. Jobs run with autonomous permissions.":"Provide clear, actionable instructions. Jobs run with autonomous permissions - include safety checks where needed."})]})]})]}),e.jsx(ie,{value:"schedule",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-[1.2fr_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(v,{className:"text-sm font-medium",children:"Days of the Week"}),e.jsx("div",{className:"grid grid-cols-2 gap-2.5",children:gs.map(s=>e.jsxs("label",{className:"flex items-center gap-2.5 text-sm rounded-md border border-input px-3.5 py-2.5 cursor-pointer hover:bg-accent/50 transition-colors",children:[e.jsx(cs,{checked:n.daysOfWeek.has(s.value),onCheckedChange:t=>qe(s.value,t)}),e.jsx("span",{className:"font-medium",children:s.label})]},s.value))}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Select which days the job should run"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2.5",children:[e.jsx(v,{htmlFor:"job-hours",className:"text-sm font-medium",children:"Frequency (hours)"}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-hours",type:"number",min:1,value:n.hours,onChange:s=>A({hours:Number(s.target.value)||1}),className:"h-11 pr-16"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"hours"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How often the job runs on selected days"})]}),e.jsxs("div",{className:"space-y-2.5",children:[e.jsxs(v,{htmlFor:"job-anchor",className:"text-sm font-medium flex items-center gap-1.5",children:["Start Hour",e.jsx("span",{className:"text-xs text-muted-foreground font-normal",children:"(optional)"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(te,{id:"job-anchor",type:"number",min:0,max:23,placeholder:"Auto",value:n.anchorHour,onChange:s=>A({anchorHour:s.target.value}),className:"h-11"}),e.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-sm text-muted-foreground",children:"0-23"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Preferred starting hour in 24h format"})]})]})]})}),e.jsx(ie,{value:"advanced",className:"space-y-5 mt-0",children:e.jsxs("div",{className:"flex items-start gap-4 rounded-lg border border-border bg-accent/20 p-4",children:[e.jsx(os,{id:"job-status",checked:n.status,onCheckedChange:s=>A({status:s}),className:"mt-1"}),e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsx(v,{htmlFor:"job-status",className:"text-base font-semibold cursor-pointer",children:n.status?"Start Active":"Start Paused"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n.status?"Job will begin running on the configured schedule immediately after creation.":"Job will be created in a paused state. You can activate it later from the schedule page."})]})]})})]})]}),e.jsxs(Fe,{className:"gap-2 sm:gap-2 pt-4 border-t mt-4",children:[e.jsx(u,{type:"button",variant:"outline",onClick:()=>y(!1),disabled:z,className:"min-w-24",children:"Cancel"}),e.jsx(u,{type:"submit",disabled:z||!n.name.trim()||!n.prompt.trim(),className:"min-w-32",children:z?e.jsxs(e.Fragment,{children:[e.jsx(O,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Creating..."]}):e.jsx(e.Fragment,{children:c?"Save Changes":"Create Job"})})]})]})]})}),e.jsx(Ne,{open:Je,onOpenChange:s=>{M(s),s||$(null)},children:e.jsxs(be,{className:"max-w-3xl",children:[e.jsxs(ye,{children:[e.jsxs(we,{children:["Run history — ",g?.name]}),e.jsxs(Se,{children:[g?.runs?.length??0," recorded runs. Logs stored in ",e.jsxs("code",{children:[".nut/jobs/",g?.id,".md"]})," and ",e.jsxs("code",{children:[".nut/jobs/logs/",g?.id]}),"."]})]}),e.jsxs("div",{className:"max-h-[420px] space-y-3 overflow-y-auto pr-2",children:[g?.runs.map(s=>e.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[e.jsxs("div",{className:"p-3 text-xs bg-card/50",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[e.jsx(F,{variant:le(s.status),className:"capitalize text-[10px] h-5",children:s.status}),e.jsxs("span",{className:"text-muted-foreground",children:[s.trigger," • ",Oe(s.startedAt)]}),s.finishedAt&&e.jsxs("span",{className:"text-muted-foreground",children:["• completed ",H(s.finishedAt)]})]}),s.error&&e.jsx("p",{className:"text-destructive font-medium mb-2",children:s.error}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-[10px] text-muted-foreground",children:[s.outputPath&&e.jsxs("span",{children:["log: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.outputPath})]}),s.cliCommand&&e.jsxs("span",{children:["cmd: ",e.jsx("code",{className:"bg-muted px-1 py-0.5 rounded",children:s.cliCommand})]})]})]}),s.summary&&e.jsx("div",{className:"px-3 pb-3",children:e.jsx("div",{className:"rounded bg-muted/50 p-2 font-mono text-[10px] leading-relaxed text-muted-foreground whitespace-pre-wrap",children:s.summary})})]},s.id)),g&&g.runs.length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No recorded runs yet."})]}),e.jsx(Fe,{children:e.jsx(u,{variant:"outline",onClick:()=>M(!1),children:"Close"})})]})}),e.jsx(q,{open:B.open,onOpenChange:s=>{s||U({open:!1,serverToRemove:null})},children:e.jsxs(V,{children:[e.jsxs(Y,{children:[e.jsx(G,{children:"Remove MCP Server?"}),e.jsxs(K,{children:["One or more selected agents require the ",e.jsx("strong",{children:B.serverToRemove})," MCP server. Removing it may lead to unexpected consequences when the job runs."]})]}),e.jsxs(Z,{children:[e.jsx(Q,{children:"Cancel"}),e.jsx(X,{onClick:_e,children:"OK"})]})]})})]})}export{Fs as default};
@@ -1 +0,0 @@
1
- import{P as S,u as C,r as x,j as e,B as a,L as n,Q as E,V as T,p as A,A as b}from"./index-hqVgTgRB.js";import{C as l,b as d,a as c,c as h,d as z}from"./card-BCFxXzRk.js";import{B as N}from"./badge-DEiQk9C9.js";import{A as j}from"./arrow-left-CdM_IPng.js";const i={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function $(){const f=S(),v=C(),[s,w]=x.useState(null),[k,p]=x.useState(!0),[g,o]=x.useState(null);x.useEffect(()=>{async function t(){try{p(!0);const u=await(await fetch(`${b}/api/v1/skills/${f.id}`)).json();u.success?w(u.document):o(u.error||"Failed to fetch skill")}catch(r){o(r instanceof Error?r.message:"Unknown error")}finally{p(!1)}}f.id&&t()},[f.id]);const y=async()=>{if(!(!s||!confirm("Are you sure you want to delete this skill?")))try{const r=await(await fetch(`${b}/api/v1/skills/${s.id}`,{method:"DELETE"})).json();r.success?v("/skills"):o(r.error?.message||"Failed to delete skill")}catch(t){o(t instanceof Error?t.message:"Unknown error")}};if(k)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-8 bg-muted rounded w-64 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-32 animate-pulse mt-2"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(n,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsxs(d,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-48 animate-pulse"}),e.jsx("div",{className:"h-4 bg-muted rounded w-64 animate-pulse"})]})})]});if(g||!s)return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Skill Not Found"}),e.jsx("p",{className:"text-muted-foreground",children:"The requested skill could not be found"})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,className:"px-2 hover:bg-transparent",children:e.jsx(n,{to:"/skills",className:"flex items-center text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})})})]}),e.jsx(l,{children:e.jsx(c,{className:"pt-6",children:e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-destructive",children:g||"Skill not found"})})})})]});const m=s.metadata?.color||"blue";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"space-y-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold tracking-tight",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsx(a,{variant:"ghost",size:"sm",asChild:!0,children:e.jsx(n,{to:"/skills",className:"flex items-center gap-1 text-muted-foreground hover:text-foreground transition-colors",children:e.jsx(j,{className:"h-4 w-4"})})}),e.jsx(a,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs(n,{to:`/skills/${s.id}/edit`,children:[e.jsx(E,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Edit"})]})}),e.jsxs(a,{variant:"destructive",size:"sm",onClick:y,children:[e.jsx(T,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Delete"})]})]})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Description"})}),e.jsx(c,{children:e.jsx("p",{children:s.description})})]}),s.content&&e.jsxs(l,{children:[e.jsxs(d,{children:[e.jsx(h,{children:"Instructions"}),e.jsx(z,{children:"System prompt and behavior instructions for this skill"})]}),e.jsx(c,{children:e.jsx("pre",{className:"whitespace-pre-wrap text-sm bg-muted p-4 rounded-md",children:s.content})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Actions"})}),e.jsx(c,{className:"space-y-2",children:e.jsx(a,{variant:"default",className:"w-full justify-start",asChild:!0,children:e.jsxs(n,{to:`/terminal/sk-${s.id}`,children:[e.jsx(A,{className:"h-4 w-4 mr-2"}),"Start Skill"]})})})]}),e.jsxs(l,{children:[e.jsx(d,{children:e.jsx(h,{children:"Information"})}),e.jsxs(c,{className:"space-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Color"}),e.jsx(N,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:i[m]?.bg||i.blue.bg,color:i[m]?.text||i.blue.text,borderColor:i[m]?.border||i.blue.border},children:m})]}),s.allowedTools&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Allowed Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:s.allowedTools})]}),s.metadata?.mcpServers&&s.metadata.mcpServers.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"MCP Servers"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:s.metadata.mcpServers.map(t=>e.jsx(N,{variant:"secondary",children:t},t))})]}),!s.allowedTools&&!(s.metadata?.mcpServers&&s.metadata.mcpServers.length>0)&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Tools"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No specific tools configured - inherits all tools"})]})]})]})]})]})]})}export{$ as default};
@@ -1,8 +0,0 @@
1
- import{c as z,j as e,S as $,a2 as O,r as h,a as B,A as E,H as _,B as v,L as y,p as F,al as U,am as D}from"./index-hqVgTgRB.js";import{C as N,a as w,b as H,c as K}from"./card-BCFxXzRk.js";import{B as b}from"./badge-DEiQk9C9.js";import{c as V}from"./clipboard-B9ndUJKl.js";import{R as Y,L}from"./browser-modal-Dp1eMxt6.js";import{R as P,f as q}from"./registry-ANRa5WBi.js";import{P as I}from"./plus-iamYJu5V.js";import{T as G}from"./tag-CRP5nL5-.js";import"./search-CH2zaibZ.js";/**
2
- * @license lucide-react v0.542.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const J=[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]],W=z("package",J),Q=["color","tools","createdAt","updatedAt","version","focusAreas","contextPreferences","tags"];function k(t){if(t){if(Array.isArray(t)){const a=t.map(i=>{if(typeof i=="string")return i.trim();if(typeof i=="number")return`${i}`}).filter(i=>typeof i=="string"&&i.length>0);return a.length>0?a:void 0}if(typeof t=="string"){const a=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);return a.length>0?a:void 0}}}function X(t,a){const i=[];if(t.content&&typeof t.content=="object")for(const d of Object.values(t.content))typeof d=="string"&&d.trim().length>0&&i.push(d.trim());const n=[];return n.push(`# ${a}`),t.description?.trim()&&n.push(t.description.trim()),[...n,...i].join(`
7
-
8
- `).trim()}function T(t,a){const i=t.name||a.name,n=a.description||t.description||"",r={registryId:t.id,registryEndpoint:t.endpoint,registrySource:P,author:t.author};for(const o of Q){const m=a[o];if(m!==void 0)if(o==="tools"){const x=k(m);x&&(r.mcpServers=x)}else if(o==="focusAreas"||o==="contextPreferences"||o==="tags"){const x=k(m);x&&(r[o]=x)}else r[o]=m}!r.version&&t.version&&(r.version=t.version),r.color||(r.color="blue"),!r.tags&&t.tags&&(r.tags=k(t.tags));for(const[o,m]of Object.entries(r))m==null&&delete r[o];let d;return a.archive&&(d=a.archive.startsWith("http")?a.archive:`${P}${a.archive}`),{name:i,description:n,content:X(a,i),metadata:Object.keys(r).length>0?r:void 0,archiveUrl:d}}function M({open:t,onOpenChange:a,onImport:i}){return e.jsx(Y,{open:t,onOpenChange:a,categoryId:"skills",title:"Coconut Registry - Skills",confirmLabel:"Import Skill",getDetail:n=>q(n.endpoint),renderPreview:(n,r)=>{if(!r)return e.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Select a skill to preview"});const d=T(n,r),o=d.metadata??{},m=typeof o.version=="string"?o.version:void 0,x=Array.isArray(n.tags)?n.tags:[],j=Array.isArray(o.mcpServers)?o.mcpServers.filter(c=>typeof c=="string"):[],f=Array.isArray(o.focusAreas)?o.focusAreas.filter(c=>typeof c=="string"):[];return e.jsx("div",{className:"h-full min-h-0 overflow-hidden rounded-md border",children:e.jsx($,{className:"h-full",children:e.jsxs("div",{className:"space-y-6 p-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:n.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]}),m&&e.jsxs(b,{variant:"outline",children:["v",m]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["Registry ID: ",e.jsx("span",{className:"font-mono",children:n.id})]}),r.archive&&e.jsxs(b,{variant:"outline",className:"gap-1 text-[10px]",children:[e.jsx(W,{className:"h-3 w-3"}),"Includes companion files"]})]}),x.length>0&&e.jsx("div",{className:"flex flex-wrap gap-2",children:x.map(c=>e.jsx(b,{variant:"secondary",children:c},c))}),j.length>0&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:"MCP Servers:"}),j.map(c=>e.jsx(b,{variant:"outline",children:c},c))]}),f.length>0&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-sm font-medium",children:"Focus Areas"}),e.jsx("ul",{className:"list-disc pl-5 text-sm text-muted-foreground",children:f.map(c=>e.jsx("li",{children:c},c))})]})]}),d.content?e.jsx(O,{className:"[&_.prose]:max-w-none",children:d.content}):r.archive?e.jsx("div",{className:"rounded-md bg-muted/50 p-4 text-sm text-muted-foreground",children:e.jsx("p",{children:"Full skill content and companion files will be downloaded during import."})}):null]})})})},onConfirm:async(n,r)=>{const d=T(n,r);await i({summary:n,detail:r,payload:d})}})}const g={blue:{bg:"#dbeafe",border:"#2563eb",text:"#1e40af"},green:{bg:"#dcfce7",border:"#16a34a",text:"#166534"},red:{bg:"#fee2e2",border:"#dc2626",text:"#991b1b"},emerald:{bg:"#d1fae5",border:"#10b981",text:"#047857"},purple:{bg:"#f3e8ff",border:"#9333ea",text:"#6b21a8"},orange:{bg:"#fed7aa",border:"#ea580c",text:"#9a3412"},yellow:{bg:"#fef9c3",border:"#eab308",text:"#854d0e"},teal:{bg:"#ccfbf1",border:"#14b8a6",text:"#0f766e"},indigo:{bg:"#e0e7ff",border:"#6366f1",text:"#4338ca"},pink:{bg:"#fce7f3",border:"#ec4899",text:"#9f1239"},cyan:{bg:"#cffafe",border:"#06b6d4",text:"#155e75"},slate:{bg:"#f1f5f9",border:"#475569",text:"#334155"},gray:{bg:"#f3f4f6",border:"#6b7280",text:"#374151"}};function ce(){const[t,a]=h.useState([]),[i,n]=h.useState(!0),[r,d]=h.useState({}),[o,m]=h.useState(!1),[x,j]=h.useState(!1),{toast:f}=B(),c=h.useCallback(async()=>{n(!0);try{const s=await fetch(`${E}/api/v1/skills`);if(!s.ok)throw new Error("Failed to load skills");const p=await s.json();a(Array.isArray(p.documents)?p.documents:[])}catch(s){console.error("Failed to load skills:",s),a([])}finally{n(!1)}},[]);h.useEffect(()=>{c()},[c]);const S=async s=>{const p=`.nut/skills/${s}/SKILL.md`;try{await V(p),d(l=>({...l,[s]:!0})),setTimeout(()=>{d(l=>({...l,[s]:!1}))},2e3),f({title:"Path copied!",description:`Copied ${p} to clipboard`})}catch(l){console.error("Failed to copy path:",l),f({title:"Failed to copy",description:"Unable to copy path to clipboard",variant:"destructive"})}},C=h.useCallback(async({payload:s})=>{let p=!1;j(!0);try{const l=await fetch(`${E}/api/v1/skills`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,description:s.description,content:s.content,metadata:s.metadata,...s.archiveUrl?{archiveUrl:s.archiveUrl}:{}})});let u=null;try{u=await l.json()}catch(A){console.error("Failed to parse registry import response:",A)}if(!(l.ok&&u?.success)){const R=(typeof u?.error=="string"?u.error:u?.error?.message)||l.statusText||"Failed to import skill from registry";throw f({title:"Failed to import skill",description:R,variant:"destructive"}),p=!0,new Error(R)}f({title:"Skill imported",description:`${s.name} is now available in Coconut`}),await c()}catch(l){if(!p){const u=l instanceof Error&&l.message?l.message:"Failed to import skill from registry";f({title:"Failed to import skill",description:u,variant:"destructive"})}throw l}finally{j(!1)}},[c,f]);return i?e.jsx("div",{className:"space-y-6",children:e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(_,{className:"h-8 w-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Loading skills..."})]})})})}):t.length===0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your AI agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(I,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx(N,{children:e.jsx(w,{className:"pt-6",children:e.jsxs("div",{className:"text-center",children:[e.jsx(F,{className:"mx-auto h-12 w-12 text-muted-foreground"}),e.jsx("h3",{className:"mt-4 text-lg font-semibold",children:"No Skills Found"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"Specialized skills help you automate your development and business workflows."})]})})})]}),e.jsx(M,{open:o,onOpenChange:m,onImport:C})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold tracking-tight",children:"Skills"}),e.jsx("p",{className:"text-muted-foreground",children:"Manage skills for your AI agents"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(v,{variant:"outline",size:"sm",onClick:()=>m(!0),disabled:x,children:[e.jsx(L,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Registry"})]}),e.jsx(v,{size:"sm",asChild:!0,children:e.jsxs(y,{to:"/skills/new",children:[e.jsx(I,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Create New"})]})})]})]}),e.jsx("div",{className:"grid gap-4",children:t.map(s=>{const p=s.metadata?.color||"blue";return e.jsx(y,{to:`/skills/${s.id}`,className:"block",children:e.jsxs(N,{className:"group hover:shadow-md hover:bg-muted/30 transition-all cursor-pointer",children:[e.jsx(H,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"text-lg",children:s.name}),e.jsx(v,{variant:"ghost",size:"sm",onClick:l=>{l.preventDefault(),S(s.id)},className:"h-6 w-6 p-0 hover:bg-muted opacity-0 group-hover:opacity-100 transition-opacity",title:"Copy file path to clipboard",children:r[s.id]?e.jsx(U,{className:"w-3 h-3 text-green-600"}):e.jsx(D,{className:"w-3 h-3"})})]}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono bg-muted/50 px-2 py-1 rounded inline-block cursor-pointer hover:bg-muted/70 transition-colors",onClick:l=>{l.preventDefault(),S(s.id)},title:"Click to copy file path to clipboard",children:[".nut/skills/",s.id,"/SKILL.md"]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(G,{className:"w-3 h-3"}),p]}),s.allowedTools&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(F,{className:"w-3 h-3"}),s.allowedTools]})]})]}),e.jsx(b,{variant:"outline",className:"capitalize border-2",style:{backgroundColor:g[p]?.bg||g.blue.bg,color:g[p]?.text||g.blue.text,borderColor:g[p]?.border||g.blue.border},children:p})]})}),e.jsx(w,{children:e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"prose prose-sm max-w-none dark:prose-invert",children:e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description})})})})]})},s.id)})})]}),e.jsx(M,{open:o,onOpenChange:m,onImport:C})]})}export{ce as default};
@@ -1 +0,0 @@
1
- import{r as h,j as t,I as x,B as d,X as j}from"./index-hqVgTgRB.js";import{P as N}from"./plus-iamYJu5V.js";import{E as v}from"./external-link-CYBz87-P.js";function g(n){return typeof n=="string"?n.startsWith("http://")||n.startsWith("https://")?{title:n,url:n}:{title:n}:n}function k(n){return n?n.map(g):[]}function I({sources:n,onChange:i,disabled:a}){const[r,m]=h.useState(""),[o,c]=h.useState(""),u=()=>{const e=r.trim();if(!e)return;const s=o.trim()||void 0,l={title:e,url:s};i([...n,l]),m(""),c("")},f=e=>{i(n.filter((s,l)=>l!==e))},p=e=>{e.key==="Enter"&&(e.preventDefault(),u())};return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[t.jsx(x,{placeholder:"Source title (e.g., Design System Audit)",value:r,onChange:e=>m(e.target.value),onKeyDown:p,disabled:a,className:"flex-1"}),t.jsx(x,{placeholder:"URL (optional)",value:o,onChange:e=>c(e.target.value),onKeyDown:p,disabled:a,className:"flex-1",type:"url"}),t.jsxs(d,{type:"button",variant:"outline",onClick:u,disabled:a||!r.trim(),className:"shrink-0",children:[t.jsx(N,{className:"h-4 w-4 sm:mr-1"}),t.jsx("span",{className:"hidden sm:inline",children:"Add"})]})]}),n.length>0&&t.jsx("ul",{className:"space-y-2",children:n.map((e,s)=>t.jsxs("li",{className:"flex items-start gap-2 rounded-md border bg-muted/50 p-2 text-sm",children:[t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"font-medium truncate",children:e.title}),e.url&&t.jsxs("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted-foreground hover:text-primary flex items-center gap-1 truncate",children:[t.jsx(v,{className:"h-3 w-3 shrink-0"}),t.jsx("span",{className:"truncate",children:e.url})]})]}),t.jsx(d,{type:"button",variant:"ghost",size:"sm",onClick:()=>f(s),disabled:a,className:"h-6 w-6 p-0 shrink-0","aria-label":`Remove source ${e.title}`,children:t.jsx(j,{className:"h-3 w-3"})})]},s))})]})}export{I as S,k as n};
@@ -1 +0,0 @@
1
- import{u as U,a as J,r as i,j as e,B as r,T as S,O as K,v as L,X as G,H,a8 as W}from"./index-hqVgTgRB.js";import{C as f,a as X}from"./card-BCFxXzRk.js";import{u as _}from"./use-terminal-DuGZuvd2.js";import{T as q}from"./terminal-preview-DMJMuORo.js";/* empty css */import{R as Q}from"./refresh-cw-Bg7vQzOw.js";import{C as V,a as Y}from"./chevrons-up-DqbWMOjv.js";import{P as M}from"./play-CCo7tau2.js";import{C as Z}from"./circle-play-BhVU869u.js";import"./xterm-DTxiCjtJ.js";function me(){const m=U(),{sessions:p,loading:o,error:k,refreshSessions:h,createSession:j,destroySession:O}=_(),{toast:l}=J(),[x,u]=i.useState(""),[g,T]=i.useState(!1),[v,I]=i.useState(!1),[N,$]=i.useState([]),[,w]=i.useState(null),B=s=>{const t=Date.now(),a=new Date(s).getTime(),n=Math.max(0,Math.floor((t-a)/1e3));if(n<60)return`${n}s ago`;const b=Math.floor(n/60);if(b<60)return`${b}m ago`;const C=Math.floor(b/60);return C<24?`${C}h ago`:`${Math.floor(C/24)}d ago`};i.useEffect(()=>{h()},[h]),i.useEffect(()=>{y(s=>{const t={...s};return p.forEach(a=>{a.id in t||(t[a.id]=!0)}),t})},[p]),i.useEffect(()=>{try{const s=localStorage.getItem("terminal.commandHistory");s&&$(JSON.parse(s))}catch{}},[]);const D=s=>{s&&($(t=>{const a=[s,...t.filter(n=>n!==s)].slice(0,5);try{localStorage.setItem("terminal.commandHistory",JSON.stringify(a))}catch{}return a}),w(null))},c=p.filter(s=>!s.proposalId?.startsWith("cp-")).sort((s,t)=>new Date(t.lastActivity).getTime()-new Date(s.lastActivity).getTime()),[d,y]=i.useState(()=>{const s={};return p.forEach(t=>{s[t.id]=!0}),s}),R=async()=>{const s=`session-${Date.now()}`;await j(s,!1)&&(l({title:"New terminal started",description:`${s}`}),m(`/terminal/${s}`))},E=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;T(!0);try{await j(t,!1,s)?(D(s),l({title:"Session started",description:`${t}`}),m(`/terminal/${t}`)):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{T(!1)}},A=async()=>{const s=x.trim();if(!s)return;const t=`session-${Date.now()}`;I(!0);try{await j(t,!1,s)?(D(s),setTimeout(()=>h(),150),u(""),l({title:"Started in background",description:`${t}`,action:e.jsx(W,{altText:"Open session",onClick:()=>m(`/terminal/${t}`),children:"Open"})})):l({title:"Failed to start",description:"See error above",variant:"destructive"})}finally{I(!1)}},P=async s=>{await O(s)?(l({title:"Session closed",description:s}),setTimeout(()=>h(),100)):l({title:"Failed to close session",description:s,variant:"destructive"})},F=()=>{const s=c.every(a=>d[a.id]),t={};c.forEach(a=>{t[a.id]=!s}),y(t)},z=c.length>0&&c.every(s=>d[s.id]);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Terminal"}),e.jsx("p",{className:"text-muted-foreground hidden sm:block",children:"Manage terminal sessions"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(r,{variant:"outline",onClick:()=>h(),disabled:o,children:[e.jsx(Q,{className:`h-4 w-4 sm:mr-2 ${o?"animate-spin":""}`}),e.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.length>0&&e.jsx(r,{variant:"outline",onClick:F,children:z?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Hide All"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Show All"})]})}),e.jsxs(r,{onClick:R,disabled:o,children:[e.jsx(S,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"New Terminal"})]})]})]}),k&&e.jsx("div",{className:"p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsx("div",{className:"text-red-600",children:k})}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Sessions"}),o?e.jsx("div",{className:"space-y-2",children:[...Array(2)].map((s,t)=>e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-4 w-4 rounded bg-muted animate-pulse"}),e.jsxs("div",{children:[e.jsx("div",{className:"h-4 w-40 bg-muted rounded animate-pulse mb-2"}),e.jsx("div",{className:"h-3 w-24 bg-muted rounded animate-pulse"})]})]}),e.jsx("div",{className:"h-6 w-20 bg-muted rounded animate-pulse"})]})},t))}):c.length===0?e.jsx(f,{className:"p-8",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center space-y-3",children:[e.jsx(S,{className:"h-12 w-12 text-muted-foreground"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-lg mb-2",children:"No active sessions"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Get started by launching a new terminal session with the"," ",e.jsx("button",{onClick:R,className:"text-primary hover:underline font-medium",children:"New Terminal"})," ","button above."]})]})]})}):e.jsx("div",{className:"space-y-2",children:c.slice(0,10).map(s=>e.jsxs(f,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(S,{className:"h-4 w-4"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.proposalId}),e.jsxs("div",{className:"text-xs text-gray-500",children:["Session ",s.id.split("-").slice(-1)[0].substring(0,8)," • Last activity ",B(s.lastActivity)]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 sm:gap-2",children:[e.jsx("div",{className:`flex items-center gap-1 ${s.connected?"text-green-600":"text-gray-400"}`,title:s.connected?"Connected":"Disconnected",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${s.connected?"bg-green-500":"bg-gray-400"}`})}),e.jsx(r,{size:"sm",variant:"outline",onClick:()=>{y(t=>({...t,[s.id]:!t[s.id]}))},"aria-label":d[s.id]?"Hide preview":"Show preview",title:d[s.id]?"Hide preview":"Show preview",children:d[s.id]?e.jsx(K,{className:"h-4 w-4"}):e.jsx(L,{className:"h-4 w-4"})}),e.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(`/terminal/${s.proposalId}`),children:[e.jsx(M,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Open"})]}),e.jsx(r,{size:"icon",variant:"destructive",onClick:()=>P(s.id),title:"Close session","aria-label":"Close session",children:e.jsx(G,{className:"h-4 w-4"})})]})]}),d[s.id]&&e.jsx("div",{className:"mt-2 w-full p-2 cursor-pointer hover:opacity-80 transition-opacity",onClick:()=>m(`/terminal/${s.proposalId}`),title:"Click to open full terminal session",children:e.jsx(q,{sessionId:s.id,heightPx:160,maxScrollback:200})})]},s.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:"text-lg font-semibold",children:"Run Custom Command"}),e.jsx(f,{children:e.jsxs(X,{className:"py-6",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:x,onChange:s=>u(s.target.value),onKeyDown:s=>{s.key==="Enter"?(s.preventDefault(),s.shiftKey?A():E()):s.key==="ArrowUp"?(s.preventDefault(),w(t=>{const a=t===null?0:Math.min((t??0)+1,N.length-1),n=N[a];return n&&u(n),a})):s.key==="ArrowDown"&&(s.preventDefault(),w(t=>{if(t===null)return null;const a=t-1;if(a<0)return u(""),null;const n=N[a];return n&&u(n),a}))},placeholder:"npm run dev",className:"flex-1 h-9 rounded-md border px-3 text-sm bg-white dark:bg-gray-900 border-gray-300 dark:border-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-500 dark:placeholder-gray-400"}),e.jsxs(r,{onClick:A,variant:"secondary",disabled:o||!x.trim()||v||g,children:[v?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-1"}):e.jsx(Z,{className:"h-4 w-4 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Background"})]}),e.jsxs(r,{onClick:E,disabled:o||!x.trim()||g||v,children:[g?e.jsx(H,{className:"h-4 w-4 animate-spin sm:mr-2"}):e.jsx(M,{className:"h-4 w-4 sm:mr-2"}),e.jsx("span",{className:"hidden sm:inline",children:"Run"})]})]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-2",children:"Enter to Run • Shift+Enter to Run in background"})]})})]})]})}export{me as default};