totem-llm 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/README.md +12 -0
  2. package/config/totem.features.json +158 -0
  3. package/package.json +2 -1
  4. package/server/models/systemSettings.js +1 -1
  5. package/server/models/workspace.js +2 -2
  6. package/server/public/assets/{404-b5c6b0dc.js → 404-56d107aa.js} +1 -1
  7. package/server/public/assets/RunDetailPage-da6aa377.js +1 -0
  8. package/server/public/assets/RunHistoryPage-2fcb4325.js +1 -0
  9. package/server/public/assets/{Trans-ca8f9cfe.js → Trans-820f1dad.js} +1 -1
  10. package/server/public/assets/{cron-1f15870f.js → cron-307d3fc6.js} +1 -1
  11. package/server/public/assets/{files-e19b0187.js → files-676613ed.js} +1 -1
  12. package/server/public/assets/index-01932fa1.js +1 -0
  13. package/server/public/assets/{index-a6e642d7.js → index-0bf4fb6b.js} +1 -1
  14. package/server/public/assets/index-166e238c.js +1 -0
  15. package/server/public/assets/{index-f86e167c.js → index-1c653bbf.js} +2 -2
  16. package/server/public/assets/index-1fe43260.js +1 -0
  17. package/server/public/assets/index-27cc497c.js +1 -0
  18. package/server/public/assets/{index-9cc77cb6.js → index-2aac91d0.js} +3 -3
  19. package/server/public/assets/index-2d84e5fe.js +1 -0
  20. package/server/public/assets/index-33ded078.js +1 -0
  21. package/server/public/assets/{index-2f526c2a.js → index-3cb59d82.js} +1 -1
  22. package/server/public/assets/{index-8eb228e2.js → index-40f9745e.js} +3 -3
  23. package/server/public/assets/{index-92d3b7bc.js → index-4277cf52.js} +1 -1
  24. package/server/public/assets/index-44ab5f11.js +1 -0
  25. package/server/public/assets/index-4750915e.js +1 -0
  26. package/server/public/assets/{index-52850dde.js → index-52c9b54b.js} +1 -1
  27. package/server/public/assets/{index-ab72b353.js → index-574ed823.js} +2 -2
  28. package/server/public/assets/{index-3a2c5fd7.js → index-631fc042.js} +1 -1
  29. package/server/public/assets/index-65184421.js +1 -0
  30. package/server/public/assets/index-6679334a.js +1 -0
  31. package/server/public/assets/{index-6cdecde9.js → index-6bd7928a.js} +9 -9
  32. package/server/public/assets/index-6d56c896.js +18 -0
  33. package/server/public/assets/{index-925792fe.js → index-72544df5.js} +1 -1
  34. package/server/public/assets/index-80edec8f.js +1 -0
  35. package/server/public/assets/index-83825216.js +1 -0
  36. package/server/public/assets/index-841db586.js +1 -0
  37. package/server/public/assets/index-882e468e.js +1 -0
  38. package/server/public/assets/{index-ab35fb74.js → index-8c2371f5.js} +1 -1
  39. package/server/public/assets/index-9da80ba7.js +3 -0
  40. package/server/public/assets/{index-ad8e77d2.js → index-a2978aa0.js} +2 -2
  41. package/server/public/assets/{index-62fee0f9.js → index-ae4f557d.js} +2 -2
  42. package/server/public/assets/{index-8132c765.js → index-b49f94f1.js} +1 -1
  43. package/server/public/assets/index-cd6bc090.js +1 -0
  44. package/server/public/assets/{index-c391a2fa.js → index-d1d3d69a.js} +1 -1
  45. package/server/public/assets/index-d29fdeda.js +1 -0
  46. package/server/public/assets/index-d54b0575.js +1 -0
  47. package/server/public/assets/index-dcc00e8c.js +3 -0
  48. package/server/public/assets/index-e58bf860.js +1 -0
  49. package/server/public/assets/index-ec3efa1e.js +1 -0
  50. package/server/public/assets/index-ed9034ac.js +1 -0
  51. package/server/public/assets/{index-92574f3a.js → index-efee6d1f.js} +1 -1
  52. package/server/public/assets/index-f9305828.js +1 -0
  53. package/server/public/assets/index-fce187ac.js +1 -0
  54. package/server/public/assets/{main-8ad4162f.js → main-0b9e408b.js} +1 -1
  55. package/server/public/assets/{mcpServers-a175e8cf.js → mcpServers-1686e782.js} +1 -1
  56. package/server/public/assets/{moment-8a59df1b.js → moment-75486807.js} +1 -1
  57. package/server/public/assets/{purify-fbc9e8e2.js → purify-eb750cf4.js} +1 -1
  58. package/server/public/assets/{react-beautiful-dnd.esm-45ea8487.js → react-beautiful-dnd.esm-bb85eef1.js} +1 -1
  59. package/server/public/assets/{truncate-352eb33b.js → truncate-06273256.js} +1 -1
  60. package/server/public/index.js +27 -27
  61. package/server/utils/AiProviders/ollama/index.js +2 -0
  62. package/server/utils/chats/agents.js +7 -1
  63. package/server/utils/telegramBot/utils/verification.js +1 -1
  64. package/totem.features.cjs +18 -106
  65. package/server/public/assets/RunDetailPage-74b1e63a.js +0 -1
  66. package/server/public/assets/RunHistoryPage-9609436a.js +0 -1
  67. package/server/public/assets/index-25b2660c.js +0 -1
  68. package/server/public/assets/index-2a7c0b04.js +0 -1
  69. package/server/public/assets/index-35b0a39b.js +0 -3
  70. package/server/public/assets/index-3643e990.js +0 -1
  71. package/server/public/assets/index-39899779.js +0 -1
  72. package/server/public/assets/index-51f23c79.js +0 -1
  73. package/server/public/assets/index-56bb11a0.js +0 -1
  74. package/server/public/assets/index-65801ac6.js +0 -1
  75. package/server/public/assets/index-6710499a.js +0 -1
  76. package/server/public/assets/index-73aba4c6.js +0 -3
  77. package/server/public/assets/index-837868b3.js +0 -1
  78. package/server/public/assets/index-86e8a6b4.js +0 -1
  79. package/server/public/assets/index-8e43159f.js +0 -1
  80. package/server/public/assets/index-994c849a.js +0 -1
  81. package/server/public/assets/index-9f71774b.js +0 -1
  82. package/server/public/assets/index-9f7dabd6.js +0 -1
  83. package/server/public/assets/index-a0e2be61.js +0 -1
  84. package/server/public/assets/index-ac4d4b42.js +0 -1
  85. package/server/public/assets/index-c9b59c35.js +0 -1
  86. package/server/public/assets/index-dad0fb8d.js +0 -18
  87. package/server/public/assets/index-dd210692.js +0 -1
  88. package/server/public/assets/index-e28b0ead.js +0 -1
  89. package/server/public/assets/index-e6c540e1.js +0 -1
  90. package/server/public/assets/index-f984ef26.js +0 -1
  91. package/server/public/assets/index-fb26b60a.js +0 -1
@@ -1 +1 @@
1
- import{R as o,r as d,g as H,u as E,j as e,M as Z,k as C,v as V,p as L,c as A,I as M,a9 as $,aD as q,a8 as U,a5 as K,a4 as G,bv as J,aC as Q}from"../index.js";import{C as T}from"./communityHub-aba61686.js";import{I as Y}from"./Brain-24e386d5.js";import{I as X}from"./Browser-1820fad0.js";const ee=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M54.8,119.49A35.06,35.06,0,0,1,49.05,128a35.06,35.06,0,0,1,5.75,8.51C60,147.24,60,159.83,60,172c0,25.94,1.84,32,20,32a12,12,0,0,1,0,24c-19.14,0-32.2-6.9-38.8-20.51C36,196.76,36,184.17,36,172c0-25.94-1.84-32-20-32a12,12,0,0,1,0-24c18.16,0,20-6.06,20-32,0-12.17,0-24.76,5.2-35.49C47.8,34.9,60.86,28,80,28a12,12,0,0,1,0,24c-18.16,0-20,6.06-20,32C60,96.17,60,108.76,54.8,119.49ZM240,116c-18.16,0-20-6.06-20-32,0-12.17,0-24.76-5.2-35.49C208.2,34.9,195.14,28,176,28a12,12,0,0,0,0,24c18.16,0,20,6.06,20,32,0,12.17,0,24.76,5.2,35.49A35.06,35.06,0,0,0,207,128a35.06,35.06,0,0,0-5.75,8.51C196,147.24,196,159.83,196,172c0,25.94-1.84,32-20,32a12,12,0,0,0,0,24c19.14,0,32.2-6.9,38.8-20.51C220,196.76,220,184.17,220,172c0-25.94,1.84-32,20-32a12,12,0,0,0,0-24Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M240,128c-64,0,0,88-64,88H80c-64,0,0-88-64-88,64,0,0-88,64-88h96C240,40,176,128,240,128Z",opacity:"0.2"}),o.createElement("path",{d:"M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM88,155.84c.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16c-31.27,0-31.72-22.43-32-35.84C71.71,141.9,71.59,136,56,136a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16C72.28,86.43,72.73,64,104,64a8,8,0,0,1,0,16c-15.59,0-15.71,5.9-16,20.16-.17,8.31-.41,20.09-8,27.84C87.59,135.75,87.83,147.53,88,155.84ZM200,136c-15.59,0-15.71,5.9-16,20.16-.28,13.41-.73,35.84-32,35.84a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16.17-8.31.41-20.09,8-27.84-7.6-7.75-7.84-19.53-8-27.84C167.71,85.9,167.59,80,152,80a8,8,0,0,1,0-16c31.27,0,31.72,22.43,32,35.84.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M39.91,128a27.68,27.68,0,0,1,9.49,11.13C54,148.62,54,160.51,54,172c0,24.27,1.21,38,26,38a6,6,0,0,1,0,12c-16.88,0-27.81-5.6-33.4-17.13C42,195.38,42,183.49,42,172c0-24.27-1.21-38-26-38a6,6,0,0,1,0-12c24.79,0,26-13.73,26-38,0-11.49,0-23.38,4.6-32.87C52.19,39.6,63.12,34,80,34a6,6,0,0,1,0,12C55.21,46,54,59.73,54,84c0,11.49,0,23.38-4.6,32.87A27.68,27.68,0,0,1,39.91,128ZM240,122c-24.79,0-26-13.73-26-38,0-11.49,0-23.38-4.6-32.87C203.81,39.6,192.88,34,176,34a6,6,0,0,0,0,12c24.79,0,26,13.73,26,38,0,11.49,0,23.38,4.6,32.87A27.68,27.68,0,0,0,216.09,128a27.68,27.68,0,0,0-9.49,11.13C202,148.62,202,160.51,202,172c0,24.27-1.21,38-26,38a6,6,0,0,0,0,12c16.88,0,27.81-5.6,33.4-17.13,4.6-9.49,4.6-21.38,4.6-32.87,0-24.27,1.21-38,26-38a6,6,0,0,0,0-12Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M35.89,128C52,136.23,52,155.64,52,172c0,24.8,1.35,40,28,40a4,4,0,0,1,0,8c-36,0-36-26.61-36-48,0-24.8-1.35-40-28-40a4,4,0,0,1,0-8c26.65,0,28-15.2,28-40,0-21.39,0-48,36-48a4,4,0,0,1,0,8C53.35,44,52,59.2,52,84,52,100.36,52,119.77,35.89,128ZM240,124c-26.65,0-28-15.2-28-40,0-21.39,0-48-36-48a4,4,0,0,0,0,8c26.65,0,28,15.2,28,40,0,16.36,0,35.77,16.11,44C204,136.23,204,155.64,204,172c0,24.8-1.35,40-28,40a4,4,0,0,0,0,8c36,0,36-26.61,36-48,0-24.8,1.35-40,28-40a4,4,0,0,0,0-8Z"}))]]);var te=Object.defineProperty,se=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,O=(s,t,r)=>t in s?te(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,ne=(s,t)=>{for(var r in t||(t={}))re.call(t,r)&&O(s,r,t[r]);if(R)for(var r of R(t))le.call(t,r)&&O(s,r,t[r]);return s},ie=(s,t)=>se(s,ae(t));const B=d.forwardRef((s,t)=>o.createElement(H,ie(ne({ref:t},s),{weights:ee})));B.displayName="BracketsCurly";const oe=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M40.14,46.88A12,12,0,0,0,36,56V224a12,12,0,0,0,24,0V181.72c22.84-17.12,42.1-9.12,70.68,5,16.23,8,34.74,17.2,54.8,17.2,14.72,0,30.28-4.94,46.38-18.88A12,12,0,0,0,236,176V56a12,12,0,0,0-19.86-9.07c-24.71,21.41-44.53,13.31-74.82-1.68C113.19,31.27,78.17,13.94,40.14,46.88ZM212,170.26c-22.84,17.13-42.1,9.11-70.68-5C118.16,153.76,90.33,140,60,153.87V61.69c22.84-17.12,42.1-9.12,70.68,5,16.23,8,34.74,17.2,54.8,17.2A63,63,0,0,0,212,78.08Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M224,56V176c-64,55.43-112-55.43-176,0V56C112,.57,160,111.43,224,56Z",opacity:"0.2"}),o.createElement("path",{d:"M42.76,50A8,8,0,0,0,40,56V224a8,8,0,0,0,16,0V179.77c26.79-21.16,49.87-9.75,76.45,3.41,16.4,8.11,34.06,16.85,53,16.85,13.93,0,28.54-4.75,43.82-18a8,8,0,0,0,2.76-6V56A8,8,0,0,0,218.76,50c-28,24.23-51.72,12.49-79.21-1.12C111.07,34.76,78.78,18.79,42.76,50ZM216,172.25c-26.79,21.16-49.87,9.74-76.45-3.41-25-12.35-52.81-26.13-83.55-8.4V59.79c26.79-21.16,49.87-9.75,76.45,3.4,25,12.35,52.82,26.13,83.55,8.4Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M232,56V176a8,8,0,0,1-2.76,6c-15.28,13.23-29.89,18-43.82,18-18.91,0-36.57-8.74-53-16.85C105.87,170,82.79,158.61,56,179.77V224a8,8,0,0,1-16,0V56a8,8,0,0,1,2.77-6h0c36-31.18,68.31-15.21,96.79-1.12C167,62.46,190.79,74.2,218.76,50A8,8,0,0,1,232,56Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M44.08,51.37A6,6,0,0,0,42,55.9V224a6,6,0,0,0,12,0V178.78c28.08-22.79,51.88-11,79.34,2.57,16.12,8,33.49,16.58,52,16.58,13.57,0,27.76-4.6,42.56-17.42A6,6,0,0,0,230,176V55.9a6,6,0,0,0-9.93-4.54c-29,25.12-53.28,13.09-81.41-.84C110.77,36.71,79,21.16,44.08,51.37ZM218,173.17c-28.08,22.8-51.88,11-79.34-2.58C113.4,158.08,85.09,144.07,54,164V58.72c28.08-22.8,51.88-11,79.34,2.56C158.6,73.79,186.91,87.8,218,67.91Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M42.76,50A8,8,0,0,0,40,56V224a8,8,0,0,0,16,0V179.77c26.79-21.16,49.87-9.75,76.45,3.41,16.4,8.11,34.06,16.85,53,16.85,13.93,0,28.54-4.75,43.82-18a8,8,0,0,0,2.76-6V56A8,8,0,0,0,218.76,50c-28,24.23-51.72,12.49-79.21-1.12C111.07,34.76,78.78,18.79,42.76,50ZM216,172.25c-26.79,21.16-49.87,9.74-76.45-3.41-25-12.35-52.81-26.13-83.55-8.4V59.79c26.79-21.16,49.87-9.75,76.45,3.4,25,12.35,52.82,26.13,83.55,8.4Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M45.39,53.06a4,4,0,0,0-1.39,3V224a4,4,0,0,0,8,0V177.87c29.41-24.39,55.08-11.69,82.23,1.73,16.5,8.17,33.33,16.5,51.13,16.5,13.14,0,26.81-4.55,41.26-17.06a4,4,0,0,0,1.38-3v-120a4,4,0,0,0-6.62-3c-30,26-56,13.07-83.61-.57C109.07,38.28,79.4,23.62,45.39,53.06ZM220,174.17c-29.41,24.4-55.08,11.7-82.23-1.73-26.82-13.27-54.5-27-85.77-4.66V57.92c29.41-24.4,55.08-11.7,82.23,1.73,26.82,13.27,54.5,27,85.77,4.66Z"}))]]);var me=Object.defineProperty,ce=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,D=(s,t,r)=>t in s?me(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,pe=(s,t)=>{for(var r in t||(t={}))de.call(t,r)&&D(s,r,t[r]);if(P)for(var r of P(t))he.call(t,r)&&D(s,r,t[r]);return s},xe=(s,t)=>ce(s,ue(t));const W=d.forwardRef((s,t)=>o.createElement(H,xe(pe({ref:t},s),{weights:oe})));W.displayName="Flag";function be(){const[s,t]=d.useState(!1),[r,a]=d.useState(!0);return d.useEffect(()=>{async function h(){a(!0);try{const{connectionKey:c}=await T.getSettings();t(!!c)}catch(c){console.error("Error checking hub auth:",c),t(!1)}finally{a(!1)}}h()},[]),{isAuthenticated:s,loading:r}}function ye({show:s,onClose:t}){const{t:r}=E();return s?e.jsx(Z,{isOpen:s,children:e.jsx("div",{className:"relative w-[400px] max-w-full bg-theme-bg-primary rounded-lg shadow border border-theme-modal-border",children:e.jsxs("div",{className:"p-6",children:[e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(C,{size:18,weight:"bold",className:"text-white"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:r("community_hub.publish.generic.unauthenticated.title")}),e.jsx("p",{className:"text-lg text-white text-center max-w-[300px]",children:r("community_hub.publish.generic.unauthenticated.description")}),e.jsx(V,{to:L.communityHub.authentication(),className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:r("community_hub.publish.generic.unauthenticated.button")})]})]})})}):null}function ge({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState("public"),[l,m]=d.useState(!1),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),prompt:i.get("prompt"),tags:c,visibility:j},{success:N,error:_,itemId:I}=await T.createSystemPrompt(y);if(!N)throw new Error(_);x(I),m(!0)}catch(i){console.error("Failed to publish prompt:",i),A(`Failed to publish prompt: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},S=n=>{b(c.filter(i=>i!==n))};return l?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.system_prompt.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.system_prompt.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.system_prompt.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("system-prompt",p),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.system_prompt.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsx("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3",children:t("community_hub.publish.system_prompt.modal_title")})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.system_prompt.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.system_prompt.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,placeholder:t("community_hub.publish.system_prompt.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.system_prompt.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,placeholder:t("community_hub.publish.system_prompt.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>S(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(C,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.system_prompt.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.visibility_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t(j==="public"?"community_hub.publish.system_prompt.public_description":"community_hub.publish.system_prompt.private_description")}),e.jsx("div",{className:"w-fit h-[42px] bg-theme-bg-secondary rounded-lg p-0.5",children:e.jsxs("div",{className:"flex items-center",role:"group",children:[e.jsx("input",{type:"radio",id:"public",name:"visibility",value:"public",className:"peer/public hidden",defaultChecked:!0,onChange:n=>u(n.target.value)}),e.jsx("input",{type:"radio",id:"private",name:"visibility",value:"private",className:"peer/private hidden",onChange:n=>u(n.target.value)}),e.jsx("label",{htmlFor:"public",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/public:bg-theme-sidebar-item-hover peer-checked/public:text-theme-primary-button flex items-center justify-center",children:"Public"}),e.jsx("label",{htmlFor:"private",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/private:bg-theme-sidebar-item-hover peer-checked/private:text-theme-primary-button flex items-center justify-center",children:"Private"})]})})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.prompt_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.prompt_description")}),e.jsx("textarea",{name:"prompt",required:!0,minLength:10,defaultValue:s,placeholder:t("community_hub.publish.system_prompt.prompt_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[300px] placeholder:text-theme-text-placeholder"})]}),e.jsx("button",{type:"submit",disabled:a,className:"border-none w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.system_prompt.submitting":"community_hub.publish.system_prompt.publish_button")})]})]})]})}function fe({config:s,onConfigChange:t,onDeleteVariable:r}){const a=(h,c)=>{r(c);const b=s.variables.filter((g,v)=>v!==h);t({variables:b})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium text-theme-text-primary",children:"Variables"}),s.variables.map((h,c)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Variable name",value:h.name,onChange:b=>{const g=[...s.variables];g[c].name=b.target.value,t({variables:g})},className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Initial value",value:h.value,onChange:b=>{const g=[...s.variables];g[c].value=b.target.value,t({variables:g})},className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),s.variables.length>1&&e.jsx("button",{onClick:()=>a(c,h.name),className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300",title:"Delete variable",children:e.jsx(C,{className:"w-4 h-4"})}),c===s.variables.length-1&&e.jsx("button",{onClick:()=>{const b=[...s.variables,{name:"",value:""}];t({variables:b})},className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300",title:"Add variable",children:e.jsx(M,{className:"w-4 h-4"})})]},c))]})}function ve({config:s,onConfigChange:t,renderVariableSelect:r}){const a=d.useRef(null),[h,c]=d.useState(!1),b=d.useRef(null),g=(l,m,p)=>{const x=[...s.headers||[]];x[l]={...x[l],[m]:p},t({headers:x})},v=()=>{const l=[...s.headers||[],{key:"",value:""}];t({headers:l})},j=l=>{const m=[...s.headers||[]].filter((p,x)=>x!==l);t({headers:m})},u=l=>{if(!a.current)return;const m=a.current,p=m.selectionStart,x=m.selectionEnd,w=s.url,k=w.substring(0,p)+"${"+l+"}"+w.substring(x);t({url:k}),c(!1),setTimeout(()=>{const S=p+l.length+3;m.setSelectionRange(S,S),m.focus()},0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:a,type:"text",placeholder:"https://api.example.com/endpoint",value:s.url,onChange:l=>t({url:l.target.value}),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:b,onClick:()=>c(!h),className:"h-full px-3 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300 flex items-center gap-1",title:"Insert variable",children:[e.jsx(M,{className:"w-4 h-4"}),e.jsx($,{className:"w-3 h-3"})]}),h&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+4px)] w-48 bg-theme-settings-input-bg border-none rounded-lg shadow-lg z-10",children:r("",u,"Select variable to insert",!0)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Method"}),e.jsx("select",{value:s.method,onChange:l=>t({method:l.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:["GET","POST","DELETE","PUT","PATCH"].map(l=>e.jsx("option",{value:l,className:"bg-theme-settings-input-bg",children:l},l))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-theme-text-primary",children:"Headers"}),e.jsx("button",{onClick:v,className:"p-1.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300",title:"Add header",children:e.jsx(M,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"space-y-2",children:(s.headers||[]).map((l,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Header name",value:l.key,onChange:p=>g(m,"key",p.target.value),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Value",value:l.value,onChange:p=>g(m,"value",p.target.value),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("button",{onClick:()=>j(m),className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300",title:"Remove header",children:e.jsx(C,{className:"w-4 h-4"})})]},m))})]}),["POST","PUT","PATCH"].includes(s.method)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Request Body"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("select",{value:s.bodyType||"json",onChange:l=>t({bodyType:l.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",children:[e.jsx("option",{value:"json",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"JSON"}),e.jsx("option",{value:"text",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"Raw Text"}),e.jsx("option",{value:"form",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"Form Data"})]}),s.bodyType==="json"?e.jsx("textarea",{placeholder:'{"key": "value"}',value:s.body,onChange:l=>t({body:l.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10 font-mono",rows:4,autoComplete:"off",spellCheck:!1}):s.bodyType==="form"?e.jsxs("div",{className:"space-y-2",children:[(s.formData||[]).map((l,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key",value:l.key,onChange:p=>{const x=[...s.formData||[]];x[m]={...l,key:p.target.value},t({formData:x})},className:"flex-1 p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Value",value:l.value,onChange:p=>{const x=[...s.formData||[]];x[m]={...l,value:p.target.value},t({formData:x})},className:"flex-1 p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",autoComplete:"off",spellCheck:!1}),e.jsx("button",{onClick:()=>{const p=[...s.formData||[]].filter((x,w)=>w!==m);t({formData:p})},className:"p-2.5 rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300 light:bg-theme-settings-input-bg light:border-black/10",title:"Remove field",children:e.jsx(C,{className:"w-4 h-4"})})]},m)),e.jsx("button",{onClick:()=>{const l=[...s.formData||[],{key:"",value:""}];t({formData:l})},className:"w-full p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300 text-sm",children:"Add Form Field"})]}):e.jsx("textarea",{placeholder:"Raw request body...",value:s.body,onChange:l=>t({body:l.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:4,autoComplete:"off",spellCheck:!1})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Store Response In"}),r(s.responseVariable,l=>t({responseVariable:l}),"Select or create variable")]})]})}function je({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"URL"}),e.jsx("input",{type:"text",placeholder:"https://example.com",value:s.url,onChange:a=>t({url:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Action"}),e.jsxs("select",{value:s.action,onChange:a=>t({action:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"read",className:"bg-theme-bg-primary",children:"Read Content"}),e.jsx("option",{value:"click",className:"bg-theme-bg-primary",children:"Click Element"}),e.jsx("option",{value:"type",className:"bg-theme-bg-primary",children:"Type Text"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"CSS Selector"}),e.jsx("input",{type:"text",placeholder:"#element-id or .class-name",value:s.selector,onChange:a=>t({selector:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function we({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Operation"}),e.jsxs("select",{value:s.operation,onChange:a=>t({operation:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"read",className:"bg-theme-bg-primary",children:"Read File"}),e.jsx("option",{value:"write",className:"bg-theme-bg-primary",children:"Write File"}),e.jsx("option",{value:"append",className:"bg-theme-bg-primary",children:"Append to File"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"File Path"}),e.jsx("input",{type:"text",placeholder:"/path/to/file",value:s.path,onChange:a=>t({path:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),s.operation!=="read"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Content"}),e.jsx("textarea",{placeholder:"File content...",value:s.content,onChange:a=>t({content:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",rows:3,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function Ne({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Language"}),e.jsxs("select",{value:s.language,onChange:a=>t({language:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"javascript",className:"bg-theme-bg-primary",children:"JavaScript"}),e.jsx("option",{value:"python",className:"bg-theme-bg-primary",children:"Python"}),e.jsx("option",{value:"shell",className:"bg-theme-bg-primary",children:"Shell"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Code"}),e.jsx("textarea",{placeholder:"Enter code...",value:s.code,onChange:a=>t({code:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none font-mono",rows:5,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function _e({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Instruction"}),e.jsx("textarea",{value:(s==null?void 0:s.instruction)||"",onChange:a=>t({...s,instruction:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:3,placeholder:"Enter instructions for the LLM..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Result Variable"}),r(s.resultVariable,a=>t({...s,resultVariable:a}),"Select or create variable",!0)]})]})}function Ce(){return e.jsx("div",{className:"text-sm text-white/60",children:"This is the end of your agent flow. All steps above will be executed in sequence."})}function Se({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"URL to Scrape"}),e.jsx("input",{type:"url",value:(s==null?void 0:s.url)||"",onChange:a=>t({...s,url:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",placeholder:"https://example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Capture Page Content As"}),e.jsx("select",{value:s.captureAs,onChange:a=>t({...s,captureAs:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:[{label:"Text content only",value:"text"},{label:"Raw HTML",value:"html"},{label:"CSS Query Selector",value:"querySelector"}].map(a=>e.jsx("option",{value:a.value,className:"bg-theme-settings-input-bg",children:a.label},a.value))})]}),s.captureAs==="querySelector"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Query Selector"}),e.jsx("p",{className:"text-xs text-theme-text-secondary mb-2",children:"Enter a valid CSS selector to scrape the content of the page."}),e.jsx("input",{value:s.querySelector,onChange:a=>t({...s,querySelector:a.target.value}),placeholder:".article-content, #content, .main-content, etc.",className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5"})]}),e.jsx(q,{size:"md",variant:"horizontal",label:"Content Summarization",hint:"content-summarization-tooltip",enabled:s.enableSummarization??!0,onChange:a=>t({...s,enableSummarization:a})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Result Variable"}),r(s.resultVariable,a=>t({...s,resultVariable:a}),"Select or create variable",!0)]})]})}const z=d.forwardRef(({config:s,onConfigChange:t},r)=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Flow Name"}),e.jsxs("div",{className:"flex flex-col text-xs text-theme-text-secondary mt-2 mb-3",children:[e.jsx("p",{className:"",children:"It is important to give your flow a name that an LLM can easily understand."}),e.jsx("p",{children:'"SendMessageToDiscord", "CheckStockPrice", "CheckWeather"'})]}),e.jsx("input",{id:"agent-flow-name-input",ref:r==null?void 0:r.nameRef,type:"text",placeholder:"Enter flow name",value:(s==null?void 0:s.name)||"",onChange:a=>t({...s,name:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Description"}),e.jsx("div",{className:"flex flex-col text-xs text-theme-text-secondary mt-2 mb-3",children:e.jsx("p",{className:"",children:"It is equally important to give your flow a description that an LLM can easily understand. Be sure to include the purpose of the flow, the context it will be used in, and any other relevant information."})}),e.jsx("textarea",{ref:r==null?void 0:r.descriptionRef,value:(s==null?void 0:s.description)||"",onChange:a=>t({...s,description:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:3,placeholder:"Enter flow description"})]})]}));z.displayName="FlowInfoNode";const f={FLOW_INFO:"flowInfo",START:"start",API_CALL:"apiCall",LLM_INSTRUCTION:"llmInstruction",WEB_SCRAPING:"webScraping",FINISH:"finish"},F={[f.FLOW_INFO]:{label:"Flow Information",icon:e.jsx(G,{className:"w-5 h-5 text-theme-text-primary"}),description:"Basic flow information",defaultConfig:{name:"",description:""},getSummary:s=>s.name||"Untitled Flow"},[f.START]:{label:"Flow Variables",icon:e.jsx(B,{className:"w-5 h-5 text-theme-text-primary"}),description:"Configure agent variables and settings",getSummary:s=>{var r,a;const t=((a=(r=s.variables)==null?void 0:r.filter(h=>h.name))==null?void 0:a.length)||0;return`${t} variable${t!==1?"s":""} defined`}},[f.API_CALL]:{label:"API Call",icon:e.jsx(J,{className:"w-5 h-5 text-theme-text-primary"}),description:"Make an HTTP request",defaultConfig:{url:"",method:"GET",headers:[],bodyType:"json",body:"",formData:[],responseVariable:"",directOutput:!1},getSummary:s=>`${s.method||"GET"} ${s.url||"(no URL)"}`},[f.LLM_INSTRUCTION]:{label:"LLM Instruction",icon:e.jsx(Y,{className:"w-5 h-5 text-theme-text-primary"}),description:"Process data using LLM instructions",defaultConfig:{instruction:"",resultVariable:"",directOutput:!1},getSummary:s=>s.instruction||"No instruction"},[f.WEB_SCRAPING]:{label:"Web Scraping",icon:e.jsx(X,{className:"w-5 h-5 text-theme-text-primary"}),description:"Scrape content from a webpage",defaultConfig:{url:"",captureAs:"text",querySelector:"",resultVariable:"",directOutput:!1},getSummary:s=>s.url||"No URL specified"},[f.FINISH]:{label:"Flow Complete",icon:e.jsx(W,{className:"w-4 h-4"}),description:"End of agent flow",getSummary:()=>"Flow will end here",defaultConfig:{},renderConfig:()=>null}};function Te({blocks:s,updateBlockConfig:t,removeBlock:r,toggleBlockExpansion:a,renderVariableSelect:h,onDeleteVariable:c,moveBlock:b,refs:g}){const v=u=>{var p;const l=((p=s[s.length-2])==null?void 0:p.id)===u.id,m={config:u.config,onConfigChange:x=>t(u.id,x),renderVariableSelect:h,onDeleteVariable:c};return l&&u.type!==f.START&&u.type!==f.FLOW_INFO?e.jsxs("div",{className:"space-y-4",children:[j(u,m),e.jsx("div",{className:"pt-4 border-t border-white/10",children:e.jsx(q,{size:"md",variant:"horizontal",label:"Direct Output",description:"The output of this block will be returned directly to the chat. This will prevent any further tool calls from being executed.",enabled:m.config.directOutput||!1,onChange:x=>m.onConfigChange({...m.config,directOutput:x})})})]}):j(u,m)},j=(u,l)=>{switch(u.type){case f.FLOW_INFO:return e.jsx(z,{...l,ref:g});case f.START:return e.jsx(fe,{...l});case f.API_CALL:return e.jsx(ve,{...l});case f.WEBSITE:return e.jsx(je,{...l});case f.FILE:return e.jsx(we,{...l});case f.CODE:return e.jsx(Ne,{...l});case f.LLM_INSTRUCTION:return e.jsx(_e,{...l});case f.WEB_SCRAPING:return e.jsx(Se,{...l});case f.FINISH:return e.jsx(Ce,{});default:return e.jsx("div",{children:"Configuration options coming soon..."})}};return e.jsxs("div",{className:"space-y-1",children:[s.map((u,l)=>e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:`bg-theme-action-menu-bg border border-white/10 rounded-lg overflow-hidden transition-all duration-300 ${u.isExpanded?"w-full":"w-[280px] mx-auto"}`,children:[e.jsxs("div",{onClick:()=>a(u.id),className:"w-full p-4 flex items-center justify-between hover:bg-theme-action-menu-item-hover transition-colors duration-300 group cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-white/10 light:bg-white flex items-center justify-center",children:o.cloneElement(F[u.type].icon,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 text-left min-w-0 max-w-[115px]",children:[e.jsx("span",{className:"text-sm font-medium text-white block",children:F[u.type].label}),!u.isExpanded&&e.jsx("p",{className:"text-xs text-white/60 truncate",children:F[u.type].getSummary(u.config)})]})]}),e.jsx("div",{className:"flex items-center",children:u.id!=="start"&&u.type!==f.FINISH&&u.type!==f.FLOW_INFO&&e.jsxs("div",{className:"flex items-center gap-1",children:[l>2&&e.jsx("button",{onClick:m=>{m.stopPropagation(),b(l,l-1)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Move block up",children:e.jsx(U,{className:"w-3.5 h-3.5"})}),l<s.length-2&&e.jsx("button",{onClick:m=>{m.stopPropagation(),b(l,l+1)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Move block down",children:e.jsx($,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:m=>{m.stopPropagation(),r(u.id)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-red-400 hover:bg-red-500/10 hover:border-red-500/20 transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Delete block",children:e.jsx(C,{className:"w-3.5 h-3.5"})})]})})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${u.isExpanded?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"}`,children:e.jsx("div",{className:"border-t border-white/10 p-4 bg-theme-bg-secondary rounded-b-lg",children:v(u)})})]}),l<s.length-1&&e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-white/40 light:invert",children:e.jsx("path",{d:"M12 4L12 20M12 20L6 14M12 20L18 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},u.id)),e.jsx(K,{id:"block-action",place:"bottom",delayShow:300,className:"tooltip !text-xs"})]})}function ke({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState(!1),[l,m]=d.useState(null),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),tags:c,visibility:"private",flow:JSON.stringify({name:i.get("name"),description:i.get("description"),steps:s.steps,tags:c,visibility:"private"})},{success:N,error:_,itemId:I}=await T.createAgentFlow(y);if(!N)throw new Error(_);m(I),u(!0)}catch(i){console.error("Failed to publish agent flow:",i),A(`Failed to publish agent flow: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},S=n=>{b(c.filter(i=>i!==n))};return j?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.agent_flow.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.agent_flow.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.agent_flow.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("agent-flow",l),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.agent_flow.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsx("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3",children:t("community_hub.publish.agent_flow.modal_title")})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.agent_flow.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.agent_flow.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,defaultValue:s.name,placeholder:t("community_hub.publish.agent_flow.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.agent_flow.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.agent_flow.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,defaultValue:s.description,placeholder:t("community_hub.publish.agent_flow.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.agent_flow.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.agent_flow.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>S(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(C,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.agent_flow.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white",children:t("community_hub.publish.agent_flow.visibility_label")}),e.jsx("span",{className:"text-xs text-theme-text-secondary",children:t("community_hub.publish.agent_flow.privacy_note")})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 flex flex-col gap-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:"Flow Steps"}),e.jsx("div",{className:"text-xs text-white/60",children:"The steps the agent will follow when the flow is triggered."})]}),e.jsx("div",{className:"flex flex-col gap-y-0.5",children:s.steps&&s.steps.length>0?s.steps.map((n,i)=>{const y=F[n.type],N=p===i,_=y!=null&&y.getSummary?y.getSummary(n.config):"";return e.jsxs("div",{className:"flex flex-col items-center w-full",children:[e.jsxs("div",{className:"flex flex-col bg-theme-bg-secondary rounded-lg px-3 py-2 w-full cursor-pointer group",onClick:()=>x(N?null:i),children:[e.jsxs("div",{className:"flex items-center gap-x-3 w-full",children:[e.jsx("span",{children:y==null?void 0:y.icon}),e.jsx("span",{className:"text-theme-text-primary text-sm font-medium flex-1",children:(y==null?void 0:y.label)||n.type}),!N&&e.jsx("span",{className:"text-theme-text-secondary text-xs ml-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-[120px] min-w-0",children:_}),e.jsx("span",{className:`ml-2 text-theme-text-secondary transition-transform duration-200 ${N?"rotate-90":""}`,children:e.jsx(Q,{size:16})})]}),N&&_&&e.jsx("div",{className:"w-full text-theme-text-secondary text-xs mt-1 whitespace-pre-line break-words",children:_})]}),i<s.steps.length-1&&e.jsx("span",{className:"text-theme-text-secondary text-lg my-1",children:"↓"})]},i)}):e.jsx("div",{className:"text-theme-text-secondary text-xs",children:"No steps defined."})}),e.jsx("button",{type:"submit",disabled:a,className:"border-none mt-4 w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.agent_flow.submitting":"community_hub.publish.agent_flow.submit")})]})]})]})}function Ie({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState("public"),[l,m]=d.useState(!1),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),command:s.command,prompt:i.get("prompt"),tags:c,visibility:j},{success:N,error:_,itemId:I}=await T.createSlashCommand(y);if(!N)throw new Error(_);x(I),m(!0)}catch(i){console.error("Failed to publish slash command:",i),A(`Failed to publish slash command: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},S=n=>{b(c.filter(i=>i!==n))};return l?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.slash_command.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.slash_command.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.slash_command.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("slash-command",p),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.slash_command.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsxs("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3 flex items-center gap-x-2",children:[t("community_hub.publish.slash_command.modal_title"),e.jsx("code",{className:"bg-theme-bg-secondary rounded-lg px-1 text-theme-text-secondary text-lg font-mono",children:s.command})]})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.slash_command.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.slash_command.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,defaultValue:s.name,placeholder:t("community_hub.publish.slash_command.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.slash_command.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,defaultValue:s.description,placeholder:t("community_hub.publish.slash_command.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>S(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(C,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.slash_command.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.visibility_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t(j==="public"?"community_hub.publish.slash_command.public_description":"community_hub.publish.slash_command.private_description")}),e.jsx("div",{className:"w-fit h-[42px] bg-theme-bg-secondary rounded-lg p-0.5",children:e.jsxs("div",{className:"flex items-center",role:"group",children:[e.jsx("input",{type:"radio",id:"public",name:"visibility",value:"public",className:"peer/public hidden",defaultChecked:!0,onChange:n=>u(n.target.value)}),e.jsx("input",{type:"radio",id:"private",name:"visibility",value:"private",className:"peer/private hidden",onChange:n=>u(n.target.value)}),e.jsx("label",{htmlFor:"public",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/public:bg-theme-sidebar-item-hover peer-checked/public:text-theme-primary-button flex items-center justify-center",children:"Public"}),e.jsx("label",{htmlFor:"private",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/private:bg-theme-sidebar-item-hover peer-checked/private:text-theme-primary-button flex items-center justify-center",children:"Private"})]})})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.prompt_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.prompt_description")}),e.jsx("textarea",{name:"prompt",required:!0,minLength:10,defaultValue:s.prompt,placeholder:t("community_hub.publish.slash_command.prompt_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[300px] placeholder:text-theme-text-placeholder"})]}),e.jsx("button",{type:"submit",disabled:a,className:"border-none w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.slash_command.submitting":"community_hub.publish.slash_command.publish_button")})]})]})]})}function Me({show:s,onClose:t,entityType:r,entity:a}){const{isAuthenticated:h,loading:c}=be();if(!s||c)return null;if(!h)return e.jsx(ye,{show:s,onClose:t});const b=()=>{switch(r){case"system-prompt":return e.jsx(ge,{entity:a});case"agent-flow":return e.jsx(ke,{entity:a});case"slash-command":return e.jsx(Ie,{entity:a});default:return null}};return e.jsx(Z,{isOpen:s,children:e.jsxs("div",{className:"relative max-w-[900px] bg-theme-bg-primary rounded-lg shadow border border-theme-modal-border",children:[e.jsx("div",{className:"relative p-6",children:e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(C,{size:18,weight:"bold",className:"text-white"})})}),b()]})})}export{F as B,Me as P,f as a,Te as b};
1
+ import{R as o,r as d,g as H,u as E,j as e,M as Z,k as S,v as V,p as L,c as A,I as M,ab as $,aF as q,aa as U,a7 as K,a6 as G,bx as J,aE as Q}from"../index.js";import{C as T}from"./communityHub-aba61686.js";import{I as Y}from"./Brain-24e386d5.js";import{I as X}from"./Browser-1820fad0.js";const ee=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M54.8,119.49A35.06,35.06,0,0,1,49.05,128a35.06,35.06,0,0,1,5.75,8.51C60,147.24,60,159.83,60,172c0,25.94,1.84,32,20,32a12,12,0,0,1,0,24c-19.14,0-32.2-6.9-38.8-20.51C36,196.76,36,184.17,36,172c0-25.94-1.84-32-20-32a12,12,0,0,1,0-24c18.16,0,20-6.06,20-32,0-12.17,0-24.76,5.2-35.49C47.8,34.9,60.86,28,80,28a12,12,0,0,1,0,24c-18.16,0-20,6.06-20,32C60,96.17,60,108.76,54.8,119.49ZM240,116c-18.16,0-20-6.06-20-32,0-12.17,0-24.76-5.2-35.49C208.2,34.9,195.14,28,176,28a12,12,0,0,0,0,24c18.16,0,20,6.06,20,32,0,12.17,0,24.76,5.2,35.49A35.06,35.06,0,0,0,207,128a35.06,35.06,0,0,0-5.75,8.51C196,147.24,196,159.83,196,172c0,25.94-1.84,32-20,32a12,12,0,0,0,0,24c19.14,0,32.2-6.9,38.8-20.51C220,196.76,220,184.17,220,172c0-25.94,1.84-32,20-32a12,12,0,0,0,0-24Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M240,128c-64,0,0,88-64,88H80c-64,0,0-88-64-88,64,0,0-88,64-88h96C240,40,176,128,240,128Z",opacity:"0.2"}),o.createElement("path",{d:"M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM88,155.84c.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16c-31.27,0-31.72-22.43-32-35.84C71.71,141.9,71.59,136,56,136a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16C72.28,86.43,72.73,64,104,64a8,8,0,0,1,0,16c-15.59,0-15.71,5.9-16,20.16-.17,8.31-.41,20.09-8,27.84C87.59,135.75,87.83,147.53,88,155.84ZM200,136c-15.59,0-15.71,5.9-16,20.16-.28,13.41-.73,35.84-32,35.84a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16.17-8.31.41-20.09,8-27.84-7.6-7.75-7.84-19.53-8-27.84C167.71,85.9,167.59,80,152,80a8,8,0,0,1,0-16c31.27,0,31.72,22.43,32,35.84.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M39.91,128a27.68,27.68,0,0,1,9.49,11.13C54,148.62,54,160.51,54,172c0,24.27,1.21,38,26,38a6,6,0,0,1,0,12c-16.88,0-27.81-5.6-33.4-17.13C42,195.38,42,183.49,42,172c0-24.27-1.21-38-26-38a6,6,0,0,1,0-12c24.79,0,26-13.73,26-38,0-11.49,0-23.38,4.6-32.87C52.19,39.6,63.12,34,80,34a6,6,0,0,1,0,12C55.21,46,54,59.73,54,84c0,11.49,0,23.38-4.6,32.87A27.68,27.68,0,0,1,39.91,128ZM240,122c-24.79,0-26-13.73-26-38,0-11.49,0-23.38-4.6-32.87C203.81,39.6,192.88,34,176,34a6,6,0,0,0,0,12c24.79,0,26,13.73,26,38,0,11.49,0,23.38,4.6,32.87A27.68,27.68,0,0,0,216.09,128a27.68,27.68,0,0,0-9.49,11.13C202,148.62,202,160.51,202,172c0,24.27-1.21,38-26,38a6,6,0,0,0,0,12c16.88,0,27.81-5.6,33.4-17.13,4.6-9.49,4.6-21.38,4.6-32.87,0-24.27,1.21-38,26-38a6,6,0,0,0,0-12Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M35.89,128C52,136.23,52,155.64,52,172c0,24.8,1.35,40,28,40a4,4,0,0,1,0,8c-36,0-36-26.61-36-48,0-24.8-1.35-40-28-40a4,4,0,0,1,0-8c26.65,0,28-15.2,28-40,0-21.39,0-48,36-48a4,4,0,0,1,0,8C53.35,44,52,59.2,52,84,52,100.36,52,119.77,35.89,128ZM240,124c-26.65,0-28-15.2-28-40,0-21.39,0-48-36-48a4,4,0,0,0,0,8c26.65,0,28,15.2,28,40,0,16.36,0,35.77,16.11,44C204,136.23,204,155.64,204,172c0,24.8-1.35,40-28,40a4,4,0,0,0,0,8c36,0,36-26.61,36-48,0-24.8,1.35-40,28-40a4,4,0,0,0,0-8Z"}))]]);var te=Object.defineProperty,se=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,R=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,O=(s,t,r)=>t in s?te(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,ne=(s,t)=>{for(var r in t||(t={}))re.call(t,r)&&O(s,r,t[r]);if(R)for(var r of R(t))le.call(t,r)&&O(s,r,t[r]);return s},ie=(s,t)=>se(s,ae(t));const B=d.forwardRef((s,t)=>o.createElement(H,ie(ne({ref:t},s),{weights:ee})));B.displayName="BracketsCurly";const oe=new Map([["bold",o.createElement(o.Fragment,null,o.createElement("path",{d:"M40.14,46.88A12,12,0,0,0,36,56V224a12,12,0,0,0,24,0V181.72c22.84-17.12,42.1-9.12,70.68,5,16.23,8,34.74,17.2,54.8,17.2,14.72,0,30.28-4.94,46.38-18.88A12,12,0,0,0,236,176V56a12,12,0,0,0-19.86-9.07c-24.71,21.41-44.53,13.31-74.82-1.68C113.19,31.27,78.17,13.94,40.14,46.88ZM212,170.26c-22.84,17.13-42.1,9.11-70.68-5C118.16,153.76,90.33,140,60,153.87V61.69c22.84-17.12,42.1-9.12,70.68,5,16.23,8,34.74,17.2,54.8,17.2A63,63,0,0,0,212,78.08Z"}))],["duotone",o.createElement(o.Fragment,null,o.createElement("path",{d:"M224,56V176c-64,55.43-112-55.43-176,0V56C112,.57,160,111.43,224,56Z",opacity:"0.2"}),o.createElement("path",{d:"M42.76,50A8,8,0,0,0,40,56V224a8,8,0,0,0,16,0V179.77c26.79-21.16,49.87-9.75,76.45,3.41,16.4,8.11,34.06,16.85,53,16.85,13.93,0,28.54-4.75,43.82-18a8,8,0,0,0,2.76-6V56A8,8,0,0,0,218.76,50c-28,24.23-51.72,12.49-79.21-1.12C111.07,34.76,78.78,18.79,42.76,50ZM216,172.25c-26.79,21.16-49.87,9.74-76.45-3.41-25-12.35-52.81-26.13-83.55-8.4V59.79c26.79-21.16,49.87-9.75,76.45,3.4,25,12.35,52.82,26.13,83.55,8.4Z"}))],["fill",o.createElement(o.Fragment,null,o.createElement("path",{d:"M232,56V176a8,8,0,0,1-2.76,6c-15.28,13.23-29.89,18-43.82,18-18.91,0-36.57-8.74-53-16.85C105.87,170,82.79,158.61,56,179.77V224a8,8,0,0,1-16,0V56a8,8,0,0,1,2.77-6h0c36-31.18,68.31-15.21,96.79-1.12C167,62.46,190.79,74.2,218.76,50A8,8,0,0,1,232,56Z"}))],["light",o.createElement(o.Fragment,null,o.createElement("path",{d:"M44.08,51.37A6,6,0,0,0,42,55.9V224a6,6,0,0,0,12,0V178.78c28.08-22.79,51.88-11,79.34,2.57,16.12,8,33.49,16.58,52,16.58,13.57,0,27.76-4.6,42.56-17.42A6,6,0,0,0,230,176V55.9a6,6,0,0,0-9.93-4.54c-29,25.12-53.28,13.09-81.41-.84C110.77,36.71,79,21.16,44.08,51.37ZM218,173.17c-28.08,22.8-51.88,11-79.34-2.58C113.4,158.08,85.09,144.07,54,164V58.72c28.08-22.8,51.88-11,79.34,2.56C158.6,73.79,186.91,87.8,218,67.91Z"}))],["regular",o.createElement(o.Fragment,null,o.createElement("path",{d:"M42.76,50A8,8,0,0,0,40,56V224a8,8,0,0,0,16,0V179.77c26.79-21.16,49.87-9.75,76.45,3.41,16.4,8.11,34.06,16.85,53,16.85,13.93,0,28.54-4.75,43.82-18a8,8,0,0,0,2.76-6V56A8,8,0,0,0,218.76,50c-28,24.23-51.72,12.49-79.21-1.12C111.07,34.76,78.78,18.79,42.76,50ZM216,172.25c-26.79,21.16-49.87,9.74-76.45-3.41-25-12.35-52.81-26.13-83.55-8.4V59.79c26.79-21.16,49.87-9.75,76.45,3.4,25,12.35,52.82,26.13,83.55,8.4Z"}))],["thin",o.createElement(o.Fragment,null,o.createElement("path",{d:"M45.39,53.06a4,4,0,0,0-1.39,3V224a4,4,0,0,0,8,0V177.87c29.41-24.39,55.08-11.69,82.23,1.73,16.5,8.17,33.33,16.5,51.13,16.5,13.14,0,26.81-4.55,41.26-17.06a4,4,0,0,0,1.38-3v-120a4,4,0,0,0-6.62-3c-30,26-56,13.07-83.61-.57C109.07,38.28,79.4,23.62,45.39,53.06ZM220,174.17c-29.41,24.4-55.08,11.7-82.23-1.73-26.82-13.27-54.5-27-85.77-4.66V57.92c29.41-24.4,55.08-11.7,82.23,1.73,26.82,13.27,54.5,27,85.77,4.66Z"}))]]);var me=Object.defineProperty,ce=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,de=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,D=(s,t,r)=>t in s?me(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,pe=(s,t)=>{for(var r in t||(t={}))de.call(t,r)&&D(s,r,t[r]);if(P)for(var r of P(t))he.call(t,r)&&D(s,r,t[r]);return s},xe=(s,t)=>ce(s,ue(t));const W=d.forwardRef((s,t)=>o.createElement(H,xe(pe({ref:t},s),{weights:oe})));W.displayName="Flag";function be(){const[s,t]=d.useState(!1),[r,a]=d.useState(!0);return d.useEffect(()=>{async function h(){a(!0);try{const{connectionKey:c}=await T.getSettings();t(!!c)}catch(c){console.error("Error checking hub auth:",c),t(!1)}finally{a(!1)}}h()},[]),{isAuthenticated:s,loading:r}}function ye({show:s,onClose:t}){const{t:r}=E();return s?e.jsx(Z,{isOpen:s,children:e.jsx("div",{className:"relative w-[400px] max-w-full bg-theme-bg-primary rounded-lg shadow border border-theme-modal-border",children:e.jsxs("div",{className:"p-6",children:[e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{size:18,weight:"bold",className:"text-white"})}),e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:r("community_hub.publish.generic.unauthenticated.title")}),e.jsx("p",{className:"text-lg text-white text-center max-w-[300px]",children:r("community_hub.publish.generic.unauthenticated.description")}),e.jsx(V,{to:L.communityHub.authentication(),className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:r("community_hub.publish.generic.unauthenticated.button")})]})]})})}):null}function ge({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState("public"),[l,m]=d.useState(!1),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),prompt:i.get("prompt"),tags:c,visibility:j},{success:N,error:_,itemId:I}=await T.createSystemPrompt(y);if(!N)throw new Error(_);x(I),m(!0)}catch(i){console.error("Failed to publish prompt:",i),A(`Failed to publish prompt: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},C=n=>{b(c.filter(i=>i!==n))};return l?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.system_prompt.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.system_prompt.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.system_prompt.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("system-prompt",p),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.system_prompt.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsx("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3",children:t("community_hub.publish.system_prompt.modal_title")})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.system_prompt.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.system_prompt.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,placeholder:t("community_hub.publish.system_prompt.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.system_prompt.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,placeholder:t("community_hub.publish.system_prompt.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>C(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(S,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.system_prompt.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.visibility_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t(j==="public"?"community_hub.publish.system_prompt.public_description":"community_hub.publish.system_prompt.private_description")}),e.jsx("div",{className:"w-fit h-[42px] bg-theme-bg-secondary rounded-lg p-0.5",children:e.jsxs("div",{className:"flex items-center",role:"group",children:[e.jsx("input",{type:"radio",id:"public",name:"visibility",value:"public",className:"peer/public hidden",defaultChecked:!0,onChange:n=>u(n.target.value)}),e.jsx("input",{type:"radio",id:"private",name:"visibility",value:"private",className:"peer/private hidden",onChange:n=>u(n.target.value)}),e.jsx("label",{htmlFor:"public",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/public:bg-theme-sidebar-item-hover peer-checked/public:text-theme-primary-button flex items-center justify-center",children:"Public"}),e.jsx("label",{htmlFor:"private",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/private:bg-theme-sidebar-item-hover peer-checked/private:text-theme-primary-button flex items-center justify-center",children:"Private"})]})})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.system_prompt.prompt_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.system_prompt.prompt_description")}),e.jsx("textarea",{name:"prompt",required:!0,minLength:10,defaultValue:s,placeholder:t("community_hub.publish.system_prompt.prompt_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[300px] placeholder:text-theme-text-placeholder"})]}),e.jsx("button",{type:"submit",disabled:a,className:"border-none w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.system_prompt.submitting":"community_hub.publish.system_prompt.publish_button")})]})]})]})}function fe({config:s,onConfigChange:t,onDeleteVariable:r}){const a=(h,c)=>{r(c);const b=s.variables.filter((g,v)=>v!==h);t({variables:b})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-medium text-theme-text-primary",children:"Variables"}),s.variables.map((h,c)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Variable name",value:h.name,onChange:b=>{const g=[...s.variables];g[c].name=b.target.value,t({variables:g})},className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Initial value",value:h.value,onChange:b=>{const g=[...s.variables];g[c].value=b.target.value,t({variables:g})},className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),s.variables.length>1&&e.jsx("button",{onClick:()=>a(c,h.name),className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300",title:"Delete variable",children:e.jsx(S,{className:"w-4 h-4"})}),c===s.variables.length-1&&e.jsx("button",{onClick:()=>{const b=[...s.variables,{name:"",value:""}];t({variables:b})},className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300",title:"Add variable",children:e.jsx(M,{className:"w-4 h-4"})})]},c))]})}function ve({config:s,onConfigChange:t,renderVariableSelect:r}){const a=d.useRef(null),[h,c]=d.useState(!1),b=d.useRef(null),g=(l,m,p)=>{const x=[...s.headers||[]];x[l]={...x[l],[m]:p},t({headers:x})},v=()=>{const l=[...s.headers||[],{key:"",value:""}];t({headers:l})},j=l=>{const m=[...s.headers||[]].filter((p,x)=>x!==l);t({headers:m})},u=l=>{if(!a.current)return;const m=a.current,p=m.selectionStart,x=m.selectionEnd,w=s.url,k=w.substring(0,p)+"${"+l+"}"+w.substring(x);t({url:k}),c(!1),setTimeout(()=>{const C=p+l.length+3;m.setSelectionRange(C,C),m.focus()},0)};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"URL"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{ref:a,type:"text",placeholder:"https://api.example.com/endpoint",value:s.url,onChange:l=>t({url:l.target.value}),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsxs("div",{className:"relative",children:[e.jsxs("button",{ref:b,onClick:()=>c(!h),className:"h-full px-3 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300 flex items-center gap-1",title:"Insert variable",children:[e.jsx(M,{className:"w-4 h-4"}),e.jsx($,{className:"w-3 h-3"})]}),h&&e.jsx("div",{className:"absolute right-0 top-[calc(100%+4px)] w-48 bg-theme-settings-input-bg border-none rounded-lg shadow-lg z-10",children:r("",u,"Select variable to insert",!0)})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Method"}),e.jsx("select",{value:s.method,onChange:l=>t({method:l.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:["GET","POST","DELETE","PUT","PATCH"].map(l=>e.jsx("option",{value:l,className:"bg-theme-settings-input-bg",children:l},l))})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-theme-text-primary",children:"Headers"}),e.jsx("button",{onClick:v,className:"p-1.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300",title:"Add header",children:e.jsx(M,{className:"w-3.5 h-3.5"})})]}),e.jsx("div",{className:"space-y-2",children:(s.headers||[]).map((l,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Header name",value:l.key,onChange:p=>g(m,"key",p.target.value),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Value",value:l.value,onChange:p=>g(m,"value",p.target.value),className:"flex-1 border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1}),e.jsx("button",{onClick:()=>j(m),className:"p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300",title:"Remove header",children:e.jsx(S,{className:"w-4 h-4"})})]},m))})]}),["POST","PUT","PATCH"].includes(s.method)&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Request Body"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("select",{value:s.bodyType||"json",onChange:l=>t({bodyType:l.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",children:[e.jsx("option",{value:"json",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"JSON"}),e.jsx("option",{value:"text",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"Raw Text"}),e.jsx("option",{value:"form",className:"bg-theme-bg-primary light:bg-theme-settings-input-bg",children:"Form Data"})]}),s.bodyType==="json"?e.jsx("textarea",{placeholder:'{"key": "value"}',value:s.body,onChange:l=>t({body:l.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10 font-mono",rows:4,autoComplete:"off",spellCheck:!1}):s.bodyType==="form"?e.jsxs("div",{className:"space-y-2",children:[(s.formData||[]).map((l,m)=>e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",placeholder:"Key",value:l.key,onChange:p=>{const x=[...s.formData||[]];x[m]={...l,key:p.target.value},t({formData:x})},className:"flex-1 p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",autoComplete:"off",spellCheck:!1}),e.jsx("input",{type:"text",placeholder:"Value",value:l.value,onChange:p=>{const x=[...s.formData||[]];x[m]={...l,value:p.target.value},t({formData:x})},className:"flex-1 p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary placeholder:text-theme-text-secondary/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none light:bg-theme-settings-input-bg light:border-black/10",autoComplete:"off",spellCheck:!1}),e.jsx("button",{onClick:()=>{const p=[...s.formData||[]].filter((x,w)=>w!==m);t({formData:p})},className:"p-2.5 rounded-lg bg-theme-bg-primary border border-white/5 text-theme-text-primary hover:text-red-500 hover:border-red-500/20 hover:bg-red-500/10 transition-colors duration-300 light:bg-theme-settings-input-bg light:border-black/10",title:"Remove field",children:e.jsx(S,{className:"w-4 h-4"})})]},m)),e.jsx("button",{onClick:()=>{const l=[...s.formData||[],{key:"",value:""}];t({formData:l})},className:"w-full p-2.5 rounded-lg border-none bg-theme-settings-input-bg text-theme-text-primary hover:bg-theme-action-menu-item-hover transition-colors duration-300 text-sm",children:"Add Form Field"})]}):e.jsx("textarea",{placeholder:"Raw request body...",value:s.body,onChange:l=>t({body:l.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:4,autoComplete:"off",spellCheck:!1})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Store Response In"}),r(s.responseVariable,l=>t({responseVariable:l}),"Select or create variable")]})]})}function je({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"URL"}),e.jsx("input",{type:"text",placeholder:"https://example.com",value:s.url,onChange:a=>t({url:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Action"}),e.jsxs("select",{value:s.action,onChange:a=>t({action:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"read",className:"bg-theme-bg-primary",children:"Read Content"}),e.jsx("option",{value:"click",className:"bg-theme-bg-primary",children:"Click Element"}),e.jsx("option",{value:"type",className:"bg-theme-bg-primary",children:"Type Text"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"CSS Selector"}),e.jsx("input",{type:"text",placeholder:"#element-id or .class-name",value:s.selector,onChange:a=>t({selector:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function we({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Operation"}),e.jsxs("select",{value:s.operation,onChange:a=>t({operation:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"read",className:"bg-theme-bg-primary",children:"Read File"}),e.jsx("option",{value:"write",className:"bg-theme-bg-primary",children:"Write File"}),e.jsx("option",{value:"append",className:"bg-theme-bg-primary",children:"Append to File"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"File Path"}),e.jsx("input",{type:"text",placeholder:"/path/to/file",value:s.path,onChange:a=>t({path:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",autoComplete:"off",spellCheck:!1})]}),s.operation!=="read"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Content"}),e.jsx("textarea",{placeholder:"File content...",value:s.content,onChange:a=>t({content:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",rows:3,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function Ne({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Language"}),e.jsxs("select",{value:s.language,onChange:a=>t({language:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none",children:[e.jsx("option",{value:"javascript",className:"bg-theme-bg-primary",children:"JavaScript"}),e.jsx("option",{value:"python",className:"bg-theme-bg-primary",children:"Python"}),e.jsx("option",{value:"shell",className:"bg-theme-bg-primary",children:"Shell"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Code"}),e.jsx("textarea",{placeholder:"Enter code...",value:s.code,onChange:a=>t({code:a.target.value}),className:"w-full p-2.5 text-sm rounded-lg bg-theme-bg-primary border border-white/5 text-white placeholder:text-white/20 focus:border-primary-button focus:ring-1 focus:ring-primary-button outline-none font-mono",rows:5,autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-white mb-2",children:"Store Result In"}),r(s.resultVariable,a=>t({resultVariable:a}),"Select or create variable")]})]})}function _e({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Instruction"}),e.jsx("textarea",{value:(s==null?void 0:s.instruction)||"",onChange:a=>t({...s,instruction:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:3,placeholder:"Enter instructions for the LLM..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Result Variable"}),r(s.resultVariable,a=>t({...s,resultVariable:a}),"Select or create variable",!0)]})]})}function Se(){return e.jsx("div",{className:"text-sm text-white/60",children:"This is the end of your agent flow. All steps above will be executed in sequence."})}function Ce({config:s,onConfigChange:t,renderVariableSelect:r}){return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"URL to Scrape"}),e.jsx("input",{type:"url",value:(s==null?void 0:s.url)||"",onChange:a=>t({...s,url:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",placeholder:"https://example.com"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Capture Page Content As"}),e.jsx("select",{value:s.captureAs,onChange:a=>t({...s,captureAs:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",children:[{label:"Text content only",value:"text"},{label:"Raw HTML",value:"html"},{label:"CSS Query Selector",value:"querySelector"}].map(a=>e.jsx("option",{value:a.value,className:"bg-theme-settings-input-bg",children:a.label},a.value))})]}),s.captureAs==="querySelector"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Query Selector"}),e.jsx("p",{className:"text-xs text-theme-text-secondary mb-2",children:"Enter a valid CSS selector to scrape the content of the page."}),e.jsx("input",{value:s.querySelector,onChange:a=>t({...s,querySelector:a.target.value}),placeholder:".article-content, #content, .main-content, etc.",className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5"})]}),e.jsx(q,{size:"md",variant:"horizontal",label:"Content Summarization",hint:"content-summarization-tooltip",enabled:s.enableSummarization??!0,onChange:a=>t({...s,enableSummarization:a})}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Result Variable"}),r(s.resultVariable,a=>t({...s,resultVariable:a}),"Select or create variable",!0)]})]})}const z=d.forwardRef(({config:s,onConfigChange:t},r)=>e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Flow Name"}),e.jsxs("div",{className:"flex flex-col text-xs text-theme-text-secondary mt-2 mb-3",children:[e.jsx("p",{className:"",children:"It is important to give your flow a name that an LLM can easily understand."}),e.jsx("p",{children:'"SendMessageToDiscord", "CheckStockPrice", "CheckWeather"'})]}),e.jsx("input",{id:"agent-flow-name-input",ref:r==null?void 0:r.nameRef,type:"text",placeholder:"Enter flow name",value:(s==null?void 0:s.name)||"",onChange:a=>t({...s,name:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",autoComplete:"off",spellCheck:!1})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-theme-text-primary mb-2",children:"Description"}),e.jsx("div",{className:"flex flex-col text-xs text-theme-text-secondary mt-2 mb-3",children:e.jsx("p",{className:"",children:"It is equally important to give your flow a description that an LLM can easily understand. Be sure to include the purpose of the flow, the context it will be used in, and any other relevant information."})}),e.jsx("textarea",{ref:r==null?void 0:r.descriptionRef,value:(s==null?void 0:s.description)||"",onChange:a=>t({...s,description:a.target.value}),className:"w-full border-none bg-theme-settings-input-bg text-theme-text-primary placeholder:text-theme-settings-input-placeholder text-sm rounded-lg focus:outline-primary-button active:outline-primary-button outline-none p-2.5",rows:3,placeholder:"Enter flow description"})]})]}));z.displayName="FlowInfoNode";const f={FLOW_INFO:"flowInfo",START:"start",API_CALL:"apiCall",LLM_INSTRUCTION:"llmInstruction",WEB_SCRAPING:"webScraping",FINISH:"finish"},F={[f.FLOW_INFO]:{label:"Flow Information",icon:e.jsx(G,{className:"w-5 h-5 text-theme-text-primary"}),description:"Basic flow information",defaultConfig:{name:"",description:""},getSummary:s=>s.name||"Untitled Flow"},[f.START]:{label:"Flow Variables",icon:e.jsx(B,{className:"w-5 h-5 text-theme-text-primary"}),description:"Configure agent variables and settings",getSummary:s=>{var r,a;const t=((a=(r=s.variables)==null?void 0:r.filter(h=>h.name))==null?void 0:a.length)||0;return`${t} variable${t!==1?"s":""} defined`}},[f.API_CALL]:{label:"API Call",icon:e.jsx(J,{className:"w-5 h-5 text-theme-text-primary"}),description:"Make an HTTP request",defaultConfig:{url:"",method:"GET",headers:[],bodyType:"json",body:"",formData:[],responseVariable:"",directOutput:!1},getSummary:s=>`${s.method||"GET"} ${s.url||"(no URL)"}`},[f.LLM_INSTRUCTION]:{label:"LLM Instruction",icon:e.jsx(Y,{className:"w-5 h-5 text-theme-text-primary"}),description:"Process data using LLM instructions",defaultConfig:{instruction:"",resultVariable:"",directOutput:!1},getSummary:s=>s.instruction||"No instruction"},[f.WEB_SCRAPING]:{label:"Web Scraping",icon:e.jsx(X,{className:"w-5 h-5 text-theme-text-primary"}),description:"Scrape content from a webpage",defaultConfig:{url:"",captureAs:"text",querySelector:"",resultVariable:"",directOutput:!1},getSummary:s=>s.url||"No URL specified"},[f.FINISH]:{label:"Flow Complete",icon:e.jsx(W,{className:"w-4 h-4"}),description:"End of agent flow",getSummary:()=>"Flow will end here",defaultConfig:{},renderConfig:()=>null}};function Te({blocks:s,updateBlockConfig:t,removeBlock:r,toggleBlockExpansion:a,renderVariableSelect:h,onDeleteVariable:c,moveBlock:b,refs:g}){const v=u=>{var p;const l=((p=s[s.length-2])==null?void 0:p.id)===u.id,m={config:u.config,onConfigChange:x=>t(u.id,x),renderVariableSelect:h,onDeleteVariable:c};return l&&u.type!==f.START&&u.type!==f.FLOW_INFO?e.jsxs("div",{className:"space-y-4",children:[j(u,m),e.jsx("div",{className:"pt-4 border-t border-white/10",children:e.jsx(q,{size:"md",variant:"horizontal",label:"Direct Output",description:"The output of this block will be returned directly to the chat. This will prevent any further tool calls from being executed.",enabled:m.config.directOutput||!1,onChange:x=>m.onConfigChange({...m.config,directOutput:x})})})]}):j(u,m)},j=(u,l)=>{switch(u.type){case f.FLOW_INFO:return e.jsx(z,{...l,ref:g});case f.START:return e.jsx(fe,{...l});case f.API_CALL:return e.jsx(ve,{...l});case f.WEBSITE:return e.jsx(je,{...l});case f.FILE:return e.jsx(we,{...l});case f.CODE:return e.jsx(Ne,{...l});case f.LLM_INSTRUCTION:return e.jsx(_e,{...l});case f.WEB_SCRAPING:return e.jsx(Ce,{...l});case f.FINISH:return e.jsx(Se,{});default:return e.jsx("div",{children:"Configuration options coming soon..."})}};return e.jsxs("div",{className:"space-y-1",children:[s.map((u,l)=>e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:`bg-theme-action-menu-bg border border-white/10 rounded-lg overflow-hidden transition-all duration-300 ${u.isExpanded?"w-full":"w-[280px] mx-auto"}`,children:[e.jsxs("div",{onClick:()=>a(u.id),className:"w-full p-4 flex items-center justify-between hover:bg-theme-action-menu-item-hover transition-colors duration-300 group cursor-pointer",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-white/10 light:bg-white flex items-center justify-center",children:o.cloneElement(F[u.type].icon,{className:"w-4 h-4 text-white"})}),e.jsxs("div",{className:"flex-1 text-left min-w-0 max-w-[115px]",children:[e.jsx("span",{className:"text-sm font-medium text-white block",children:F[u.type].label}),!u.isExpanded&&e.jsx("p",{className:"text-xs text-white/60 truncate",children:F[u.type].getSummary(u.config)})]})]}),e.jsx("div",{className:"flex items-center",children:u.id!=="start"&&u.type!==f.FINISH&&u.type!==f.FLOW_INFO&&e.jsxs("div",{className:"flex items-center gap-1",children:[l>2&&e.jsx("button",{onClick:m=>{m.stopPropagation(),b(l,l-1)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Move block up",children:e.jsx(U,{className:"w-3.5 h-3.5"})}),l<s.length-2&&e.jsx("button",{onClick:m=>{m.stopPropagation(),b(l,l+1)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-white hover:bg-theme-action-menu-item-hover transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Move block down",children:e.jsx($,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:m=>{m.stopPropagation(),r(u.id)},className:"w-7 h-7 flex items-center justify-center rounded-lg bg-theme-bg-primary border border-white/5 text-red-400 hover:bg-red-500/10 hover:border-red-500/20 transition-colors duration-300","data-tooltip-id":"block-action","data-tooltip-content":"Delete block",children:e.jsx(S,{className:"w-3.5 h-3.5"})})]})})]}),e.jsx("div",{className:`overflow-hidden transition-all duration-300 ease-in-out ${u.isExpanded?"max-h-[1000px] opacity-100":"max-h-0 opacity-0"}`,children:e.jsx("div",{className:"border-t border-white/10 p-4 bg-theme-bg-secondary rounded-b-lg",children:v(u)})})]}),l<s.length-1&&e.jsx("div",{className:"flex justify-center my-1",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-white/40 light:invert",children:e.jsx("path",{d:"M12 4L12 20M12 20L6 14M12 20L18 14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})]},u.id)),e.jsx(K,{id:"block-action",place:"bottom",delayShow:300,className:"tooltip !text-xs"})]})}function ke({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState(!1),[l,m]=d.useState(null),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),tags:c,visibility:"private",flow:JSON.stringify({name:i.get("name"),description:i.get("description"),steps:s.steps,tags:c,visibility:"private"})},{success:N,error:_,itemId:I}=await T.createAgentFlow(y);if(!N)throw new Error(_);m(I),u(!0)}catch(i){console.error("Failed to publish agent flow:",i),A(`Failed to publish agent flow: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},C=n=>{b(c.filter(i=>i!==n))};return j?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.agent_flow.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.agent_flow.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.agent_flow.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("agent-flow",l),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.agent_flow.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsx("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3",children:t("community_hub.publish.agent_flow.modal_title")})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.agent_flow.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.agent_flow.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,defaultValue:s.name,placeholder:t("community_hub.publish.agent_flow.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.agent_flow.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.agent_flow.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,defaultValue:s.description,placeholder:t("community_hub.publish.agent_flow.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.agent_flow.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.agent_flow.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>C(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(S,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.agent_flow.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white",children:t("community_hub.publish.agent_flow.visibility_label")}),e.jsx("span",{className:"text-xs text-theme-text-secondary",children:t("community_hub.publish.agent_flow.privacy_note")})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 flex flex-col gap-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:"Flow Steps"}),e.jsx("div",{className:"text-xs text-white/60",children:"The steps the agent will follow when the flow is triggered."})]}),e.jsx("div",{className:"flex flex-col gap-y-0.5",children:s.steps&&s.steps.length>0?s.steps.map((n,i)=>{const y=F[n.type],N=p===i,_=y!=null&&y.getSummary?y.getSummary(n.config):"";return e.jsxs("div",{className:"flex flex-col items-center w-full",children:[e.jsxs("div",{className:"flex flex-col bg-theme-bg-secondary rounded-lg px-3 py-2 w-full cursor-pointer group",onClick:()=>x(N?null:i),children:[e.jsxs("div",{className:"flex items-center gap-x-3 w-full",children:[e.jsx("span",{children:y==null?void 0:y.icon}),e.jsx("span",{className:"text-theme-text-primary text-sm font-medium flex-1",children:(y==null?void 0:y.label)||n.type}),!N&&e.jsx("span",{className:"text-theme-text-secondary text-xs ml-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-[120px] min-w-0",children:_}),e.jsx("span",{className:`ml-2 text-theme-text-secondary transition-transform duration-200 ${N?"rotate-90":""}`,children:e.jsx(Q,{size:16})})]}),N&&_&&e.jsx("div",{className:"w-full text-theme-text-secondary text-xs mt-1 whitespace-pre-line break-words",children:_})]}),i<s.steps.length-1&&e.jsx("span",{className:"text-theme-text-secondary text-lg my-1",children:"↓"})]},i)}):e.jsx("div",{className:"text-theme-text-secondary text-xs",children:"No steps defined."})}),e.jsx("button",{type:"submit",disabled:a,className:"border-none mt-4 w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.agent_flow.submitting":"community_hub.publish.agent_flow.submit")})]})]})]})}function Ie({entity:s}){const{t}=E(),r=d.useRef(null),[a,h]=d.useState(!1),[c,b]=d.useState([]),[g,v]=d.useState(""),[j,u]=d.useState("public"),[l,m]=d.useState(!1),[p,x]=d.useState(null),w=async n=>{n.preventDefault(),n.stopPropagation(),h(!0);try{const i=new FormData(r.current),y={name:i.get("name"),description:i.get("description"),command:s.command,prompt:i.get("prompt"),tags:c,visibility:j},{success:N,error:_,itemId:I}=await T.createSlashCommand(y);if(!N)throw new Error(_);x(I),m(!0)}catch(i){console.error("Failed to publish slash command:",i),A(`Failed to publish slash command: ${i.message}`,"error",{clear:!0})}finally{h(!1)}},k=n=>{if(n.key==="Enter"||n.key===","){n.preventDefault();const i=g.trim();if(i.length>20)return;i&&!c.includes(i)&&(b(y=>[...y,i].slice(0,5)),v(""))}},C=n=>{b(c.filter(i=>i!==n))};return l?e.jsx("div",{className:"p-6 -mt-12 w-[400px]",children:e.jsxs("div",{className:"flex flex-col items-center justify-center gap-y-2",children:[e.jsx("h3",{className:"text-lg font-semibold text-theme-text-primary",children:t("community_hub.publish.slash_command.success_title")}),e.jsx("p",{className:"text-lg text-theme-text-primary text-center max-w-2xl",children:t("community_hub.publish.slash_command.success_description")}),e.jsx("p",{className:"text-theme-text-secondary text-center text-sm",children:t("community_hub.publish.slash_command.success_thank_you")}),e.jsx(V,{to:L.communityHub.viewItem("slash-command",p),target:"_blank",rel:"noreferrer",className:"w-[265px] bg-theme-bg-secondary hover:bg-theme-sidebar-item-hover text-theme-text-primary py-2 px-4 rounded-lg transition-colors mt-4 text-sm font-semibold text-center",children:t("community_hub.publish.slash_command.view_on_hub")})]})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full flex gap-x-2 items-center mb-3 -mt-8",children:e.jsxs("h3",{className:"text-xl font-semibold text-theme-text-primary px-6 py-3 flex items-center gap-x-2",children:[t("community_hub.publish.slash_command.modal_title"),e.jsx("code",{className:"bg-theme-bg-secondary rounded-lg px-1 text-theme-text-secondary text-lg font-mono",children:s.command})]})}),e.jsxs("form",{ref:r,className:"flex",onSubmit:w,children:[e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.slash_command.name_label")}),e.jsx("div",{className:"text-xs text-theme-text-secondary mb-2",children:t("community_hub.publish.slash_command.name_description")}),e.jsx("input",{type:"text",name:"name",required:!0,minLength:3,maxLength:300,defaultValue:s.name,placeholder:t("community_hub.publish.slash_command.name_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-theme-text-primary text-sm focus:outline-primary-button active:outline-primary-button outline-none placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-theme-text-primary mb-1",children:t("community_hub.publish.slash_command.description_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.description_description")}),e.jsx("textarea",{name:"description",required:!0,minLength:10,maxLength:1e3,defaultValue:s.description,placeholder:t("community_hub.publish.slash_command.description_description"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[80px] placeholder:text-theme-text-placeholder"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.tags_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.tags_description")}),e.jsxs("div",{className:"flex flex-wrap gap-2 p-2 bg-theme-bg-secondary rounded-lg min-h-[42px]",children:[c.map((n,i)=>e.jsxs("span",{className:"flex items-center gap-1 px-2 py-1 text-sm text-theme-text-primary bg-white/10 light:bg-black/10 rounded-md",children:[n,e.jsx("button",{type:"button",onClick:()=>C(n),className:"border-none text-theme-text-primary hover:text-theme-text-secondary cursor-pointer",children:e.jsx(S,{size:14})})]},i)),e.jsx("input",{type:"text",value:g,onChange:n=>v(n.target.value),onKeyDown:k,placeholder:t("community_hub.publish.slash_command.tags_placeholder"),className:"flex-1 min-w-[200px] border-none text-sm bg-transparent text-theme-text-primary placeholder:text-theme-text-placeholder p-0 h-[24px] focus:outline-none"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.visibility_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t(j==="public"?"community_hub.publish.slash_command.public_description":"community_hub.publish.slash_command.private_description")}),e.jsx("div",{className:"w-fit h-[42px] bg-theme-bg-secondary rounded-lg p-0.5",children:e.jsxs("div",{className:"flex items-center",role:"group",children:[e.jsx("input",{type:"radio",id:"public",name:"visibility",value:"public",className:"peer/public hidden",defaultChecked:!0,onChange:n=>u(n.target.value)}),e.jsx("input",{type:"radio",id:"private",name:"visibility",value:"private",className:"peer/private hidden",onChange:n=>u(n.target.value)}),e.jsx("label",{htmlFor:"public",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/public:bg-theme-sidebar-item-hover peer-checked/public:text-theme-primary-button flex items-center justify-center",children:"Public"}),e.jsx("label",{htmlFor:"private",className:"h-[36px] px-4 rounded-lg text-sm font-medium transition-all duration-200 cursor-pointer text-theme-text-primary hover:text-theme-text-secondary peer-checked/private:bg-theme-sidebar-item-hover peer-checked/private:text-theme-primary-button flex items-center justify-center",children:"Private"})]})})]})]}),e.jsxs("div",{className:"w-1/2 p-6 pt-0 space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-semibold text-white mb-1",children:t("community_hub.publish.slash_command.prompt_label")}),e.jsx("div",{className:"text-xs text-white/60 mb-2",children:t("community_hub.publish.slash_command.prompt_description")}),e.jsx("textarea",{name:"prompt",required:!0,minLength:10,defaultValue:s.prompt,placeholder:t("community_hub.publish.slash_command.prompt_placeholder"),className:"border-none w-full bg-theme-bg-secondary rounded-lg p-2 text-white text-sm focus:outline-primary-button active:outline-primary-button outline-none min-h-[300px] placeholder:text-theme-text-placeholder"})]}),e.jsx("button",{type:"submit",disabled:a,className:"border-none w-full bg-cta-button hover:opacity-80 text-theme-text-primary font-medium py-2 px-4 rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:t(a?"community_hub.publish.slash_command.submitting":"community_hub.publish.slash_command.publish_button")})]})]})]})}function Me({show:s,onClose:t,entityType:r,entity:a}){const{isAuthenticated:h,loading:c}=be();if(!s||c)return null;if(!h)return e.jsx(ye,{show:s,onClose:t});const b=()=>{switch(r){case"system-prompt":return e.jsx(ge,{entity:a});case"agent-flow":return e.jsx(ke,{entity:a});case"slash-command":return e.jsx(Ie,{entity:a});default:return null}};return e.jsx(Z,{isOpen:s,children:e.jsxs("div",{className:"relative max-w-[900px] bg-theme-bg-primary rounded-lg shadow border border-theme-modal-border",children:[e.jsx("div",{className:"relative p-6",children:e.jsx("button",{onClick:t,type:"button",className:"absolute top-4 right-4 transition-all duration-300 bg-transparent rounded-lg text-sm p-1 inline-flex items-center hover:bg-theme-modal-border hover:border-theme-modal-border hover:border-opacity-50 border-transparent border",children:e.jsx(S,{size:18,weight:"bold",className:"text-white"})})}),b()]})})}export{F as B,Me as P,f as a,Te as b};