@johpaz/hive-agents 1.0.1 → 1.0.3

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 (120) hide show
  1. package/README.md +3 -3
  2. package/dist/hive.js +1286 -764
  3. package/dist/ui/assets/A2UIPage-DExwevBV.js +8 -0
  4. package/dist/ui/assets/{AgentCreateForm-M2RhjeA1.js → AgentCreateForm-7PPShsUn.js} +1 -1
  5. package/dist/ui/assets/{AgentDetailPage-DkFRtj8g.js → AgentDetailPage-CiV4tz4P.js} +1 -1
  6. package/dist/ui/assets/AgentNewPage-D3TtVwQf.js +1 -0
  7. package/dist/ui/assets/{AgentsPage-Ctzq2LWx.js → AgentsPage-C2DThet7.js} +1 -1
  8. package/dist/ui/assets/{ApiClientPage-DKbGO1QW.js → ApiClientPage-Cowdq-0f.js} +1 -1
  9. package/dist/ui/assets/{ChannelsPage-H6rgr8DQ.js → ChannelsPage-D4IgglwJ.js} +1 -1
  10. package/dist/ui/assets/{DashboardPage-BIjYGf4m.js → DashboardPage-DAgVB7Iy.js} +1 -1
  11. package/dist/ui/assets/{LoginPage-DazoxtBJ.js → LoginPage-CpU61b3u.js} +1 -1
  12. package/dist/ui/assets/{LogsPage-DMZ6KtQ3.js → LogsPage-DyJOGQNy.js} +1 -1
  13. package/dist/ui/assets/{MeetingPage-CSLFvHL7.js → MeetingPage-DLmqHmm2.js} +1 -1
  14. package/dist/ui/assets/{ModelSelector-BCfvugHB.js → ModelSelector-D4OaICwN.js} +1 -1
  15. package/dist/ui/assets/{Office3DPage-BE6Epe0d.js → Office3DPage-BvO66B0h.js} +1 -1
  16. package/dist/ui/assets/{ProvidersPage-D0cApfM1.js → ProvidersPage-Bhb6Qr87.js} +1 -1
  17. package/dist/ui/assets/{RecoverPage-BVUPHG9z.js → RecoverPage-DaZrCpdB.js} +1 -1
  18. package/dist/ui/assets/SettingsPage-BRD2F7up.js +9 -0
  19. package/dist/ui/assets/{SetupPage-In19p30M.js → SetupPage-DKppgTja.js} +1 -1
  20. package/dist/ui/assets/WebChatPage-CPtETNL5.js +29 -0
  21. package/dist/ui/assets/{activity-BIIli7ET.js → activity-BSosMryb.js} +1 -1
  22. package/dist/ui/assets/{agentCapabilities-D1PD9yFH.js → agentCapabilities-VqxLmrF6.js} +1 -1
  23. package/dist/ui/assets/arrow-left-C9Y6p4Jt.js +1 -0
  24. package/dist/ui/assets/arrow-right-BYfOLnTB.js +1 -0
  25. package/dist/ui/assets/arrow-up-right-D2trA3Ob.js +1 -0
  26. package/dist/ui/assets/{calendar-S9-_Q6QR.js → calendar-rdd4nvY1.js} +1 -1
  27. package/dist/ui/assets/check-DUq9uoNQ.js +1 -0
  28. package/dist/ui/assets/chevron-down-rPF4Pr1n.js +1 -0
  29. package/dist/ui/assets/chevron-left-Crzzf2sY.js +1 -0
  30. package/dist/ui/assets/chevron-right-DtMIvG9A.js +1 -0
  31. package/dist/ui/assets/chevron-up-CG0_KGBy.js +1 -0
  32. package/dist/ui/assets/{circle-alert-DTVW4R94.js → circle-alert-CYt6gsDA.js} +1 -1
  33. package/dist/ui/assets/circle-check-Zl32-jCa.js +1 -0
  34. package/dist/ui/assets/{circle-x-CJXbXzRh.js → circle-x-BJXzKGmx.js} +1 -1
  35. package/dist/ui/assets/{copy-X_TPpA-A.js → copy-BmtJXmDe.js} +1 -1
  36. package/dist/ui/assets/{dialog-uUBz_NIB.js → dialog-Dn9hGPYl.js} +1 -1
  37. package/dist/ui/assets/{download-C-fXu08w.js → download-D3mYhuuL.js} +1 -1
  38. package/dist/ui/assets/{earth-CTsVjCmp.js → earth-BZzdDXFC.js} +1 -1
  39. package/dist/ui/assets/{ellipsis-vertical-5zBh5yzc.js → ellipsis-vertical-BF705XvB.js} +1 -1
  40. package/dist/ui/assets/{external-link-CvpRhwC_.js → external-link-gdpMTHUV.js} +1 -1
  41. package/dist/ui/assets/{eye-CM-HQEWU.js → eye-lSG04hI7.js} +1 -1
  42. package/dist/ui/assets/{file-text-lwkvYGtA.js → file-text-CjQxcJvN.js} +1 -1
  43. package/dist/ui/assets/gauge-DBryKhDK.js +1 -0
  44. package/dist/ui/assets/{history-eSHspWRr.js → history-BC6ir9qU.js} +1 -1
  45. package/dist/ui/assets/{index-ZjAc-KQS.js → index-DyxoAvTq.js} +2 -2
  46. package/dist/ui/assets/index-wML8DaUo.css +2 -0
  47. package/dist/ui/assets/{info-DTgFQ_jA.js → info-BGBaIyKc.js} +1 -1
  48. package/dist/ui/assets/{key-CeM9JJkq.js → key-D_CNJTY2.js} +1 -1
  49. package/dist/ui/assets/loader-circle-RXdrfPsH.js +1 -0
  50. package/dist/ui/assets/{lock-open-B089GUAJ.js → lock-open-UB61lorP.js} +1 -1
  51. package/dist/ui/assets/{mail--gNFIe4M.js → mail-C5bJ_dBt.js} +1 -1
  52. package/dist/ui/assets/{pause-DjT1nwQM.js → pause-BSTJvxDu.js} +1 -1
  53. package/dist/ui/assets/{pencil-6PRgdjiU.js → pencil-C2B1Q7y2.js} +1 -1
  54. package/dist/ui/assets/play-tcMbj-0p.js +1 -0
  55. package/dist/ui/assets/plus-BSZvyMND.js +1 -0
  56. package/dist/ui/assets/{radio-D-joO9J0.js → radio-D9CrjAar.js} +1 -1
  57. package/dist/ui/assets/{refresh-cw-BRrzoHQW.js → refresh-cw-D7EB_fVv.js} +1 -1
  58. package/dist/ui/assets/search-5S6LY69I.js +1 -0
  59. package/dist/ui/assets/{select-BOR8MsSL.js → select-ot0a6art.js} +1 -1
  60. package/dist/ui/assets/{send-DIlj81PT.js → send-Dax1tJ5b.js} +1 -1
  61. package/dist/ui/assets/{settings-CkBjgAEm.js → settings-97CL32lC.js} +1 -1
  62. package/dist/ui/assets/{shield-U0hIjGzm.js → shield-DwbCEZbF.js} +1 -1
  63. package/dist/ui/assets/{sparkles-VXHGDbNh.js → sparkles-CWMAzkpD.js} +1 -1
  64. package/dist/ui/assets/{square-OHeetvN3.js → square-B4dgTXI3.js} +1 -1
  65. package/dist/ui/assets/terminal-DoLedTPM.js +1 -0
  66. package/dist/ui/assets/{trash-2-DQxm7DUM.js → trash-2-DxnVYOz8.js} +1 -1
  67. package/dist/ui/assets/{triangle-alert-Dj8ZhmWj.js → triangle-alert-Cka-BeIE.js} +1 -1
  68. package/dist/ui/assets/{useHiveAgentsModelLoad-COLvs-Ho.js → useHiveAgentsModelLoad-BjnIsQKR.js} +1 -1
  69. package/dist/ui/assets/{useProviders-q6iROeWE.js → useProviders-CueMz_mL.js} +1 -1
  70. package/dist/ui/assets/{volume-x-Bm735CXN.js → volume-x-DLsli9cf.js} +1 -1
  71. package/dist/ui/assets/{wifi-DklBfOZ6.js → wifi-BQRJGfLZ.js} +1 -1
  72. package/dist/ui/assets/{zap-BEZNJ0i0.js → zap-DSR3CEce.js} +1 -1
  73. package/dist/ui/index.html +2 -2
  74. package/package.json +1 -1
  75. package/packages/cli/src/index.ts +23 -17
  76. package/packages/core/src/agent/agent-loop.ts +29 -3
  77. package/packages/core/src/agent/context-compiler.ts +13 -2
  78. package/packages/core/src/agent/mcp-result-normalizer.ts +150 -0
  79. package/packages/core/src/agent/providers/index.ts +8 -0
  80. package/packages/core/src/artifacts/store.ts +16 -0
  81. package/packages/core/src/canvas/canvas-manager.ts +36 -7
  82. package/packages/core/src/channels/base.ts +33 -0
  83. package/packages/core/src/channels/discord.ts +20 -1
  84. package/packages/core/src/channels/slack.ts +21 -2
  85. package/packages/core/src/channels/telegram.ts +16 -1
  86. package/packages/core/src/channels/whatsapp.ts +16 -3
  87. package/packages/core/src/gateway/durable-queue.ts +2 -1
  88. package/packages/core/src/gateway/failure-notify.ts +78 -0
  89. package/packages/core/src/gateway/job-executors.ts +1 -0
  90. package/packages/core/src/gateway/job-store.ts +6 -0
  91. package/packages/core/src/gateway/process-safety.ts +40 -0
  92. package/packages/core/src/gateway/routes/a2ui.ts +43 -0
  93. package/packages/core/src/gateway/routes/artifacts.ts +60 -0
  94. package/packages/core/src/gateway/routes/runtime.ts +58 -0
  95. package/packages/core/src/gateway/routes/setup.ts +127 -108
  96. package/packages/core/src/gateway/server.ts +52 -5
  97. package/packages/core/src/gateway/webchat-turn.ts +40 -1
  98. package/packages/core/src/storage/onboarding.ts +23 -7
  99. package/packages/core/src/storage/seed.ts +31 -2
  100. package/packages/core/src/utils/redact-binary.ts +17 -0
  101. package/dist/ui/assets/A2UIPage-D4nzp5NV.js +0 -8
  102. package/dist/ui/assets/AgentNewPage-CfBU7puz.js +0 -1
  103. package/dist/ui/assets/SettingsPage-DCZ4nql4.js +0 -9
  104. package/dist/ui/assets/WebChatPage-ByVBSzxL.js +0 -29
  105. package/dist/ui/assets/arrow-left-BfcnX8Er.js +0 -1
  106. package/dist/ui/assets/arrow-right-Q-dzAn8k.js +0 -1
  107. package/dist/ui/assets/arrow-up-right-Bf-8wrUQ.js +0 -1
  108. package/dist/ui/assets/check-CryV78SQ.js +0 -1
  109. package/dist/ui/assets/chevron-down-QCtMs-Af.js +0 -1
  110. package/dist/ui/assets/chevron-left-dTGbyl5G.js +0 -1
  111. package/dist/ui/assets/chevron-right-D0GjXbnO.js +0 -1
  112. package/dist/ui/assets/chevron-up-Cg0jO8uT.js +0 -1
  113. package/dist/ui/assets/circle-check-BAolxswA.js +0 -1
  114. package/dist/ui/assets/gauge-CB-cas-h.js +0 -1
  115. package/dist/ui/assets/index-D489S18g.css +0 -2
  116. package/dist/ui/assets/loader-circle-Dtfz4FWw.js +0 -1
  117. package/dist/ui/assets/play-tOrP0xUJ.js +0 -1
  118. package/dist/ui/assets/plus-Cnom3j47.js +0 -1
  119. package/dist/ui/assets/search-D277MUP0.js +0 -1
  120. package/dist/ui/assets/terminal-C6YPcJl_.js +0 -1
@@ -290,15 +290,17 @@ export const SEED_DATA: SeedData = {
290
290
  // Solo los mejores modelos agénticos (tool calling) del catálogo vivo. NVIDIA
291
291
  // retira modelos del endpoint sin avisar y responde 410 Gone al llamarlos, así
292
292
  // que esta lista se valida contra /v1/models — no contra la web de build.nvidia.com,
293
- // que sigue mostrando fichas de modelos ya retirados. Verificado 2026-08-03.
293
+ // que sigue mostrando fichas de modelos ya retirados. Verificado 2026-08-11.
294
294
  // Nota: Qwen ya no tiene ningún modelo en el catálogo NVIDIA (todos retirados);
295
295
  // para Qwen usar el provider `qwen` (DashScope) directamente.
296
+ // DeepSeek V4 Pro (deepseek-ai/deepseek-v4-pro) se sacó: devuelve 404
297
+ // "Function not found for account" en cuentas normales — no está habilitado
298
+ // de forma general aunque figure en el listado público de /v1/models.
296
299
  { id: "z-ai/glm-5.2", providerId: "nvidia", name: "GLM 5.2 (NVIDIA)", modelType: "llm", contextWindow: 200000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
297
300
  { id: "moonshotai/kimi-k2.6", providerId: "nvidia", name: "Kimi K2.6 (NVIDIA)", modelType: "llm", contextWindow: 262144, capabilities: JSON.stringify(["chat", "code", "vision", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
298
301
  { id: "minimaxai/minimax-m3", providerId: "nvidia", name: "MiniMax M3 (NVIDIA)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "vision", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
299
302
  { id: "nvidia/nemotron-3-ultra-550b-a55b", providerId: "nvidia", name: "Nemotron 3 Ultra 550B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
300
303
  { id: "nvidia/nemotron-3-super-120b-a12b", providerId: "nvidia", name: "Nemotron 3 Super 120B", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
301
- { id: "deepseek-ai/deepseek-v4-pro", providerId: "nvidia", name: "DeepSeek V4 Pro (NVIDIA)", modelType: "llm", contextWindow: 1000000, capabilities: JSON.stringify(["chat", "code", "json_mode", "function_calling", "streaming", "reasoning"]), inputPer1M: 0, outputPer1M: 0 },
302
304
 
303
305
  // ── ModelScope Qwen (fuente: GET https://api-inference.modelscope.ai/v1/models) ──
304
306
  // Endpoint gratuito dentro de cuota (2000 llamadas/día, ≤500 por modelo), por
@@ -513,6 +515,15 @@ const RETIRED_CATALOG_AGENT_IDS = [
513
515
  "acceptance_verifier",
514
516
  ];
515
517
 
518
+ function parseSkillList(value: string | null | undefined): string[] {
519
+ try {
520
+ const parsed = value ? JSON.parse(value) : [];
521
+ return Array.isArray(parsed) ? parsed.filter((id): id is string => typeof id === "string") : [];
522
+ } catch {
523
+ return [];
524
+ }
525
+ }
526
+
516
527
  const LEGACY_CRON_PERSONA = {
517
528
  id: "schedule_automation_agent",
518
529
  name: "Operador de agenda",
@@ -799,6 +810,7 @@ export async function seedAllData(): Promise<void> {
799
810
  // rows. Existing user choices remain untouched; narrowly identified
800
811
  // factory values from older releases are migrated in place.
801
812
  let catalogAgentCount = 0;
813
+ let repairedCatalogSkills = 0;
802
814
  for (const catalogAgent of createSeedCatalogAgents()) {
803
815
  await putIfAbsent(agentsCol, catalogAgent.id, catalogAgent);
804
816
  const existing = await agentsCol.get(catalogAgent.id);
@@ -815,6 +827,20 @@ export async function seedAllData(): Promise<void> {
815
827
  if (reconciled.status === "archived") {
816
828
  reconciled = { ...reconciled, status: "idle" };
817
829
  }
830
+
831
+ // Catalog agents may survive upgrades with an older skills_json. Keep
832
+ // any user-added skills, but restore every canonical dependency so a
833
+ // worker cannot reach delegation with a stale/missing reference.
834
+ const currentSkills = parseSkillList(reconciled.skills_json);
835
+ const missingCatalogSkills = parseSkillList(catalogAgent.skills_json)
836
+ .filter((id) => !currentSkills.includes(id));
837
+ if (missingCatalogSkills.length > 0) {
838
+ reconciled = {
839
+ ...reconciled,
840
+ skills_json: JSON.stringify([...currentSkills, ...missingCatalogSkills]),
841
+ };
842
+ repairedCatalogSkills += missingCatalogSkills.length;
843
+ }
818
844
  if (JSON.stringify(reconciled) !== JSON.stringify(existing.doc)) {
819
845
  await agentsCol.put(
820
846
  existing.id,
@@ -825,6 +851,9 @@ export async function seedAllData(): Promise<void> {
825
851
  catalogAgentCount++;
826
852
  }
827
853
  log.info(`[seed] ✅ ${catalogAgentCount} catalog agents ensured`);
854
+ if (repairedCatalogSkills > 0) {
855
+ log.info(`[seed] 🔧 Restauradas ${repairedCatalogSkills} dependencia(s) de skills en agentes de catálogo`);
856
+ }
828
857
 
829
858
  // Catalog rows are born without a provider/model (no provider exists at
830
859
  // first boot), and setup only runs once — so anything that arrives later
@@ -0,0 +1,17 @@
1
+ /**
2
+ * redact-binary — last-line-of-defense redaction for stray base64 blobs.
3
+ *
4
+ * mcp-result-normalizer.ts (agent/mcp-result-normalizer.ts) is the real fix:
5
+ * it intercepts MCP image/audio/resource content blocks before they ever
6
+ * reach a string. This utility is the safety net for whatever slips past
7
+ * that — a producer that isn't MCP, a content shape normalizeMcpResult
8
+ * doesn't recognize, etc. Never rely on this alone to keep binaries out of
9
+ * the LLM context.
10
+ */
11
+
12
+ const DATA_URI_RE = /data:[a-z0-9.+-]+\/[a-z0-9.+-]+;base64,[a-z0-9+/=\s]+/gi;
13
+ const LONG_BASE64_RE = /[A-Za-z0-9+/]{1000,}={0,2}/g;
14
+
15
+ export function redactBinaryStrings(text: string): string {
16
+ return text.replace(DATA_URI_RE, "[REDACTED_BINARY]").replace(LONG_BASE64_RE, "[REDACTED_BINARY]");
17
+ }
@@ -1,8 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./arrow-left-BfcnX8Er.js";import{t as i}from"./arrow-right-Q-dzAn8k.js";import{t as a}from"./calendar-S9-_Q6QR.js";import{t as o}from"./check-CryV78SQ.js";import{t as s}from"./circle-alert-DTVW4R94.js";import{t as c}from"./download-C-fXu08w.js";import{t as l}from"./ellipsis-vertical-5zBh5yzc.js";import{n as u,t as d}from"./eye-CM-HQEWU.js";import{t as f}from"./info-DTgFQ_jA.js";import{t as p}from"./lock-open-B089GUAJ.js";import{n as m,t as ee}from"./pencil-6PRgdjiU.js";import{t as te}from"./mail--gNFIe4M.js";import{t as ne}from"./plus-Cnom3j47.js";import{t as re}from"./refresh-cw-BRrzoHQW.js";import{t as h}from"./search-D277MUP0.js";import{t as g}from"./send-DIlj81PT.js";import{t as _}from"./settings-CkBjgAEm.js";import{t as ie}from"./trash-2-DQxm7DUM.js";import{t as ae}from"./triangle-alert-Dj8ZhmWj.js";import{n as oe,t as se}from"./wifi-DklBfOZ6.js";import{l as ce}from"./vendor-router-zpB-76nT.js";import{B as v,C as y,F as b,G as le,K as x,M as S,S as C,T as w,_ as T,b as E,d as D,v as O,w as k,x as A,y as j}from"./index-ZjAc-KQS.js";import{t as M}from"./badge-DKGZbVZJ.js";import{t as N}from"./scroll-area-CfHn94Vb.js";import{t as P}from"./slider-CmE_z1Ii.js";import{i as F,n as I,r as L,t as R}from"./tabs-CxiybXcw.js";import{c as z,i as B,r as V,s as H,t as U}from"./dialog-uUBz_NIB.js";var W=x(`Camera`,[[`path`,{d:`M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z`,key:`1tc9qg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]),G=x(`CircleHelp`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),ue=x(`CreditCard`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`5`,rx:`2`,key:`ynyp8z`}],[`line`,{x1:`2`,x2:`22`,y1:`10`,y2:`10`,key:`1b3vmo`}]]),de=x(`Ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),fe=x(`Folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),K=x(`Heart`,[[`path`,{d:`M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z`,key:`c3ymky`}]]),pe=x(`House`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]),me=x(`Image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),he=x(`MapPin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),ge=x(`Phone`,[[`path`,{d:`M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z`,key:`foiqr5`}]]),_e=x(`Printer`,[[`path`,{d:`M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`143wyd`}],[`path`,{d:`M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6`,key:`1itne7`}],[`rect`,{x:`6`,y:`14`,width:`12`,height:`8`,rx:`1`,key:`1ue0tg`}]]),ve=x(`Share2`,[[`circle`,{cx:`18`,cy:`5`,r:`3`,key:`gq8acd`}],[`circle`,{cx:`6`,cy:`12`,r:`3`,key:`w7nqdw`}],[`circle`,{cx:`18`,cy:`19`,r:`3`,key:`1xt0gg`}],[`line`,{x1:`8.59`,x2:`15.42`,y1:`13.51`,y2:`17.49`,key:`47mynk`}],[`line`,{x1:`15.41`,x2:`8.59`,y1:`6.51`,y2:`10.49`,key:`1n3mei`}]]),ye=x(`ShoppingCart`,[[`circle`,{cx:`8`,cy:`21`,r:`1`,key:`jimo8o`}],[`circle`,{cx:`19`,cy:`21`,r:`1`,key:`13723u`}],[`path`,{d:`M2.05 2.05h2l2.66 12.42a2 2 0 0 0 2 1.58h9.78a2 2 0 0 0 1.95-1.57l1.65-7.43H5.12`,key:`9zh506`}]]),be=x(`Star`,[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]),xe=x(`Upload`,[[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`polyline`,{points:`17 8 12 3 7 8`,key:`t8dd8p`}],[`line`,{x1:`12`,x2:`12`,y1:`3`,y2:`15`,key:`widbto`}]]),q=e(t(),1),J=n(),Y={h1:`text-2xl font-black text-white`,h2:`text-xl font-bold text-white`,h3:`text-base font-bold text-white`,h4:`text-sm font-semibold text-white/90`,h5:`text-xs font-semibold text-white/80`,body:`text-sm text-white/70 leading-relaxed`,caption:`text-xs text-white/40`,label:`text-xs font-semibold text-white/50 uppercase tracking-wider`,code:`font-mono text-xs text-green-300 bg-black/40 rounded-lg p-3 leading-relaxed whitespace-pre-wrap break-all`};function Se({def:e,ctx:t}){let n=y(e.text,t.dataModel,t.scopeData),r=e.variant??e.usageHint??`body`,i=Y[r]??Y.body;if(r===`code`)return(0,J.jsx)(`pre`,{className:i,children:n});let a=n.split(/(\*\*[^*]+\*\*|\*[^*]+\*|`[^`]+`|\n)/g);return(0,J.jsx)(`p`,{className:i,style:e.weight?{flex:e.weight}:void 0,children:a.map((e,t)=>e.startsWith(`**`)&&e.endsWith(`**`)?(0,J.jsx)(`strong`,{className:`font-bold`,children:e.slice(2,-2)},t):e.startsWith(`*`)&&e.endsWith(`*`)?(0,J.jsx)(`em`,{className:`italic`,children:e.slice(1,-1)},t):e.startsWith("`")&&e.endsWith("`")?(0,J.jsx)(`code`,{className:`font-mono text-green-300 bg-black/30 px-1 rounded text-[0.9em]`,children:e.slice(1,-1)},t):e===`
2
- `?(0,J.jsx)(`br`,{},t):e)})}function Ce(e,t,n,r){let i=[];for(let a of e)X(a,t,n,r)||i.push({message:a.message??`Validation failed: ${a.call}`});return{valid:i.length===0,errors:i}}function X(e,t,n,r){if(e.condition)return O(e.condition,t,n,r)===!0;let i=O({call:e.call,args:e.args??{}},t,n,r);return i===!0||i===`true`}function we(e,t,n,r){if(!e||e.length===0)return!1;for(let i of e)if(!X(i,t,n,r))return!0;return!1}function Te({def:e,ctx:t}){let n=e.action,r=e.variant??`primary`,i=e.disabled===!0||we(e.checks,t.dataModel,t.scopeData),a=r===`primary`?`bg-blue-600 hover:bg-blue-500 text-white font-bold`:r===`borderless`?`text-white/70 hover:text-white hover:bg-white/5`:`bg-white/5 hover:bg-white/10 text-white/70 border border-white/10`;return(0,J.jsx)(`button`,{onClick:()=>{if(i)return;let r=n?.event??n,a=r?.name;if(!a)return;let o={},s=r.context??{};for(let[e,n]of Object.entries(s))E(n)?o[e]=w(n.path,t.dataModel,t.scopeData):j(n)?o[e]=O(n,t.dataModel,t.scopeData):o[e]=n;t.onAction(a,o,e.id)},disabled:i,className:`w-full py-2.5 rounded-xl text-sm transition-all disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center gap-2 ${a}`,style:e.weight?{flex:e.weight}:void 0,children:e.child?(0,J.jsx)(Q,{...t,id:e.child}):y(e.text,t.dataModel,t.scopeData)||`Button`})}var Ee={start:`flex-start`,end:`flex-end`,center:`center`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`};function De({def:e,ctx:t}){return(0,J.jsx)(`div`,{className:`flex flex-row gap-2`,style:{justifyContent:Ee[String(e.justify??e.distribution??`start`)]??`flex-start`,alignItems:(()=>{let t=e.align??e.alignment;return t===`center`?`center`:t===`end`?`flex-end`:t===`stretch`?`stretch`:`flex-start`})(),...e.weight?{flex:e.weight}:{}},children:$(e.children,t)})}var Oe={start:`flex-start`,end:`flex-end`,center:`center`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`};function ke({def:e,ctx:t}){return(0,J.jsx)(`div`,{className:`flex flex-col gap-3`,style:{justifyContent:Oe[String(e.justify??e.distribution??`start`)]??`flex-start`,alignItems:(()=>{let t=e.align??e.alignment;return t===`center`?`center`:t===`end`?`flex-end`:t===`stretch`?`stretch`:`flex-start`})(),...e.weight?{flex:e.weight}:{}},children:$(e.children,t)})}function Ae({def:e,ctx:t}){return(0,J.jsx)(`div`,{className:`rounded-xl border p-4`,style:{background:`rgba(255,255,255,0.03)`,borderColor:`rgba(255,255,255,0.08)`,...e.weight?{flex:e.weight}:{}},children:e.child&&(0,J.jsx)(Q,{...t,id:e.child})})}function je({def:e,ctx:t}){let n=e.direction===`horizontal`?`flex-row`:`flex-col`;return e.children?(0,J.jsx)(`div`,{className:`flex ${n} gap-2 overflow-x-auto pb-1`,style:e.weight?{flex:e.weight}:void 0,children:$(e.children,t)}):e.child?(0,J.jsx)(Q,{...t,id:e.child}):null}function Me({def:e}){return(0,J.jsx)(`div`,{className:e.axis===`vertical`?`w-px bg-white/[0.06] self-stretch`:`h-px bg-white/[0.06] w-full`,style:e.weight?{flex:e.weight}:void 0})}var Ne={contain:`contain`,cover:`cover`,fill:`fill`,none:`none`,"scale-down":`scale-down`},Pe={icon:`w-8 h-8`,avatar:`w-12 h-12 rounded-full`,smallFeature:`w-24 h-24`,mediumFeature:`w-48 h-48`,largeFeature:`w-64 h-64`,header:`w-full h-48`};function Fe({def:e,ctx:t}){let n=y(e.url,t.dataModel,t.scopeData);if(!n)return null;let r=Ne[e.fit??`contain`]??`contain`,i=Pe[e.usageHint??``]??``,a=typeof e.alt==`string`?e.alt:``;return(0,J.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-white/[0.08] ${i}`,style:e.weight?{flex:e.weight}:void 0,children:(0,J.jsx)(`img`,{src:n,alt:a,className:`w-full max-h-64 block`,style:{objectFit:r}})})}var Ie={settings:_,home:pe,search:h,mail:te,call:ge,camera:W,calendarToday:a,star:be,check:o,close:S,delete:ie,download:c,upload:xe,edit:ee,refresh:re,send:g,share:ve,shoppingCart:ye,warning:ae,info:f,error:s,favorite:K,favoriteOff:K,folder:fe,help:G,lock:m,lockOpen:p,visibility:d,visibilityOff:u,add:ne,arrowBack:r,arrowForward:i,accountCircle:b,notifications:le,moreVert:l,moreHoriz:de,locationOn:he,payment:ue,photo:me,print:_e,person:b};function Z({def:e,ctx:t}){return(0,J.jsx)(Ie[y(e.name,t.dataModel,t.scopeData)]??G,{className:`text-white/70`,style:e.weight?{flex:e.weight}:void 0})}function Le({def:e,ctx:t}){let[n,r]=(0,q.useState)(y((typeof e.value==`object`&&e.value,e.value),t.dataModel,t.scopeData)),i=y(e.label,t.dataModel,t.scopeData),a=y(e.placeholder,t.dataModel,t.scopeData),o=e.variant??e.textFieldType??`shortText`,s=o===`code`||o===`multiline_code`,c=o===`longText`||s||o===`multiline`,l=e.checks?Ce(e.checks,t.dataModel,t.scopeData):e.validationRegexp&&n?new RegExp(e.validationRegexp).test(n)?{valid:!0,errors:[]}:{valid:!1,errors:[{message:`Formato inválido`}]}:{valid:!0,errors:[]},u=n=>{if(r(n.target.value),typeof e.value==`object`&&e.value!==null&&`path`in e.value){let r=e.value.path;t.setDataModel(e=>{let t=structuredClone(e),i=r.replace(/^\//,``).split(`/`),a=t;for(let e=0;e<i.length-1;e++)a[i[e]]??(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n.target.value,t})}},d=n=>{let r=e.action,i=(r?.event??r)?.name;i&&t.onAction(i,{value:n},e.id)},f=e=>{d(e.target.value)},p=e=>{e.key===`Enter`&&!c&&d(e.target.value)},m=`w-full rounded-xl border px-3 py-2.5 text-sm resize-none outline-none transition-all
3
- bg-white/[0.04] border-white/[0.08] focus:border-blue-500/50 focus:bg-white/[0.06]
4
- disabled:opacity-50 placeholder:text-white/20
5
- ${s?`font-mono text-green-300 leading-relaxed`:`text-white/80 leading-relaxed`}
6
- ${l.valid?``:`border-red-500/50`}`;return(0,J.jsxs)(`div`,{className:`space-y-1.5`,style:e.weight?{flex:e.weight}:void 0,children:[i&&(0,J.jsx)(`label`,{className:`text-xs font-semibold text-white/45 uppercase tracking-wider`,children:i}),c?(0,J.jsx)(`textarea`,{value:n,onChange:u,onBlur:f,onKeyDown:p,placeholder:a,rows:s?5:3,className:m}):(0,J.jsx)(`input`,{type:o===`obscured`?`password`:o===`number`?`number`:`text`,value:n,onChange:u,onBlur:f,onKeyDown:p,placeholder:a,className:m}),!l.valid&&l.errors.length>0&&(0,J.jsx)(`p`,{className:`text-xs text-red-400`,children:l.errors[0].message})]})}function Re({def:e,ctx:t}){let n=y(e.label,t.dataModel,t.scopeData),[r,i]=(0,q.useState)(A(e.value,t.dataModel,t.scopeData));return(0,J.jsxs)(`label`,{className:`flex items-center gap-2.5 cursor-pointer`,style:e.weight?{flex:e.weight}:void 0,children:[(0,J.jsx)(`input`,{type:`checkbox`,checked:r,onChange:n=>{if(i(n.target.checked),typeof e.value==`object`&&e.value!==null&&`path`in e.value){let r=e.value.path;t.setDataModel(e=>{let t=structuredClone(e),i=r.replace(/^\//,``).split(`/`),a=t;for(let e=0;e<i.length-1;e++)a[i[e]]??(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n.target.checked,t})}},className:`w-4 h-4 rounded border-white/20 bg-white/5 text-blue-500 focus:ring-blue-500/30`}),(0,J.jsx)(`span`,{className:`text-sm text-white/70`,children:n})]})}function ze({def:e,ctx:t}){let n=e.variant===`mutuallyExclusive`?`single`:`multi`,r=e.maxAllowedSelections??(n===`single`?1:5),[i,a]=(0,q.useState)(k(e.selections??e.value,t.dataModel,t.scopeData)),o=e.options??[],s=i=>{a(a=>{let o;o=n===`single`?[i]:a.includes(i)?a.filter(e=>e!==i):a.length>=r?a:[...a,i];let s=e.selections??e.value;if(typeof s==`object`&&s&&`path`in s){let e=s.path;t.setDataModel(t=>{let n=structuredClone(t),r=e.replace(/^\//,``).split(`/`),i=n;for(let e=0;e<r.length-1;e++)i[r[e]]??(i[r[e]]={}),i=i[r[e]];return i[r[r.length-1]]=o,n})}let c=e.action,l=(c?.event??c)?.name;return l&&t.onAction(l,{selections:o,selected:o[0]??null},e.id),o})};return(0,J.jsx)(`div`,{className:`space-y-2`,style:e.weight?{flex:e.weight}:void 0,children:o.map((e,n)=>{let r=y(e.label,t.dataModel,t.scopeData),a=e.value??r,o=i.includes(a),c=String.fromCharCode(65+n);return(0,J.jsxs)(`button`,{type:`button`,onClick:()=>s(a),className:`w-full text-left px-3 py-2.5 rounded-xl border text-sm transition-all flex items-center gap-2.5
7
- ${o?`bg-blue-500/15 border-blue-500/50 text-blue-100`:`bg-white/[0.03] border-white/[0.08] text-white/65 hover:border-white/20 hover:bg-white/[0.06]`}`,children:[(0,J.jsx)(`span`,{className:`text-xs font-bold w-6 h-6 rounded-lg flex items-center justify-center flex-shrink-0 transition-colors
8
- ${o?`bg-blue-500/40 text-blue-200`:`bg-white/5 text-white/40`}`,children:o?`✓`:c}),(0,J.jsx)(`span`,{className:`leading-snug`,children:r})]},n)})})}function Be({def:e,ctx:t}){let n=typeof e.min==`number`?e.min:e.minValue??0,r=typeof e.max==`number`?e.max:e.maxValue??100,i=typeof e.step==`number`?e.step:1,a=e.label,[o,s]=(0,q.useState)(C(e.value,t.dataModel,t.scopeData)),c=n=>{if(typeof e.value==`object`&&e.value!==null&&`path`in e.value){let r=e.value.path;t.setDataModel(e=>{let t=structuredClone(e),i=r.replace(/^\//,``).split(`/`),a=t;for(let e=0;e<i.length-1;e++)a[i[e]]??(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n,t})}};return(0,J.jsxs)(`div`,{className:`space-y-2`,style:e.weight?{flex:e.weight}:void 0,children:[a&&(0,J.jsx)(`span`,{className:`text-xs font-semibold text-white/45 uppercase tracking-wider`,children:a}),(0,J.jsxs)(`div`,{className:`flex justify-between text-xs text-white/40`,children:[(0,J.jsx)(`span`,{children:n}),(0,J.jsx)(`span`,{className:`text-white/70 font-mono`,children:o}),(0,J.jsx)(`span`,{children:r})]}),(0,J.jsx)(P,{value:[o],min:n,max:r,step:i,onValueChange:e=>{s(e[0]),c(e[0])},onValueCommit:n=>{let r=n[0],i=e.action,a=(i?.event??i)?.name;a&&t.onAction(a,{value:r},e.id)},className:`w-full`})]})}function Ve({def:e,ctx:t}){let[n,r]=(0,q.useState)(``),i=n=>{if(r(n.target.value),typeof e.value==`object`&&e.value!==null&&`path`in e.value){let r=e.value.path;t.setDataModel(e=>{let t=structuredClone(e),i=r.replace(/^\//,``).split(`/`),a=t;for(let e=0;e<i.length-1;e++)a[i[e]]??(a[i[e]]={}),a=a[i[e]];return a[i[i.length-1]]=n.target.value,t})}},a=e.enableTime&&e.enableDate?`datetime-local`:e.enableDate?`date`:`time`;return(0,J.jsxs)(`div`,{className:`space-y-1.5`,style:e.weight?{flex:e.weight}:void 0,children:[e.label&&(0,J.jsx)(`label`,{className:`text-xs font-semibold text-white/45 uppercase tracking-wider`,children:typeof e.label==`string`?e.label:String(e.label)}),(0,J.jsx)(`input`,{type:a,value:n,onChange:i,className:`w-full rounded-xl border px-3 py-2.5 text-sm bg-white/[0.04] border-white/[0.08] focus:border-blue-500/50 focus:bg-white/[0.06] outline-none text-white/80`})]})}function He({def:e,ctx:t}){let n=Array.isArray(e.tabs)?e.tabs:e.tabItems??[];return(0,J.jsxs)(R,{defaultValue:n[0]?.title?y(n[0].title,t.dataModel,t.scopeData):``,style:e.weight?{flex:e.weight}:void 0,children:[(0,J.jsx)(L,{className:`w-full`,children:n.map((e,n)=>(0,J.jsx)(F,{value:y(e.title,t.dataModel,t.scopeData),children:y(e.title,t.dataModel,t.scopeData)},n))}),n.map((e,n)=>(0,J.jsx)(I,{value:y(e.title,t.dataModel,t.scopeData),children:(0,J.jsx)(Q,{...t,id:e.child})},n))]})}function Ue({def:e,ctx:t}){let[n,r]=(0,q.useState)(!1);return(0,J.jsxs)(U,{open:n,onOpenChange:r,children:[(e.trigger??e.entryPointChild)&&(0,J.jsx)(z,{asChild:!0,children:(0,J.jsx)(`div`,{className:`cursor-pointer`,children:(0,J.jsx)(Q,{...t,id:e.trigger??e.entryPointChild})})}),(0,J.jsxs)(V,{children:[(0,J.jsx)(H,{className:`sr-only`,children:`Interactive modal`}),(0,J.jsx)(B,{className:`sr-only`,children:`Interactive modal content generated by the agent.`}),(e.content??e.contentChild)&&(0,J.jsx)(Q,{...t,id:e.content??e.contentChild})]})]})}function We({def:e,ctx:t}){let n=y(e.url,t.dataModel,t.scopeData);return n?(0,J.jsx)(`div`,{className:`rounded-xl overflow-hidden border border-white/[0.08]`,style:e.weight?{flex:e.weight}:void 0,children:(0,J.jsx)(`video`,{src:n,controls:!0,className:`w-full max-h-96`,children:`Tu navegador no soporta video.`})}):null}function Ge({def:e,ctx:t}){let n=y(e.url,t.dataModel,t.scopeData),r=y(e.description,t.dataModel,t.scopeData);return n?(0,J.jsxs)(`div`,{className:`rounded-xl border border-white/[0.08] p-4 bg-white/[0.02]`,style:e.weight?{flex:e.weight}:void 0,children:[r&&(0,J.jsx)(`p`,{className:`text-xs text-white/40 mb-2`,children:r}),(0,J.jsx)(`audio`,{src:n,controls:!0,className:`w-full`,style:{height:40},children:`Tu navegador no soporta audio.`})]}):null}function Ke({surface:e,onAction:t,isLoading:n}){let{components:r,dataModel:i,rootId:a,theme:o}=e,[s,c]=(0,q.useState)(()=>structuredClone(i));(0,q.useEffect)(()=>{c(structuredClone(i))},[i]);let l=(0,q.useMemo)(()=>{let e=new Map;for(let t of r)e.set(t.id,t);return e},[r]),u=o?.primaryColor||`#3B82F6`,d=(0,q.useCallback)((n,r,i)=>{t&&t({name:n,surfaceId:e.surfaceId,sourceComponentId:i,timestamp:new Date().toISOString(),context:r})},[t,e.surfaceId]);return n?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,J.jsx)(`span`,{className:`text-white/30 text-sm animate-pulse`,children:`Cargando superficie...`})}):!a||!l.has(a)?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8 text-white/20 text-sm`,children:`Sin contenido disponible`}):(0,J.jsx)(`div`,{className:`a2ui-surface`,style:{"--a2ui-primary":u},children:(0,J.jsx)(Q,{id:a,compMap:l,dataModel:s,setDataModel:c,scopeData:void 0,onAction:d})})}function Q(e){let t=e.compMap.get(e.id);if(!t)return null;let n=t.component?.replace(/[^\x00-\x7F]/g,``).trim();switch(n){case`Text`:return(0,J.jsx)(Se,{def:t,ctx:e});case`Button`:return(0,J.jsx)(Te,{def:t,ctx:e});case`Row`:return(0,J.jsx)(De,{def:t,ctx:e});case`Column`:return(0,J.jsx)(ke,{def:t,ctx:e});case`Card`:return(0,J.jsx)(Ae,{def:t,ctx:e});case`List`:return(0,J.jsx)(je,{def:t,ctx:e});case`Divider`:return(0,J.jsx)(Me,{def:t,ctx:e});case`Image`:return(0,J.jsx)(Fe,{def:t,ctx:e});case`Icon`:return(0,J.jsx)(Z,{def:t,ctx:e});case`TextField`:return(0,J.jsx)(Le,{def:t,ctx:e});case`CheckBox`:return(0,J.jsx)(Re,{def:t,ctx:e});case`ChoicePicker`:return(0,J.jsx)(ze,{def:t,ctx:e});case`Slider`:return(0,J.jsx)(Be,{def:t,ctx:e});case`DateTimeInput`:return(0,J.jsx)(Ve,{def:t,ctx:e});case`Tabs`:return(0,J.jsx)(He,{def:t,ctx:e});case`Modal`:return(0,J.jsx)(Ue,{def:t,ctx:e});case`Video`:return(0,J.jsx)(We,{def:t,ctx:e});case`AudioPlayer`:return(0,J.jsx)(Ge,{def:t,ctx:e});default:return(0,J.jsxs)(`div`,{className:`rounded-md border border-dashed border-white/10 px-3 py-2 text-xs text-white/30`,children:[`Unknown component: `,n]})}}function $(e,t){if(!e)return[];if(typeof e==`string`)return[(0,J.jsx)(Q,{...t,id:e},e)];if(Array.isArray(e))return e.map(e=>(0,J.jsx)(Q,{...t,id:e},e));if(`explicitList`in e||`array`in e)return(`explicitList`in e?e.explicitList:e.array).map(e=>(0,J.jsx)(Q,{...t,id:e},e));if(`path`in e&&`componentId`in e){let n=e,r=w(n.path,t.dataModel,t.scopeData);return Array.isArray(r)?r.map((e,r)=>{let i=typeof e==`object`&&e?e:{value:e,index:r};return(0,J.jsx)(Q,{...t,id:n.componentId,scopeData:i},`${n.componentId}_${r}`)}):[]}if(`template`in e){let n=e.template,r=w(n.dataBinding,t.dataModel,t.scopeData);return Array.isArray(r)?r.map((e,r)=>{let i=typeof e==`object`&&e?e:{value:e,index:r};return(0,J.jsx)(Q,{...t,id:n.componentId,scopeData:i},`${n.componentId}_${r}`)}):[]}return[]}function qe(){let e=T(e=>e.a2uiSurfaces),t=T(e=>e.sendA2UIAction),n=(0,q.useCallback)(e=>{t(e)},[t]),r=Array.from(e.values());return(0,J.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden`,style:{backgroundImage:`radial-gradient(circle, rgba(59,130,246,0.03) 1px, transparent 1px)`,backgroundSize:`40px 40px`},children:[r.length===0?(0,J.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 text-white/20`,children:[(0,J.jsx)(v,{className:`h-10 w-10 opacity-30`}),(0,J.jsx)(`p`,{className:`text-sm`,children:`Sin paneles interactivos activos`}),(0,J.jsx)(`p`,{className:`text-xs text-white/15`,children:`Los resultados y formularios creados por los agentes aparecerán aquí.`})]}):(0,J.jsx)(N,{className:`flex-1 p-6`,children:r.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:r.map(e=>(0,J.jsxs)(`div`,{className:`rounded-xl border border-blue-500/20 bg-[rgba(255,255,255,0.02)] backdrop-blur-sm p-4`,style:e.theme?.primaryColor?{borderColor:`${e.theme.primaryColor}33`}:void 0,children:[e.theme?.agentDisplayName&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-3 pb-3 border-b border-white/5`,children:[e.theme.iconUrl&&(0,J.jsx)(`img`,{src:e.theme.iconUrl,alt:``,className:`w-5 h-5 rounded-full`}),(0,J.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider`,style:{color:e.theme.primaryColor??`#93c5fd`},children:e.theme.agentDisplayName})]}),(0,J.jsx)(Ke,{surface:e,onAction:n})]},e.surfaceId))})}),(0,J.jsx)(`div`,{className:`border-t border-white/5 bg-white/[0.02] px-6 py-2.5`,children:(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(v,{className:`h-3 w-3 text-blue-400/50`}),(0,J.jsx)(`span`,{className:`hive-mono`,children:r.length>0?`${r.length} superficie${r.length>1?`s`:``} A2UI activa${r.length>1?`s`:``}`:`Panel interactivo · sin superficies`})]})})]})}function Je(){let{sessionId:e}=ce(),{currentUser:t}=D(),n=T(e=>e.isConnected),r=T(e=>e.markA2UISeen),i=e&&e!==`default`?e:t?.id;return(0,q.useEffect)(()=>{r()},[r]),i?(0,J.jsx)(`div`,{className:`flex h-[calc(100vh-4rem)] flex-col bg-background/50 backdrop-blur-sm`,children:(0,J.jsx)(`div`,{className:`flex-1 overflow-hidden p-4 lg:p-8`,children:(0,J.jsx)(`div`,{className:`mx-auto h-full max-w-7xl`,children:(0,J.jsxs)(`div`,{className:`hive-card flex h-full flex-col shadow-2xl`,children:[(0,J.jsxs)(`div`,{className:`flex flex-row items-center justify-between space-y-0 border-b border-white/5 bg-white/5 px-6 py-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`div`,{className:`hive-icon-wrap hive-icon-wrap--primary`,children:(0,J.jsx)(v,{className:`h-5 w-5`})}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h2`,{className:`hive-title-page !text-lg`,children:`Panel interactivo`}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-white/40 mt-0.5`,children:[(0,J.jsx)(b,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:i})]})]})]}),(0,J.jsx)(M,{variant:`outline`,className:`flex items-center gap-1.5 px-3 py-1 transition-all duration-500 border ${n?`bg-emerald-500/15 text-emerald-500 border-emerald-500/20 hover:bg-emerald-500/20`:`bg-red-500/15 text-red-500 border-red-500/20 hover:bg-red-500/20`}`,children:n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(se,{className:`h-3.5 w-3.5 animate-pulse`}),(0,J.jsx)(`span`,{className:`font-semibold uppercase tracking-wider text-[10px]`,children:`Live`})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(oe,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{className:`font-semibold uppercase tracking-wider text-[10px]`,children:`Offline`})]})})]}),(0,J.jsx)(qe,{})]})})})}):(0,J.jsx)(`div`,{className:`flex h-[calc(100vh-4rem)] items-center justify-center`,children:(0,J.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,J.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-primary border-t-transparent`}),(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Cargando sesión...`})]})})}export{Je as A2UIPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./vendor-query-Dj8xYhQD.js";import{t}from"./AgentCreateForm-M2RhjeA1.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
@@ -1,9 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./activity-BIIli7ET.js";import{t as i}from"./calendar-S9-_Q6QR.js";import{t as a}from"./check-CryV78SQ.js";import{t as o}from"./chevron-down-QCtMs-Af.js";import{t as s}from"./chevron-up-Cg0jO8uT.js";import{t as c}from"./circle-alert-DTVW4R94.js";import{t as l}from"./circle-check-BAolxswA.js";import{n as u,t as d}from"./earth-CTsVjCmp.js";import{t as f}from"./copy-X_TPpA-A.js";import{t as p}from"./useProviders-q6iROeWE.js";import{n as m,t as h}from"./eye-CM-HQEWU.js";import{t as g}from"./history-eSHspWRr.js";import{t as _}from"./info-DTgFQ_jA.js";import{n as v,t as y}from"./key-CeM9JJkq.js";import{t as b}from"./loader-circle-Dtfz4FWw.js";import{n as x,t as S}from"./pencil-6PRgdjiU.js";import{t as C}from"./mail--gNFIe4M.js";import{t as w}from"./pause-DjT1nwQM.js";import{t as T}from"./play-tOrP0xUJ.js";import{t as E}from"./plus-Cnom3j47.js";import{t as D}from"./refresh-cw-BRrzoHQW.js";import{t as O}from"./search-D277MUP0.js";import{t as ee}from"./send-DIlj81PT.js";import{t as k}from"./shield-U0hIjGzm.js";import{t as A}from"./sparkles-VXHGDbNh.js";import{t as j}from"./terminal-C6YPcJl_.js";import{t as te}from"./trash-2-DQxm7DUM.js";import{t as M}from"./triangle-alert-Dj8ZhmWj.js";import{t as N}from"./zap-BEZNJ0i0.js";import{n as ne}from"./utils-Dyb7SC2_.js";import{l as re}from"./vendor-router-zpB-76nT.js";import{r as P}from"./gateway-url-BlnabM5e.js";import{F,G as ie,H as I,I as L,K as R,L as ae,M as oe,N as se,O as z,P as ce,R as le,U as ue,V as de,W as fe,a as pe,c as me,d as he,f as B,h as V,k as H,l as ge,m as U,p as W,z as _e}from"./index-ZjAc-KQS.js";import{t as ve}from"./badge-DKGZbVZJ.js";import{t as ye}from"./scroll-area-CfHn94Vb.js";import{a as be,c as xe,i as G,o as Se,r as Ce,s as we,t as Te}from"./dialog-uUBz_NIB.js";import{t as K}from"./label-k0jYxoWW.js";import{t as Ee}from"./textarea-rp6vsOZl.js";import{i as q,n as J,o as Y,s as X,t as Z}from"./select-BOR8MsSL.js";import{t as De}from"./switch-DXcELPsM.js";import{a as Oe,i as ke,n as Ae,r as je,t as Me}from"./card-D3Nw3kh3.js";var Ne=R(`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`}]]),Pe=R(`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`}]]),Fe=R(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Ie=R(`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`}]]),Le=R(`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`}]]),Re=R(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),ze=R(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Be=R(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Ve=R(`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`}]]),He=R(`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`}]]),Ue=R(`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`}]]),Q=e(t(),1),We=P((e,t)=>({isLoading:!1,error:null,configs:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await B(`/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 B(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await B(`/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}},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:ne(),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 Ge(){let{configs:e,fetchEthics:t,isLoading:n}=We(),[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=>{V.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>B(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);W.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){W.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{V.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)(b,{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)(k,{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)(M,{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,$.jsxs)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:[`No se detectaron lineamientos éticos en el sistema. Esto no debería ocurrir en una instalación completa — verifica la conexión con el gateway o ejecuta `,(0,$.jsx)(`code`,{children:`hive doctor`}),`.`]})]})]})}):(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)(ae,{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)(Te,{open:a,onOpenChange:o,children:(0,$.jsx)(Ce,{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)(k,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(we,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(G,{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)(K,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(z,{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)(K,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(z,{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)(K,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(Ee,{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),V.show(`Guardando lineamientos éticos...`);try{let e=await B(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),W.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){W.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),V.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var Ke={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`};function qe(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=ge(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[f,p]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let m=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),W.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{W.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},h=async()=>{if(s){p(!0),V.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),W.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{W.fire({icon:`error`,title:`Error al guardar cambios`})}finally{p(!1),V.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)(b,{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)(se,{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`,`cli`,`agents`,`a2ui`].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`:Ke[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)(M,{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)(d,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(d,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(O,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(j,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(Ve,{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)(De,{checked:t,onCheckedChange:()=>m(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)(Te,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(Ce,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsxs)(we,{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)(Ve,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(G,{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)(K,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(z,{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)(K,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(Ee,{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)(ve,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(be,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(H,{size:`sm`,onClick:h,disabled:f,className:`hive-btn--form-submit h-10`,children:[f&&(0,$.jsx)(b,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function Je({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(Me,{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)(ke,{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)(p,{className:`h-5 w-5`}):(0,$.jsx)(I,{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)(ve,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Oe,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(je,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(Ae,{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)(ve,{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 Ye({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)(O,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(z,{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)(Ie,{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)(ve,{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)(_,{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 Xe(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 Ze({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=pe(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[c,l]=(0,Q.useState)(e.command||``),[u,d]=(0,Q.useState)(e.args?.join(` `)||``),[f,p]=(0,Q.useState)(e.url||``),[m,h]=(0,Q.useState)(()=>Xe(e.headers).authType),[g,_]=(0,Q.useState)(()=>Xe(e.headers).authToken),[v,S]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),[ee,k]=(0,Q.useState)(!0),[A,M]=(0,Q.useState)(!1),[N,ne]=(0,Q.useState)(`config`),[re,P]=(0,Q.useState)(e.status),[F,ie]=(0,Q.useState)(e.active),L=re===`connected`||F===1||F===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{k(!0);try{let n=await B(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),l(n.command||``),d(Array.isArray(n.args)?n.args.join(` `):``),p(n.url||``);let r=Xe(n.headers);h(r.authType),_(r.authToken),S(n.headers?JSON.stringify(n.headers,null,2):``),P(n.status||e.status),ie(+!!n.enabled)}catch{}finally{t||k(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Te,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(Ce,{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)(Se,{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 ${L?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Ve,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(we,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,L&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(G,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(H,{variant:`ghost`,size:`icon`,onClick:()=>M(!0),disabled:T||A,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:()=>ne(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${N===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,N===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>ne(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${N===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,N===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),A&&(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)(H,{variant:`ghost`,size:`sm`,onClick:()=>M(!1),disabled:T,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(H,{size:`sm`,onClick:async()=>{E(!0);try{await B(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{E(!1),M(!1)}},disabled:T,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:T?(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:N===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[ee&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(Z,{value:o,onValueChange:s,children:[(0,$.jsx)(Y,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(q,{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)(j,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(q,{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)(I,{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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(z,{value:c,onChange:e=>l(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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(z,{value:u,onChange:e=>d(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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(z,{value:f,onChange:e=>p(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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(q,{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)(I,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(q,{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)(y,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(q,{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)(He,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(q,{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)(Fe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(x,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:v,onChange:e=>S(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 ${L?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Be,{className:`h-3.5 w-3.5 ${L?`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 ${L?`text-green-500`:`text-zinc-500`}`,children:L?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(H,{size:`sm`,variant:L?`outline`:`default`,onClick:async()=>{O(!0),V.show(L?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!L),ie(+!L),P(L?`disconnected`:`connected`),W.fire({icon:`success`,title:L?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{W.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{O(!1),V.hide()}},disabled:D,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${L?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:D?(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}):L?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(Ye,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(be,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(H,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),N===`config`&&(0,$.jsx)(H,{onClick:async()=>{w(!0),V.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){W.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=u.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(!f){W.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=f;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{W.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(),W.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){W.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{w(!1),V.hide()}},disabled:C,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:C?(0,$.jsx)(b,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function Qe(){let{fetchMCPServers:e}=pe(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`stdio`),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`none`),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(!1);return(0,$.jsxs)(Te,{open:t,onOpenChange:n,children:[(0,$.jsx)(xe,{asChild:!0,children:(0,$.jsxs)(H,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(E,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(Ce,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(Se,{children:[(0,$.jsxs)(we,{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)(le,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(G,{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)(K,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(z,{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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(Z,{value:u,onValueChange:d,children:[(0,$.jsx)(Y,{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)(X,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(J,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(q,{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)(j,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(q,{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)(I,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),u===`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)(K,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(z,{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)(K,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(z,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>c(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)(K,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(z,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:f,onChange:e=>p(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)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{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)(X,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(J,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(q,{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)(I,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(q,{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)(y,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(q,{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)(He,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(q,{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)(y,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(q,{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)(Fe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`google-api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(K,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:m===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(x,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`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)(K,{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:v,onChange:e=>{let t=e.target.value;b(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)(l,{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)(be,{children:[(0,$.jsx)(H,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(H,{onClick:async()=>{if(!r){W.fire({icon:`error`,title:`El nombre es obligatorio`});return}C(!0);try{let t={transport:u};if(u===`stdio`){if(!a){W.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),C(!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(!f){W.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),C(!1);return}t.url=f;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`google-api-key`&&g)e[`X-Goog-Api-Key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{U.fire(`Error`,`JSON de Headers inválido`,`error`),C(!1);return}Object.keys(e).length>0&&(t.headers=e)}await B(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),W.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),p(``),h(`none`),_(``),b(``),n(!1),await e()}catch{}finally{C(!1)}},disabled:S,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:S?`Conectando...`:`Conectar Servidor`})]})]})]})}function $e(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=pe(),[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)(le,{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)(O,{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)(z,{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)(Qe,{})]})]}),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)(M,{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)(Je,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(Ze,{server:i,onClose:()=>a(null)})]})}var et=P((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 B(`/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 B(t?`/api/cron?status=${t}`:`/api/cron`)).tasks??[],isLoading:!1})}catch(t){e({error:t.message,isLoading:!1,scheduledTasks:[]})}},pauseTask:async t=>{try{await B(`/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 B(`/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 B(`/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 B(`/api/cron/${t}/trigger`,{method:`POST`})}catch(t){e({error:t.message})}},fetchTaskHistory:async(t,n=10)=>{try{let r=await B(`/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 B(`/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:t.preference??`auto`})}catch{}},saveCronChannelPreference:async t=>{try{await B(`/api/user/settings`,{method:`PATCH`,body:{preferred_cron_channel:t}}),e({cronUserPreference:t})}catch(t){e({error:t.message})}}}));function tt({email:e,profileEditing:t=!1}){let[n,r]=(0,Q.useState)(!1),[i,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(!1),[d,p]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(``),[S,C]=(0,Q.useState)(``),[w,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(!1),[O,ee]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{j()},[]);async function j(){c(!0);try{let e=await B(`/api/auth/status`);r(e.hasCredentials),o(e.email??``)}catch{}finally{c(!1)}}async function te(){if(!t){u(!0);try{p((await B(`/api/auth/recovery-key`)).recoveryKey)}catch{}}}function M(){x(``),C(``),T(``)}async function N(e){if(e.preventDefault(),y!==S){await U.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(y.length<8){await U.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}A(!0);try{n?await B(`/api/auth/change-password`,{method:`POST`,body:{currentPassword:w,newPassword:y}}):await B(`/api/auth/setup-credentials`,{method:`POST`,body:{password:y}}),await U.fire({icon:`success`,title:n?`Contraseña actualizada`:`Protección activada`,timer:2200,showConfirmButton:!1,toast:!0,position:`top-end`}),M(),u(!1),await j()}catch{}finally{A(!1)}}async function ne(){if((await U.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 B(`/api/auth/disable`,{method:`POST`}),await U.fire({icon:`success`,title:`Protección desactivada`,timer:1800,showConfirmButton:!1,toast:!0,position:`top-end`}),r(!1),o(``),M(),u(!1)}catch{}}async function re(){d&&(await navigator.clipboard.writeText(d),_(!0),window.setTimeout(()=>_(!1),2e3))}let P=i||e.trim().toLowerCase();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border p-3.5 sm:flex-row sm:items-center sm:justify-between`,style:{background:`hsl(var(--hive-glass))`,borderColor:n?`hsl(var(--hive-green) / 0.25)`:`hsl(var(--hive-border-base))`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 rounded-lg border p-2`,style:{color:n?`hsl(var(--hive-green))`:`hsl(var(--hive-amber))`,background:n?`hsl(var(--hive-green) / 0.08)`:`hsl(var(--hive-amber) / 0.08)`,borderColor:n?`hsl(var(--hive-green) / 0.18)`:`hsl(var(--hive-amber) / 0.18)`},children:n?(0,$.jsx)(He,{className:`h-4 w-4`}):(0,$.jsx)(Ue,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-bold text-white`,children:`Acceso con contraseña`}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate text-[11px]`,style:{color:`hsl(var(--hive-text-muted))`},children:s?`Comprobando protección…`:n?`Protegido · ${P}`:P?`Sin contraseña · ${P}`:`Guarda un correo válido para activar la protección`})]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void te(),disabled:s||t||!P,className:`flex h-9 flex-shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 text-[11px] font-bold transition-colors disabled:cursor-not-allowed disabled:opacity-45`,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)(v,{className:`h-3.5 w-3.5`}),t?`Guarda el perfil primero`:n?`Gestionar acceso`:`Crear contraseña`]})]}),(0,$.jsx)(Te,{open:l,onOpenChange:e=>{u(e),e||M()},children:(0,$.jsxs)(Ce,{className:`overflow-hidden rounded-2xl p-0`,style:{background:`hsl(var(--hive-surface))`,borderColor:`hsl(var(--hive-border-base))`},children:[(0,$.jsx)(`div`,{className:`border-b px-6 py-5`,style:{background:`linear-gradient(135deg, hsl(var(--hive-amber) / 0.12), transparent 65%)`,borderColor:`hsl(var(--hive-border-subtle))`},children:(0,$.jsxs)(Se,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex h-10 w-10 items-center justify-center rounded-xl border`,style:{color:`hsl(var(--hive-amber))`,background:`hsl(var(--hive-amber) / 0.1)`,borderColor:`hsl(var(--hive-amber) / 0.25)`},children:(0,$.jsx)(Re,{className:`h-5 w-5`})}),(0,$.jsx)(we,{children:n?`Cambiar contraseña`:`Proteger tu instancia`}),(0,$.jsxs)(G,{children:[`Tu identidad de acceso será `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:P}),`.`]})]})}),(0,$.jsxs)(`form`,{onSubmit:N,className:`space-y-4 px-6 pb-6`,children:[n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-current-password`,children:`Contraseña actual`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{id:`profile-current-password`,type:E?`text`:`password`,autoComplete:`current-password`,value:w,onChange:e=>T(e.target.value),required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":E?`Ocultar contraseña actual`:`Mostrar contraseña actual`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>D(e=>!e),children:E?(0,$.jsx)(m,{className:`h-4 w-4`}):(0,$.jsx)(h,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-new-password`,children:n?`Nueva contraseña`:`Contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(z,{id:`profile-new-password`,type:O?`text`:`password`,autoComplete:`new-password`,placeholder:`Mínimo 8 caracteres`,value:y,onChange:e=>x(e.target.value),minLength:8,required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":O?`Ocultar contraseña nueva`:`Mostrar contraseña nueva`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>ee(e=>!e),children:O?(0,$.jsx)(m,{className:`h-4 w-4`}):(0,$.jsx)(h,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-confirm-password`,children:`Confirmar contraseña`}),(0,$.jsx)(z,{id:`profile-confirm-password`,type:O?`text`:`password`,autoComplete:`new-password`,value:S,onChange:e=>C(e.target.value),minLength:8,required:!0,disabled:k})]}),d&&(0,$.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`hsl(var(--hive-glass))`,borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsx)(`p`,{className:`text-[11px] font-bold`,children:`Clave de recuperación`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:`Guárdala fuera de este equipo por si olvidas tu contraseña.`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-md bg-black/20 px-2.5 py-2 text-[10px]`,children:d}),(0,$.jsx)(H,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Copiar clave de recuperación`,onClick:()=>void re(),children:g?(0,$.jsx)(a,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(f,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(be,{className:`gap-2 pt-1 sm:justify-between`,children:[n?(0,$.jsx)(H,{type:`button`,variant:`ghost`,className:`text-destructive`,onClick:()=>void ne(),disabled:k,children:`Desactivar protección`}):(0,$.jsx)(`span`,{}),(0,$.jsxs)(H,{type:`submit`,disabled:k,children:[k&&(0,$.jsx)(b,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Actualizar contraseña`:`Activar protección`]})]})]})]})})]})}var nt=()=>(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)`})]}),rt=({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)`}})]})},it=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(de,{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})]}),at=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),ot=({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]}),st=({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]});function ct(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function lt(){let{fetchUser:e,saveUser:t,isLoading:n}=he(),{cronChannels:r,fetchCronChannels:i}=et(),[o,s]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)({name:``,email:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[u,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,email:e.email||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};l(t),d(t)}).catch(console.error),i()},[e,i]);let f=(e,t)=>l(n=>({...n,[e]:t})),p=()=>{u&&l(u),s(!1)},m=async()=>{let e=c.email.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){W.fire({icon:`error`,title:`Ingresa un correo válido`});return}V.show(`Guardando perfil...`);try{let n={...c,email:e},r=await t(n);l(n),d(n),W.fire({icon:`success`,title:r}),s(!1)}catch(e){W.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{V.hide()}},h=r.filter(e=>e.active),g=c.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:h.find(e=>e.id===c.preferred_cron_channel)?.type??c.preferred_cron_channel,_=ct(c.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)(nt,{}),(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)(rt,{initials:_,size:`sm`})}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)(rt,{initials:_,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:c.name||(0,$.jsx)(`span`,{className:`text-sm font-normal italic`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Sin nombre`})}),c.occupation&&(0,$.jsx)(`p`,{className:`text-xs`,style:{color:`hsl(var(--hive-text-muted))`},children:c.occupation}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 lg:justify-center pt-0.5`,children:[c.language&&(0,$.jsx)(ot,{icon:I,label:c.language,colorVar:`--hive-blue`}),c.timezone&&(0,$.jsx)(ot,{icon:ue,label:c.timezone,colorVar:`--hive-blue`}),c.preferred_cron_channel!==`auto`&&(0,$.jsx)(ot,{icon:ie,label:c.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:fe,label:`Agente`,value:`Activo`,colorVar:`--hive-green`},{icon:I,label:`Idioma`,value:c.language||`—`,colorVar:`--hive-blue`},{icon:ue,label:`Zona`,value:c.timezone||`—`,colorVar:`--hive-blue`},{icon:N,label:`Canal`,value:g.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)(F,{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:()=>o?p():s(!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:o?{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:[o?(0,$.jsx)(oe,{className:`h-3 w-3`}):(0,$.jsx)(S,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:o?`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)(it,{children:`Identidad`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(st,{label:`Nombre completo`,icon:F,editing:o,children:(0,$.jsx)(z,{placeholder:`John Doe`,value:c.name,disabled:!o,onChange:e=>f(`name`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(st,{label:`Ocupación`,icon:Ne,editing:o,children:(0,$.jsx)(z,{placeholder:`AI Engineer`,value:c.occupation,disabled:!o,onChange:e=>f(`occupation`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,$.jsx)(st,{label:`Correo propio`,icon:C,editing:o,children:(0,$.jsx)(z,{type:`email`,autoComplete:`email`,placeholder:`tu@correo.com`,maxLength:254,required:!0,value:c.email,disabled:!o,onChange:e=>f(`email`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px]`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`El coordinador lo usa como destinatario cuando dices «envíame».`})]})]})]}),(0,$.jsx)(at,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(it,{children:`Acceso y seguridad`}),(0,$.jsx)(tt,{email:c.email,profileEditing:o})]}),(0,$.jsx)(at,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(it,{children:`Localización`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(st,{label:`Idioma`,icon:I,editing:o,children:(0,$.jsx)(z,{placeholder:`Spanish`,value:c.language,disabled:!o,onChange:e=>f(`language`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(st,{label:`Zona horaria`,icon:ue,editing:o,children:(0,$.jsx)(z,{placeholder:`America/Bogota`,value:c.timezone,disabled:!o,onChange:e=>f(`timezone`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})})]})]}),(0,$.jsx)(at,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(it,{children:`Notificaciones`}),(0,$.jsx)(st,{label:`Canal para Cron Jobs`,icon:ie,editing:o,children:(0,$.jsxs)(Z,{value:c.preferred_cron_channel,onValueChange:e=>f(`preferred_cron_channel`,e),disabled:!o,children:[(0,$.jsx)(Y,{className:`hive-select-trigger h-9 text-sm rounded-lg disabled:opacity-50`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`hive-select-content`,children:[(0,$.jsx)(q,{value:`auto`,className:`hive-select-item text-sm`,children:`Auto — detectar mejor canal`}),h.map(e=>(0,$.jsx)(q,{value:e.id,className:`hive-select-item text-sm`,children:e.id===`webchat`?`Web Chat`:e.id===`telegram`?`Telegram`:e.id===`discord`?`Discord`:e.id===`slack`?`Slack`:e.id===`whatsapp`?`WhatsApp`:e.id},e.id))]})]})})]}),(0,$.jsx)(at,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(it,{children:`Contexto para el agente`}),(0,$.jsx)(Ee,{placeholder:`Describe tu perfil, preferencias de trabajo, estilo de comunicación...`,value:c.notes,disabled:!o,onChange:e=>f(`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:o?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:p,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)(oe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancelar`})]}),(0,$.jsxs)(`button`,{onClick:m,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)(b,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(a,{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:()=>s(!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)(S,{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 ut=e=>{let t=e.toLowerCase();return t.includes(`code`)||t.includes(`program`)?(0,$.jsx)(u,{className:`h-5 w-5`}):t.includes(`research`)||t.includes(`investiga`)?(0,$.jsx)(O,{className:`h-5 w-5`}):t.includes(`write`)||t.includes(`escrib`)?(0,$.jsx)(_e,{className:`h-5 w-5`}):t.includes(`data`)||t.includes(`anal`)||t.includes(`estad`)?(0,$.jsx)(Pe,{className:`h-5 w-5`}):t.includes(`trans`)||t.includes(`traduc`)?(0,$.jsx)(Le,{className:`h-5 w-5`}):t.includes(`web`)||t.includes(`glob`)||t.includes(`scrape`)?(0,$.jsx)(I,{className:`h-5 w-5`}):t.includes(`tool`)||t.includes(`herram`)?(0,$.jsx)(se,{className:`h-5 w-5`}):t.includes(`cpu`)||t.includes(`proc`)?(0,$.jsx)(p,{className:`h-5 w-5`}):(0,$.jsx)(N,{className:`h-5 w-5`})},dt=e=>e?e.split(`,`).filter(Boolean).length:0,ft=e=>e?e.split(`,`).filter(Boolean).length:0;function pt({skill:e,onClick:t,className:n}){let r=!!e.active,i=dt(e.tools),a=ft(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:ut(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)(A,{className:`h-3 w-3 text-blue-400`})})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${r?`bg-blue-500`:`bg-white/5`}`})]})}var mt={name:``,body:``,tools:``,triggers:``,category:``,version:1,active:!0};function ht(){let{skills:e,isLoading:t,fetchSkills:n,toggleSkill:r,updateSkill:i}=me(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`TODOS`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(mt),[g,v]=(0,Q.useState)(null),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),D=(0,Q.useRef)(null),ee=()=>{let e=D.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{(l||d)&&setTimeout(ee,0)},[l,d,m.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]),j=(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]),M=e.filter(e=>e.active).length,N=async(e,t)=>{if(!g){v(e);try{await r(e,t),await n(),W.fire({icon:`success`,title:t?`Skill habilitado`:`Skill deshabilitado`})}catch{W.fire({icon:`error`,title:`Error al cambiar estado del skill`})}finally{v(null)}}},ne=async()=>{if(l){T(!0);try{await B(`/api/skills/${l.id}`,{method:`DELETE`,showError:!0}),W.fire({icon:`success`,title:`Skill eliminado`}),n(),u(null)}catch{W.fire({icon:`error`,title:`Error al eliminar skill`})}finally{T(!1),C(!1)}}},re=e=>{f(!1),C(!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})},P=()=>{u(null),C(!1),h(mt),f(!0)},F=()=>{u(null),f(!1),C(!1)},ie=async()=>{x(!0),V.show(d?`Creando skill...`:`Guardando skill...`);try{d?(await B(`/api/skills`,{method:`POST`,body:m,showError:!0}),W.fire({icon:`success`,title:`Skill creado correctamente`})):l&&(await i(l.id,m),W.fire({icon:`success`,title:`Skill actualizado correctamente`})),n(),F()}catch{W.fire({icon:`error`,title:d?`Error al crear skill`:`Error al actualizar skill`})}finally{x(!1),V.hide()}},I=!!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)(b,{className:`h-10 w-10 animate-spin text-primary/40`}),(0,$.jsx)(A,{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)(ce,{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:[M,` 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)(O,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-white/20`}),(0,$.jsx)(z,{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)(oe,{className:`h-3 w-3`})})]}),(0,$.jsxs)(H,{onClick:P,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)(E,{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)(ce,{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)(H,{onClick:P,className:`hive-btn hive-btn--primary px-8`,children:[(0,$.jsx)(E,{className:`h-4 w-4 mr-2`}),`Crear Habilidad`]})]})}):j.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 space-y-3 text-center`,children:[(0,$.jsx)(O,{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:j.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(pt,{skill:e,onClick:()=>re(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)(De,{checked:!!e.active,disabled:g===e.id,onClick:e=>e.stopPropagation(),onCheckedChange:t=>N(e.id,t),className:`scale-75 data-[state=checked]:bg-blue-500`})]})]},e.id))}),(0,$.jsx)(Te,{open:I,onOpenChange:e=>{e||F()},children:(0,$.jsxs)(Ce,{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)(E,{className:`h-5 w-5`}):(0,$.jsx)(p,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(we,{className:`text-sm font-black text-white uppercase tracking-tight`,children:d?`Nueva Habilidad`:`Propiedades del Nodo`}),(0,$.jsx)(G,{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)(H,{variant:`ghost`,size:`icon`,onClick:()=>C(!0),disabled:w||S,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`})})]})}),S&&(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)(H,{variant:`ghost`,size:`sm`,onClick:()=>C(!1),disabled:w,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(H,{size:`sm`,onClick:ne,disabled:w,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:w?(0,$.jsx)(b,{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)(K,{htmlFor:`skill-name`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Nombre del Nodo`}),(0,$.jsx)(z,{id:`skill-name`,value:m.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: a2ui_dashboard`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(K,{htmlFor:`skill-category`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Categoría Funcional`}),(0,$.jsx)(z,{id:`skill-category`,value:m.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)(K,{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)(z,{id:`skill-tools`,value:m.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)(K,{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)(z,{id:`skill-triggers`,value:m.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)(Ee,{ref:D,value:m.body,onChange:e=>{h(t=>({...t,body:e.target.value})),ee()},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)(K,{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)(z,{id:`skill-version`,type:`number`,step:`0.1`,min:`0.1`,value:m.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)(K,{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 ${m.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 ${m.active?`text-white`:`text-white/30`}`,children:m.active?`OPERATIVO / ACTIVO`:`FUERA DE LÍNEA / INACTIVO`}),(0,$.jsx)(De,{checked:m.active,onCheckedChange:e=>h(t=>({...t,active:e})),className:`data-[state=checked]:bg-blue-500`})]})]})]})]}),(0,$.jsxs)(be,{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)(_,{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)(H,{variant:`ghost`,className:`text-[10px] font-black tracking-widest hover:bg-white/5 hover:text-white text-white/30 uppercase`,onClick:F,children:`Cancelar`}),(0,$.jsx)(H,{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:ie,disabled:y||!m.name.trim(),children:y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(b,{className:`h-3 w-3 animate-spin mr-2`}),`PROCESANDO...`]}):d?`Crear Habilidad`:`Sincronizar Propiedades`})]})]})]})})]})}var gt=()=>{let{notes:e,isLoading:t,fetchNotes:n}=et();return(0,Q.useEffect)(()=>{n()},[n]),(0,$.jsxs)(Me,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden group border border-white/10`,children:[(0,$.jsx)(ke,{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)(L,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Oe,{className:`text-xl font-bold tracking-tight`,children:`Notas`}),(0,$.jsx)(je,{children:`Scratchpad del agente`})]})]}),t&&(0,$.jsx)(b,{className:`w-4 h-4 animate-spin text-muted-foreground`})]})}),(0,$.jsx)(Ae,{children:(0,$.jsx)(ye,{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)(L,{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)(ve,{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 _t(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}function vt({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 yt({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)(D,{className:`w-2.5 h-2.5`}):(0,$.jsx)(i,{className:`w-2.5 h-2.5`}),t?`Recurrente`:`Una vez`]})}function bt({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)(ze,{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)(ee,{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 xt({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 St(e,t){let n=e===`telegram`?`Telegram`:e===`webchat`?`Web Chat`:e;return e===t?`${n} (recomendado)`:n}function Ct({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)(xt,{status:e.status}),(0,$.jsx)(`span`,{className:`font-mono`,children:_t(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 wt({task:e,onPause:t,onResume:n,onDelete:a,onTrigger:l,onLoadHistory:u,history:d}){let[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),_=e.status===`active`,v=e.status===`active`||e.status===`paused`;function y(){!f&&!d&&u(e.id),p(e=>!e)}function b(){m?a(e.id):(h(!0),setTimeout(()=>h(!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)(vt,{status:e.status})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap mb-2`,children:[(0,$.jsx)(yt,{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)(i,{className:`w-3 h-3`}),e.task_type===`recurring`?e.cron_expression??`—`:e.fire_at?_t(e.fire_at):`—`]}),(0,$.jsx)(bt,{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)(c,{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: `,_t(e.last_run_at)]}),e.next_run_at&&e.status===`active`&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[`Próximo: `,_t(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:[v&&(_?(0,$.jsxs)(H,{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)(w,{className:`w-3 h-3 mr-1`}),`Pausar`]}):(0,$.jsxs)(H,{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)(T,{className:`w-3 h-3 mr-1`}),`Reanudar`]})),_&&(0,$.jsxs)(H,{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:()=>l(e.id),title:`Ejecutar ahora (sin afectar el schedule)`,children:[(0,$.jsx)(N,{className:`w-3 h-3 mr-1`}),`Ejecutar`]}),(0,$.jsxs)(H,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 text-muted-foreground hover:text-foreground`,onClick:y,children:[(0,$.jsx)(g,{className:`w-3 h-3 mr-1`}),`Historial`,f?(0,$.jsx)(s,{className:`w-3 h-3 ml-1`}):(0,$.jsx)(o,{className:`w-3 h-3 ml-1`})]}),(0,$.jsxs)(H,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 ml-auto ${m?`text-red-400 bg-red-500/10 border border-red-500/20`:`text-muted-foreground hover:text-red-400`}`,onClick:b,title:m?`Confirmar eliminación`:`Eliminar tarea`,children:[(0,$.jsx)(te,{className:`w-3 h-3 mr-1`}),m?`Confirmar`:`Eliminar`]})]}),f&&(0,$.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/5`,children:(0,$.jsx)(Ct,{taskId:e.id,history:d})})]})}var Tt=()=>{let{scheduledTasks:e,taskHistory:t,cronChannels:n,cronRecommended:r,cronUserPreference:i,isLoading:a,fetchScheduledTasks:o,fetchCronChannels:s,pauseTask:c,resumeTask:l,deleteTask:u,triggerTask:d,fetchTaskHistory:f,saveCronChannelPreference:p}=et(),[m,h]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{o(),s()},[o,s]);let g=m===`all`?e:e.filter(e=>e.status===m),_=(n??[]).filter(e=>e.active),v=g.filter(e=>!e.name.startsWith(`_hive_`));return(0,$.jsxs)(Me,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden border border-white/10`,children:[(0,$.jsx)(ke,{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)(ue,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Oe,{className:`text-xl font-bold tracking-tight`,children:`Tareas Programadas`}),(0,$.jsx)(je,{children:`Scheduler basado en Croner`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,$.jsx)(b,{className:`w-4 h-4 animate-spin text-muted-foreground`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{className:`h-7 text-[10px] w-[110px] border-white/10 bg-card/40`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(q,{value:`all`,className:`text-xs`,children:`Todas`}),(0,$.jsx)(q,{value:`active`,className:`text-xs`,children:`Activas`}),(0,$.jsx)(q,{value:`paused`,className:`text-xs`,children:`Pausadas`}),(0,$.jsx)(q,{value:`completed`,className:`text-xs`,children:`Completadas`}),(0,$.jsx)(q,{value:`failed`,className:`text-xs`,children:`Fallidas`})]})]}),_.length>1&&(0,$.jsxs)(Z,{value:i,onValueChange:p,children:[(0,$.jsx)(Y,{className:`h-7 text-[10px] w-[130px] border-white/10 bg-card/40`,children:(0,$.jsx)(X,{placeholder:`Canal`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(q,{value:`auto`,className:`text-xs`,children:`Auto`}),_.map(e=>(0,$.jsx)(q,{value:e.id,className:`text-xs`,children:St(e.id,r)},e.id))]})]}),(0,$.jsx)(H,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,onClick:()=>o(m===`all`?void 0:m),disabled:a,title:`Refrescar`,children:(0,$.jsx)(D,{className:`w-3.5 h-3.5`})})]})]})}),(0,$.jsx)(Ae,{children:(0,$.jsx)(ye,{className:`h-[420px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:v.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[280px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(ue,{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`})]})]}):v.map(e=>(0,$.jsx)(wt,{task:e,onPause:c,onResume:l,onDelete:u,onTrigger:d,onLoadHistory:f,history:t[e.id]},e.id))})})})]})};function Et(e){if(e.includes(` & `)){let[t,n]=e.split(` & `,2);return{lead:t,accent:`& ${n}`}}let[t,...n]=e.split(` `);return{lead:t,accent:n.join(` `)}}function Dt({panel:e}){switch(e){case`etica`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Ge,{})});case`herramientas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(qe,{})});case`mcp`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)($e,{})});case`skills`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(ht,{})});case`perfil`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(lt,{})});case`notas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(gt,{})});case`cron-jobs`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Tt,{})});default:return null}}var Ot=[`etica`,`herramientas`,`mcp`,`skills`,`perfil`,`notas`,`cron-jobs`];function kt({forcePanel:e}){let{panel:t}=re(),{fetchSkills:n}=me(),{fetchTools:r}=ge(),{fetchMCPServers:i}=pe();(0,Q.useEffect)(()=>{n(),r(),i()},[n,r,i]);let a=t===`seguridad`?`perfil`:t,o=e||(Ot.includes(a)?a:`herramientas`),{title:s,subtitle:c,eyebrow:l}={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.`}}[o],u=Et(s);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:l})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[u.lead,u.accent&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:u.accent})]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle`,children:c})]})}),(0,$.jsx)(`div`,{className:`animate-fade-in`,children:(0,$.jsx)(Dt,{panel:o})})]})}export{kt as SettingsPage};