@johpaz/hive-agents 0.0.28 → 0.0.30

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 (183) hide show
  1. package/README.md +27 -17
  2. package/dist/hive.js +11349 -12001
  3. package/dist/ui/assets/AgentCreateForm-BmRLLGIL.js +1 -0
  4. package/dist/ui/assets/AgentDetailPage-BOVOgECU.js +1 -0
  5. package/dist/ui/assets/AgentNewPage-BCMuhksF.js +1 -0
  6. package/dist/ui/assets/AgentsPage-BYGTwib8.js +10 -0
  7. package/dist/ui/assets/BridgePage-CEMpmdql.js +1 -0
  8. package/dist/ui/assets/CanvasPage-Dcmx4S1-.js +33 -0
  9. package/dist/ui/assets/ChannelsPage-B_PiavjN.js +8 -0
  10. package/dist/ui/assets/DashboardPage-sSu1NU7V.js +6 -0
  11. package/dist/ui/assets/LoginPage-D1kejzak.js +1 -0
  12. package/dist/ui/assets/LogsPage-CaD4OOff.js +1 -0
  13. package/dist/ui/assets/MeetingPage-C0iKxHOI.js +1 -0
  14. package/dist/ui/assets/NotFound-CBnwE5nh.js +1 -0
  15. package/dist/ui/assets/ProjectsPage-DGliWwpu.js +1 -0
  16. package/dist/ui/assets/ProvidersPage-_O0WMMVK.js +1 -0
  17. package/dist/ui/assets/RecoverPage-DVESenp8.js +1 -0
  18. package/dist/ui/assets/SettingsPage-BKCZqIq2.js +9 -0
  19. package/dist/ui/assets/SetupPage-IjKq_kLj.js +1 -0
  20. package/dist/ui/assets/WebChatPage-D-zO53Yt.js +16 -0
  21. package/dist/ui/assets/accordion-_sozXeaB.js +1 -0
  22. package/dist/ui/assets/activity-BB8JBT7a.js +1 -0
  23. package/dist/ui/assets/alert-Bgqky__w.js +1 -0
  24. package/dist/ui/assets/alert-dialog-B12geoBt.js +1 -0
  25. package/dist/ui/assets/arrow-left-WQsWOWW_.js +1 -0
  26. package/dist/ui/assets/badge-BY-VUaxL.js +1 -0
  27. package/dist/ui/assets/calendar-D_GHXR8q.js +1 -0
  28. package/dist/ui/assets/card-CE_kGxdL.js +1 -0
  29. package/dist/ui/assets/chevron-down-DLfCQOQA.js +1 -0
  30. package/dist/ui/assets/chevron-left-5XF9hbEm.js +1 -0
  31. package/dist/ui/assets/chevron-right-B60x0b2L.js +1 -0
  32. package/dist/ui/assets/chevron-up-GfewdYph.js +1 -0
  33. package/dist/ui/assets/circle-DLFOVgkH.js +1 -0
  34. package/dist/ui/assets/circle-alert-Qf59MV-u.js +1 -0
  35. package/dist/ui/assets/circle-check-BhwUUu4Z.js +1 -0
  36. package/dist/ui/assets/circle-minus-BcF7EW2K.js +1 -0
  37. package/dist/ui/assets/circle-x-C55wB-DP.js +1 -0
  38. package/dist/ui/assets/cpu-BxFtjoPn.js +1 -0
  39. package/dist/ui/assets/dialog-CWlGzRqi.js +1 -0
  40. package/dist/ui/assets/download-DRO1cmbw.js +1 -0
  41. package/dist/ui/assets/dropdown-menu-CdulmYlU.js +1 -0
  42. package/dist/ui/assets/es-JYPdzK5t.js +1 -0
  43. package/dist/ui/assets/external-link-BULKsDvk.js +1 -0
  44. package/dist/ui/assets/eye-SOUMoM2-.js +1 -0
  45. package/dist/ui/assets/file-text-CxAwK_Ze.js +1 -0
  46. package/dist/ui/assets/folder-open-BnXDc8BG.js +1 -0
  47. package/dist/ui/assets/format-CR2WWfql.js +1 -0
  48. package/dist/ui/assets/gauge-DYmZYnET.js +1 -0
  49. package/dist/ui/assets/globe-C7sirxEy.js +1 -0
  50. package/dist/ui/assets/hexagon-BGGuDxI7.js +1 -0
  51. package/dist/ui/assets/history-vA8Y7XQq.js +1 -0
  52. package/dist/ui/assets/index-9GZvkGGW.css +2 -0
  53. package/dist/ui/assets/index-B4lS14UW.js +116 -0
  54. package/dist/ui/assets/info-CFGdNsZs.js +1 -0
  55. package/dist/ui/assets/key-DFIqRGXl.js +1 -0
  56. package/dist/ui/assets/label-CplWBwSz.js +1 -0
  57. package/dist/ui/assets/loader-circle-BaadtldT.js +1 -0
  58. package/dist/ui/assets/lock-DUwqtzEo.js +1 -0
  59. package/dist/ui/assets/pause-BsToEchU.js +1 -0
  60. package/dist/ui/assets/play-Rmf5Px63.js +1 -0
  61. package/dist/ui/assets/plus-CqJyiQvM.js +1 -0
  62. package/dist/ui/assets/progress-CFpWXmru.js +1 -0
  63. package/dist/ui/assets/refresh-cw-Yf5FGfA5.js +1 -0
  64. package/dist/ui/assets/save-Diu387yr.js +1 -0
  65. package/dist/ui/assets/scroll-area-B3bGhGnD.js +1 -0
  66. package/dist/ui/assets/search-CnhAnemg.js +1 -0
  67. package/dist/ui/assets/send-CU73wLDC.js +1 -0
  68. package/dist/ui/assets/settings-OcD7AWkq.js +1 -0
  69. package/dist/ui/assets/slider-B7ibzqE3.js +14 -0
  70. package/dist/ui/assets/sparkles-Dnx_Tpre.js +1 -0
  71. package/dist/ui/assets/square-PyIpnS-W.js +1 -0
  72. package/dist/ui/assets/switch-CQf9jQKN.js +1 -0
  73. package/dist/ui/assets/table-CN6cGA9v.js +1 -0
  74. package/dist/ui/assets/terminal-CNLY74vg.js +1 -0
  75. package/dist/ui/assets/textarea-CPuZn8Rg.js +1 -0
  76. package/dist/ui/assets/trash-2-CUqHaFaC.js +1 -0
  77. package/dist/ui/assets/triangle-alert-vUtWDfZd.js +1 -0
  78. package/dist/ui/assets/useProviders-77fYN2hY.js +1 -0
  79. package/dist/ui/assets/vendor-charts-Bu2lyBKP.js +65 -0
  80. package/dist/ui/assets/vendor-query-DsWPbQdG.js +1 -0
  81. package/dist/ui/assets/vendor-radix-JY4ncZrD.js +63 -0
  82. package/dist/ui/assets/vendor-react-CscwQerf.js +1 -0
  83. package/dist/ui/assets/vendor-router-4QM6Fwg6.js +3 -0
  84. package/dist/ui/assets/volume-2-B8dkjcEZ.js +1 -0
  85. package/dist/ui/assets/wifi-DK-RxSqc.js +1 -0
  86. package/dist/ui/assets/zap-BD57u2UH.js +1 -0
  87. package/dist/ui/dist/assets/AgentCreateForm-BmRLLGIL.js +1 -0
  88. package/dist/ui/dist/assets/AgentDetailPage-BOVOgECU.js +1 -0
  89. package/dist/ui/dist/assets/AgentNewPage-BCMuhksF.js +1 -0
  90. package/dist/ui/dist/assets/AgentsPage-BYGTwib8.js +10 -0
  91. package/dist/ui/dist/assets/BridgePage-CEMpmdql.js +1 -0
  92. package/dist/ui/dist/assets/CanvasPage-Dcmx4S1-.js +33 -0
  93. package/dist/ui/dist/assets/ChannelsPage-B_PiavjN.js +8 -0
  94. package/dist/ui/dist/assets/DashboardPage-sSu1NU7V.js +6 -0
  95. package/dist/ui/dist/assets/LoginPage-D1kejzak.js +1 -0
  96. package/dist/ui/dist/assets/LogsPage-CaD4OOff.js +1 -0
  97. package/dist/ui/dist/assets/MeetingPage-C0iKxHOI.js +1 -0
  98. package/dist/ui/dist/assets/NotFound-CBnwE5nh.js +1 -0
  99. package/dist/ui/dist/assets/ProjectsPage-DGliWwpu.js +1 -0
  100. package/dist/ui/dist/assets/ProvidersPage-_O0WMMVK.js +1 -0
  101. package/dist/ui/dist/assets/RecoverPage-DVESenp8.js +1 -0
  102. package/dist/ui/dist/assets/SettingsPage-BKCZqIq2.js +9 -0
  103. package/dist/ui/dist/assets/SetupPage-IjKq_kLj.js +1 -0
  104. package/dist/ui/dist/assets/WebChatPage-D-zO53Yt.js +16 -0
  105. package/dist/ui/dist/assets/accordion-_sozXeaB.js +1 -0
  106. package/dist/ui/dist/assets/activity-BB8JBT7a.js +1 -0
  107. package/dist/ui/dist/assets/alert-Bgqky__w.js +1 -0
  108. package/dist/ui/dist/assets/alert-dialog-B12geoBt.js +1 -0
  109. package/dist/ui/dist/assets/arrow-left-WQsWOWW_.js +1 -0
  110. package/dist/ui/dist/assets/badge-BY-VUaxL.js +1 -0
  111. package/dist/ui/dist/assets/calendar-D_GHXR8q.js +1 -0
  112. package/dist/ui/dist/assets/card-CE_kGxdL.js +1 -0
  113. package/dist/ui/dist/assets/chevron-down-DLfCQOQA.js +1 -0
  114. package/dist/ui/dist/assets/chevron-left-5XF9hbEm.js +1 -0
  115. package/dist/ui/dist/assets/chevron-right-B60x0b2L.js +1 -0
  116. package/dist/ui/dist/assets/chevron-up-GfewdYph.js +1 -0
  117. package/dist/ui/dist/assets/circle-DLFOVgkH.js +1 -0
  118. package/dist/ui/dist/assets/circle-alert-Qf59MV-u.js +1 -0
  119. package/dist/ui/dist/assets/circle-check-BhwUUu4Z.js +1 -0
  120. package/dist/ui/dist/assets/circle-minus-BcF7EW2K.js +1 -0
  121. package/dist/ui/dist/assets/circle-x-C55wB-DP.js +1 -0
  122. package/dist/ui/dist/assets/cpu-BxFtjoPn.js +1 -0
  123. package/dist/ui/dist/assets/dialog-CWlGzRqi.js +1 -0
  124. package/dist/ui/dist/assets/download-DRO1cmbw.js +1 -0
  125. package/dist/ui/dist/assets/dropdown-menu-CdulmYlU.js +1 -0
  126. package/dist/ui/dist/assets/es-JYPdzK5t.js +1 -0
  127. package/dist/ui/dist/assets/external-link-BULKsDvk.js +1 -0
  128. package/dist/ui/dist/assets/eye-SOUMoM2-.js +1 -0
  129. package/dist/ui/dist/assets/file-text-CxAwK_Ze.js +1 -0
  130. package/dist/ui/dist/assets/folder-open-BnXDc8BG.js +1 -0
  131. package/dist/ui/dist/assets/format-CR2WWfql.js +1 -0
  132. package/dist/ui/dist/assets/gauge-DYmZYnET.js +1 -0
  133. package/dist/ui/dist/assets/globe-C7sirxEy.js +1 -0
  134. package/dist/ui/dist/assets/hexagon-BGGuDxI7.js +1 -0
  135. package/dist/ui/dist/assets/history-vA8Y7XQq.js +1 -0
  136. package/dist/ui/dist/assets/index-9GZvkGGW.css +2 -0
  137. package/dist/ui/dist/assets/index-B4lS14UW.js +116 -0
  138. package/dist/ui/dist/assets/info-CFGdNsZs.js +1 -0
  139. package/dist/ui/dist/assets/key-DFIqRGXl.js +1 -0
  140. package/dist/ui/dist/assets/label-CplWBwSz.js +1 -0
  141. package/dist/ui/dist/assets/loader-circle-BaadtldT.js +1 -0
  142. package/dist/ui/dist/assets/lock-DUwqtzEo.js +1 -0
  143. package/dist/ui/dist/assets/pause-BsToEchU.js +1 -0
  144. package/dist/ui/dist/assets/play-Rmf5Px63.js +1 -0
  145. package/dist/ui/dist/assets/plus-CqJyiQvM.js +1 -0
  146. package/dist/ui/dist/assets/progress-CFpWXmru.js +1 -0
  147. package/dist/ui/dist/assets/refresh-cw-Yf5FGfA5.js +1 -0
  148. package/dist/ui/dist/assets/save-Diu387yr.js +1 -0
  149. package/dist/ui/dist/assets/scroll-area-B3bGhGnD.js +1 -0
  150. package/dist/ui/dist/assets/search-CnhAnemg.js +1 -0
  151. package/dist/ui/dist/assets/send-CU73wLDC.js +1 -0
  152. package/dist/ui/dist/assets/settings-OcD7AWkq.js +1 -0
  153. package/dist/ui/dist/assets/slider-B7ibzqE3.js +14 -0
  154. package/dist/ui/dist/assets/sparkles-Dnx_Tpre.js +1 -0
  155. package/dist/ui/dist/assets/square-PyIpnS-W.js +1 -0
  156. package/dist/ui/dist/assets/switch-CQf9jQKN.js +1 -0
  157. package/dist/ui/dist/assets/table-CN6cGA9v.js +1 -0
  158. package/dist/ui/dist/assets/terminal-CNLY74vg.js +1 -0
  159. package/dist/ui/dist/assets/textarea-CPuZn8Rg.js +1 -0
  160. package/dist/ui/dist/assets/trash-2-CUqHaFaC.js +1 -0
  161. package/dist/ui/dist/assets/triangle-alert-vUtWDfZd.js +1 -0
  162. package/dist/ui/dist/assets/useProviders-77fYN2hY.js +1 -0
  163. package/dist/ui/dist/assets/vendor-charts-Bu2lyBKP.js +65 -0
  164. package/dist/ui/dist/assets/vendor-query-DsWPbQdG.js +1 -0
  165. package/dist/ui/dist/assets/vendor-radix-JY4ncZrD.js +63 -0
  166. package/dist/ui/dist/assets/vendor-react-CscwQerf.js +1 -0
  167. package/dist/ui/dist/assets/vendor-router-4QM6Fwg6.js +3 -0
  168. package/dist/ui/dist/assets/volume-2-B8dkjcEZ.js +1 -0
  169. package/dist/ui/dist/assets/wifi-DK-RxSqc.js +1 -0
  170. package/dist/ui/dist/assets/zap-BD57u2UH.js +1 -0
  171. package/dist/ui/dist/index.html +30 -25
  172. package/dist/ui/index.html +30 -25
  173. package/package.json +3 -5
  174. package/dist/ui/assets/index-BPhhlVgu.js +0 -344
  175. package/dist/ui/assets/index-D-gAnNFM.css +0 -2
  176. package/dist/ui/assets/react-C63RN3Ve.js +0 -1
  177. package/dist/ui/assets/ui-CHpVij2M.css +0 -1
  178. package/dist/ui/assets/ui-Cw_eF3wo.js +0 -22
  179. package/dist/ui/dist/assets/index-BPhhlVgu.js +0 -344
  180. package/dist/ui/dist/assets/index-D-gAnNFM.css +0 -2
  181. package/dist/ui/dist/assets/react-C63RN3Ve.js +0 -1
  182. package/dist/ui/dist/assets/ui-CHpVij2M.css +0 -1
  183. package/dist/ui/dist/assets/ui-Cw_eF3wo.js +0 -22
@@ -0,0 +1,9 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./activity-BB8JBT7a.js";import{n as i,r as a,t as o}from"./send-CU73wLDC.js";import{t as s}from"./calendar-D_GHXR8q.js";import{a as c,c as l,l as u,n as d,r as f,s as p,t as m}from"./switch-CQf9jQKN.js";import{t as h}from"./chevron-down-DLfCQOQA.js";import{t as g}from"./chevron-up-GfewdYph.js";import{t as _}from"./circle-alert-Qf59MV-u.js";import{t as v}from"./circle-check-BhwUUu4Z.js";import{t as y}from"./cpu-BxFtjoPn.js";import{n as b,t as x}from"./eye-SOUMoM2-.js";import{t as S}from"./globe-C7sirxEy.js";import{t as C}from"./hexagon-BGGuDxI7.js";import{t as w}from"./history-vA8Y7XQq.js";import{t as T}from"./info-CFGdNsZs.js";import{t as E}from"./key-DFIqRGXl.js";import{t as D}from"./loader-circle-BaadtldT.js";import{t as O}from"./lock-DUwqtzEo.js";import{t as k}from"./pause-BsToEchU.js";import{n as A,r as j,t as M}from"./wifi-DK-RxSqc.js";import{t as N}from"./play-Rmf5Px63.js";import{t as P}from"./plus-CqJyiQvM.js";import{t as F}from"./refresh-cw-Yf5FGfA5.js";import{t as I}from"./search-CnhAnemg.js";import{t as L}from"./settings-OcD7AWkq.js";import{n as R,t as z}from"./textarea-CPuZn8Rg.js";import{t as ee}from"./sparkles-Dnx_Tpre.js";import{t as B}from"./terminal-CNLY74vg.js";import{t as te}from"./trash-2-CUqHaFaC.js";import{t as ne}from"./triangle-alert-vUtWDfZd.js";import{t as re}from"./zap-BD57u2UH.js";import{l as ie}from"./vendor-router-4QM6Fwg6.js";import{G as ae,H as V,J as oe,K as se,N as H,P as U,Q as ce,U as le,V as ue,W as de,X as fe,Y as pe,a as me,c as he,d as ge,et as _e,f as W,h as G,l as ve,m as K,p as q,q as ye,tt as J,w as be}from"./index-B4lS14UW.js";import{t as Y}from"./label-CplWBwSz.js";import{a as xe,c as Se,i as Ce,o as we,r as Te,s as Ee,t as De}from"./dialog-CWlGzRqi.js";import{t as X}from"./badge-BY-VUaxL.js";import{a as Oe,n as ke,o as Z,r as Ae,t as je}from"./card-CE_kGxdL.js";import"./useProviders-77fYN2hY.js";import{t as Me}from"./scroll-area-B3bGhGnD.js";import{n as Ne,t as Pe}from"./alert-Bgqky__w.js";var Fe=J(`Briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),Ie=J(`ChartColumn`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Le=J(`CodeXml`,[[`path`,{d:`m18 16 4-4-4-4`,key:`1inbqp`}],[`path`,{d:`m6 8-4 4 4 4`,key:`15zrgr`}],[`path`,{d:`m14.5 4-5 16`,key:`e7oirm`}]]),Re=J(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),ze=J(`Copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Be=J(`Earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ve=J(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),He=J(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ue=J(`LogOut`,[[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}],[`polyline`,{points:`16 17 21 12 16 7`,key:`1gabdz`}],[`line`,{x1:`21`,x2:`9`,y1:`12`,y2:`12`,key:`1uyos4`}]]),We=J(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Ge=J(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Ke=J(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),qe=J(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Je=J(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Ye=J(`Users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`path`,{d:`M16 3.13a4 4 0 0 1 0 7.75`,key:`1da9ce`}]]),Q=e(t(),1),Xe=be((e,t)=>({isLoading:!1,error:null,configs:[],conflicts:[],templates:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await W(`/api/ethics`)).ethics||[],n=t.find(e=>e.active)||t[0];return e({configs:t,isLoading:!1}),n?.content||``}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch ethics`}),t}},saveEthics:async n=>{e({isLoading:!0,error:null});try{let r=t(),i=r.configs.find(e=>e.active)||r.configs[0],a;return a=i?await W(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await W(`/api/ethics`,{method:`POST`,body:{name:`Default`,content:n,active:!0}}),e({isLoading:!1}),a.message||`Guardado correctamente`}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to save ethics`}),t}},fetchConfigs:async()=>{e({isLoading:!0,error:null});try{e({configs:await W(`/api/workspace/ethics/configs`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch configs`})}},fetchConflicts:async()=>{e({isLoading:!0,error:null});try{e({conflicts:await W(`/api/workspace/ethics/conflicts`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch conflicts`})}},fetchTemplates:async()=>{e({isLoading:!0,error:null});try{e({templates:await W(`/api/workspace/ethics/templates`),isLoading:!1})}catch(t){e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch templates`})}},updateConfig:(t,n)=>{e(e=>({configs:e.configs.map(e=>e.id===t?{...e,...n,updatedAt:new Date().toISOString(),version:e.version+1}:e)}))},addConfig:t=>{let n={...t,id:ue(),version:1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e(e=>({configs:[...e.configs,n]}))},removeConfig:t=>{e(e=>({configs:e.configs.filter(e=>e.id!==t)}))}})),$=n();function Ze(){let{configs:e,fetchEthics:t,isLoading:n}=Xe(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,description:``,content:``}),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Q.useEffect)(()=>{t().catch(console.error)},[t]),(0,Q.useEffect)(()=>{if(e.length===0)return;let t=e,n=t.find(e=>e.active)||t[0];r||(i(n.id),c({name:n.name,description:n.description||``,content:n.content}))},[e,r]);let p=e.find(e=>e.id===r),m=e=>{i(e.id),c({name:e.name,description:e.description||``,content:e.content}),o(!0)},h=async n=>{G.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>W(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);q.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{G.hide()}};return n&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(D,{className:`h-8 w-8 animate-spin text-amber-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`hive-label`,children:`Cargando lineamientos operativos...`})]}):(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Protocolos Éticos`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[e.length,` REGISTROS`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Define la capa moral y los límites operacionales de tus agentes inteligentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(R,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Configuración del Núcleo`})]})]}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(ne,{className:`h-8 w-8 text-white/20`})}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`Sin Protocolos Base`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`No se han detectado lineamientos éticos en el sistema. Selecciona una de las plantillas inferiores para comenzar.`})]})]})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>{let t=!!e.active,n=r===e.id;return(0,$.jsxs)(`div`,{onClick:()=>m(e),className:`hive-card group transition-all duration-500 cursor-pointer ${n?`hive-card--active`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal ${n?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,$.jsx)(ye,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`ACTIVO`}),(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors text-ellipsis`,children:e.name}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 font-medium leading-relaxed line-clamp-1 h-4`,children:e.description||`Sin descripción adicional`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`CONFIG`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:e.is_default?`DEFAULT`:`CUSTOM`})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`PRECEDENCIA`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:t?`ALTA`:`NORMAL`})]})]})]}),n&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(De,{open:a,onOpenChange:o,children:(0,$.jsx)(Te,{className:`max-w-4xl border-white/10 !bg-[#09090b] p-0 overflow-hidden shadow-2xl`,children:p&&(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 relative z-10`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal hive-icon-wrap--internal-active`,children:(0,$.jsx)(R,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ee,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(Ce,{className:`hive-subtitle !mt-0`,children:`Sintonización de la capa moral y operativa del agente.`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-3 relative z-10`,children:!p.active&&(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>h(p.id),children:`ESTABLECER COMO ACTIVO`})})]}),(0,$.jsx)(`div`,{className:`p-6 space-y-4 border-b border-white/5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(H,{value:s.name,onChange:e=>c(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white font-bold`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(H,{value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white/60 text-xs italic`})]})]})}),(0,$.jsxs)(`div`,{className:`p-0 bg-[#09090b]`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-4`,children:(0,$.jsx)(Y,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(z,{ref:d,placeholder:`Define los lineamientos éticos del agente...`,value:s.content,onChange:e=>{c(t=>({...t,content:e.target.value})),f()},className:`hive-textarea w-full !bg-zinc-950/50 border-none focus-visible:ring-0 text-amber-50/90 font-mono text-xs leading-relaxed min-h-[400px] p-8 resize-none placeholder:text-white/10 overflow-hidden`})]}),(0,$.jsxs)(`div`,{className:`p-6 bg-white/[0.02] border-t border-white/5 flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`IDENTIFICADOR`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:p.id})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO DE CAPA`}),(0,$.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:p.active?`SISTEMA ACTIVO`:`PENDIENTE`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>o(!1),children:`CANCELAR`}),(0,$.jsx)(`button`,{onClick:async()=>{if(p){u(!0),G.show(`Guardando lineamientos éticos...`);try{let e=await W(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),q.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),G.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var Qe={filesystem:`Sistema de archivos`,web:`Web`,codebridge:`Code Bridge`,cron:`Cron`,projects:`Proyectos`,cli:`CLI`,agents:`Agentes`,canvas:`Canvas`,voice:`Voz`};function $e(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=ve(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let p=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),q.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{q.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},h=async()=>{if(s){f(!0),G.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),q.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{q.fire({icon:`error`,title:`Error al guardar cambios`})}finally{f(!1),G.hide()}}};if(t&&e.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(D,{className:`h-8 w-8 animate-spin text-violet-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-[0.2em] text-zinc-500`,children:`Cargando herramientas...`})]});let g=e.filter(e=>a===`all`?!0:e.category===a);return(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg !text-white/80`,children:`Herramientas`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/40 border-white/10`,children:[g.length,` DISPONIBLES`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona las capacidades externas y el arsenal tecnológico de tu agente.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(le,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Arsenal Operativo`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5`,children:[`all`,`filesystem`,`web`,`cron`,`codebridge`,`cli`,`agents`,`canvas`,`a2ui`,`voice`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(e),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${a===e?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e===`all`?`TODAS`:Qe[e]||e},e))}),g.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-violet-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(ne,{className:`h-8 w-8 text-zinc-700 group-hover:text-violet-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`Sin herramientas en esta categoría.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:g.map(e=>{let t=e.active,n=e.core;return(0,$.jsxs)(`div`,{onClick:()=>c({...e}),className:`hive-card group cursor-pointer transition-all duration-500 ${t?`hive-card--active`:`hive-card--disabled`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsxs)(`div`,{className:`hive-icon-wrap--internal ${t?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:[e.category===`filesystem`&&(0,$.jsx)(Be,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(Be,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(I,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(B,{className:`h-6 w-6`}),e.category===`codebridge`&&(0,$.jsx)(B,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(Ke,{className:`h-6 w-6`}),e.category===`projects`&&(0,$.jsx)(B,{className:`h-6 w-6`}),e.category===`canvas`&&(0,$.jsx)(B,{className:`h-6 w-6`}),e.category===`voice`&&(0,$.jsx)(Ke,{className:`h-6 w-6`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`NATIVO`}),(0,$.jsx)(m,{checked:t,onCheckedChange:()=>p(e.id,!t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-blue-500 scale-75 origin-right`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors`,children:e.name}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-[11px] h-8 line-clamp-2`,children:e.description||`Sin descripción disponible`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`TIPO`}),(0,$.jsx)(`span`,{className:`hive-stat__value truncate max-w-[80px]`,children:e.category})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,$.jsx)(`span`,{className:t?`hive-status-label--active`:`hive-status-label--disabled`,children:t?`ACTIVE`:`STANDBY`})]})]})]})]}),t&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(De,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(Te,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(we,{children:[(0,$.jsxs)(Ee,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg bg-violet-500/10 text-violet-400`,children:(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(Ce,{className:`text-[10px] text-zinc-500 font-medium`,children:`Modifica los parámetros y la descripción de la herramienta seleccionada.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(H,{value:s?.name||``,onChange:e=>c({...s,name:e.target.value}),className:`h-9 text-sm bg-white/5 border-white/10 focus:border-violet-500/50`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(z,{value:s?.description||``,onChange:e=>c({...s,description:e.target.value}),className:`text-sm min-h-[80px] resize-none bg-white/5 border-white/10 focus:border-violet-500/50 font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 border-t border-white/5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] bg-zinc-900 border border-white/5 text-zinc-500 px-2 py-0.5 rounded truncate max-w-[180px]`,children:s?.id}),(0,$.jsx)(X,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(xe,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(U,{size:`sm`,onClick:h,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function et({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(je,{onClick:t,className:`group relative overflow-hidden transition-all hover:border-cyan-500/50 hover:shadow-lg hover:shadow-cyan-500/5 cursor-pointer border-white/5 bg-zinc-950/50 backdrop-blur-sm ${i?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${r?`pointer-events-none opacity-50`:``}`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-1 h-full transition-colors ${i?`bg-cyan-500`:`bg-zinc-800`}`}),(0,$.jsxs)(Oe,{className:`pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg transition-colors ${i?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:a?(0,$.jsx)(y,{className:`h-5 w-5`}):(0,$.jsx)(S,{className:`h-5 w-5`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:i?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-500 uppercase tracking-wider`,children:`LIVE`})]}):(0,$.jsx)(X,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Z,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(Ae,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(ke,{className:`pt-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:e.transport})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[e.tools?.length||e.tools_count||0,` expuestas`]})]})]}),e.builtin&&(0,$.jsx)(X,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`})]}),i&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`})]})}function tt({serverId:e,serverName:t,tools:n=[]}){let[r,i]=(0,Q.useState)(``),a=n.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase()));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,$.jsx)(I,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(H,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:a.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:r?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):a.map(e=>(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900/50 border border-white/5 hover:border-cyan-500/20 transition-all group`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded bg-cyan-500/5 text-cyan-400 group-hover:bg-cyan-500/10 transition-colors`,children:(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`h5`,{className:`text-[11px] font-bold text-zinc-200 group-hover:text-cyan-400 transition-colors`,children:e.name})]}),e.inputSchema&&(0,$.jsx)(X,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-600 h-4`,children:`JSON Schema`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px] text-zinc-500 leading-relaxed line-clamp-2`,children:e.description})]},e.name))}),(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[(0,$.jsx)(T,{className:`h-3 w-3 text-cyan-500`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-cyan-200/50`,children:[`Estas herramientas son gestionadas directamente por `,(0,$.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:t}),`.`]})]})]})}function nt(e){return e?e[`x-api-key`]?{authType:`api-key`,authToken:e[`x-api-key`]}:e.Authorization?.startsWith(`Bearer `)?{authType:`bearer`,authToken:e.Authorization.replace(`Bearer `,``)}:Object.keys(e).length>0?{authType:`custom`,authToken:``}:{authType:`none`,authToken:``}:{authType:`none`,authToken:``}}function rt({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=me(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[u,m]=(0,Q.useState)(e.command||``),[h,g]=(0,Q.useState)(e.args?.join(` `)||``),[_,v]=(0,Q.useState)(e.url||``),[y,b]=(0,Q.useState)(()=>nt(e.headers).authType),[x,C]=(0,Q.useState)(()=>nt(e.headers).authToken),[w,T]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!0),[L,R]=(0,Q.useState)(!1),[z,ee]=(0,Q.useState)(`config`),[ne,re]=(0,Q.useState)(e.status),[ie,ae]=(0,Q.useState)(e.active),V=ne===`connected`||ie===1||ie===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{I(!0);try{let n=await W(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),m(n.command||``),g(Array.isArray(n.args)?n.args.join(` `):``),v(n.url||``);let r=nt(n.headers);b(r.authType),C(r.authToken),T(n.headers?JSON.stringify(n.headers,null,2):``),re(n.status||e.status),ae(+!!n.enabled)}catch{}finally{t||I(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(De,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(Te,{className:`sm:max-w-[500px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl p-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent`}),(0,$.jsxs)(we,{className:`p-6 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg ${V?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Ke,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Ee,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,V&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(Ce,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>R(!0),disabled:j||L,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors`,title:`Eliminar Servidor`,children:(0,$.jsx)(te,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mt-6 border-b border-white/5`,children:[(0,$.jsxs)(`button`,{onClick:()=>ee(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${z===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,z===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>ee(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${z===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,z===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),L&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-bold`,children:e.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>R(!1),disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(U,{size:`sm`,onClick:async()=>{M(!0);try{await W(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{M(!1),R(!1)}},disabled:j,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:j?(0,$.jsx)(D,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:z===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[F&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(D,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(d,{value:o,onValueChange:s,children:[(0,$.jsx)(p,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(l,{})}),(0,$.jsxs)(f,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(c,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(B,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(c,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),o===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(H,{value:u,onChange:e=>m(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(H,{value:h,onChange:e=>g(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(H,{value:_,onChange:e=>v(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(d,{value:y,onValueChange:b,children:[(0,$.jsx)(p,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(l,{})}),(0,$.jsxs)(f,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(c,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(c,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(c,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(c,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{type:`password`,placeholder:`sk-...`,value:x,onChange:e=>C(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(O,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:w,onChange:e=>T(e.target.value),placeholder:`{ "x-custom-auth": "secret" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900 border border-white/5 flex items-center justify-between mt-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-full ${V?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Ge,{className:`h-3.5 w-3.5 ${V?`animate-pulse`:``}`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-zinc-300 uppercase tracking-tight`,children:`Estado del Nodo`}),(0,$.jsx)(`span`,{className:`text-[9px] font-mono ${V?`text-green-500`:`text-zinc-500`}`,children:V?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(U,{size:`sm`,variant:V?`outline`:`default`,onClick:async()=>{P(!0),G.show(V?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!V),ae(+!V),re(V?`disconnected`:`connected`),q.fire({icon:`success`,title:V?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{q.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{P(!1),G.hide()}},disabled:N,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${V?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:N?(0,$.jsx)(D,{className:`h-3 w-3 animate-spin`}):V?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(tt,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(xe,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(U,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),z===`config`&&(0,$.jsx)(U,{onClick:async()=>{A(!0),G.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!u){q.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=u;let e=h.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else if(o===`sse`){if(!_){q.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=_;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{q.fire({icon:`error`,title:`JSON de Headers inválido`});return}Object.keys(e).length>0&&(t.headers=e)}await n(e.id,t),await a(),q.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{A(!1),G.hide()}},disabled:k,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:k?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function it(){let{fetchMCPServers:e}=me(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,u]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`stdio`),[g,_]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`none`),[x,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[D,k]=(0,Q.useState)(!1);return(0,$.jsxs)(De,{open:t,onOpenChange:n,children:[(0,$.jsx)(Se,{asChild:!0,children:(0,$.jsxs)(U,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(P,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(Te,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(we,{children:[(0,$.jsxs)(Ee,{className:`flex items-center gap-2 text-white`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-md bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(oe,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(Ce,{className:`text-zinc-400`,children:`Conecta una nueva fuente de herramientas para tus agentes mediante el protocolo MCP.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(H,{id:`mcp-name`,placeholder:`github-tools`,value:r,onChange:e=>i(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(d,{value:m,onValueChange:h,children:[(0,$.jsx)(p,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(l,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(f,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(c,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(B,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(c,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),m===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(H,{id:`mcp-cmd`,placeholder:`npx`,value:a,onChange:e=>o(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(H,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>u(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(H,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(d,{value:y,onValueChange:b,children:[(0,$.jsx)(p,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(l,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(f,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(c,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(S,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(c,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(c,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(c,{value:`google-api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(E,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(c,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Re,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(y===`api-key`||y===`google-api-key`||y===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(Y,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:y===`api-key`?`API Key`:y===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:x,onChange:e=>C(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(O,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),y===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(Y,{htmlFor:`mcp-headers`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{id:`mcp-headers`,placeholder:`{ "x-custom-auth": "secret" }`,rows:3,value:w,onChange:e=>{let t=e.target.value;T(t);try{t.trim()&&JSON.parse(t.trim()),e.target.style.borderColor=``}catch{t.trim()?e.target.style.borderColor=`rgba(239, 68, 68, 0.5)`:e.target.style.borderColor=``}},className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-3`,children:[(0,$.jsx)(v,{className:`h-5 w-5 text-cyan-500 shrink-0`}),(0,$.jsx)(`div`,{className:`text-[10px] text-cyan-200/70`,children:`El servidor se inicializará y validará inmediatamente después de ser añadido.`})]})]}),(0,$.jsxs)(xe,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(U,{onClick:async()=>{if(!r){q.fire({icon:`error`,title:`El nombre es obligatorio`});return}k(!0);try{let t={transport:m};if(m===`stdio`){if(!a){q.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),k(!1);return}t.command=a;let e=s.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else{if(!g){q.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),k(!1);return}t.url=g;let e={};if(y===`api-key`&&x)e[`x-api-key`]=x;else if(y===`google-api-key`&&x)e[`X-Goog-Api-Key`]=x;else if(y===`bearer`&&x)e.Authorization=`Bearer ${x}`;else if(y===`custom`&&w.trim())try{e=JSON.parse(w.trim())}catch{K.fire(`Error`,`JSON de Headers inválido`,`error`),k(!1);return}Object.keys(e).length>0&&(t.headers=e)}await W(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),q.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),u(``),_(``),b(`none`),C(``),T(``),n(!1),await e()}catch{}finally{k(!1)}},disabled:D,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:D?`Conectando...`:`Conectar Servidor`})]})]})]})}function at(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=me(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{r()},[r]);let c=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),l=e=>{a({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(oe,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-white uppercase tracking-wider`,children:`MCP Ecosystem`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:`Model Context Protocol Servers`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(I,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-zinc-500 group-focus-within:text-cyan-400 transition-colors`}),(0,$.jsx)(H,{placeholder:`Buscar servidor...`,value:o,onChange:e=>s(e.target.value),className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),(0,$.jsx)(it,{})]})]}),c.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-cyan-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(ne,{className:`h-8 w-8 text-zinc-700 group-hover:text-cyan-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`No se detectan servidores MCP configurados.`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-600 mt-1`,children:`Añade uno para expandir las capacidades de tus agentes.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:c.map(e=>(0,$.jsx)(et,{server:e,isConnected:e.status===`connected`||e.active===1,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(rt,{server:i,onClose:()=>a(null)})]})}var ot=()=>(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`absolute inset-0 w-full h-full pointer-events-none`,xmlns:`http://www.w3.org/2000/svg`,style:{opacity:.05,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(`defs`,{children:(0,$.jsx)(`pattern`,{id:`hc-profile`,x:`0`,y:`0`,width:`30`,height:`34`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`polygon`,{points:`15,2 28,9.5 28,24.5 15,32 2,24.5 2,9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})})}),(0,$.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#hc-profile)`})]}),st=({initials:e,size:t=`lg`})=>{let n=t===`sm`?`w-14 h-14`:`w-20 h-20`,r=t===`sm`?`text-lg`:`text-2xl`;return(0,$.jsxs)(`div`,{className:`relative ${n} flex-shrink-0`,children:[(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white font-black ${r} tracking-tight select-none`,style:{clipPath:`polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)`,background:`linear-gradient(135deg, hsl(var(--hive-amber)) 0%, hsl(var(--hive-orange)) 100%)`,boxShadow:`0 0 24px hsl(var(--hive-amber) / 0.4)`},children:e}),(0,$.jsx)(`span`,{className:`absolute bottom-0.5 right-1 h-3.5 w-3.5 rounded-full border-2 animate-pulse`,style:{background:`hsl(var(--hive-green))`,borderColor:`hsl(var(--background))`,boxShadow:`0 0 8px hsl(var(--hive-green) / 0.6)`}})]})},ct=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(C,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:{color:`hsl(var(--hive-amber) / 0.85)`},children:e})]}),lt=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),ut=({icon:e,label:t,colorVar:n})=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:{background:`hsl(var(${n}) / 0.08)`,borderColor:`hsl(var(${n}) / 0.2)`,color:`hsl(var(${n}))`},children:[(0,$.jsx)(e,{className:`h-2.5 w-2.5 flex-shrink-0`}),t]}),dt=({label:e,icon:t,editing:n,children:r})=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:{color:n?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`},children:[(0,$.jsx)(t,{className:`h-3 w-3 opacity-60`}),e]}),r]}),ft=[{value:`auto`,label:`Auto — detectar mejor canal`},{value:`webchat`,label:`Web Chat`},{value:`telegram`,label:`Telegram`},{value:`discord`,label:`Discord`}];function pt(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function mt(){let{fetchUser:e,saveUser:t,isLoading:n}=ge(),[r,i]=(0,Q.useState)(!1),[o,s]=(0,Q.useState)({name:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[m,h]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};s(t),h(t)}).catch(console.error)},[e]);let g=(e,t)=>s(n=>({...n,[e]:t})),_=()=>{m&&s(m),i(!1)},v=async()=>{G.show(`Guardando perfil...`);try{let e=await t(o);h(o),q.fire({icon:`success`,title:e}),i(!1)}catch(e){q.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{G.hide()}},y=ft.find(e=>e.value===o.preferred_cron_channel)?.label??`auto`,b=pt(o.name);return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border flex flex-col lg:flex-row`,style:{background:`hsl(var(--hive-surface)/0.7)`,borderColor:`hsl(var(--hive-border-base))`,backdropFilter:`blur(16px)`,boxShadow:`0 0 60px hsl(var(--hive-amber)/0.05)`},children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden flex-shrink-0 lg:w-[40%] lg:flex-col lg:items-center lg:text-center
2
+
3
+ /* mobile: horizontal compact row */
4
+ flex flex-row items-center gap-4 p-4
5
+ /* tablet: slightly more padding */
6
+ sm:p-5
7
+ /* desktop: vertical centered column */
8
+ lg:flex-col lg:items-center lg:text-center lg:gap-4 lg:p-6`,style:{background:`hsl(220 15% 10% / 0.85)`},children:[(0,$.jsx)(ot,{}),(0,$.jsx)(`div`,{className:`absolute -top-16 -left-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-amber)/0.1)`}}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px lg:hidden`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.3),transparent)`}}),(0,$.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 w-px hidden lg:block`,style:{background:`linear-gradient(to bottom,transparent,hsl(var(--hive-amber)/0.25),transparent)`}}),(0,$.jsxs)(`div`,{className:`relative w-full hidden lg:flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full animate-pulse`,style:{background:`hsl(var(--hive-amber))`,boxShadow:`0 0 6px hsl(var(--hive-amber))`}}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-[0.25em] uppercase`,style:{color:`hsl(var(--hive-amber)/0.7)`},children:`HIVE OS`})]}),(0,$.jsx)(`span`,{className:`text-[8px] font-mono uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`v1.0`})]}),(0,$.jsxs)(`div`,{className:`relative flex-shrink-0 lg:mx-auto`,children:[(0,$.jsx)(`div`,{className:`block lg:hidden`,children:(0,$.jsx)(st,{initials:b,size:`sm`})}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)(st,{initials:b,size:`lg`})})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 lg:flex-none lg:w-full space-y-1 lg:text-center`,children:[(0,$.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-white leading-tight`,children:o.name||(0,$.jsx)(`span`,{className:`text-sm font-normal italic`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Sin nombre`})}),o.occupation&&(0,$.jsx)(`p`,{className:`text-xs`,style:{color:`hsl(var(--hive-text-muted))`},children:o.occupation}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 lg:justify-center pt-0.5`,children:[o.language&&(0,$.jsx)(ut,{icon:S,label:o.language,colorVar:`--hive-blue`}),o.timezone&&(0,$.jsx)(ut,{icon:ce,label:o.timezone,colorVar:`--hive-blue`}),o.preferred_cron_channel!==`auto`&&(0,$.jsx)(ut,{icon:a,label:o.preferred_cron_channel,colorVar:`--hive-purple`})]})]}),(0,$.jsx)(`div`,{className:`relative hidden sm:grid sm:grid-cols-2 lg:grid-cols-1 lg:w-full gap-x-4 gap-y-2
9
+ sm:mt-0 lg:mt-auto lg:pt-4 lg:border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[{icon:_e,label:`Agente`,value:`Activo`,colorVar:`--hive-green`},{icon:S,label:`Idioma`,value:o.language||`—`,colorVar:`--hive-blue`},{icon:ce,label:`Zona`,value:o.timezone||`—`,colorVar:`--hive-blue`},{icon:re,label:`Canal`,value:y.split(`—`)[0].trim(),colorVar:`--hive-amber`}].map(({icon:e,label:t,value:n,colorVar:r})=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(e,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(${r}))`}}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:t})]}),(0,$.jsx)(`span`,{className:`text-[10px] font-semibold truncate max-w-[90px] text-right`,style:{color:`hsl(var(--hive-surface-foreground)/0.7)`},children:n})]},t))})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -bottom-16 -right-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-blue)/0.07)`}}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 sm:px-5 pt-4 pb-3 border-b`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg border flex-shrink-0`,style:{background:`hsl(var(--hive-amber)/0.1)`,borderColor:`hsl(var(--hive-amber)/0.2)`,color:`hsl(var(--hive-amber))`},children:(0,$.jsx)(ae,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-black uppercase tracking-[0.18em] truncate`,style:{color:`hsl(var(--hive-amber))`},children:`Perfil de usuario`}),(0,$.jsx)(`p`,{className:`text-[9px] mt-0.5 hidden sm:block`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Configuración personal y preferencias del agente`})]})]}),(0,$.jsxs)(`button`,{onClick:()=>r?_():i(!0),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-semibold transition-all duration-200 flex-shrink-0 ml-2`,style:r?{background:`hsl(var(--hive-red-dark)/0.15)`,border:`1px solid hsl(var(--hive-red)/0.3)`,color:`hsl(var(--hive-red))`}:{background:`hsl(var(--hive-glass))`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[r?(0,$.jsx)(V,{className:`h-3 w-3`}):(0,$.jsx)(j,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:r?`Cancelar`:`Editar`})]})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-y-auto p-4 sm:p-5 space-y-4`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(ct,{children:`Identidad`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(dt,{label:`Nombre completo`,icon:ae,editing:r,children:(0,$.jsx)(H,{placeholder:`John Doe`,value:o.name,disabled:!r,onChange:e=>g(`name`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(dt,{label:`Ocupación`,icon:Fe,editing:r,children:(0,$.jsx)(H,{placeholder:`AI Engineer`,value:o.occupation,disabled:!r,onChange:e=>g(`occupation`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})})]})]}),(0,$.jsx)(lt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(ct,{children:`Localización`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(dt,{label:`Idioma`,icon:S,editing:r,children:(0,$.jsx)(H,{placeholder:`Spanish`,value:o.language,disabled:!r,onChange:e=>g(`language`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(dt,{label:`Zona horaria`,icon:ce,editing:r,children:(0,$.jsx)(H,{placeholder:`America/Bogota`,value:o.timezone,disabled:!r,onChange:e=>g(`timezone`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})})]})]}),(0,$.jsx)(lt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(ct,{children:`Notificaciones`}),(0,$.jsx)(dt,{label:`Canal para Cron Jobs`,icon:a,editing:r,children:(0,$.jsxs)(d,{value:o.preferred_cron_channel,onValueChange:e=>g(`preferred_cron_channel`,e),disabled:!r,children:[(0,$.jsx)(p,{className:`hive-select-trigger h-9 text-sm rounded-lg disabled:opacity-50`,children:(0,$.jsx)(l,{})}),(0,$.jsx)(f,{className:`hive-select-content`,children:ft.map(e=>(0,$.jsx)(c,{value:e.value,className:`hive-select-item text-sm`,children:e.label},e.value))})]})})]}),(0,$.jsx)(lt,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(ct,{children:`Contexto para el agente`}),(0,$.jsx)(z,{placeholder:`Describe tu perfil, preferencias de trabajo, estilo de comunicación...`,value:o.notes,disabled:!r,onChange:e=>g(`notes`,e.target.value),className:`hive-textarea text-sm rounded-lg min-h-[80px] disabled:opacity-50 disabled:cursor-default`})]})]}),(0,$.jsx)(`div`,{className:`px-4 sm:px-5 py-3 flex items-center justify-end gap-2 border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:_,className:`flex items-center gap-1.5 h-9 px-3 sm:px-4 rounded-lg text-xs font-semibold transition-all`,style:{background:`transparent`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancelar`})]}),(0,$.jsxs)(`button`,{onClick:v,disabled:n,className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold text-white transition-all disabled:opacity-60`,style:{background:`hsl(var(--hive-blue-dark))`,boxShadow:`var(--shadow-btn-primary)`},children:[n?(0,$.jsx)(D,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(u,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Guardar cambios`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Guardar`})]})]}):(0,$.jsxs)(`button`,{onClick:()=>i(!0),className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold transition-all`,style:{background:`hsl(var(--hive-amber)/0.12)`,border:`1px solid hsl(var(--hive-amber)/0.3)`,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(j,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Editar perfil`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Editar`})]})}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-blue)/0.3),transparent)`}})]})]})}var ht=e=>{let t=e.toLowerCase();return t.includes(`code`)||t.includes(`program`)?(0,$.jsx)(Le,{className:`h-5 w-5`}):t.includes(`research`)||t.includes(`investiga`)?(0,$.jsx)(I,{className:`h-5 w-5`}):t.includes(`write`)||t.includes(`escrib`)?(0,$.jsx)(fe,{className:`h-5 w-5`}):t.includes(`data`)||t.includes(`anal`)||t.includes(`estad`)?(0,$.jsx)(Ie,{className:`h-5 w-5`}):t.includes(`trans`)||t.includes(`traduc`)?(0,$.jsx)(He,{className:`h-5 w-5`}):t.includes(`web`)||t.includes(`glob`)||t.includes(`scrape`)?(0,$.jsx)(S,{className:`h-5 w-5`}):t.includes(`tool`)||t.includes(`herram`)?(0,$.jsx)(le,{className:`h-5 w-5`}):t.includes(`cpu`)||t.includes(`proc`)?(0,$.jsx)(y,{className:`h-5 w-5`}):(0,$.jsx)(re,{className:`h-5 w-5`})},gt=e=>e?e.split(`,`).filter(Boolean).length:0,_t=e=>e?e.split(`,`).filter(Boolean).length:0;function vt({skill:e,onClick:t,className:n}){let r=!!e.active,i=gt(e.tools),a=_t(e.triggers);return(0,$.jsxs)(`div`,{onClick:t,className:`hive-card group cursor-pointer transition-all duration-300 hover:scale-[1.02] ${r?`hive-card--active`:`hive-card--disabled`} ${n}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest text-white/30 bg-white/5 border border-white/5 rounded-full px-2.5 py-1`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),e.category||`GENERAL`]}),r&&(0,$.jsxs)(`span`,{className:`flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute h-2 w-2 rounded-full bg-blue-400 opacity-40`}),(0,$.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-500`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`shrink-0 h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-300 ${r?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_12px_hsl(217_91%_60%/0.2)]`:`bg-white/5 border-white/10 text-white/25`}`,children:ht(e.name)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-black uppercase tracking-tight line-clamp-1 transition-colors ${r?`text-white group-hover:text-blue-400`:`text-white/40`}`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed line-clamp-2 mt-1`,children:e.body?.substring(0,90)||`Sin descripción`})]})]}),(0,$.jsxs)(`div`,{className:`pt-3 border-t border-white/5 flex items-center gap-2 flex-wrap`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-amber-400/70 bg-amber-500/5 border border-amber-500/10 rounded px-2 py-0.5`,children:[`v`,e.version??1]}),i>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-cyan-400/70 bg-cyan-500/5 border border-cyan-500/10 rounded px-2 py-0.5`,children:[i,` TOOLS`]}),a>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-purple-400/70 bg-purple-500/5 border border-purple-500/10 rounded px-2 py-0.5`,children:[a,` TRIGGERS`]}),(0,$.jsx)(`div`,{className:`ml-auto opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(ee,{className:`h-3 w-3 text-blue-400`})})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${r?`bg-blue-500`:`bg-white/5`}`})]})}var yt={name:``,body:``,tools:``,triggers:``,category:``,version:1,active:!0};function bt(){let{skills:e,isLoading:t,fetchSkills:n,toggleSkill:r,updateSkill:i}=he(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`TODOS`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(yt),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),E=(0,Q.useRef)(null),O=()=>{let e=E.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{(l||d)&&setTimeout(O,0)},[l,d,p.body]),(0,Q.useEffect)(()=>{n()},[n]);let k=(0,Q.useMemo)(()=>{let t=new Set(e.map(e=>(e.category||`GENERAL`).toUpperCase()));return[`TODOS`,...Array.from(t).sort()]},[e]),A=(0,Q.useMemo)(()=>{let t=a.toLowerCase();return e.filter(e=>{let n=!t||e.name.toLowerCase().includes(t)||(e.category||``).toLowerCase().includes(t)||(e.body||``).toLowerCase().includes(t),r=s===`TODOS`||(e.category||`GENERAL`).toUpperCase()===s;return n&&r})},[e,a,s]),j=e.filter(e=>e.active).length,M=async(e,t)=>{if(!g){_(e);try{await r(e,t),await n(),q.fire({icon:`success`,title:t?`Skill habilitado`:`Skill deshabilitado`})}catch{q.fire({icon:`error`,title:`Error al cambiar estado del skill`})}finally{_(null)}}},N=async()=>{if(l){w(!0);try{await W(`/api/skills/${l.id}`,{method:`DELETE`,showError:!0}),q.fire({icon:`success`,title:`Skill eliminado`}),n(),u(null)}catch{q.fire({icon:`error`,title:`Error al eliminar skill`})}finally{w(!1),S(!1)}}},F=e=>{f(!1),S(!1),u(e),h({name:e.name,body:e.body||``,tools:e.tools||``,triggers:e.triggers||``,category:e.category||``,version:Number(e.version)||1,active:!!e.active})},L=()=>{u(null),S(!1),h(yt),f(!0)},R=()=>{u(null),f(!1),S(!1)},B=async()=>{b(!0),G.show(d?`Creando skill...`:`Guardando skill...`);try{d?(await W(`/api/skills`,{method:`POST`,body:p,showError:!0}),q.fire({icon:`success`,title:`Skill creado correctamente`})):l&&(await i(l.id,p),q.fire({icon:`success`,title:`Skill actualizado correctamente`})),n(),R()}catch{q.fire({icon:`error`,title:d?`Error al crear skill`:`Error al actualizar skill`})}finally{b(!1),G.hide()}},ne=!!l||d;return t&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(D,{className:`h-10 w-10 animate-spin text-primary/40`}),(0,$.jsx)(ee,{className:`h-4 w-4 text-primary absolute -top-1 -right-1 animate-pulse`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground animate-pulse`,children:`Cargando habilidades del sistema...`})]}):(0,$.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,$.jsx)(de,{className:`h-4 w-4 text-blue-400`}),(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Habilidades del Sistema`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-blue-500/10 text-blue-400 border-blue-500/20`,children:[j,` ACTIVAS`]}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/30 border-white/5`,children:[e.length,` TOTAL`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona los módulos cognitivos que otorgan capacidades autónomas a tus agentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(I,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-white/20`}),(0,$.jsx)(H,{value:a,onChange:e=>o(e.target.value),placeholder:`Buscar habilidad...`,className:`pl-8 pr-8 h-8 w-52 bg-white/5 border-white/10 text-white text-xs placeholder:text-white/20 focus-visible:ring-blue-500/30`}),a&&(0,$.jsx)(`button`,{onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/60 transition-colors`,children:(0,$.jsx)(V,{className:`h-3 w-3`})})]}),(0,$.jsxs)(U,{onClick:L,className:`h-8 bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest uppercase px-4 shadow-btn-primary`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5 mr-1.5`}),`Nueva Habilidad`]})]})]}),e.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none`,children:k.map(t=>{let n=t===`TODOS`?e.length:e.filter(e=>(e.category||`GENERAL`).toUpperCase()===t).length,r=s===t;return(0,$.jsxs)(`button`,{onClick:()=>c(t),className:`shrink-0 inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full border transition-all duration-200 ${r?`bg-blue-500/15 border-blue-500/40 text-blue-400 shadow-[0_0_8px_hsl(217_91%_60%/0.15)]`:`bg-white/5 border-white/10 text-white/30 hover:text-white/60 hover:border-white/20`}`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),t,(0,$.jsxs)(`span`,{className:`text-[8px] ${r?`text-blue-300/70`:`text-white/20`}`,children:[`(`,n,`)`]})]},t)})}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(de,{className:`h-8 w-8 text-white/20`})}),(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`No se detectan habilidades`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed text-center`,children:`El repositorio de habilidades está vacío. Crea una nueva habilidad o visita el Marketplace.`}),(0,$.jsxs)(U,{onClick:L,className:`hive-btn hive-btn--primary px-8`,children:[(0,$.jsx)(P,{className:`h-4 w-4 mr-2`}),`Crear Habilidad`]})]})}):A.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 space-y-3 text-center`,children:[(0,$.jsx)(I,{className:`h-8 w-8 text-white/10`}),(0,$.jsx)(`p`,{className:`text-sm font-bold text-white/30 uppercase tracking-widest`,children:`Sin resultados`}),(0,$.jsxs)(`p`,{className:`text-xs text-white/20`,children:[`No hay habilidades que coincidan con “`,a,`”`,s!==`TODOS`&&` en la categoría ${s}`,`.`]}),(0,$.jsx)(`button`,{onClick:()=>{o(``),c(`TODOS`)},className:`text-[10px] font-black uppercase tracking-widest text-blue-400/60 hover:text-blue-400 transition-colors mt-2`,children:`Limpiar filtros`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-5`,children:A.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(vt,{skill:e,onClick:()=>F(e)}),(0,$.jsxs)(`div`,{className:`absolute top-5 right-5 z-20 pointer-events-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${e.active?`text-blue-400`:`text-white/20`}`,children:e.active?`ON`:`OFF`}),(0,$.jsx)(m,{checked:!!e.active,disabled:g===e.id,onClick:e=>e.stopPropagation(),onCheckedChange:t=>M(e.id,t),className:`scale-75 data-[state=checked]:bg-blue-500`})]})]},e.id))}),(0,$.jsx)(De,{open:ne,onOpenChange:e=>{e||R()},children:(0,$.jsxs)(Te,{className:`max-w-3xl bg-zinc-950 border-white/10 text-white p-0 overflow-hidden shadow-2xl`,children:[(0,$.jsx)(`div`,{className:`p-6 border-b border-white/5 bg-white/[0.03]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg flex items-center justify-center border ${d?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/60`}`,children:d?(0,$.jsx)(P,{className:`h-5 w-5`}):(0,$.jsx)(y,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ee,{className:`text-sm font-black text-white uppercase tracking-tight`,children:d?`Nueva Habilidad`:`Propiedades del Nodo`}),(0,$.jsx)(Ce,{className:`text-[10px] text-white/30`,children:d?`Define las propiedades del nuevo módulo cognitivo.`:`Editor granular de capacidades cognitivas y herramientas vinculadas.`})]})]}),!d&&(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),disabled:C||x,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors shrink-0`,title:`Eliminar Skill`,children:(0,$.jsx)(te,{className:`h-4 w-4`})})]})}),x&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-black`,children:l?.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>S(!1),disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(U,{size:`sm`,onClick:N,disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:C?(0,$.jsx)(D,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsxs)(`div`,{className:`p-6 space-y-7 max-h-[65vh] overflow-y-auto custom-scrollbar`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Información General`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{htmlFor:`skill-name`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Nombre del Nodo`}),(0,$.jsx)(H,{id:`skill-name`,value:p.name,onChange:e=>h(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white font-medium`,placeholder:`Ej: canvas_dashboard`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(Y,{htmlFor:`skill-category`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Categoría Funcional`}),(0,$.jsx)(H,{id:`skill-category`,value:p.category,onChange:e=>h(t=>({...t,category:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/70`,placeholder:`Ej: visualización, análisis...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Capacidades y Activación`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-tools`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-cyan-400/60`,children:`Herramientas Vinculadas`}),` (CSV)`]}),(0,$.jsx)(H,{id:`skill-tools`,value:p.tools,onChange:e=>h(t=>({...t,tools:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-cyan-500/30 text-white/80 font-mono text-[11px]`,placeholder:`tool1, tool2, tool3...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-triggers`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-purple-400/60`,children:`Triggers`}),` de Activación (CSV)`]}),(0,$.jsx)(H,{id:`skill-triggers`,value:p.triggers,onChange:e=>h(t=>({...t,triggers:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-purple-500/30 text-white/80 font-mono text-[11px]`,placeholder:`mostrar panel, dashboard...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Cuerpo / Lógica del Nodo`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsx)(z,{ref:E,value:p.body,onChange:e=>{h(t=>({...t,body:e.target.value})),O()},className:`min-h-[140px] resize-none bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/80 text-sm overflow-hidden font-sans leading-relaxed p-4`,placeholder:`Instrucciones detalladas y lógica de ejecución del módulo cognitivo...`})]}),(0,$.jsxs)(`section`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 pt-4 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(Y,{htmlFor:`skill-version`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-amber-400/60`,children:`Versión`}),` del Skill`]}),(0,$.jsx)(H,{id:`skill-version`,type:`number`,step:`0.1`,min:`0.1`,value:p.version,onChange:e=>h(t=>({...t,version:Number(e.target.value)})),className:`bg-white/5 border-white/10 focus-visible:ring-amber-500/20 text-white w-32`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col justify-center space-y-2`,children:[(0,$.jsx)(Y,{className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Estado del Nodo`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 bg-white/5 p-3 rounded-xl border border-white/10 w-fit`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full transition-colors ${p.active?`bg-blue-500 shadow-[0_0_6px_hsl(217_91%_60%/0.8)] animate-pulse`:`bg-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${p.active?`text-white`:`text-white/30`}`,children:p.active?`OPERATIVO / ACTIVO`:`FUERA DE LÍNEA / INACTIVO`}),(0,$.jsx)(m,{checked:p.active,onCheckedChange:e=>h(t=>({...t,active:e})),className:`data-[state=checked]:bg-blue-500`})]})]})]})]}),(0,$.jsxs)(xe,{className:`p-5 bg-white/[0.02] flex items-center justify-between gap-3 border-t border-white/5 sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-black tracking-widest text-white/15 uppercase`,children:[(0,$.jsx)(T,{className:`h-3 w-3`}),d?`Nueva habilidad`:`ID: ${l?.id?.substring(0,8)}...`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(U,{variant:`ghost`,className:`text-[10px] font-black tracking-widest hover:bg-white/5 hover:text-white text-white/30 uppercase`,onClick:R,children:`Cancelar`}),(0,$.jsx)(U,{className:`bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest px-6 rounded-lg shadow-btn-primary uppercase`,onClick:B,disabled:v||!p.name.trim(),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(D,{className:`h-3 w-3 animate-spin mr-2`}),`PROCESANDO...`]}):d?`Crear Habilidad`:`Sincronizar Propiedades`})]})]})]})})]})}function xt(){let[e,t]=(0,Q.useState)(null),[n,r]=(0,Q.useState)(!0),[a,o]=(0,Q.useState)(!1),[s,u]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)({acceptGroups:!1,reconnectMaxAttempts:10,reconnectBaseDelayMs:5e3,dmPolicy:`allowlist`}),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),O=(0,Q.useRef)(null),k=(0,Q.useCallback)(async()=>{try{let e=(await W(`/api/channels`,{showError:!1}))?.channels?.filter(e=>e.type===`whatsapp`)||[];if(e.length>0){let n=e[0];w(n.id);let r=await W(`/api/channels/whatsapp/${n.id}/details`,{showError:!1}).catch(()=>null);r&&(t(r),b({acceptGroups:r.acceptGroups??!1,reconnectMaxAttempts:r.reconnectMaxAttempts??10,reconnectBaseDelayMs:5e3,dmPolicy:r.dmPolicy??`allowlist`}))}}catch(e){console.error(`Failed to fetch WhatsApp details:`,e)}finally{r(!1)}},[]);(0,Q.useEffect)(()=>(k(),()=>{O.current&&clearInterval(O.current)}),[k]);let j=async()=>{if(C){o(!0);try{await W(`/api/channels/${C}/reconnect`,{method:`POST`}),O.current=setInterval(k,3e3)}catch(e){console.error(`Failed to connect:`,e)}finally{o(!1)}}},N=async(e=!1)=>{if(C){u(!0);try{await W(`/api/channels/whatsapp/${C}/disconnect`,{method:`POST`,body:{clearSession:e}}),await k()}catch(e){console.error(`Failed to disconnect:`,e)}finally{u(!1)}}};return n?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(D,{className:`h-8 w-8 animate-spin text-blue-400`})}):C?(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(je,{className:`border-white/10 bg-white/5`,children:[(0,$.jsx)(Oe,{className:`pb-3 border-b border-white/5`,children:(0,$.jsxs)(Z,{className:`text-sm font-bold flex items-center gap-2`,children:[(0,$.jsx)(pe,{className:`h-4 w-4 text-emerald-400`}),`Estado de Conexión`]})}),(0,$.jsxs)(ke,{className:`pt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[e?.status===`connected`?(0,$.jsx)(M,{className:`h-5 w-5 text-green-400`}):(0,$.jsx)(A,{className:`h-5 w-5 text-red-400`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-white`,children:e?.status===`connected`&&e.phoneNumber?`+${e.phoneNumber}`:`Sin conexión`}),e?.waVersion&&(0,$.jsxs)(`p`,{className:`text-xs text-white/40`,children:[`WhatsApp Web v`,e.waVersion]})]})]}),(()=>{if(!e)return null;let t={connected:{color:`text-green-400`,bg:`bg-green-500/10`,icon:v},connecting:{color:`text-amber-400`,bg:`bg-amber-500/10`,icon:D},disconnected:{color:`text-red-400`,bg:`bg-red-500/10`,icon:A},qr:{color:`text-blue-400`,bg:`bg-blue-500/10`,icon:F},error:{color:`text-red-400`,bg:`bg-red-500/10`,icon:_}},{color:n,bg:r,icon:i}=t[e.status]||t.disconnected;return(0,$.jsxs)(X,{className:`${r} ${n} border-none`,children:[(0,$.jsx)(i,{className:`h-3 w-3 mr-1 ${e.status===`connecting`?`animate-spin`:``}`}),e.status===`connected`?`Conectado`:e.status===`connecting`?`Conectando...`:e.status===`qr`?`Esperando QR`:e.status===`error`?`Error`:`Desconectado`]})})()]}),e?.lastConnected&&(0,$.jsxs)(`div`,{className:`text-xs text-white/40`,children:[`Última conexión: `,new Date(e.lastConnected).toLocaleString(`es-CO`)]}),e?.error&&(0,$.jsxs)(Pe,{variant:`destructive`,className:`bg-red-500/10 border-red-500/30`,children:[(0,$.jsx)(_,{className:`h-4 w-4`}),(0,$.jsx)(Ne,{className:`text-red-200/80 text-xs`,children:e.error})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(U,{onClick:j,disabled:a,size:`sm`,className:`bg-emerald-600 hover:bg-emerald-700`,children:[a?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin mr-2`}):(0,$.jsx)(F,{className:`h-4 w-4 mr-2`}),e?.status===`connected`?`Reconectar`:`Conectar`]}),(0,$.jsxs)(U,{onClick:()=>N(!1),disabled:s||e?.status===`disconnected`,variant:`outline`,size:`sm`,children:[s?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin mr-2`}):(0,$.jsx)(Ue,{className:`h-4 w-4 mr-2`}),`Desconectar`]}),(0,$.jsxs)(U,{onClick:()=>N(!0),disabled:h,variant:`outline`,size:`sm`,className:`border-red-500/30 text-red-400 hover:bg-red-500/10`,children:[h?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin mr-2`}):(0,$.jsx)(Ue,{className:`h-4 w-4 mr-2`}),`Cerrar Sesión`]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-white/30`,children:[(0,$.jsx)(`strong`,{children:`Cerrar Sesión`}),` borra las credenciales y requiere escanear un nuevo QR.`]})]})]}),(0,$.jsxs)(je,{className:`border-white/10 bg-white/5`,children:[(0,$.jsx)(Oe,{className:`pb-3 border-b border-white/5`,children:(0,$.jsxs)(Z,{className:`text-sm font-bold flex items-center gap-2`,children:[(0,$.jsx)(L,{className:`h-4 w-4 text-blue-400`}),`Configuración`]})}),(0,$.jsxs)(ke,{className:`pt-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ye,{className:`h-4 w-4 text-white/50`}),(0,$.jsx)(Y,{className:`text-sm`,children:`Aceptar mensajes de grupo`})]}),(0,$.jsx)(m,{checked:y.acceptGroups,onCheckedChange:e=>b({...y,acceptGroups:e})})]}),(0,$.jsx)(`p`,{className:`text-xs text-white/40`,children:`Si está activado, el agente procesará mensajes de grupos donde estés. Por defecto, solo procesa mensajes directos (te escribes a ti mismo).`}),(0,$.jsxs)(`div`,{className:`space-y-2 pt-2`,children:[(0,$.jsx)(Y,{className:`text-sm`,children:`Política de Mensajes`}),(0,$.jsxs)(d,{value:y.dmPolicy,onValueChange:e=>b({...y,dmPolicy:e}),children:[(0,$.jsx)(p,{className:`bg-white/5 border-white/10`,children:(0,$.jsx)(l,{})}),(0,$.jsxs)(f,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(c,{value:`open`,children:`Abierto - Cualquier mensaje`}),(0,$.jsx)(c,{value:`pairing`,children:`Emparejamiento - Requiere vinculación`}),(0,$.jsx)(c,{value:`allowlist`,children:`Lista blanca - Solo usuarios permitidos`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-sm`,children:`Intentos de reconexión`}),(0,$.jsx)(H,{type:`number`,min:1,max:30,value:y.reconnectMaxAttempts,onChange:e=>b({...y,reconnectMaxAttempts:parseInt(e.target.value)||10}),className:`bg-white/5 border-white/10`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40`,children:`Intentos máximos antes de detenerse (default: 10)`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{className:`text-sm`,children:`Delay base de reconexión (ms)`}),(0,$.jsx)(H,{type:`number`,min:1e3,max:3e4,step:500,value:y.reconnectBaseDelayMs,onChange:e=>b({...y,reconnectBaseDelayMs:parseInt(e.target.value)||5e3}),className:`bg-white/5 border-white/10`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40`,children:`Espera inicial entre reintentos con backoff exponencial (default: 5000 ms)`})]}),(0,$.jsxs)(U,{onClick:async()=>{if(C){S(!0);try{await W(`/api/channels/whatsapp/${C}/config`,{method:`PUT`,body:y}),await k()}catch(e){console.error(`Failed to save config:`,e)}finally{S(!1)}}},disabled:x,className:`w-full`,children:[x?(0,$.jsx)(D,{className:`h-4 w-4 animate-spin mr-2`}):null,`Guardar Configuración`]})]})]}),(0,$.jsxs)(je,{className:`border-white/10 bg-white/5`,children:[(0,$.jsx)(Oe,{className:`pb-3 border-b border-white/5`,children:(0,$.jsxs)(Z,{className:`text-sm font-bold flex items-center gap-2`,children:[(0,$.jsx)(i,{className:`h-4 w-4 text-amber-400`}),`Guía de Uso`]})}),(0,$.jsxs)(ke,{className:`pt-4 space-y-4 text-sm text-white/70`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-medium text-white mb-1`,children:`¿Cómo funciona?`}),(0,$.jsxs)(`p`,{className:`text-xs text-white/50`,children:[`WhatsApp en Hive usa el protocolo WhatsApp Web (Baileys). Te conectas escaneando un QR con tu teléfono. Luego, `,(0,$.jsx)(`strong`,{children:`te escribes a ti mismo`}),` para chatear con el agente — es como si usaras un segundo WhatsApp vinculado.`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-medium text-white mb-1`,children:`Cómo vincular`}),(0,$.jsxs)(`ol`,{className:`text-xs text-white/50 list-decimal list-inside space-y-1`,children:[(0,$.jsx)(`li`,{children:`Haz clic en "Conectar" arriba`}),(0,$.jsx)(`li`,{children:`Escanea el QR con WhatsApp → Ajustes → Dispositivos vinculados`}),(0,$.jsx)(`li`,{children:`Espera a que diga "Conectado"`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-medium text-white mb-1`,children:`Si se desconecta`}),(0,$.jsx)(`p`,{className:`text-xs text-white/50`,children:`El sistema intentará reconectarse automáticamente. Si ves "Error" o "loggedOut", haz clic en "Reconectar" para generar un nuevo QR y escanea de nuevo.`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-medium text-white mb-1`,children:`Limitaciones`}),(0,$.jsx)(`p`,{className:`text-xs text-white/50`,children:`Este NO es la API oficial de WhatsApp (que cuesta $!). Usabaileys (protocolo no oficial) que puede rompersi WhatsApp cambia el protocolo. Es para uso personal.`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`font-medium text-white mb-1`,children:`Voz`}),(0,$.jsx)(`p`,{className:`text-xs text-white/50`,children:`Activa voz en la configuración del canal en la página de Canales. Necesitas configurar un provider STT/TTS en Ajustes → Voz.`})]})]})]})]}):(0,$.jsx)(`div`,{className:`hive-card border-white/10`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-12`,children:[(0,$.jsx)(pe,{className:`h-12 w-12 text-white/20 mb-4`}),(0,$.jsx)(`h3`,{className:`text-lg font-bold text-white mb-2`,children:`WhatsApp no configurado`}),(0,$.jsx)(`p`,{className:`text-sm text-white/40 text-center max-w-md`,children:`Ve a la página de Canales para conectar tu cuenta de WhatsApp.`}),(0,$.jsx)(U,{asChild:!0,className:`mt-4`,children:(0,$.jsx)(`a`,{href:`/channels`,children:`Ir a Canales`})})]})})}var St=be((e,t)=>({notes:[],scheduledTasks:[],taskHistory:{},cronChannels:[],cronRecommended:`webchat`,cronUserPreference:`auto`,isLoading:!1,error:null,fetchNotes:async()=>{e({isLoading:!0,error:null});try{e({notes:(await W(`/api/notes`)).notes,isLoading:!1})}catch(t){e({error:t.message,isLoading:!1})}},fetchScheduledTasks:async t=>{e({isLoading:!0,error:null});try{e({scheduledTasks:(await W(t?`/api/cron?status=${t}`:`/api/cron`)).tasks??[],isLoading:!1})}catch(t){e({error:t.message,isLoading:!1,scheduledTasks:[]})}},pauseTask:async t=>{try{await W(`/api/cron/${t}/pause`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`paused`}:e)}))}catch(t){e({error:t.message})}},resumeTask:async t=>{try{await W(`/api/cron/${t}/resume`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch(t){e({error:t.message})}},deleteTask:async t=>{try{await W(`/api/cron/${t}`,{method:`DELETE`}),e(e=>({scheduledTasks:e.scheduledTasks.filter(e=>e.id!==t)}))}catch(t){e({error:t.message})}},triggerTask:async t=>{try{await W(`/api/cron/${t}/trigger`,{method:`POST`})}catch(t){e({error:t.message})}},fetchTaskHistory:async(t,n=10)=>{try{let r=await W(`/api/cron/${t}/history?limit=${n}`);e(e=>({taskHistory:{...e.taskHistory,[t]:r.history??[]}}))}catch(t){e({error:t.message})}},fetchCronChannels:async()=>{try{let t=await W(`/api/cron/channels`),n=[];Array.isArray(t.channels)&&(n=t.channels.map(e=>typeof e==`string`?{id:e,type:e,active:!0,recommended:e===`webchat`||e===`telegram`}:e)),e({cronChannels:n,cronRecommended:`webchat`,cronUserPreference:`auto`})}catch{}},saveCronChannelPreference:async t=>{try{await W(`/api/user/settings`,{method:`PATCH`,body:{preferred_cron_channel:t}}),e({cronUserPreference:t})}catch(t){e({error:t.message})}}})),Ct=()=>{let{notes:e,isLoading:t,fetchNotes:n}=St();return(0,Q.useEffect)(()=>{n()},[n]),(0,$.jsxs)(je,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden group border border-white/10`,children:[(0,$.jsx)(Oe,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(se,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Z,{className:`text-xl font-bold tracking-tight`,children:`Notas`}),(0,$.jsx)(Ae,{children:`Scratchpad del agente`})]})]}),t&&(0,$.jsx)(D,{className:`w-4 h-4 animate-spin text-muted-foreground`})]})}),(0,$.jsx)(ke,{children:(0,$.jsx)(Me,{className:`h-[350px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[250px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(se,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No hay notas guardadas`}),(0,$.jsx)(`p`,{className:`text-[10px] opacity-70`,children:`El agente guardará notas con save_note`})]}):e.map(e=>(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-300 relative overflow-hidden`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm mb-1.5 line-clamp-1`,children:e.key}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3 leading-relaxed`,children:e.value}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(X,{variant:`secondary`,className:`text-[10px] px-2 py-0.5 bg-primary/10 text-primary border-none font-medium font-mono truncate max-w-[120px]`,children:e.thread_id.slice(-8)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:new Date(e.updated_at*1e3).toLocaleDateString()})]})]},e.id))})})})]})};function wt(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}function Tt({status:e}){let t={active:{label:`Activa`,className:`bg-green-500/10 text-green-400 border-green-500/20`},paused:{label:`Pausada`,className:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`},completed:{label:`Completada`,className:`bg-blue-500/10 text-blue-400 border-blue-500/20`},failed:{label:`Fallida`,className:`bg-red-500/10 text-red-400 border-red-500/20`},cancelled:{label:`Cancelada`,className:`bg-muted/30 text-muted-foreground border-white/10`}},{label:n,className:r}=t[e]??t.cancelled;return(0,$.jsx)(`span`,{className:`inline-flex items-center text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${r}`,children:n})}function Et({type:e}){let t=e===`recurring`;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${t?`bg-violet-500/10 text-violet-400 border-violet-500/20`:`bg-teal-500/10 text-teal-400 border-teal-500/20`}`,children:[t?(0,$.jsx)(F,{className:`w-2.5 h-2.5`}):(0,$.jsx)(s,{className:`w-2.5 h-2.5`}),t?`Recurrente`:`Una vez`]})}function Dt({channel:e}){return!e||e===`system`?(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:`System`}):e===`webchat`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-blue-500/10 text-blue-400 border border-blue-500/20`,children:[(0,$.jsx)(We,{className:`w-2.5 h-2.5`}),`Web`]}):e===`telegram`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-sky-500/10 text-sky-400 border border-sky-500/20`,children:[(0,$.jsx)(o,{className:`w-2.5 h-2.5`}),`Telegram`]}):(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:e})}function Ot({status:e}){return(0,$.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${{running:`bg-blue-400 animate-pulse`,success:`bg-green-400`,failed:`bg-red-400`,timeout:`bg-amber-400`}[e]??`bg-muted-foreground`}`})}function kt(e,t){let n=e===`telegram`?`Telegram`:e===`webchat`?`Web Chat`:e;return e===t?`${n} (recomendado)`:n}function At({taskId:e,history:t}){return t?t.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Sin ejecuciones registradas.`}):(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(Ot,{status:e.status}),(0,$.jsx)(`span`,{className:`font-mono`,children:wt(e.started_at)}),e.duration_ms!=null&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[e.duration_ms,`ms`]}),e.error_message&&(0,$.jsx)(`span`,{className:`text-red-400 truncate max-w-[160px]`,children:e.error_message})]},e.id))}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Cargando historial…`})}function jt({task:e,onPause:t,onResume:n,onDelete:i,onTrigger:a,onLoadHistory:o,history:c}){let[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),p=e.status===`active`,m=e.status===`active`||e.status===`paused`;function v(){!l&&!c&&o(e.id),u(e=>!e)}function y(){d?i(e.id):(f(!0),setTimeout(()=>f(!1),3e3))}return(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm truncate`,children:e.name}),e.description&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.description})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:(0,$.jsx)(Tt,{status:e.status})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap mb-2`,children:[(0,$.jsx)(Et,{type:e.task_type}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-primary font-bold uppercase tracking-wider bg-primary/5 px-2 py-0.5 rounded-full`,children:[(0,$.jsx)(s,{className:`w-3 h-3`}),e.task_type===`recurring`?e.cron_expression??`—`:e.fire_at?wt(e.fire_at):`—`]}),(0,$.jsx)(Dt,{channel:e.channel})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(r,{className:`w-3 h-3`}),e.run_count,` runs`]}),e.error_count>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,$.jsx)(_,{className:`w-3 h-3`}),e.error_count,` errores`]}),e.timezone&&e.timezone!==`UTC`&&(0,$.jsx)(`span`,{className:`font-mono`,children:e.timezone})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-3`,children:[e.last_run_at&&(0,$.jsxs)(`span`,{children:[`Último: `,wt(e.last_run_at)]}),e.next_run_at&&e.status===`active`&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[`Próximo: `,wt(e.next_run_at)]})]}),e.last_error&&(0,$.jsx)(`div`,{className:`mb-2 text-[10px] text-red-400 bg-red-500/5 border border-red-500/20 rounded-lg px-2 py-1 truncate`,children:e.last_error}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[m&&(p?(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-yellow-500/10 hover:text-yellow-400 hover:border-yellow-500/20`,onClick:()=>t(e.id),children:[(0,$.jsx)(k,{className:`w-3 h-3 mr-1`}),`Pausar`]}):(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-green-500/10 hover:text-green-400 hover:border-green-500/20`,onClick:()=>n(e.id),children:[(0,$.jsx)(N,{className:`w-3 h-3 mr-1`}),`Reanudar`]})),p&&(0,$.jsxs)(U,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-primary/10 hover:text-primary hover:border-primary/20`,onClick:()=>a(e.id),title:`Ejecutar ahora (sin afectar el schedule)`,children:[(0,$.jsx)(re,{className:`w-3 h-3 mr-1`}),`Ejecutar`]}),(0,$.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 text-muted-foreground hover:text-foreground`,onClick:v,children:[(0,$.jsx)(w,{className:`w-3 h-3 mr-1`}),`Historial`,l?(0,$.jsx)(g,{className:`w-3 h-3 ml-1`}):(0,$.jsx)(h,{className:`w-3 h-3 ml-1`})]}),(0,$.jsxs)(U,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 ml-auto ${d?`text-red-400 bg-red-500/10 border border-red-500/20`:`text-muted-foreground hover:text-red-400`}`,onClick:y,title:d?`Confirmar eliminación`:`Eliminar tarea`,children:[(0,$.jsx)(te,{className:`w-3 h-3 mr-1`}),d?`Confirmar`:`Eliminar`]})]}),l&&(0,$.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/5`,children:(0,$.jsx)(At,{taskId:e.id,history:c})})]})}var Mt=()=>{let{scheduledTasks:e,taskHistory:t,cronChannels:n,cronRecommended:r,cronUserPreference:i,isLoading:a,fetchScheduledTasks:o,fetchCronChannels:s,pauseTask:u,resumeTask:m,deleteTask:h,triggerTask:g,fetchTaskHistory:_,saveCronChannelPreference:v}=St(),[y,b]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{o(),s()},[o,s]);let x=y===`all`?e:e.filter(e=>e.status===y),S=(n??[]).filter(e=>e.active),C=x.filter(e=>!e.name.startsWith(`_hive_`));return(0,$.jsxs)(je,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden border border-white/10`,children:[(0,$.jsx)(Oe,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(ce,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Z,{className:`text-xl font-bold tracking-tight`,children:`Tareas Programadas`}),(0,$.jsx)(Ae,{children:`Scheduler basado en Croner`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,$.jsx)(D,{className:`w-4 h-4 animate-spin text-muted-foreground`}),(0,$.jsxs)(d,{value:y,onValueChange:b,children:[(0,$.jsx)(p,{className:`h-7 text-[10px] w-[110px] border-white/10 bg-card/40`,children:(0,$.jsx)(l,{})}),(0,$.jsxs)(f,{children:[(0,$.jsx)(c,{value:`all`,className:`text-xs`,children:`Todas`}),(0,$.jsx)(c,{value:`active`,className:`text-xs`,children:`Activas`}),(0,$.jsx)(c,{value:`paused`,className:`text-xs`,children:`Pausadas`}),(0,$.jsx)(c,{value:`completed`,className:`text-xs`,children:`Completadas`}),(0,$.jsx)(c,{value:`failed`,className:`text-xs`,children:`Fallidas`})]})]}),S.length>1&&(0,$.jsxs)(d,{value:i,onValueChange:v,children:[(0,$.jsx)(p,{className:`h-7 text-[10px] w-[130px] border-white/10 bg-card/40`,children:(0,$.jsx)(l,{placeholder:`Canal`})}),(0,$.jsxs)(f,{children:[(0,$.jsx)(c,{value:`auto`,className:`text-xs`,children:`Auto`}),S.map(e=>(0,$.jsx)(c,{value:e.id,className:`text-xs`,children:kt(e.id,r)},e.id))]})]}),(0,$.jsx)(U,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,onClick:()=>o(y===`all`?void 0:y),disabled:a,title:`Refrescar`,children:(0,$.jsx)(F,{className:`w-3.5 h-3.5`})})]})]})}),(0,$.jsx)(ke,{children:(0,$.jsx)(Me,{className:`h-[420px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:C.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[280px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(ce,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Sin tareas programadas`}),(0,$.jsxs)(`p`,{className:`text-[10px] opacity-70`,children:[`Crea tareas desde el chat o con `,(0,$.jsx)(`code`,{className:`font-mono`,children:`hive cron add`})]})]}):C.map(e=>(0,$.jsx)(jt,{task:e,onPause:u,onResume:m,onDelete:h,onTrigger:g,onLoadHistory:_,history:t[e.id]},e.id))})})})]})};function Nt(){let[e,t]=(0,Q.useState)(!1),[n,r]=(0,Q.useState)(``),[i,a]=(0,Q.useState)(!0),[o,s]=(0,Q.useState)(`status`),[c,l]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{z(),ee()},[]);async function z(){a(!0);try{let e=await fetch(`/api/auth/status`).then(e=>e.json());t(e.hasCredentials),e.email&&r(e.email)}catch{}finally{a(!1)}}async function ee(){try{l((await W(`/api/auth/recovery-key`)).recoveryKey)}catch{}}async function B(e){if(e.preventDefault(),g!==v){K.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(g.length<8){K.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}T(!0);try{await W(`/api/auth/setup-credentials`,{method:`POST`,body:{email:p,password:g}}),K.fire({icon:`success`,title:`Protección activada`,text:`La próxima vez que accedas necesitarás tu email y contraseña.`,timer:3e3,showConfirmButton:!1,toast:!0,position:`top-end`}),h(``),_(``),y(``),s(`status`),await z()}catch{}finally{T(!1)}}async function te(){if((await K.fire({title:`¿Desactivar protección?`,text:`Cualquiera con acceso a la URL podrá usar Hive sin contraseña.`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, desactivar`,cancelButtonText:`Cancelar`})).isConfirmed)try{await W(`/api/auth/disable`,{method:`POST`}),K.fire({icon:`success`,title:`Protección desactivada`,timer:2e3,showConfirmButton:!1,toast:!0,position:`top-end`}),t(!1),r(``),s(`status`)}catch{}}async function ne(e){if(e.preventDefault(),k!==j){K.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(k.length<8){K.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}R(!0);try{await W(`/api/auth/change-password`,{method:`POST`,body:{currentPassword:E,newPassword:k}}),K.fire({icon:`success`,title:`Contraseña actualizada`,timer:2e3,showConfirmButton:!1,toast:!0,position:`top-end`}),O(``),A(``),M(``),s(`status`)}catch{}finally{R(!1)}}function re(){c&&(navigator.clipboard.writeText(c),f(!0),setTimeout(()=>f(!1),2e3))}return i?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,children:[(0,$.jsx)(D,{className:`h-4 w-4 animate-spin`}),` Cargando...`]}):(0,$.jsxs)(`div`,{className:`space-y-8 max-w-xl`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e?(0,$.jsx)(qe,{className:`h-5 w-5 text-green-500`}):(0,$.jsx)(Je,{className:`h-5 w-5 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`font-medium`,children:`Protección con contraseña`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e?`Activa — ${n||`credenciales configuradas`}`:`Desactivada — acceso libre sin contraseña`})]}),(0,$.jsx)(m,{checked:e,onCheckedChange:e=>{e?s(`enable`):te()}})]}),o===`enable`&&!e&&(0,$.jsxs)(`form`,{onSubmit:B,className:`space-y-4 border rounded-lg p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:`Configurar credenciales`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`sec-email`,children:`Email`}),(0,$.jsx)(H,{id:`sec-email`,type:`email`,placeholder:`tu@email.com`,value:p,onChange:e=>h(e.target.value),required:!0,disabled:w})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`sec-pwd`,children:`Contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{id:`sec-pwd`,type:S?`text`:`password`,placeholder:`Mínimo 8 caracteres`,value:g,onChange:e=>_(e.target.value),required:!0,disabled:w,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>C(e=>!e),tabIndex:-1,children:S?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`sec-confirm`,children:`Confirmar contraseña`}),(0,$.jsx)(H,{id:`sec-confirm`,type:S?`text`:`password`,placeholder:`Repite la contraseña`,value:v,onChange:e=>y(e.target.value),required:!0,disabled:w})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(U,{type:`submit`,disabled:w,children:[w&&(0,$.jsx)(D,{className:`mr-2 h-4 w-4 animate-spin`}),`Activar protección`]}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>s(`status`),disabled:w,children:`Cancelar`})]})]}),e&&o===`status`&&(0,$.jsx)(`div`,{className:`flex gap-2`,children:(0,$.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>s(`change-password`),children:`Cambiar contraseña`})}),o===`change-password`&&e&&(0,$.jsxs)(`form`,{onSubmit:ne,className:`space-y-4 border rounded-lg p-4`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:`Cambiar contraseña`}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`current-pwd`,children:`Contraseña actual`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{id:`current-pwd`,type:N?`text`:`password`,placeholder:`••••••••`,value:E,onChange:e=>O(e.target.value),required:!0,disabled:L,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>P(e=>!e),tabIndex:-1,children:N?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`new-pwd`,children:`Nueva contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(H,{id:`new-pwd`,type:F?`text`:`password`,placeholder:`Mínimo 8 caracteres`,value:k,onChange:e=>A(e.target.value),required:!0,disabled:L,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>I(e=>!e),tabIndex:-1,children:F?(0,$.jsx)(b,{className:`h-4 w-4`}):(0,$.jsx)(x,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(Y,{htmlFor:`confirm-new`,children:`Confirmar nueva contraseña`}),(0,$.jsx)(H,{id:`confirm-new`,type:F?`text`:`password`,placeholder:`••••••••`,value:j,onChange:e=>M(e.target.value),required:!0,disabled:L})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(U,{type:`submit`,disabled:L,children:[L&&(0,$.jsx)(D,{className:`mr-2 h-4 w-4 animate-spin`}),`Actualizar contraseña`]}),(0,$.jsx)(U,{type:`button`,variant:`ghost`,onClick:()=>s(`status`),disabled:L,children:`Cancelar`})]})]}),c&&(0,$.jsxs)(`div`,{className:`space-y-2 border rounded-lg p-4 bg-muted/30`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium`,children:`Recovery Key`}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Úsalo para recuperar el acceso si olvidas tu contraseña`})]})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`flex-1 text-xs bg-muted rounded px-3 py-2 font-mono break-all`,children:c}),(0,$.jsx)(U,{variant:`ghost`,size:`icon`,onClick:re,className:`shrink-0`,children:d?(0,$.jsx)(u,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(ze,{className:`h-4 w-4`})})]})]})]})}function Pt({panel:e}){switch(e){case`etica`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ze,{})});case`herramientas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)($e,{})});case`mcp`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(at,{})});case`skills`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(bt,{})});case`perfil`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(mt,{})});case`notas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ct,{})});case`cron-jobs`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Mt,{})});case`seguridad`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Nt,{})});case`whatsapp`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(xt,{})});default:return null}}var Ft=[`etica`,`herramientas`,`mcp`,`skills`,`perfil`,`notas`,`cron-jobs`,`seguridad`,`whatsapp`];function It({forcePanel:e}){let{panel:t}=ie(),{fetchSkills:n}=he(),{fetchTools:r}=ve(),{fetchMCPServers:i}=me();(0,Q.useEffect)(()=>{n(),r(),i()},[n,r,i]);let a=e||(Ft.includes(t)?t:`herramientas`),{title:o,subtitle:s,eyebrow:c}={etica:{eyebrow:`PROTOCOLOS DE CONDUCTA`,title:`Ética & Alineación`,subtitle:`Configura los límites morales y el comportamiento base de tus agentes.`},herramientas:{eyebrow:`CAPACIDADES DINÁMICAS`,title:`Gestión de Herramientas`,subtitle:`Habilita y configura las funciones que tus agentes pueden ejecutar.`},mcp:{eyebrow:`CONECTIVIDAD EXTERNA`,title:`Servidores MCP`,subtitle:`Conecta Hive con fuentes de datos externas y herramientas de terceros.`},skills:{eyebrow:`HABILIDADES ESPECIALIZADAS`,title:`Galería de Skills`,subtitle:`Nodos cognitivos preconfigurados para tareas específicas de alto nivel.`},perfil:{eyebrow:`IDENTIDAD DEL OPERADOR`,title:`Perfil de Usuario`,subtitle:`Gestiona tu información personal y preferencias de la interfaz.`},notas:{eyebrow:`MEMORIA OPERATIVA`,title:`Notas del Sistema`,subtitle:`Registro de información persistente y recordatorios del enjambre.`},"cron-jobs":{eyebrow:`AUTOMATIZACIÓN TEMPORAL`,title:`Tareas Programadas`,subtitle:`Gestión de ejecuciones recurrentes y disparadores cron.`},seguridad:{eyebrow:`CONTROL DE ACCESO`,title:`Seguridad`,subtitle:`Protege tu instancia con email y contraseña. Esencial si despliegas Hive en un servidor público.`},whatsapp:{eyebrow:`CANAL DE MENSAJERÍA`,title:`WhatsApp`,subtitle:`Configura tu conexión de WhatsApp. Gestiona la sesión, opciones de grupo y reconexión.`}}[a];return(0,$.jsxs)(`div`,{className:`hive-page-container`,children:[(0,$.jsx)(`div`,{className:`hive-page-header`,children:(0,$.jsxs)(`div`,{className:`relative z-10`,children:[(0,$.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:c})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[o.split(` & `)[0],` `,o.includes(` & `)&&(0,$.jsxs)(`span`,{className:`hive-title-page__accent`,children:[`& `,o.split(` & `)[1]]}),o.includes(` `)&&!o.includes(` & `)&&(0,$.jsxs)($.Fragment,{children:[o.split(` `)[0],` `,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:o.split(` `).slice(1).join(` `)})]}),!o.includes(` `)&&o]}),(0,$.jsx)(`p`,{className:`hive-subtitle`,children:s})]})}),(0,$.jsx)(`div`,{className:`animate-fade-in`,children:(0,$.jsx)(Pt,{panel:a})})]})}export{It as SettingsPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{a as r,c as i,n as a,r as o,s,t as c}from"./switch-CQf9jQKN.js";import{t as l}from"./circle-check-BhwUUu4Z.js";import{t as u}from"./circle-x-C55wB-DP.js";import{t as d}from"./hexagon-BGGuDxI7.js";import{t as f}from"./loader-circle-BaadtldT.js";import{t as p}from"./sparkles-Dnx_Tpre.js";import{t as ee}from"./volume-2-B8dkjcEZ.js";import{c as te}from"./vendor-router-4QM6Fwg6.js";import{B as m,N as h,P as g,S as _,f as v,g as ne}from"./index-B4lS14UW.js";import{t as y}from"./label-CplWBwSz.js";import{t as b}from"./badge-BY-VUaxL.js";import{a as x,n as S,o as C,r as w,t as T}from"./card-CE_kGxdL.js";import{t as E}from"./progress-CFpWXmru.js";import{n as D,t as O}from"./alert-Bgqky__w.js";import{a as re,i as ie,n as ae,r as oe,t as se}from"./accordion-_sozXeaB.js";var k=e(t(),1),A=n(),ce={gemini:`🔵`,anthropic:`🟠`,openai:`🟢`,groq:`🔴`,ollama:`🟣`,openrouter:`🟡`,deepseek:`🔷`,mistral:`🔸`,kimi:`🌙`},j={gemini:`https://aistudio.google.com/app/apikey`,anthropic:`https://console.anthropic.com/keys`,openai:`https://platform.openai.com/api-keys`,groq:`https://console.groq.com/keys`,openrouter:`https://openrouter.ai/keys`,deepseek:`https://platform.deepseek.com/api_keys`,mistral:`https://console.mistral.ai/api-keys`,kimi:`https://platform.moonshot.cn/console/api-keys`},M=[{id:`webchat`,name:`WebChat`,description:`Chat web integrado`,icon:`💬`,required:!0},{id:`telegram`,name:`Telegram`,description:`Bot de Telegram`,icon:`✈️`,required:!1},{id:`discord`,name:`Discord`,description:`Bot de Discord`,icon:`🎮`,required:!1},{id:`whatsapp`,name:`WhatsApp`,description:`Bot de WhatsApp`,icon:`📱`,required:!1},{id:`slack`,name:`Slack`,description:`Bot de Slack`,icon:`💼`,required:!1}],N=`hive_setup_wizard_data`;function le(){try{let e=sessionStorage.getItem(N);if(e){let t=JSON.parse(e);return{...F(),...t}}}catch(e){console.error(`Failed to load wizard data:`,e)}return null}function ue(e){try{sessionStorage.setItem(N,JSON.stringify(e))}catch(e){console.error(`Failed to save wizard data:`,e)}}function P(){try{sessionStorage.removeItem(N)}catch(e){console.error(`Failed to clear wizard data:`,e)}}function F(){return{userName:``,userLanguage:`es`,userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,userOccupation:``,userNotes:``,agentName:`Bee`,agentDescription:``,agentTone:`friendly`,provider:``,apiKey:``,model:``,apiKeyVerified:!1,channels:{webchat:{enabled:!0},telegram:{enabled:!1},discord:{enabled:!1},whatsapp:{enabled:!1},slack:{enabled:!1}},voiceEnabled:!1,sttProvider:`groq-whisper`,ttsProvider:`elevenlabs`,ttsVoice:``,ethicsRules:{},customRules:[]}}function I(){let e=te(),[t,n]=(0,k.useState)(1),[N,I]=(0,k.useState)(()=>le()||F()),[L,R]=(0,k.useState)(!1),[z,de]=(0,k.useState)(!1),{showLoader:B,hideLoader:V}=ne(),[H,U]=(0,k.useState)(`idle`),[W,G]=(0,k.useState)(null),[K,fe]=(0,k.useState)([]),[q,J]=(0,k.useState)(null),[Y,X]=(0,k.useState)(!1),[Z,pe]=(0,k.useState)([]);(0,k.useEffect)(()=>{fetch(`${_()}/api/setup/providers`).then(e=>e.json()).then(e=>{Array.isArray(e)&&fe(e)}).catch(()=>{}),fetch(`${_()}/api/setup/ethics`).then(e=>e.json()).then(e=>{Array.isArray(e)&&(pe(e),I(t=>Object.keys(t.ethicsRules).length===0?{...t,ethicsRules:Object.fromEntries(e.map(e=>[e.id,!0]))}:t))}).catch(()=>{})},[]),(0,k.useEffect)(()=>{ue(N)},[N]),(0,k.useEffect)(()=>{fetch(`${_()}/api/setup/status`).then(e=>e.json()).then(t=>{t.configured&&e(`/ui`)}).catch(()=>{})},[e]);let Q=e=>{G(null),I(t=>({...t,...e}))},me=()=>{switch(t){case 1:return N.userName.trim()?N.userName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre es obligatorio.`;case 2:return N.agentName.trim()?N.agentName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre del agente es obligatorio.`;case 3:return N.provider?N.provider!==`ollama`&&!N.apiKey?`Ingresa tu API key.`:N.provider!==`ollama`&&!N.apiKeyVerified?`Verifica tu API key antes de continuar.`:N.model?null:`Selecciona un modelo.`:`Selecciona un proveedor LLM.`;default:return null}},he=()=>{let e=me();if(e){G(e);return}G(null),t<8&&n(e=>e+1)},ge=()=>{t>1&&n(e=>e-1)},_e=()=>{confirm(`¿Estás seguro de que quieres reiniciar la configuración? Se perderá todo el progreso.`)&&(P(),I(F()),n(1))},ve=async()=>{if(!(!N.apiKey||!N.provider)){U(`verifying`);try{(await v(`/api/setup/verify-provider`,{method:`POST`,body:{provider:N.provider,apiKey:N.apiKey},showLoader:`Verificando conexión...`,showError:!1})).success?(U(`success`),Q({apiKeyVerified:!0})):(U(`error`),Q({apiKeyVerified:!1}))}catch{U(`error`),Q({apiKeyVerified:!1})}}},ye=async()=>{R(!0);try{let t=await v(`/api/setup/complete`,{method:`POST`,body:N,showLoader:`Finalizando configuración...`,showError:!0});if(t.success){let n=t.authToken;n&&localStorage.setItem(`hive-auth-token`,n),de(!0),P(),(async()=>{await new Promise(e=>setTimeout(e,1500)),B(`Iniciando a ${N.agentName}... esto toma unos segundos`);for(let t=0;t<40;t++){try{let t=await fetch(`${_()}/api/setup/status`);if(t.ok){let{configured:r}=await t.json();if(r){V(),e(n?`/?token=${n}`:`/`);return}}}catch{}await new Promise(e=>setTimeout(e,1e3))}V(),e(n?`/?token=${n}`:`/`)})()}}catch{}finally{R(!1)}},be=()=>{switch(t){case 1:return xe();case 2:return Se();case 3:return $();case 4:return Ce();case 5:return we();case 6:return Te();case 7:return Ee();case 8:return De();default:return null}},xe=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(d,{className:`w-24 h-24 text-amber-500`,fill:`currentColor`}),(0,A.jsx)(p,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2`})]})}),(0,A.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Bienvenido a Hive`}),(0,A.jsx)(`p`,{className:`text-muted-foreground max-w-md mx-auto`,children:`Hive es tu colmena de agentes IA. Local-first. Multi-canal. Open source. En los próximos minutos configurarás tu agente personal Bee.`})]}),(0,A.jsxs)(T,{children:[(0,A.jsxs)(x,{children:[(0,A.jsx)(C,{children:`Tu información`}),(0,A.jsx)(w,{children:`Comencemos con tus datos básicos`})]}),(0,A.jsxs)(S,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`userName`,children:`Tu nombre`}),(0,A.jsx)(h,{id:`userName`,placeholder:`¿Cómo te llamas?`,value:N.userName,onChange:e=>Q({userName:e.target.value})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`userLanguage`,children:`Idioma preferido`}),(0,A.jsxs)(a,{value:N.userLanguage,onValueChange:e=>Q({userLanguage:e}),children:[(0,A.jsx)(s,{children:(0,A.jsx)(i,{})}),(0,A.jsxs)(o,{children:[(0,A.jsx)(r,{value:`es`,children:`Español`}),(0,A.jsx)(r,{value:`en`,children:`English`}),(0,A.jsx)(r,{value:`pt`,children:`Português`}),(0,A.jsx)(r,{value:`fr`,children:`Français`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`userTimezone`,children:`Zona horaria`}),(0,A.jsx)(h,{id:`userTimezone`,value:N.userTimezone,onChange:e=>Q({userTimezone:e.target.value}),placeholder:`America/Bogota`}),(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Detectada automáticamente: `,Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(y,{htmlFor:`userOccupation`,children:[`Ocupación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(h,{id:`userOccupation`,value:N.userOccupation,onChange:e=>Q({userOccupation:e.target.value}),placeholder:`Ej: Desarrollador de software, diseñador, estudiante...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsxs)(y,{htmlFor:`userNotes`,children:[`Preferencias de comunicación `,(0,A.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,A.jsx)(`textarea`,{id:`userNotes`,className:`w-full min-h-[80px] p-3 border rounded-md bg-background resize-none text-sm`,value:N.userNotes,onChange:e=>Q({userNotes:e.target.value}),placeholder:`Ej: Prefiero respuestas cortas y directas. Usa ejemplos de código cuando expliques conceptos técnicos...`})]})]})]})]}),Se=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Tu agente`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Personaliza a Bee, tu agente personal`})]}),(0,A.jsxs)(T,{children:[(0,A.jsx)(x,{children:(0,A.jsx)(C,{children:`Identidad del agente`})}),(0,A.jsxs)(S,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`agentName`,children:`Nombre del agente`}),(0,A.jsx)(h,{id:`agentName`,value:N.agentName,onChange:e=>Q({agentName:e.target.value}),placeholder:`Bee`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`agentDescription`,children:`Descripción / Personalidad`}),(0,A.jsx)(`textarea`,{id:`agentDescription`,className:`w-full min-h-[100px] p-3 border rounded-md bg-background resize-none`,value:N.agentDescription,onChange:e=>Q({agentDescription:e.target.value}),placeholder:`Ej: Eres un asistente útil y amable. Respondes de forma concisa pero completa. Te especializas en ayudar con tareas de programación y productividad...`})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`agentTone`,children:`Tono de comunicación`}),(0,A.jsxs)(a,{value:N.agentTone,onValueChange:e=>Q({agentTone:e}),children:[(0,A.jsx)(s,{children:(0,A.jsx)(i,{placeholder:`Selecciona un tono`})}),(0,A.jsxs)(o,{children:[(0,A.jsx)(r,{value:`friendly`,children:`Amigable y cercano`}),(0,A.jsx)(r,{value:`professional`,children:`Profesional y formal`}),(0,A.jsx)(r,{value:`direct`,children:`Directo y conciso`}),(0,A.jsx)(r,{value:`casual`,children:`Casual y relajado`})]})]}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Define cómo se comunicará tu agente contigo`})]})]})]})]}),$=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Proveedor LLM`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Selecciona el cerebro de tu agente`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:K.map(e=>(0,A.jsx)(T,{className:m(`cursor-pointer transition-all hover:shadow-md`,N.provider===e.id&&`border-amber-500 ring-2 ring-amber-500`),onClick:()=>{Q({provider:e.id,model:``,apiKeyVerified:!1}),e.id===`ollama`&&J(null)},children:(0,A.jsxs)(S,{className:`flex items-center gap-4 p-4`,children:[(0,A.jsx)(`span`,{className:`text-3xl`,children:ce[e.id]??`🤖`}),(0,A.jsxs)(`div`,{className:`flex-1`,children:[(0,A.jsx)(`h3`,{className:`font-semibold`,children:e.name}),(0,A.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.models.length,` modelo`,e.models.length===1?``:`s`,` disponible`,e.models.length===1?``:`s`]})]}),N.provider===e.id&&(0,A.jsx)(l,{className:`w-5 h-5 text-amber-500`})]})},e.id))}),N.provider&&(()=>{let e=K.find(e=>e.id===N.provider);return(0,A.jsxs)(T,{className:`mt-4`,children:[(0,A.jsx)(x,{children:(0,A.jsxs)(C,{children:[`Configuración de `,e?.name]})}),(0,A.jsxs)(S,{className:`space-y-4`,children:[N.provider!==`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`apiKey`,children:`API Key`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsx)(h,{id:`apiKey`,type:`password`,value:N.apiKey,onChange:e=>Q({apiKey:e.target.value,apiKeyVerified:!1}),placeholder:`sk-...`,className:m(W?.includes(`API key`)&&!N.apiKey&&`border-red-500`)}),(0,A.jsx)(g,{variant:`outline`,onClick:ve,disabled:!N.apiKey||H===`verifying`,children:H===`verifying`?(0,A.jsx)(f,{className:`w-4 h-4 animate-spin`}):H===`success`?(0,A.jsx)(l,{className:`w-4 h-4 text-green-500`}):H===`error`?(0,A.jsx)(u,{className:`w-4 h-4 text-red-500`}):`Verificar`})]}),H===`success`&&(0,A.jsxs)(`p`,{className:`text-sm text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(l,{className:`w-4 h-4`}),` API key verificada correctamente`]}),H===`error`&&(0,A.jsxs)(`p`,{className:`text-sm text-red-600 flex items-center gap-1`,children:[(0,A.jsx)(u,{className:`w-4 h-4`}),` API key inválida o error de conexión`]}),j[N.provider]&&(0,A.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`¿No tienes tu API key?`,` `,(0,A.jsx)(`a`,{href:j[N.provider],target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtener aquí`})]})]}),N.provider===`ollama`&&(0,A.jsxs)(`div`,{className:`space-y-3`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,disabled:Y,onClick:()=>{J(null),X(!0),Q({model:``}),fetch(`${_()}/api/setup/ollama-models`).then(e=>e.json()).then(e=>{J(e.models??[]),X(!1)}).catch(()=>{J([]),X(!1)})},children:Y?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(f,{className:`w-3 h-3 animate-spin mr-1`}),`Detectando...`]}):`🔍 Detectar modelos`}),!Y&&q!==null&&(0,A.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q.length>0?`${q.length} modelo${q.length===1?``:`s`} encontrado${q.length===1?``:`s`}`:`Sin modelos — instala uno con ollama pull`})]}),q&&q.length>0&&(0,A.jsxs)(`div`,{className:`space-y-1`,children:[(0,A.jsx)(y,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(a,{value:N.model,onValueChange:e=>Q({model:e}),children:[(0,A.jsx)(s,{className:m(!N.model&&W?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(i,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(o,{children:q.map((e,t)=>(0,A.jsxs)(r,{value:e.id,children:[e.name,t===0?` (Recomendado)`:``]},e.id))})]})]}),!Y&&q!==null&&q.length===0&&(0,A.jsxs)(`p`,{className:`text-xs text-amber-600`,children:[`Asegúrate que Ollama esté corriendo (`,(0,A.jsx)(`code`,{children:`ollama serve`}),`) y tengas modelos (`,(0,A.jsx)(`code`,{children:`ollama pull llama3.2`}),`).`]})]}),N.provider!==`ollama`&&N.apiKeyVerified&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`model`,children:`Modelo`}),(0,A.jsxs)(a,{value:N.model,onValueChange:e=>Q({model:e}),children:[(0,A.jsx)(s,{className:m(!N.model&&W?.includes(`modelo`)&&`border-red-500`),children:(0,A.jsx)(i,{placeholder:`Selecciona un modelo`})}),(0,A.jsx)(o,{children:(e?.models??[]).map((e,t)=>(0,A.jsxs)(r,{value:e.id,children:[e.name||e.id,t===0?` (Recomendado)`:``]},e.id))})]})]})]})]})})()]}),Ce=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Canales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`¿Dónde quieres que Bee esté disponible?`})]}),(0,A.jsx)(`div`,{className:`grid gap-3`,children:M.map(e=>(0,A.jsx)(T,{className:m(`transition-all`,N.channels[e.id]?.enabled&&`border-amber-500`),children:(0,A.jsxs)(S,{className:`p-4`,children:[(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`span`,{className:`text-2xl`,children:e.icon}),(0,A.jsxs)(`div`,{children:[(0,A.jsxs)(`h3`,{className:`font-semibold flex items-center gap-2`,children:[e.name,e.required&&(0,A.jsx)(b,{variant:`secondary`,className:`text-xs`,children:`Requerido`})]}),(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]})]}),(0,A.jsx)(c,{checked:N.channels[e.id]?.enabled,onCheckedChange:t=>{e.required&&!t||Q({channels:{...N.channels,[e.id]:{enabled:t}}})},disabled:e.required})]}),!e.required&&N.channels[e.id]?.enabled&&(0,A.jsx)(se,{type:`single`,collapsible:!0,className:`mt-4`,children:(0,A.jsxs)(oe,{value:`config`,children:[(0,A.jsx)(ie,{children:`Configuración`}),(0,A.jsx)(ae,{children:(0,A.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[e.id===`telegram`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`telegramToken`,children:`Token del Bot`}),(0,A.jsx)(h,{id:`telegramToken`,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,value:N.channels.telegram.config?.botToken||``,onChange:e=>Q({channels:{...N.channels,telegram:{enabled:!0,config:{botToken:e.target.value}}}})}),(0,A.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,A.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtén tu token en BotFather`})})]})}),e.id===`discord`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`discordToken`,children:`Token del Bot`}),(0,A.jsx)(h,{id:`discordToken`,placeholder:`MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GJKlMn.OpQrStUvWxYz`,value:N.channels.discord.config?.botToken||``,onChange:e=>Q({channels:{...N.channels,discord:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`discordClientId`,children:`Client ID`}),(0,A.jsx)(h,{id:`discordClientId`,placeholder:`1234567890123456789`,value:N.channels.discord.config?.clientId||``,onChange:e=>Q({channels:{...N.channels,discord:{enabled:!0,config:{clientId:e.target.value}}}})})]})]}),e.id===`whatsapp`&&(0,A.jsx)(A.Fragment,{children:(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`whatsappToken`,children:`Token de la API`}),(0,A.jsx)(h,{id:`whatsappToken`,placeholder:`...`,value:N.channels.whatsapp.config?.apiToken||``,onChange:e=>Q({channels:{...N.channels,whatsapp:{enabled:!0,config:{apiToken:e.target.value}}}})})]})}),e.id===`slack`&&(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`slackToken`,children:`Bot Token`}),(0,A.jsx)(h,{id:`slackToken`,placeholder:`xoxb-...`,value:N.channels.slack.config?.botToken||``,onChange:e=>Q({channels:{...N.channels,slack:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`slackSigningSecret`,children:`Signing Secret`}),(0,A.jsx)(h,{id:`slackSigningSecret`,placeholder:`...`,value:N.channels.slack.config?.signingSecret||``,onChange:e=>Q({channels:{...N.channels,slack:{enabled:!0,config:{signingSecret:e.target.value}}}})})]})]})]})})]})})]})},e.id))})]}),we=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Voz (opcional)`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Permite que Bee hable y escuche`})]}),(0,A.jsxs)(T,{children:[(0,A.jsx)(x,{children:(0,A.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,A.jsx)(C,{children:`Activar voz`}),(0,A.jsx)(c,{checked:N.voiceEnabled,onCheckedChange:e=>Q({voiceEnabled:e})})]})}),(0,A.jsx)(S,{children:N.voiceEnabled?(0,A.jsxs)(`div`,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`sttProvider`,children:`Reconocimiento de voz (STT)`}),(0,A.jsxs)(a,{value:N.sttProvider,onValueChange:e=>Q({sttProvider:e}),children:[(0,A.jsx)(s,{children:(0,A.jsx)(i,{})}),(0,A.jsxs)(o,{children:[(0,A.jsx)(r,{value:`groq-whisper`,children:`Groq Whisper (Recomendado)`}),(0,A.jsx)(r,{value:`openai-whisper`,children:`OpenAI Whisper`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`ttsProvider`,children:`Síntesis de voz (TTS)`}),(0,A.jsxs)(a,{value:N.ttsProvider,onValueChange:e=>Q({ttsProvider:e}),children:[(0,A.jsx)(s,{children:(0,A.jsx)(i,{})}),(0,A.jsxs)(o,{children:[(0,A.jsx)(r,{value:`elevenlabs`,children:`ElevenLabs (Recomendado)`}),(0,A.jsx)(r,{value:`openai`,children:`OpenAI TTS`}),(0,A.jsx)(r,{value:`gemini`,children:`Google Gemini`})]})]})]}),(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{htmlFor:`ttsVoice`,children:`Voz`}),(0,A.jsxs)(`div`,{className:`flex gap-2`,children:[(0,A.jsxs)(a,{value:N.ttsVoice,onValueChange:e=>Q({ttsVoice:e}),children:[(0,A.jsx)(s,{children:(0,A.jsx)(i,{placeholder:`Selecciona una voz`})}),(0,A.jsxs)(o,{children:[(0,A.jsx)(r,{value:`Rachel`,children:`Rachel (ElevenLabs)`}),(0,A.jsx)(r,{value:`Adam`,children:`Adam (ElevenLabs)`}),(0,A.jsx)(r,{value:`Antoni`,children:`Antoni (ElevenLabs)`}),(0,A.jsx)(r,{value:`Elli`,children:`Elli (ElevenLabs)`}),(0,A.jsx)(r,{value:`Josh`,children:`Josh (ElevenLabs)`}),(0,A.jsx)(r,{value:`alloy`,children:`Alloy (OpenAI)`}),(0,A.jsx)(r,{value:`echo`,children:`Echo (OpenAI)`}),(0,A.jsx)(r,{value:`fable`,children:`Fable (OpenAI)`}),(0,A.jsx)(r,{value:`onyx`,children:`Onyx (OpenAI)`}),(0,A.jsx)(r,{value:`nova`,children:`Nova (OpenAI)`}),(0,A.jsx)(r,{value:`shimmer`,children:`Shimmer (OpenAI)`})]})]}),(0,A.jsx)(g,{variant:`outline`,size:`icon`,children:(0,A.jsx)(ee,{className:`w-4 h-4`})})]})]}),(0,A.jsx)(O,{children:(0,A.jsx)(D,{className:`text-sm`,children:N.provider===N.ttsProvider&&(0,A.jsxs)(`span`,{className:`text-green-600 flex items-center gap-1`,children:[(0,A.jsx)(l,{className:`w-4 h-4`}),` Ya tienes la API key configurada`]})})})]}):(0,A.jsx)(`p`,{className:`text-muted-foreground text-center py-4`,children:`Puedes activar la voz más tarde en la configuración`})})]})]}),Te=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Reglas éticas`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Define los límites de tu agente`})]}),(0,A.jsx)(O,{children:(0,A.jsxs)(D,{className:`text-sm`,children:[`Las reglas de categoría `,(0,A.jsx)(`strong`,{className:`text-red-500`,children:`NUNCA`}),` son las protecciones más importantes. Desactivarlas puede comprometer la seguridad.`]})}),(0,A.jsxs)(`div`,{className:`space-y-3`,children:[Z.map(e=>{let t=N.ethicsRules[e.id]!==!1;return(0,A.jsx)(T,{className:m(!t&&`opacity-60`),children:(0,A.jsx)(S,{className:`p-4`,children:(0,A.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,A.jsx)(re,{checked:t,onCheckedChange:t=>{e.isDefault&&!t&&!confirm(`¿Estás seguro de desactivar los lineamientos éticos por defecto?`)||Q({ethicsRules:{...N.ethicsRules,[e.id]:t}})}}),(0,A.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,A.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,A.jsx)(`h3`,{className:`font-medium`,children:e.name}),e.isDefault&&(0,A.jsx)(b,{className:`text-xs bg-blue-500/10 text-blue-500`,children:`Por defecto`})]}),e.description&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,A.jsxs)(`details`,{className:`mt-2`,children:[(0,A.jsx)(`summary`,{className:`text-xs text-muted-foreground cursor-pointer hover:text-foreground`,children:`Ver contenido`}),(0,A.jsx)(`pre`,{className:`text-xs mt-2 p-2 bg-muted rounded whitespace-pre-wrap font-mono`,children:e.content})]})]})]})})},e.id)}),Z.length===0&&(0,A.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`Cargando lineamientos éticos...`})]}),(0,A.jsx)(g,{variant:`outline`,className:`w-full`,onClick:()=>{let e=prompt(`Ingresa tu regla personalizada:`);if(e){let t=prompt(`Categoría (SIEMPRE/NUNCA/CONFIRMAR):`,`CONFIRMAR`);t&&[`SIEMPRE`,`NUNCA`,`CONFIRMAR`].includes(t.toUpperCase())&&Q({customRules:[...N.customRules,{text:e,category:t.toUpperCase()}]})}},children:`+ Añadir regla personalizada`}),N.customRules.length>0&&(0,A.jsxs)(`div`,{className:`space-y-2`,children:[(0,A.jsx)(y,{children:`Reglas personalizadas`}),N.customRules.map((e,t)=>(0,A.jsx)(T,{children:(0,A.jsxs)(S,{className:`p-4 flex items-center justify-between`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`p`,{className:`font-medium`,children:e.text}),(0,A.jsx)(b,{className:m(`text-xs mt-1`,e.category===`NUNCA`&&`text-red-500 bg-red-500/10`,e.category===`SIEMPRE`&&`text-green-500 bg-green-500/10`,e.category===`CONFIRMAR`&&`text-amber-500 bg-amber-500/10`),children:e.category})]}),(0,A.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>{Q({customRules:N.customRules.filter((e,n)=>n!==t)})},children:`Eliminar`})]})},t))]})]}),Ee=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Módulos opcionales`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Activa las funcionalidades adicionales que quieras usar`})]}),(0,A.jsx)(T,{className:`border-border`,children:(0,A.jsx)(S,{className:`p-8 text-center`,children:(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`No hay módulos opcionales disponibles en este momento.`})})})]}),De=()=>(0,A.jsxs)(`div`,{className:`space-y-6`,children:[(0,A.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,A.jsx)(`h2`,{className:`text-2xl font-bold`,children:`¡Todo listo!`}),(0,A.jsx)(`p`,{className:`text-muted-foreground`,children:`Revisa tu configuración antes de continuar`})]}),z?(0,A.jsx)(T,{className:`border-green-500 bg-green-500/10`,children:(0,A.jsxs)(S,{className:`p-8 text-center space-y-4`,children:[(0,A.jsx)(`div`,{className:`flex justify-center`,children:(0,A.jsxs)(`div`,{className:`relative`,children:[(0,A.jsx)(d,{className:`w-24 h-24 text-amber-500 animate-pulse`,fill:`currentColor`}),(0,A.jsx)(p,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2 animate-bounce`})]})}),(0,A.jsx)(`h3`,{className:`text-xl font-bold`,children:`¡Bienvenido a Hive!`}),(0,A.jsxs)(`p`,{className:`text-muted-foreground`,children:[N.agentName,` está listo para ayudarte.`]})]})}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(T,{children:[(0,A.jsxs)(x,{children:[(0,A.jsxs)(C,{className:`flex items-center gap-3`,children:[(0,A.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center bg-amber-500`,children:(0,A.jsx)(d,{className:`w-6 h-6 text-white`,fill:`currentColor`})}),N.agentName]}),(0,A.jsx)(w,{children:N.agentDescription||`Sin descripción`})]}),(0,A.jsxs)(S,{className:`space-y-4`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(y,{className:`text-sm text-muted-foreground`,children:`Proveedor`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[K.find(e=>e.id===N.provider)?.name||N.provider,` — `,N.model]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(y,{className:`text-sm text-muted-foreground`,children:`Canales activos`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.channels).filter(([e,t])=>t.enabled).map(([e])=>{let t=M.find(t=>t.id===e);return(0,A.jsxs)(b,{variant:`secondary`,children:[t?.icon,` `,t?.name]},e)})})]}),N.voiceEnabled&&(0,A.jsxs)(`div`,{children:[(0,A.jsx)(y,{className:`text-sm text-muted-foreground`,children:`Voz`}),(0,A.jsxs)(`p`,{className:`font-medium`,children:[`STT: `,N.sttProvider,` | TTS: `,N.ttsProvider,N.ttsVoice&&` (${N.ttsVoice})`]})]}),(0,A.jsxs)(`div`,{children:[(0,A.jsx)(y,{className:`text-sm text-muted-foreground`,children:`Reglas éticas activas`}),(0,A.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(N.ethicsRules).filter(([e,t])=>t).map(([e])=>(0,A.jsx)(b,{variant:`outline`,children:Z.find(t=>t.id===e)?.name??e},e))})]})]})]}),(0,A.jsx)(g,{className:`w-full h-14 text-lg bg-amber-500 hover:bg-amber-600`,onClick:ye,disabled:L,children:L?(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(f,{className:`w-5 h-5 mr-2 animate-spin`}),`Configurando...`]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(p,{className:`w-5 h-5 mr-2`}),`Iniciar a `,N.agentName]})})]})]});return(0,A.jsx)(`div`,{className:`min-h-screen bg-gradient-to-b from-background to-muted/20`,children:(0,A.jsxs)(`div`,{className:`container max-w-2xl mx-auto py-8 px-4`,children:[(0,A.jsxs)(`div`,{className:`mb-8 space-y-2`,children:[(0,A.jsxs)(`div`,{className:`flex justify-between text-sm text-muted-foreground`,children:[(0,A.jsxs)(`span`,{children:[`Paso `,t,` de 8`]}),(0,A.jsx)(`button`,{onClick:_e,className:`text-xs text-muted-foreground hover:text-foreground`,children:`Reiniciar configuración`})]}),(0,A.jsx)(E,{value:t/8*100,className:`h-2`})]}),be(),W&&(0,A.jsx)(O,{variant:`destructive`,className:`mt-6`,children:(0,A.jsx)(D,{children:W})}),!z&&(0,A.jsxs)(`div`,{className:`flex justify-between mt-6 pt-6 border-t`,children:[(0,A.jsx)(g,{variant:`outline`,onClick:ge,disabled:t===1,children:`← Anterior`}),t<8?(0,A.jsx)(g,{onClick:he,className:`bg-amber-500 hover:bg-amber-600`,children:`Siguiente →`}):(0,A.jsx)(`div`,{})]})]})})}export{I as default};
@@ -0,0 +1,16 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./circle-alert-Qf59MV-u.js";import{t as i}from"./file-text-CxAwK_Ze.js";import{t as a}from"./gauge-DYmZYnET.js";import{n as o,t as s}from"./square-PyIpnS-W.js";import{t as c}from"./pause-BsToEchU.js";import{t as l}from"./play-Rmf5Px63.js";import{t as u}from"./refresh-cw-Yf5FGfA5.js";import{C as d,_ as f,a as p,b as m,c as h,d as g,f as _,g as v,h as y,i as b,l as x,m as S,n as C,o as w,p as T,r as E,s as D,t as O,u as k,v as A,x as ee,y as te}from"./slider-B7ibzqE3.js";import{t as ne}from"./sparkles-Dnx_Tpre.js";import{t as re}from"./triangle-alert-vUtWDfZd.js";import{t as j}from"./volume-2-B8dkjcEZ.js";import{t as ie}from"./zap-BD57u2UH.js";import{H as ae,V as M,b as oe,d as se,et as N,f as ce,r as le,tt as P,w as ue,x as de}from"./index-B4lS14UW.js";var fe=P(`Paperclip`,[[`path`,{d:`m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48`,key:`1u3ebp`}]]),pe=P(`SendHorizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),me=P(`Volume1`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}]]),he=P(`VolumeX`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`line`,{x1:`22`,x2:`16`,y1:`9`,y2:`15`,key:`1ewh16`}],[`line`,{x1:`16`,x2:`22`,y1:`9`,y2:`15`,key:`5ykzw1`}]]),F=e(t(),1);function ge(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var I=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return I(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return I(t)(e)}}}},L=ue()(((e,t)=>(n,r,i)=>{let a={storage:ge(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return I(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p})(e=>({messages:[],isLoading:!1,currentSteps:[],streamingMessageId:null,connectionWarning:null,addMessage:t=>e(e=>({messages:[...e.messages,t]})),addMessages:t=>e(e=>({messages:[...e.messages,...t]})),updateMessage:(t,n)=>e(e=>({messages:e.messages.map(e=>e.id===t?{...e,...n}:e)})),setMessages:t=>e({messages:t}),clearMessages:()=>e({messages:[],currentSteps:[],streamingMessageId:null}),setLoading:t=>e({isLoading:t}),addStep:t=>e(e=>({currentSteps:[...e.currentSteps.slice(-4),t]})),clearSteps:()=>e({currentSteps:[]}),setStreamingMessageId:t=>e({streamingMessageId:t}),setConnectionWarning:t=>e({connectionWarning:t})}),{name:`hive-chat-storage`,partialize:e=>({messages:e.messages.slice(-15)})}));function _e(e,t){let n=L(e=>e.addMessage),r=L(e=>e.updateMessage),i=L(e=>e.setLoading);L(e=>e.addStep);let a=L(e=>e.clearSteps),o=L(e=>e.setStreamingMessageId),s=(0,F.useRef)(null);return{handleStreamingChunk:(0,F.useCallback)(c=>{c.content?.startsWith(`🎙️ Transcripción:`)&&i(!0);let l=c.id||s.current||M(),{messages:u}=L.getState(),d=u.find(e=>e.id===l);c.isChunk&&d?r(l,{content:(d.content||``)+c.content,timestamp:c.timestamp||d.timestamp}):c.isChunk&&!d?(s.current=l,o(l),n({id:l,conversationId:t,type:`agent`,content:c.content||``,agentId:e,timestamp:c.timestamp||new Date().toISOString()})):d?r(l,{content:c.content||d.content,timestamp:c.timestamp||d.timestamp,...c.audio&&{audio:{base64:c.audio,mimeType:c.mimeType}}}):n({id:l,conversationId:t,type:`agent`,content:c.content||c.message||``,agentId:e,timestamp:c.timestamp||new Date().toISOString(),...c.audio&&{audio:{base64:c.audio,mimeType:c.mimeType}}}),c.isChunk||(s.current=null,o(null),a(),i(!1))},[e,t,n,r,i,a,o]),handleAudioMessage:(0,F.useCallback)(r=>{n({id:r.id||M(),conversationId:t,type:`agent`,content:r.content||``,agentId:e,timestamp:r.timestamp||new Date().toISOString(),audio:r.audio?{base64:r.audio,mimeType:r.mimeType||`audio/wav`}:void 0}),a(),i(!1)},[e,t,n,a,i]),handleProgress:(0,F.useCallback)(e=>{e.content&&(L.getState().addStep(e.content),L.getState().setLoading(!0))},[]),handleTyping:(0,F.useCallback)(e=>{e.isTyping===!0?L.getState().setLoading(!0):e.isTyping===!1&&(L.getState().clearSteps(),L.getState().setLoading(!1))},[]),resetStreamingRef:(0,F.useCallback)(()=>{s.current=null,o(null)},[o])}}var ve=`hive-narration-prefs`;function ye(){try{let e=localStorage.getItem(ve);if(e)return JSON.parse(e)}catch{}return{enabled:!1,rate:1,pitch:1,voiceName:null}}function be(e){try{localStorage.setItem(ve,JSON.stringify(e))}catch{}}function xe(){let[e,t]=(0,F.useState)(ye),[n,r]=(0,F.useState)(!1),[i,a]=(0,F.useState)(null),o=(0,F.useRef)(null),s=(0,F.useCallback)(e=>e&&window.speechSynthesis.getVoices().find(t=>t.name===e)||null,[]),c=(0,F.useCallback)(t=>{if(!e.enabled||!window.speechSynthesis)return;window.speechSynthesis.cancel();let n=t.replace(/```[\s\S]*?```/g,``).replace(/`[^`]+`/g,``).replace(/[#*_~\[\]()]/g,``).replace(/\n{2,}/g,`. `).replace(/\n/g,` `).trim();if(!n)return;let i=new SpeechSynthesisUtterance(n);i.rate=e.rate,i.pitch=e.pitch;let c=s(e.voiceName);c&&(i.voice=c),i.onstart=()=>{r(!0),a(n.slice(0,50))},i.onend=()=>{r(!1),a(null),o.current=null},i.onerror=()=>{r(!1),a(null),o.current=null},o.current=i,window.speechSynthesis.speak(i)},[e,s]),l=(0,F.useCallback)(()=>{window.speechSynthesis.cancel(),r(!1),a(null),o.current=null},[]),u=(0,F.useCallback)(()=>{t(e=>{let t={...e,enabled:!e.enabled};return be(t),t.enabled||(window.speechSynthesis.cancel(),r(!1),a(null)),t})},[]),d=(0,F.useCallback)(e=>{t(t=>{let n={...t,...e};return be(n),n})},[]);return(0,F.useEffect)(()=>{typeof window<`u`&&window.speechSynthesis&&window.speechSynthesis.getVoices()},[]),(0,F.useEffect)(()=>()=>{window.speechSynthesis?.cancel()},[]),{isEnabled:e.enabled,isSpeaking:n,currentText:i,rate:e.rate,pitch:e.pitch,narrate:c,stop:l,toggle:u,updatePrefs:d}}function Se(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Ce(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function we(e,t,n){let r=p((n||{}).ignore||[]),i=Te(t),a=-1;for(;++a<i.length;)b(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Te(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Ee(e[0]),De(e[1])])}return t}function Ee(e){return typeof e==`string`?new RegExp(Ce(e),`g`):e}function De(e){return typeof e==`function`?e:function(){return e}}var R=`phrasing`,z=[`autolink`,`link`,`image`,`label`];function Oe(){return{transforms:[Fe],enter:{literalAutolink:Ae,literalAutolinkEmail:B,literalAutolinkHttp:B,literalAutolinkWww:B},exit:{literalAutolink:Pe,literalAutolinkEmail:Ne,literalAutolinkHttp:je,literalAutolinkWww:Me}}}function ke(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:R,notInConstruct:z},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:R,notInConstruct:z}]}}function Ae(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function B(e){this.config.enter.autolinkProtocol.call(this,e)}function je(e){this.config.exit.autolinkProtocol.call(this,e)}function Me(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function Ne(e){this.config.exit.autolinkEmail.call(this,e)}function Pe(e){this.exit(e)}function Fe(e){we(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Ie],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,Le]],{ignore:[`link`,`linkReference`]})}function Ie(e,t,n,r,i){let a=``;if(!Be(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!Re(n)))return!1;let o=ze(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function Le(e,t,n,r){return!Be(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function Re(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function ze(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Se(e,`(`),a=Se(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function Be(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||f(n)||v(n))&&(!t||n!==47)}Xe.peek=Ye;function Ve(){this.buffer()}function He(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function Ue(){this.buffer()}function We(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function Ge(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=A(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Ke(e){this.exit(e)}function qe(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=A(this.sliceSerialize(e)).toLowerCase(),n.label=t}function Je(e){this.exit(e)}function Ye(){return`[`}function Xe(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function Ze(){return{enter:{gfmFootnoteCallString:Ve,gfmFootnoteCall:He,gfmFootnoteDefinitionLabelString:Ue,gfmFootnoteDefinition:We},exit:{gfmFootnoteCallString:Ge,gfmFootnoteCall:Ke,gfmFootnoteDefinitionLabelString:qe,gfmFootnoteDefinition:Je}}}function Qe(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Xe},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
2
+ `:` `)+r.indentLines(r.containerFlow(e,a.current()),t?et:$e))),s(),o}}function $e(e,t,n){return t===0?e:et(e,t,n)}function et(e,t,n){return(n?``:` `)+e}var tt=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];ot.peek=st;function nt(){return{canContainEols:[`delete`],enter:{strikethrough:it},exit:{strikethrough:at}}}function rt(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:tt}],handlers:{delete:ot}}}function it(e){this.enter({type:`delete`,children:[]},e)}function at(e){this.exit(e)}function ot(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function st(){return`~`}function ct(e){return e.length}function lt(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ct,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=ut(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=dt(r[d]);else{let e=dt(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&!(n.alignDelimiters===!1&&i===``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
3
+ `)}function ut(e){return e==null?``:String(e)}function dt(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function ft(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),pt);return i(),o}function pt(e,t,n){return`>`+(n?``:` `)+e}function mt(e,t){return ht(e,t.inConstruct,!0)&&!ht(e,t.notInConstruct,!1)}function ht(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function gt(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
4
+ `&&mt(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
5
+ `}function _t(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function vt(e,t){return!!(t.options.fences===!1&&e.value&&!e.lang&&/[^ \r\n]/.test(e.value)&&!/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function yt(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function bt(e,t,n,r){let i=yt(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(vt(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,xt);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(_t(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
6
+ `,encode:["`"],...s.current()})),t()}return u+=s.move(`
7
+ `),a&&(u+=s.move(a+`
8
+ `)),u+=s.move(c),l(),u}function xt(e,t,n){return(n?``:` `)+e}function V(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function St(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
9
+ `,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Ct(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function H(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function U(e,t,n){let r=h(e),i=h(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}wt.peek=Tt;function wt(e,t,n,r){let i=Ct(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Tt(e,t,n){return n.options.emphasis||`*`}function Et(e,t){let n=!1;return E(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&ee(e)&&(t.options.setext||n))}function Dt(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Et(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
10
+ `,after:`
11
+ `});return r(),t(),o+`
12
+ `+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
13
+ `))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
14
+ `,...a.current()});return/^[\t ]/.test(l)&&(l=H(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Ot.peek=kt;function Ot(e){return e.value||``}function kt(){return`<`}At.peek=jt;function At(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function jt(){return`!`}Mt.peek=Nt;function Mt(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Nt(){return`!`}Pt.peek=Ft;function Pt(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function Ft(){return"`"}function It(e,t){let n=ee(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type===`text`&&(n===e.url||`mailto:`+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Lt.peek=Rt;function Lt(e,t,n,r){let i=V(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(It(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function Rt(e,t,n){return It(e,n)?`<`:`[`}zt.peek=Bt;function zt(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function Bt(){return`[`}function W(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function Vt(e){let t=W(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Ht(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function Ut(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function Wt(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?Ht(n):W(n),s=e.ordered?o===`.`?`)`:`.`:Vt(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),Ut(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function Gt(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function Kt(e,t,n,r){let i=Gt(n),a=n.bulletCurrent||W(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function qt(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var Jt=p([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function Yt(e,t,n,r){return(e.children.some(function(e){return Jt(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function Xt(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Zt.peek=Qt;function Zt(e,t,n,r){let i=Xt(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=U(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=H(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=U(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+H(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Qt(e,t,n){return n.options.strong||`*`}function $t(e,t,n,r){return n.safe(e.value,r)}function en(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function tn(e,t,n){let r=(Ut(n)+(n.options.ruleSpaces?` `:``)).repeat(en(n));return n.options.ruleSpaces?r.slice(0,-1):r}var nn={blockquote:ft,break:gt,code:bt,definition:St,emphasis:wt,hardBreak:gt,heading:Dt,html:Ot,image:At,imageReference:Mt,inlineCode:Pt,link:Lt,linkReference:zt,list:Wt,listItem:Kt,paragraph:qt,root:Yt,strong:Zt,text:$t,thematicBreak:tn};function rn(){return{enter:{table:an,tableData:cn,tableHeader:cn,tableRow:sn},exit:{codeText:ln,table:on,tableData:G,tableHeader:G,tableRow:G}}}function an(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function on(e){this.exit(e),this.data.inTable=void 0}function sn(e){this.enter({type:`tableRow`,children:[]},e)}function G(e){this.exit(e)}function cn(e){this.enter({type:`tableCell`,children:[]},e)}function ln(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,un));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function un(e,t){return t===`|`?t:e}function dn(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
15
+ `,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[ :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
16
+ `))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return lt(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=nn.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function fn(){return{exit:{taskListCheckValueChecked:mn,taskListCheckValueUnchecked:mn,paragraph:hn}}}function pn(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:gn}}}function mn(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function hn(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function gn(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=nn.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function _n(){return[Oe(),Ze(),nt(),rn(),fn()]}function vn(e){return{extensions:[ke(),Qe(e),rt(),dn(e),pn()]}}var yn={tokenize:An,partial:!0},bn={tokenize:jn,partial:!0},xn={tokenize:Mn,partial:!0},Sn={tokenize:Nn,partial:!0},Cn={tokenize:Pn,partial:!0},wn={name:`wwwAutolink`,tokenize:On,previous:Fn},Tn={name:`protocolAutolink`,tokenize:kn,previous:In},K={name:`emailAutolink`,tokenize:Dn,previous:Ln},q={};function En(){return{text:q}}for(var J=48;J<123;)q[J]=K,J++,J===58?J=65:J===91&&(J=97);q[43]=K,q[45]=K,q[46]=K,q[95]=K,q[72]=[K,Tn],q[104]=[K,Tn],q[87]=[K,wn],q[119]=[K,wn];function Dn(e,t,n){let r=this,i,a;return o;function o(t){return!Y(t)||!Ln.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return Y(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Cn,u,l)(t):t===45||t===95||g(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&k(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function On(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!Fn.call(r,r.previous)||X(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(yn,e.attempt(bn,e.attempt(xn,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function kn(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&In.call(r,r.previous)&&!X(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(k(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||_(t)||S(t)||f(t)||v(t)?n(t):e.attempt(bn,e.attempt(xn,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function An(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function jn(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(Sn,c,s)(t):t===null||S(t)||f(t)||t!==45&&v(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function Mn(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(Sn,t,a)(o):o===null||S(o)||f(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function Nn(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||S(o)||f(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||S(e)||f(e)?t(e):r(e)}function a(e){return k(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):k(t)?(e.consume(t),o):n(t)}}function Pn(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return g(e)?n(e):t(e)}}function Fn(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||S(e)}function In(e){return!k(e)}function Ln(e){return!(e===47||Y(e))}function Y(e){return e===43||e===45||e===46||e===95||g(e)}function X(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var Rn={tokenize:Kn,partial:!0};function zn(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:Un,continuation:{tokenize:Wn},exit:Gn}},text:{91:{name:`gfmFootnoteCall`,tokenize:Hn},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:Bn,resolveTo:Vn}}}}function Bn(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=A(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function Vn(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function Hn(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||S(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(A(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return S(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function Un(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||S(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=A(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return S(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),x(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function Wn(e,t,n){return e.check(w,t,e.attempt(Rn,t,n))}function Gn(e){e.exit(`gfmFootnoteDefinition`)}function Kn(e,t,n){let r=this;return x(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function qn(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&m(o,o.length,0,D(s,e.slice(r+1,n),t)),m(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),m(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=h(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=h(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var Jn=class{constructor(){this.map=[]}add(e,t,n){Yn(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Yn(e,t,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Xn(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Zn(){return{flow:{null:{name:`table`,tokenize:Qn,resolveAll:$n}}}}function Qn(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?E:c;return a===E&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):T(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):y(t)?x(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||S(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,y(t)?x(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):w(t)}function h(t){return y(t)?x(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||T(t)?C(t):w(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):w(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),b):(e.exit(`tableDelimiterFiller`),b(t))}function b(t){return y(t)?x(e,C,`whitespace`)(t):C(t)}function C(n){return n===124?m(n):n===null||T(n)?!o||i!==a?w(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):w(n)}function w(e){return n(e)}function E(t){return e.enter(`tableRow`),D(t)}function D(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),D):n===null||T(n)?(e.exit(`tableRow`),t(n)):y(n)?x(e,D,`whitespace`)(n):(e.enter(`data`),O(n))}function O(t){return t===null||t===124||S(t)?(e.exit(`data`),D(t)):(e.consume(t),t===92?k:O)}function k(t){return t===92||t===124?(e.consume(t),O):O(t)}}function $n(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new Jn;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(er(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Z(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Z(f,t,o,i,n,d)):(o[0]=o[1],d=Z(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&er(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Xn(t.events,n))}return e}function Z(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Q(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Q(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Q(t.events,n[2]),a=Q(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Q(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function er(e,t,n,r,i){let a=[],o=Q(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Q(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var tr={name:`tasklistCheck`,tokenize:rr};function nr(){return{text:{91:tr}}}function rr(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return S(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return T(r)?t(r):y(r)?e.check({tokenize:ir},t,n)(r):n(r)}}function ir(e,t,n){return x(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function ar(e){return te([En(),zn(),qn(e),Zn(),nr()])}var or={};function sr(e){let t=this,n=e||or,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(ar(n)),a.push(_n()),o.push(vn(n))}var $=n();function cr(e){return new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}function lr({audio:e,mimeType:t=`audio/webm`}){let[n,r]=(0,F.useState)(!1),[i,o]=(0,F.useState)(null),[s,u]=(0,F.useState)(0),[f,p]=(0,F.useState)(0),[m,h]=(0,F.useState)(1),[g,_]=(0,F.useState)(1),v=(0,F.useRef)(null);(0,F.useEffect)(()=>{e&&!i&&o(`data:${t};base64,${e}`)},[e,i,t]),(0,F.useEffect)(()=>{v.current&&(v.current.playbackRate=g)},[g]),(0,F.useEffect)(()=>{v.current&&(v.current.volume=m)},[m]);let y=()=>{v.current&&(n?v.current.pause():v.current.play(),r(!n))},b=()=>{v.current&&(u(v.current.currentTime),p(v.current.duration))},x=e=>{v.current&&(v.current.currentTime=e[0],u(e[0]))},S=()=>{let e=[1,1.25,1.5,2];_(e[(e.indexOf(g)+1)%e.length])},C=e=>isNaN(e)?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;if(!e)return null;let w=m===0?he:m<.5?me:j;return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 mt-3 p-3 bg-zinc-900/50 border border-white/5 rounded-2xl w-full max-w-sm shadow-xl backdrop-blur-sm`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{onClick:y,className:`h-10 w-10 rounded-full bg-blue-600 hover:bg-blue-500 flex items-center justify-center transition-all active:scale-95 shadow-lg shadow-blue-600/20`,children:n?(0,$.jsx)(c,{className:`h-5 w-5 text-white fill-white`}):(0,$.jsx)(l,{className:`h-5 w-5 text-white fill-white ml-0.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col gap-1.5 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-end mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-blue-400/80 uppercase tracking-widest flex items-center gap-1.5`,children:n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex gap-0.5 items-end h-3`,children:[(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_0ms]`,style:{height:`40%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_200ms]`,style:{height:`80%`}}),(0,$.jsx)(`span`,{className:`w-0.5 bg-blue-400/60 animate-[bounce_0.8s_infinite_400ms]`,style:{height:`60%`}})]}),`Reproduciendo`]}):`Audio del Agente`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-white/40 tabular-nums`,children:[C(s),` / `,C(f)]})]}),(0,$.jsx)(O,{value:[s],max:f||100,step:.1,onValueChange:x,className:`w-full`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between pt-1 mt-1 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 group/vol`,children:[(0,$.jsx)(`button`,{onClick:()=>h(+(m===0)),className:`text-white/40 hover:text-white transition-colors`,children:(0,$.jsx)(w,{className:`h-4 w-4`})}),(0,$.jsx)(`div`,{className:`w-16`,children:(0,$.jsx)(O,{value:[m*100],max:100,onValueChange:e=>h(e[0]/100),className:`h-4`})})]}),(0,$.jsxs)(`button`,{onClick:S,className:`flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/5 text-white/40 hover:text-blue-400 transition-all`,children:[(0,$.jsx)(a,{className:`h-3.5 w-3.5`}),(0,$.jsxs)(`span`,{className:`text-[10px] font-bold min-w-[2.5ch]`,children:[g,`x`]})]})]}),(0,$.jsx)(`button`,{onClick:()=>{v.current&&(v.current.currentTime=0)},className:`text-white/20 hover:text-white/60 transition-colors p-1`,title:`Reiniciar`,children:(0,$.jsx)(d,{className:`h-3.5 w-3.5`})})]}),i&&(0,$.jsx)(`audio`,{ref:v,src:i,onTimeUpdate:b,onLoadedMetadata:b,onEnded:()=>r(!1),onPlay:()=>r(!0),onPause:()=>r(!1),className:`hidden`})]})}function ur({message:e,userName:t=`Tú`,agentName:n=`Agente`,isStreaming:r,onNarrate:a}){let o=e.type===`user`,s=e.type===`error`,c=e.type===`system`,l=!!e.audio?.base64||!!e.audio?.url;return c?(0,$.jsx)(`div`,{className:`flex justify-center my-2`,children:(0,$.jsx)(`span`,{className:`text-[11px] text-white/50 bg-white/5 border border-white/10 px-3 py-1 rounded-full font-mono`,children:e.content})}):s?(0,$.jsx)(`div`,{className:`flex items-center gap-2 justify-center my-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[12px] font-medium text-rose-400 bg-rose-500/10 border border-rose-500/20 px-4 py-2 rounded-xl`,children:[(0,$.jsx)(re,{className:`h-3.5 w-3.5 shrink-0`}),e.content]})}):o?(0,$.jsx)(`div`,{className:`flex items-end justify-end gap-2 group mb-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-1 max-w-[75%] md:max-w-[65%]`,children:[e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(i,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsx)(`div`,{className:`bg-blue-600/20 text-white px-5 py-3 rounded-3xl rounded-br-sm shadow-sm ring-1 ring-blue-500/30 text-[15px] leading-relaxed whitespace-pre-wrap font-manrope`,children:e.content}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 font-medium pr-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:cr(e.timestamp)})]})}):(0,$.jsxs)(`div`,{className:`flex items-start gap-4 group mb-4`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 mt-0.5 shadow-sm`,children:(0,$.jsx)(N,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 max-w-[85%] min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:n}),e.image&&(0,$.jsx)(`div`,{className:`mb-2 rounded-2xl overflow-hidden border border-white/10 shadow-lg bg-black/20 w-fit`,children:(0,$.jsx)(`img`,{src:e.image.url||`data:${e.image.mimeType||`image/jpeg`};base64,${e.image.base64}`,alt:`adjunto`,className:`max-w-full h-auto max-h-[300px] object-contain`})}),e.document&&(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-3 bg-white/5 border border-white/10 px-4 py-3 rounded-2xl w-fit max-w-full`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg bg-blue-500/10 flex items-center justify-center border border-blue-500/20`,children:(0,$.jsx)(i,{className:`h-6 w-6 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-white truncate`,children:e.document.fileName||`Documento`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/40 uppercase font-bold tracking-wider`,children:e.document.mimeType?.split(`/`)[1]||`DOC`})]})]}),(0,$.jsxs)(`div`,{className:`text-white/80 text-[15px] leading-relaxed prose prose-invert max-w-none font-newsreader`,children:[(0,$.jsx)(C,{remarkPlugins:[sr],children:e.content}),r&&(0,$.jsx)(`span`,{className:`inline-block w-2 h-4 bg-blue-400 ml-1 align-text-bottom rounded-sm opacity-70`})]}),l&&e.audio?.base64&&(0,$.jsx)(lr,{audio:e.audio.base64,mimeType:e.audio.mimeType}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pl-1 mt-1 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/40`,children:cr(e.timestamp)}),a&&(0,$.jsx)(`button`,{onClick:()=>a(e.content),className:`h-6 w-6 rounded flex items-center justify-center text-white/40 hover:text-blue-400 hover:bg-white/5 transition-colors`,title:`Narrar mensaje`,children:(0,$.jsx)(j,{className:`h-3.5 w-3.5`})})]})]})]})}var dr=[{icon:ne,text:`Que puedes hacer?`},{icon:ie,text:`Dame un resumen`},{icon:N,text:`Ayudame con una tarea`}];function fr({messages:e,isLoading:t=!1,currentSteps:n=[],streamingMessageId:r,userName:i,agentName:a,onSuggestionClick:o,onNarrateMessage:s}){let c=(0,F.useRef)(null),l=(0,F.useRef)(null);return(0,F.useLayoutEffect)(()=>{if(l.current){let t=l.current.querySelector(`.overflow-y-auto`);if(t&&(t.scrollHeight-t.scrollTop-t.clientHeight<200||e.length<=1)){let e=setTimeout(()=>{t.scrollTop=t.scrollHeight},0);return()=>clearTimeout(e)}}},[e,t,n]),e.length===0&&!t?(0,$.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center p-8 w-full`,children:[(0,$.jsxs)(`div`,{className:`relative mb-6`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 border border-white/10 flex items-center justify-center shadow-sm`,children:(0,$.jsx)(N,{className:`h-8 w-8 text-blue-400`})}),(0,$.jsx)(`span`,{className:`absolute -bottom-1 -right-1 h-4 w-4 rounded-full bg-emerald-500 border-2 border-white shadow-sm`})]}),(0,$.jsxs)(`div`,{className:`text-center space-y-2 mb-8`,children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold text-white font-manrope`,children:a?`${a} está listo`:`Agente listo`}),(0,$.jsx)(`p`,{className:`text-sm text-white/50 font-manrope`,children:`Inicia la conversación escribiendo un mensaje abajo`})]}),o&&(0,$.jsx)(`div`,{className:`flex flex-col sm:flex-row items-center gap-3`,children:dr.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{onClick:()=>o(e.text),className:`flex items-center gap-2 text-sm text-white/70 hover:text-white bg-white/5 border border-white/10 hover:border-white/20 hover:bg-white/10 px-4 py-2.5 rounded-full transition-all cursor-pointer font-medium`,children:[(0,$.jsx)(t,{className:`h-4 w-4 text-blue-400`}),e.text]},e.text)})})]}):(0,$.jsx)(`div`,{ref:l,className:`flex-1 flex flex-col min-h-0 w-full`,children:(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto w-full`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto flex flex-col gap-6 p-4 md:p-8 pb-2`,children:[e.map(e=>(0,$.jsx)(ur,{message:e,userName:i,agentName:a,isStreaming:e.id===r,onNarrate:s},e.id)),t&&!r&&(0,$.jsxs)(`div`,{className:`flex items-start gap-4 animate-in fade-in slide-in-from-bottom-2 duration-300`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-full bg-white/5 border border-white/10 flex items-center justify-center shrink-0 shadow-sm mt-1`,children:(0,$.jsx)(N,{className:`h-5 w-5 text-blue-400`})}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 max-w-[80%] min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-bold text-white/40 uppercase tracking-wider ml-1`,children:a}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[n.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-1.5 ml-1`,children:n.map((e,t)=>{let r=t===n.length-1;return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-lg border text-xs font-medium transition-all w-fit ${r?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/50`}`,children:[(0,$.jsx)(ie,{className:`h-3 w-3 shrink-0 ${r?`text-blue-400`:`text-white/30`}`}),(0,$.jsx)(`span`,{className:`leading-tight`,children:e})]},t)})}),(0,$.jsxs)(`div`,{className:`bg-white/5 border border-white/10 px-4 py-3.5 rounded-2xl rounded-tl-none shadow-sm flex items-center gap-1.5 w-fit`,children:[(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:0ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:150ms]`}),(0,$.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-white/30 animate-bounce [animation-delay:300ms]`})]})]})]})]}),(0,$.jsx)(`div`,{ref:c,className:`h-0`})]})})})}function pr({onSendMessage:e,onStop:t,disabled:n=!1,isStreaming:r=!1}){let[a,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(!1),[d,f]=(0,F.useState)([]),p=(0,F.useRef)(null),m=(0,F.useRef)([]),h=(0,F.useRef)(null),g=(0,F.useRef)(null);(0,F.useEffect)(()=>{h.current&&(h.current.style.height=`auto`,h.current.style.height=h.current.scrollHeight+`px`)},[a]);let _=()=>{(a.trim()||d.length>0)&&!n&&(e(a.trim()||(d.length>0?`[Adjunto]`:``),{attachments:d.length>0?d:void 0}),c(``),f([]),h.current&&(h.current.style.height=`auto`))},v=async e=>{let t=e.target.files;if(!(!t||t.length===0)){for(let e of Array.from(t)){let t=new FileReader;t.readAsDataURL(e),t.onload=()=>{let n=t.result.split(`,`)[1],r={type:e.type.startsWith(`image/`)?`image`:`document`,base64:n,mimeType:e.type,fileName:e.name};f(e=>[...e,r])}}g.current&&(g.current.value=``)}},y=e=>{f(t=>t.filter((t,n)=>n!==e))};return(0,$.jsx)(`div`,{className:`px-4 pb-4 pt-2 shrink-0 bg-transparent`,children:(0,$.jsxs)(`div`,{className:`max-w-3xl mx-auto`,children:[d.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-2 px-2`,children:d.map((e,t)=>(0,$.jsxs)(`div`,{className:`group relative flex items-center gap-2 bg-white/10 backdrop-blur-md rounded-lg px-3 py-1.5 border border-white/10`,children:[e.type===`image`?(0,$.jsx)(`img`,{src:`data:${e.mimeType};base64,${e.base64}`,className:`h-8 w-8 rounded object-cover border border-white/20`,alt:`preview`}):(0,$.jsx)(i,{className:`h-5 w-5 text-blue-400`}),(0,$.jsx)(`span`,{className:`text-xs text-white/70 max-w-[120px] truncate`,children:e.fileName}),(0,$.jsx)(`button`,{onClick:()=>y(t),className:`absolute -top-2 -right-2 bg-rose-500 text-white rounded-full p-0.5 opacity-0 group-hover:opacity-100 transition-opacity shadow-lg`,children:(0,$.jsx)(ae,{className:`h-3 w-3`})})]},t))}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2 rounded-[2rem] bg-black/40 backdrop-blur-md px-4 py-3 transition-all shadow-sm border border-white/10 ${n?`opacity-60 bg-black/20`:`hover:border-white/20 focus-within:border-blue-500/50 focus-within:shadow-blue-glow`}`,children:[(0,$.jsx)(`input`,{type:`file`,ref:g,onChange:v,className:`hidden`,multiple:!0}),(0,$.jsx)(`button`,{onClick:()=>g.current?.click(),disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-white/5 text-white/50 hover:bg-white/10 hover:text-white disabled:opacity-30 disabled:cursor-not-allowed`,title:`Adjuntar archivo`,children:(0,$.jsx)(fe,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{onClick:l?()=>{p.current&&l&&(p.current.stop(),u(!1))}:async()=>{try{let t=await navigator.mediaDevices.getUserMedia({audio:!0}),n=new MediaRecorder(t,{mimeType:`audio/webm`});p.current=n,m.current=[],n.ondataavailable=e=>{e.data.size>0&&m.current.push(e.data)},n.onstop=async()=>{let n=new Blob(m.current,{type:`audio/webm`}),r=new FileReader;r.readAsDataURL(n),r.onloadend=()=>{let t=r.result.split(`,`)[1];e(`[Audio mensaje]`,{audio:t})},t.getTracks().forEach(e=>e.stop())},n.start(),u(!0)}catch(e){console.error(`Error accessing microphone:`,e)}},disabled:n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all ${l?`bg-rose-500/20 text-rose-400 hover:bg-rose-500/30 animate-pulse`:`bg-white/5 text-white/50 hover:bg-white/10 hover:text-white`} disabled:opacity-30 disabled:cursor-not-allowed`,children:l?(0,$.jsx)(s,{className:`h-4 w-4`}):(0,$.jsx)(o,{className:`h-4 w-4`})}),(0,$.jsx)(`textarea`,{ref:h,value:a,onChange:e=>{c(e.target.value)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),_())},placeholder:n?`Conectando al agente...`:r?`Escribe mientras espera...`:`Escribe un mensaje...`,disabled:n,rows:1,className:`flex-1 min-h-[36px] max-h-[160px] resize-none bg-transparent text-[15px] font-manrope text-white placeholder:text-white/30 focus:outline-none leading-relaxed py-1.5 px-2`,style:{overflow:`auto`}}),r&&t?(0,$.jsx)(`button`,{onClick:t,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all bg-rose-500 hover:bg-rose-600 text-white shadow-sm shadow-rose-500/20`,title:`Detener generación`,children:(0,$.jsx)(s,{className:`h-4 w-4 fill-current`})}):(0,$.jsx)(`button`,{onClick:_,disabled:!a.trim()&&d.length===0||n,className:`h-9 w-9 rounded-full flex items-center justify-center shrink-0 mb-0.5 transition-all disabled:opacity-30 disabled:cursor-not-allowed bg-blue-600 hover:bg-blue-500 disabled:bg-white/10 text-white shadow-sm`,children:(0,$.jsx)(pe,{className:`h-4 w-4`})})]}),(0,$.jsx)(`p`,{className:`text-[11px] font-medium text-white/30 mt-2.5 text-center font-manrope tracking-wide`,children:l?`Grabando... haz clic para enviar`:`Enter para enviar · Shift+Enter nueva línea`})]})})}function mr(){let e=`main`,{messages:t,addMessage:n,setMessages:i,isLoading:a,currentSteps:o,streamingMessageId:s,connectionWarning:c,setConnectionWarning:l}=L(),{status:d,send:f,subscribe:p}=oe(),{currentUser:m,fetchUser:h}=se(),g=le(e=>e.agents),_=le(e=>e.fetchAgents),v=m?.id||`default`,{handleStreamingChunk:y,handleAudioMessage:b,handleProgress:x,handleTyping:S,resetStreamingRef:C}=_e(e,v),w=xe(),T=d===`connected`,E=d===`connecting`,D=g.find(e=>e.role===`coordinator`&&e.enabled)?.name??`Coordinador`;(0,F.useEffect)(()=>{m||h(),g.length===0&&_()},[]),(0,F.useEffect)(()=>{v&&(async()=>{try{let t=await ce(`/api/chat/history?sessionId=${v}&limit=15`);t.messages&&i(t.messages.filter(e=>e.role===`user`||e.role===`assistant`).map(t=>({id:t.id,conversationId:t.session_id||t.thread_id,type:t.role===`user`?`user`:`agent`,content:t.content,agentId:e,timestamp:t.created_at})))}catch(e){console.error(`Failed to fetch chat history:`,e)}})()},[v,e,i]),(0,F.useEffect)(()=>{let e=p(`message`,y),t=p(`response`,y),n=p(`audio`,b),r=p(`progress`,x),i=p(`typing`,S);return()=>{e(),t(),n(),r(),i()}},[p,y,b,x,S]),(0,F.useEffect)(()=>{T?l(null):E||l(`Conexion perdida. Reconectando...`)},[T,E,l]);let O=(0,F.useCallback)((t,r)=>{let i=M();w.stop();let a=r?.audio,o=r?.attachments,s={id:i,conversationId:v,type:`user`,content:t,agentId:e,timestamp:new Date().toISOString()};if(a&&(s.audio={base64:a,mimeType:`audio/webm`}),o&&o.length>0){let e=o.find(e=>e.type===`image`),t=o.find(e=>e.type===`document`);e&&(s.image={base64:e.base64,mimeType:e.mimeType,caption:e.fileName}),t&&(s.document={base64:t.base64,mimeType:t.mimeType,fileName:t.fileName})}if(n(s),L.getState().setLoading(!0),C(),T)if(a)f({type:`audio`,audio:a,sessionId:v,timestamp:new Date().toISOString()});else{let e={type:`message`,content:t,sessionId:v,timestamp:new Date().toISOString()};if(o&&o.length>0){let t=o.find(e=>e.type===`image`),n=o.find(e=>e.type===`document`);t&&(e.image={base64:t.base64,mimeType:t.mimeType,caption:t.fileName}),n&&(e.document={base64:n.base64,mimeType:n.mimeType,fileName:n.fileName})}f(e)}else n({id:M(),conversationId:v,type:`error`,content:`No se pudo conectar al agente. Verifica que el gateway este funcionando.`,timestamp:new Date().toISOString()}),L.getState().setLoading(!1)},[T,v,e,n,f,w,C]),k=(0,F.useCallback)(e=>{w.isSpeaking?w.stop():w.narrate(e)},[w]);return(0,$.jsxs)(`div`,{className:`flex-1 flex flex-col w-full min-h-0 bg-transparent overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 shrink-0 z-10 bg-transparent border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-semibold text-white font-manrope tracking-tight`,children:D}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-white/5 border border-white/10`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${T?`bg-emerald-500`:E?`bg-amber-500 animate-pulse`:`bg-slate-400`}`}),(0,$.jsx)(`span`,{className:`text-[10px] font-medium text-white/50 uppercase tracking-wider`,children:T?`Conectado`:E?`Conectando`:`Desconectado`})]})]}),(0,$.jsx)(`button`,{onClick:w.toggle,className:`h-8 w-8 rounded-full flex items-center justify-center transition-all ${w.isEnabled?`bg-blue-500/20 text-blue-400 hover:bg-blue-500/30`:`text-white/40 hover:text-white/70 hover:bg-white/5`}`,title:w.isEnabled?`Desactivar narracion`:`Activar narracion`,children:w.isEnabled?(0,$.jsx)(j,{className:`h-4 w-4`}):(0,$.jsx)(he,{className:`h-4 w-4`})})]}),c&&!T&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-rose-50 border-b border-rose-100 shrink-0`,children:[(0,$.jsx)(r,{className:`h-3.5 w-3.5 text-rose-500 shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-rose-600 flex-1 font-medium`,children:c}),(0,$.jsxs)(`button`,{onClick:()=>{let{connect:e}=de.getState();m?.id&&e(m.id)},className:`flex items-center gap-1 text-[10px] font-bold text-rose-600 hover:text-rose-800 transition-colors uppercase tracking-wider`,children:[(0,$.jsx)(u,{className:`h-3 w-3`}),`Reintentar`]})]}),w.isSpeaking&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-blue-500/10 border-b border-blue-500/20 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex gap-0.5`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`0ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`150ms`}}),(0,$.jsx)(`span`,{className:`h-1.5 w-0.5 bg-blue-400 rounded-full animate-pulse`,style:{animationDelay:`300ms`}})]}),(0,$.jsxs)(`span`,{className:`text-[10px] text-blue-400 font-medium font-manrope`,children:[`Narrando`,w.currentText?`: ${w.currentText}...`:`...`]}),(0,$.jsx)(`button`,{onClick:w.stop,className:`text-[10px] text-blue-500 hover:text-blue-300 ml-auto font-bold uppercase tracking-wider`,children:`Detener`})]}),(0,$.jsx)(fr,{messages:t,isLoading:a,currentSteps:o,streamingMessageId:s,userName:m?.name??`Usuario`,agentName:D,onSuggestionClick:O,onNarrateMessage:w.isEnabled?k:void 0}),(0,$.jsx)(pr,{onSendMessage:O,onStop:()=>{T&&f({type:`stop`,sessionId:v})},disabled:!T&&!E,isStreaming:a})]})}export{mr as WebChatPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{C as n,S as r,b as i,ht as a,mt as o,w as s,x as c}from"./vendor-radix-JY4ncZrD.js";import{o as l}from"./vendor-query-DsWPbQdG.js";import{l as u}from"./switch-CQf9jQKN.js";import{t as d}from"./chevron-down-DLfCQOQA.js";import{B as f}from"./index-B4lS14UW.js";var p=e(t(),1),m=l(),h=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(o,{ref:n,className:f(`peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,m.jsx)(a,{className:f(`flex items-center justify-center text-current`),children:(0,m.jsx)(u,{className:`h-4 w-4`})})}));h.displayName=o.displayName;var g=n,_=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(r,{ref:n,className:f(`border-b`,e),...t}));_.displayName=`AccordionItem`;var v=p.forwardRef(({className:e,children:t,...n},r)=>(0,m.jsx)(c,{className:`flex`,children:(0,m.jsxs)(s,{ref:r,className:f(`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,m.jsx)(d,{className:`h-4 w-4 shrink-0 transition-transform duration-200`})]})}));v.displayName=s.displayName;var y=p.forwardRef(({className:e,children:t,...n},r)=>(0,m.jsx)(i,{ref:r,className:`overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,...n,children:(0,m.jsx)(`div`,{className:f(`pb-4 pt-0`,e),children:t})}));y.displayName=i.displayName;export{h as a,v as i,y as n,_ as r,g as t};
@@ -0,0 +1 @@
1
+ import{tt as e}from"./index-B4lS14UW.js";var t=e(`Activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{B as r,nt as i}from"./index-B4lS14UW.js";var a=e(t(),1),o=n(),s=i(`relative w-full rounded-lg border p-4 [&>svg~*]:pl-7 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground`,{variants:{variant:{default:`bg-background text-foreground`,destructive:`border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive`}},defaultVariants:{variant:`default`}}),c=a.forwardRef(({className:e,variant:t,...n},i)=>(0,o.jsx)(`div`,{ref:i,role:`alert`,className:r(s({variant:t}),e),...n}));c.displayName=`Alert`;var l=a.forwardRef(({className:e,children:t,...n},i)=>(0,o.jsx)(`h5`,{ref:i,className:r(`mb-1 font-medium leading-none tracking-tight`,e),...n,children:t}));l.displayName=`AlertTitle`;var u=a.forwardRef(({className:e,...t},n)=>(0,o.jsx)(`div`,{ref:n,className:r(`text-sm [&_p]:leading-relaxed`,e),...t}));u.displayName=`AlertDescription`;export{u as n,l as r,c as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{a as n,c as r,d as i,f as a,l as o,o as s,s as c,u as l}from"./vendor-radix-JY4ncZrD.js";import{o as u}from"./vendor-query-DsWPbQdG.js";import{B as d,F as f}from"./index-B4lS14UW.js";var p=e(t(),1),m=u(),h=i,g=l,_=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(o,{className:d(`fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0`,e),...t,ref:n}));_.displayName=o.displayName;var v=p.forwardRef(({className:e,...t},n)=>(0,m.jsxs)(g,{children:[(0,m.jsx)(_,{}),(0,m.jsx)(c,{ref:n,className:d(`fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg`,e),...t})]}));v.displayName=c.displayName;var y=({className:e,...t})=>(0,m.jsx)(`div`,{className:d(`flex flex-col space-y-2 text-center sm:text-left`,e),...t});y.displayName=`AlertDialogHeader`;var b=({className:e,...t})=>(0,m.jsx)(`div`,{className:d(`flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2`,e),...t});b.displayName=`AlertDialogFooter`;var x=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(a,{ref:n,className:d(`text-lg font-semibold`,e),...t}));x.displayName=a.displayName;var S=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(r,{ref:n,className:d(`text-sm text-muted-foreground`,e),...t}));S.displayName=r.displayName;var C=p.forwardRef(({className:e,...t},r)=>(0,m.jsx)(n,{ref:r,className:d(f(),e),...t}));C.displayName=n.displayName;var w=p.forwardRef(({className:e,...t},n)=>(0,m.jsx)(s,{ref:n,className:d(f({variant:`outline`}),`mt-2 sm:mt-0`,e),...t}));w.displayName=s.displayName;export{S as a,x as c,v as i,C as n,b as o,w as r,y as s,h as t};
@@ -0,0 +1 @@
1
+ import{tt as e}from"./index-B4lS14UW.js";var t=e(`ArrowLeft`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]);export{t};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-S-ySWqyJ.js";import{_ as e}from"./vendor-charts-Bu2lyBKP.js";import{o as t}from"./vendor-query-DsWPbQdG.js";import{B as n,nt as r}from"./index-B4lS14UW.js";e();var i=t(),a=r(`inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2`,{variants:{variant:{default:`border-transparent bg-primary text-primary-foreground hover:bg-primary/80`,secondary:`border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80`,destructive:`border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80`,outline:`text-foreground`}},defaultVariants:{variant:`default`}});function o({className:e,variant:t,...r}){return(0,i.jsx)(`div`,{className:n(a({variant:t}),e),...r})}export{o as t};
@@ -0,0 +1 @@
1
+ import{tt as e}from"./index-B4lS14UW.js";var t=e(`Calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]);export{t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{B as r}from"./index-B4lS14UW.js";var i=e(t(),1),a=n(),o=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`rounded-lg border bg-card text-card-foreground shadow-sm`,e),...t}));o.displayName=`Card`;var s=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex flex-col space-y-1.5 p-6`,e),...t}));s.displayName=`CardHeader`;var c=i.forwardRef(({className:e,children:t,...n},i)=>(0,a.jsx)(`h3`,{ref:i,className:r(`text-2xl font-semibold leading-none tracking-tight`,e),...n,children:t}));c.displayName=`CardTitle`;var l=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`p`,{ref:n,className:r(`text-sm text-muted-foreground`,e),...t}));l.displayName=`CardDescription`;var u=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`p-6 pt-0`,e),...t}));u.displayName=`CardContent`;var d=i.forwardRef(({className:e,...t},n)=>(0,a.jsx)(`div`,{ref:n,className:r(`flex items-center p-6 pt-0`,e),...t}));d.displayName=`CardFooter`;export{s as a,d as i,u as n,c as o,l as r,o as t};
@@ -0,0 +1 @@
1
+ import{tt as e}from"./index-B4lS14UW.js";var t=e(`ChevronDown`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]);export{t};