@johpaz/hive-agents 1.0.4 → 1.0.5

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 (128) hide show
  1. package/README.md +3 -3
  2. package/dist/hive.js +4275 -3624
  3. package/dist/tool-worker.js +2 -1
  4. package/dist/ui/assets/A2UIPage-DTW79pyL.js +8 -0
  5. package/dist/ui/assets/AgentCreateForm-Bcp3HN8D.js +1 -0
  6. package/dist/ui/assets/AgentDetailPage-10XptMde.js +1 -0
  7. package/dist/ui/assets/AgentNewPage-CUt49rVS.js +1 -0
  8. package/dist/ui/assets/{AgentsPage-YZrDmgNI.js → AgentsPage-1_e1a9xa.js} +3 -3
  9. package/dist/ui/assets/{ApiClientPage-6a6KFwsQ.js → ApiClientPage-DHfIlSAg.js} +1 -1
  10. package/dist/ui/assets/ChannelsPage-BnCQAGZL.js +8 -0
  11. package/dist/ui/assets/DashboardPage-BsCCKHgg.js +6 -0
  12. package/dist/ui/assets/LoginPage-BaX6cAPa.js +1 -0
  13. package/dist/ui/assets/{LogsPage-8-H1OJs3.js → LogsPage-DiFBQt7o.js} +1 -1
  14. package/dist/ui/assets/MeetingPage-Bpv5zVXf.js +1 -0
  15. package/dist/ui/assets/{ModelSelector-CrgJQ7DG.js → ModelSelector-DfExlPzx.js} +1 -1
  16. package/dist/ui/assets/{NotFound-B06kVW7N.js → NotFound-C8HBdF73.js} +1 -1
  17. package/dist/ui/assets/Office3DPage-ChsGMapf.js +319 -0
  18. package/dist/ui/assets/ProvidersPage-B39pfWHf.js +1 -0
  19. package/dist/ui/assets/RecoverPage-C_Id9WM-.js +1 -0
  20. package/dist/ui/assets/SettingsPage-BgFqasyg.js +9 -0
  21. package/dist/ui/assets/SetupPage-YeJFfgbt.js +1 -0
  22. package/dist/ui/assets/Vignette-Cyi27LQH.js +4302 -0
  23. package/dist/ui/assets/VoicePage-Cp63Abj4.js +307 -0
  24. package/dist/ui/assets/VoicePage-uLWdtoD4.css +1 -0
  25. package/dist/ui/assets/{WebChatPage-Yahufnth.js → WebChatPage-DxFLWgtM.js} +2 -2
  26. package/dist/ui/assets/{agentCapabilities-Dg72UAFj.js → agentCapabilities-DOeepCty.js} +1 -1
  27. package/dist/ui/assets/{alert-DChoEVJw.js → alert-Cj4DpKv6.js} +1 -1
  28. package/dist/ui/assets/{badge-uRjRSt86.js → badge-DKpeVCpY.js} +1 -1
  29. package/dist/ui/assets/bia-4LFKOyxR.webp +0 -0
  30. package/dist/ui/assets/bia-BFcUpOu3.glb +0 -0
  31. package/dist/ui/assets/{card-DwQizslL.js → card-Cag15G4h.js} +1 -1
  32. package/dist/ui/assets/{dialog--mljnfAi.js → dialog-7E3EoEt3.js} +1 -1
  33. package/dist/ui/assets/{dist-js-CLxM1g2B.js → dist-js-Bg0g3vPS.js} +1 -1
  34. package/dist/ui/assets/dist-js-DwLn9F4C.js +1 -0
  35. package/dist/ui/assets/index-Bi8qEmrK.js +116 -0
  36. package/dist/ui/assets/index-D2UhaSb0.css +2 -0
  37. package/dist/ui/assets/{label-BceoUB2w.js → label-C6atPuIh.js} +1 -1
  38. package/dist/ui/assets/{square-psq7k_CB.js → mic-Rq4BxU1R.js} +1 -1
  39. package/dist/ui/assets/rotate-ccw-Dx92orJM.js +1 -0
  40. package/dist/ui/assets/{scroll-area-DMEaZZUp.js → scroll-area-CSoG2z53.js} +1 -1
  41. package/dist/ui/assets/{select-BBEBtcLm.js → select-DlCT21_r.js} +1 -1
  42. package/dist/ui/assets/{slider-DcmBdvYD.js → slider-Bb_PHFJT.js} +1 -1
  43. package/dist/ui/assets/square-CcWzRWyG.js +1 -0
  44. package/dist/ui/assets/{switch-CgiDezVR.js → switch-CUsGuBNi.js} +1 -1
  45. package/dist/ui/assets/{tabs-gUXIjjZv.js → tabs-Ckfc7DGG.js} +1 -1
  46. package/dist/ui/assets/{textarea-DedxQYBx.js → textarea-BH6pI9Ax.js} +1 -1
  47. package/dist/ui/assets/useAudioDevices-Dpr_hn6i.js +41 -0
  48. package/dist/ui/assets/useHiveAgentsModelLoad-CHmtvNp4.js +1 -0
  49. package/dist/ui/assets/{useProviders-CiLSc05q.js → useProviders-C7FA6z4M.js} +1 -1
  50. package/dist/ui/assets/volume-2-CBMYsuF3.js +1 -0
  51. package/dist/ui/assets/volume-x-vNFf2e4-.js +1 -0
  52. package/dist/ui/index.html +5 -5
  53. package/package.json +1 -1
  54. package/packages/cli/src/commands/doctor.ts +99 -44
  55. package/packages/cli/src/commands/onboard.ts +4 -2
  56. package/packages/core/src/agent/agent-catalog.ts +23 -23
  57. package/packages/core/src/agent/context-compiler.ts +1 -1
  58. package/packages/core/src/agent/conversation-store.ts +14 -1
  59. package/packages/core/src/agent/llm-client.ts +3 -3
  60. package/packages/core/src/agent/prompt-builder.ts +1 -1
  61. package/packages/core/src/agent/realtime-providers/gemini-live.ts +230 -0
  62. package/packages/core/src/agent/realtime-providers/index.ts +29 -0
  63. package/packages/core/src/agent/realtime-providers/interface.ts +108 -0
  64. package/packages/core/src/agent/skill-selector.ts +1 -1
  65. package/packages/core/src/agent/tool-selector.ts +1 -0
  66. package/packages/core/src/canvas/canvas-manager.ts +128 -26
  67. package/packages/core/src/config/loader.ts +6 -4
  68. package/packages/core/src/events/tool-narration.ts +1 -0
  69. package/packages/core/src/gateway/delegation-groups.ts +4 -4
  70. package/packages/core/src/gateway/initializer.ts +17 -10
  71. package/packages/core/src/gateway/realtime/bridge-tools.ts +392 -0
  72. package/packages/core/src/gateway/realtime/index.ts +249 -0
  73. package/packages/core/src/gateway/realtime/prompt.ts +137 -0
  74. package/packages/core/src/gateway/realtime/protocol.ts +60 -0
  75. package/packages/core/src/gateway/realtime/voice-session.ts +441 -0
  76. package/packages/core/src/gateway/routes/providers.ts +1 -1
  77. package/packages/core/src/gateway/routes/setup.ts +3 -3
  78. package/packages/core/src/gateway/server.ts +86 -1
  79. package/packages/core/src/gateway/slash-commands.ts +3 -1
  80. package/packages/core/src/storage/collections.ts +10 -1
  81. package/packages/core/src/storage/onboarding.ts +39 -39
  82. package/packages/core/src/storage/seed.ts +20 -2
  83. package/packages/core/src/tools/index.ts +1 -0
  84. package/packages/core/src/tools/web/browser-backend.ts +141 -44
  85. package/packages/core/src/tools/web/browser-click.ts +2 -2
  86. package/packages/core/src/tools/web/browser-extract.ts +2 -2
  87. package/packages/core/src/tools/web/browser-navigate.ts +2 -2
  88. package/packages/core/src/tools/web/browser-screenshot.ts +12 -5
  89. package/packages/core/src/tools/web/browser-script.ts +2 -2
  90. package/packages/core/src/tools/web/browser-service.ts +63 -384
  91. package/packages/core/src/tools/web/browser-session.ts +125 -0
  92. package/packages/core/src/tools/web/browser-type.ts +2 -2
  93. package/packages/core/src/tools/web/browser-wait.ts +2 -2
  94. package/packages/core/src/tools/web/computer-use.ts +553 -0
  95. package/packages/core/src/tools/web/index.ts +5 -1
  96. package/packages/core/src/tools/web/webview-backend.ts +439 -21
  97. package/dist/ui/assets/A2UIPage-7Ry5rHh9.js +0 -8
  98. package/dist/ui/assets/AgentCreateForm-Dh5W0q_t.js +0 -1
  99. package/dist/ui/assets/AgentDetailPage-CIoPjtsS.js +0 -1
  100. package/dist/ui/assets/AgentNewPage-BNsZcJQf.js +0 -1
  101. package/dist/ui/assets/ChannelsPage-Dice4dkJ.js +0 -8
  102. package/dist/ui/assets/DashboardPage-B9r0sc0F.js +0 -6
  103. package/dist/ui/assets/LoginPage-BkAAX_tu.js +0 -1
  104. package/dist/ui/assets/MeetingPage-14JoQo71.js +0 -1
  105. package/dist/ui/assets/Office3DPage-BMUZWkFS.js +0 -4614
  106. package/dist/ui/assets/ProvidersPage-BiL3QxCs.js +0 -1
  107. package/dist/ui/assets/RecoverPage-D1o8yxNz.js +0 -1
  108. package/dist/ui/assets/SettingsPage-GP8UwQIL.js +0 -9
  109. package/dist/ui/assets/SetupPage-B_gU1YQU.js +0 -1
  110. package/dist/ui/assets/dist-js-B0s_TDau.js +0 -1
  111. package/dist/ui/assets/index-BHHUQZJd.js +0 -116
  112. package/dist/ui/assets/index-CEFhf4dF.css +0 -2
  113. package/dist/ui/assets/useHiveAgentsModelLoad-C7bhWPDG.js +0 -1
  114. package/dist/ui/assets/volume-x-BDlMCDYT.js +0 -1
  115. /package/dist/ui/assets/{core-Sjunb8Z1.js → core-Dz04EE_8.js} +0 -0
  116. /package/dist/ui/assets/{gateway-url-BZj_2-jf.js → gateway-url-BzQV75Ig.js} +0 -0
  117. /package/dist/ui/assets/{search-ykSx-zZU.js → search-DB4w9YHW.js} +0 -0
  118. /package/dist/ui/assets/{send-DAhlz2i9.js → send-xi8HzUdc.js} +0 -0
  119. /package/dist/ui/assets/{settings-DL0REysC.js → settings-pV0cF8Kf.js} +0 -0
  120. /package/dist/ui/assets/{shield-BPZZhjCT.js → shield-nLNsomh_.js} +0 -0
  121. /package/dist/ui/assets/{sparkles-BViXTAh7.js → sparkles-CerRDYxk.js} +0 -0
  122. /package/dist/ui/assets/{terminal-CzxPKG-h.js → terminal-C2SUZUAD.js} +0 -0
  123. /package/dist/ui/assets/{trash-2-SgYCWiVk.js → trash-2-BZsMCfso.js} +0 -0
  124. /package/dist/ui/assets/{useOfficeModel-BAFasrg8.js → useOfficeModel-Cc5VkReZ.js} +0 -0
  125. /package/dist/ui/assets/{utils-SGUggNJc.js → utils-lc8H6VGT.js} +0 -0
  126. /package/dist/ui/assets/{vendor-router-Dsg8fxNQ.js → vendor-router-DCsSv_I7.js} +0 -0
  127. /package/dist/ui/assets/{wifi-CyPHteEm.js → wifi-DNv53AfN.js} +0 -0
  128. /package/dist/ui/assets/{zap-OVVrfEHr.js → zap-Yed86Sh8.js} +0 -0
@@ -161920,7 +161920,8 @@ var BrowserConfigSchema = object({
161920
161920
  headless: boolean2().optional(),
161921
161921
  timeoutMs: number2().optional(),
161922
161922
  sessionName: string2().optional(),
161923
- backend: _enum(["agent-browser", "webview", "auto"]).optional()
161923
+ backend: _enum(["agent-browser", "webview", "auto"]).optional(),
161924
+ persistSession: boolean2().optional()
161924
161925
  });
161925
161926
  var CanvasConfigSchema = object({
161926
161927
  enabled: boolean2().optional(),
@@ -0,0 +1,8 @@
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"./createLucideIcon-BRaPSYgN.js";import{t as i}from"./arrow-left-WyDPYZXU.js";import{t as a}from"./arrow-right-BuNjN-bk.js";import{t as o}from"./calendar-B6x9cw-q.js";import{t as s}from"./check-C8pw-7Fx.js";import{t as c}from"./circle-alert-CtDbK2nl.js";import{t as l}from"./download-D0aDV8Y_.js";import{t as u}from"./ellipsis-vertical-BOW_iEOO.js";import{n as d,t as f}from"./eye-sRPY5qOa.js";import{t as p}from"./info-CG1VohyH.js";import{t as m}from"./lock-open-Bhp0UJlL.js";import{n as ee,t as h}from"./pencil-CUbpCfeG.js";import{t as g}from"./mail-Biwn8WrV.js";import{t as _}from"./plus-DzvRxH4U.js";import{t as v}from"./refresh-cw-DZXu5FrG.js";import{t as y}from"./search-DB4w9YHW.js";import{t as b}from"./send-xi8HzUdc.js";import{t as te}from"./settings-pV0cF8Kf.js";import{t as x}from"./trash-2-BZsMCfso.js";import{n as ne,t as re}from"./wifi-DNv53AfN.js";import{l as ie}from"./vendor-router-DCsSv_I7.js";import{B as ae,D as oe,F as se,I as ce,L as le,N as S,O as C,P as w,Q as T,R as E,V as D,Z as O,it as k,q as A,ut as j,z as M}from"./index-Bi8qEmrK.js";import{t as N}from"./badge-DKpeVCpY.js";import{t as P}from"./scroll-area-CSoG2z53.js";import{t as F}from"./slider-Bb_PHFJT.js";import{i as I,n as L,r as R,t as z}from"./tabs-Ckfc7DGG.js";import{c as B,i as V,r as H,s as U,t as W}from"./dialog-7E3EoEt3.js";var ue=r(`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=r(`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`}]]),de=r(`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`}]]),fe=r(`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`}]]),pe=r(`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=r(`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`}]]),me=r(`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`}]]),he=r(`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`}]]),ge=r(`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`}]]),_e=r(`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`}]]),ve=r(`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`}]]),ye=r(`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`}]]),be=r(`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`}]]),xe=r(`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`}]]),Se=r(`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 Ce({def:e,ctx:t}){let n=M(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 we(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 w(e.condition,t,n,r)===!0;let i=w({call:e.call,args:e.args??{}},t,n,r);return i===!0||i===`true`}function Te(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 Ee({def:e,ctx:t}){let n=e.action,r=e.variant??`primary`,i=e.disabled===!0||Te(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))ce(n)?o[e]=D(n.path,t.dataModel,t.scopeData):se(n)?o[e]=w(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}):M(e.text,t.dataModel,t.scopeData)||`Button`})}var De={start:`flex-start`,end:`flex-end`,center:`center`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`};function Oe({def:e,ctx:t}){return(0,J.jsx)(`div`,{className:`flex flex-row gap-2`,style:{justifyContent:De[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 ke={start:`flex-start`,end:`flex-end`,center:`center`,spaceBetween:`space-between`,spaceAround:`space-around`,spaceEvenly:`space-evenly`};function Ae({def:e,ctx:t}){return(0,J.jsx)(`div`,{className:`flex flex-col gap-3`,style:{justifyContent:ke[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 je({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 Me({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 Ne({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 Pe={contain:`contain`,cover:`cover`,fill:`fill`,none:`none`,"scale-down":`scale-down`},Fe={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 Ie({def:e,ctx:t}){let n=M(e.url,t.dataModel,t.scopeData);if(!n)return null;let r=Pe[e.fit??`contain`]??`contain`,i=Fe[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 Le={settings:te,home:me,search:y,mail:g,call:_e,camera:ue,calendarToday:o,star:xe,check:s,close:A,delete:x,download:l,upload:Se,edit:h,refresh:v,send:b,share:ye,shoppingCart:be,warning:T,info:p,error:c,favorite:K,favoriteOff:K,folder:pe,help:G,lock:ee,lockOpen:m,visibility:f,visibilityOff:d,add:_,arrowBack:i,arrowForward:a,accountCircle:O,notifications:j,moreVert:u,moreHoriz:fe,locationOn:ge,payment:de,photo:he,print:ve,person:O};function Re({def:e,ctx:t}){return(0,J.jsx)(Le[M(e.name,t.dataModel,t.scopeData)]??G,{className:`text-white/70`,style:e.weight?{flex:e.weight}:void 0})}function ze({def:e,ctx:t}){let[n,r]=(0,q.useState)(M((typeof e.value==`object`&&e.value,e.value),t.dataModel,t.scopeData)),i=M(e.label,t.dataModel,t.scopeData),a=M(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?we(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 Be({def:e,ctx:t}){let n=M(e.label,t.dataModel,t.scopeData),[r,i]=(0,q.useState)(le(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 Ve({def:e,ctx:t}){let n=e.variant===`mutuallyExclusive`?`single`:`multi`,r=e.maxAllowedSelections??(n===`single`?1:5),[i,a]=(0,q.useState)(ae(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=M(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 He({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)(E(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)(F,{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 Ue({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 Z({def:e,ctx:t}){let n=Array.isArray(e.tabs)?e.tabs:e.tabItems??[];return(0,J.jsxs)(z,{defaultValue:n[0]?.title?M(n[0].title,t.dataModel,t.scopeData):``,style:e.weight?{flex:e.weight}:void 0,children:[(0,J.jsx)(R,{className:`w-full`,children:n.map((e,n)=>(0,J.jsx)(I,{value:M(e.title,t.dataModel,t.scopeData),children:M(e.title,t.dataModel,t.scopeData)},n))}),n.map((e,n)=>(0,J.jsx)(L,{value:M(e.title,t.dataModel,t.scopeData),children:(0,J.jsx)(Q,{...t,id:e.child})},n))]})}function We({def:e,ctx:t}){let[n,r]=(0,q.useState)(!1);return(0,J.jsxs)(W,{open:n,onOpenChange:r,children:[(e.trigger??e.entryPointChild)&&(0,J.jsx)(B,{asChild:!0,children:(0,J.jsx)(`div`,{className:`cursor-pointer`,children:(0,J.jsx)(Q,{...t,id:e.trigger??e.entryPointChild})})}),(0,J.jsxs)(H,{children:[(0,J.jsx)(U,{className:`sr-only`,children:`Interactive modal`}),(0,J.jsx)(V,{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 Ge({def:e,ctx:t}){let n=M(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 Ke({def:e,ctx:t}){let n=M(e.url,t.dataModel,t.scopeData),r=M(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 qe({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)(Ce,{def:t,ctx:e});case`Button`:return(0,J.jsx)(Ee,{def:t,ctx:e});case`Row`:return(0,J.jsx)(Oe,{def:t,ctx:e});case`Column`:return(0,J.jsx)(Ae,{def:t,ctx:e});case`Card`:return(0,J.jsx)(je,{def:t,ctx:e});case`List`:return(0,J.jsx)(Me,{def:t,ctx:e});case`Divider`:return(0,J.jsx)(Ne,{def:t,ctx:e});case`Image`:return(0,J.jsx)(Ie,{def:t,ctx:e});case`Icon`:return(0,J.jsx)(Re,{def:t,ctx:e});case`TextField`:return(0,J.jsx)(ze,{def:t,ctx:e});case`CheckBox`:return(0,J.jsx)(Be,{def:t,ctx:e});case`ChoicePicker`:return(0,J.jsx)(Ve,{def:t,ctx:e});case`Slider`:return(0,J.jsx)(He,{def:t,ctx:e});case`DateTimeInput`:return(0,J.jsx)(Ue,{def:t,ctx:e});case`Tabs`:return(0,J.jsx)(Z,{def:t,ctx:e});case`Modal`:return(0,J.jsx)(We,{def:t,ctx:e});case`Video`:return(0,J.jsx)(Ge,{def:t,ctx:e});case`AudioPlayer`:return(0,J.jsx)(Ke,{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=D(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=D(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 Je(){let e=S(e=>e.a2uiSurfaces),t=S(e=>e.sendA2UIAction),n=S(e=>e.deleteA2UISurface),[r,i]=(0,q.useState)(null),a=(0,q.useCallback)(e=>{t(e)},[t]),o=async e=>{i(e);try{await C(`/api/a2ui/surfaces/${encodeURIComponent(e)}`,{method:`DELETE`,showError:!0}),n(e)}catch{}finally{i(null)}},s=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:[s.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)(k,{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)(P,{className:`flex-1 p-6`,children:s.length>0&&(0,J.jsx)(`div`,{className:`grid grid-cols-1 gap-6 lg:grid-cols-2`,children:s.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:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-3 pb-3 border-b border-white/5`,children:[e.theme?.agentDisplayName?(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,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)(`span`,{className:`font-mono text-[10px] text-white/40`,children:e.surfaceId}),(0,J.jsx)(`button`,{type:`button`,title:`Eliminar superficie ${e.surfaceId}`,"aria-label":`Eliminar superficie ${e.surfaceId}`,disabled:r===e.surfaceId,onClick:()=>o(e.surfaceId),className:`rounded-md p-1.5 text-white/25 transition hover:bg-red-500/10 hover:text-red-300 disabled:opacity-40`,children:(0,J.jsx)(x,{className:`h-3.5 w-3.5`})})]}),(0,J.jsx)(qe,{surface:e,onAction:a})]},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)(k,{className:`h-3 w-3 text-blue-400/50`}),(0,J.jsx)(`span`,{className:`hive-mono`,children:s.length>0?`${s.length} superficie${s.length>1?`s`:``} A2UI activa${s.length>1?`s`:``}`:`Panel interactivo · sin superficies`})]})})]})}function Ye(){let{sessionId:e}=ie(),{currentUser:t}=oe(),n=S(e=>e.isConnected),r=S(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)(k,{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)(O,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{className:`font-mono`,children:i})]})]})]}),(0,J.jsx)(N,{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)(re,{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)(ne,{className:`h-3.5 w-3.5`}),(0,J.jsx)(`span`,{className:`font-semibold uppercase tracking-wider text-[10px]`,children:`Offline`})]})})]}),(0,J.jsx)(Je,{})]})})})}):(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{Ye as A2UIPage};
@@ -0,0 +1 @@
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"./check-C8pw-7Fx.js";import{t as i}from"./circle-alert-CtDbK2nl.js";import{t as a}from"./useProviders-C7FA6z4M.js";import{t as o}from"./external-link-5cujQzfV.js";import{n as s,r as c,t as l}from"./ModelSelector-DfExlPzx.js";import{t as u}from"./shield-nLNsomh_.js";import{t as d}from"./sparkles-CerRDYxk.js";import{t as f}from"./utils-lc8H6VGT.js";import{A as p,C as m,G as h,O as g,W as _,_ as v,q as y,rt as b}from"./index-Bi8qEmrK.js";import{a as x,c as S,i as C,n as w,o as T,r as E,s as ee,t as D}from"./dialog-7E3EoEt3.js";import{t as O}from"./label-C6atPuIh.js";import{t as k}from"./textarea-BH6pI9Ax.js";import{i as A,n as j,o as M,s as N,t as P}from"./select-DlCT21_r.js";import{t as F}from"./switch-CUsGuBNi.js";import{a as I,i as L,n as R,r as z,t as B}from"./card-Cag15G4h.js";var V=e(t(),1),H=n(),U=[{value:`friendly`,label:`Amigable`},{value:`professional`,label:`Profesional`},{value:`casual`,label:`Casual`},{value:`formal`,label:`Formal`},{value:`creative`,label:`Creativo`}];function W({initialData:e,onSuccess:t,onCancel:n}){let{createAgent:W,updateAgent:G,isLoading:K,error:q}=v(),{activeProviders:te}=m(),[J,Y]=(0,V.useState)({isValidating:!1,exists:!1,accessible:!1}),[X,Z]=(0,V.useState)({name:``,description:``,tone:`professional`,provider_id:``,model_id:``,role:`coordinator`,enabled:!0,systemPrompt:``,workspace:e?.workspace||``});(0,V.useEffect)(()=>{e&&Z({...e,provider_id:e.provider_id||e.providerId||``,model_id:e.model_id||e.modelId||``})},[e]);let Q=async e=>{if(!e||e.trim()===``){Y({isValidating:!1,exists:!1,accessible:!1});return}Y({isValidating:!0,exists:!1,accessible:!1});try{let t=await g(`/api/workspace/validate`,{method:`POST`,body:{path:e}});Y({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){Y({isValidating:!1,exists:!1,accessible:!1,error:e.message})}},ne=async()=>{if(X.workspace)try{await g(`/api/workspace/create`,{method:`POST`,body:{path:X.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await Q(X.workspace)}catch(e){p.fire(`Error`,e.message,`error`)}},re=async()=>{if(X.workspace)try{await g(`/api/workspace/open?path=${encodeURIComponent(X.workspace)}`,{method:`GET`})}catch(e){p.fire(`Error`,e.message,`error`)}},ie=async n=>{if(n.preventDefault(),!X.provider_id||!X.model_id){p.fire(`Incompleto`,`Por favor selecciona un proveedor y modelo`,`warning`);return}try{e?.id?await G(e.id,X):await W(X),t&&t()}catch(e){console.error(e)}},$=!!e?.id;return(0,H.jsxs)(B,{className:`hive-card--form group`,children:[(0,H.jsx)(`div`,{className:`hive-glow-blob--card absolute -top-24 -right-24 h-48 w-48 bg-blue-600/10 group-hover:bg-blue-600/20`,style:{borderRadius:`50%`,filter:`blur(80px)`}}),(0,H.jsx)(L,{className:`relative`,children:(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`hive-icon-wrap hive-icon-wrap--primary`,children:$?(0,H.jsx)(s,{className:`h-5 w-5`}):(0,H.jsx)(d,{className:`h-5 w-5`})}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(I,{className:`text-xl font-bold text-white/90`,children:$?`Configurar Nodo`:`Desplegar Nuevo Nodo`}),(0,H.jsx)(z,{className:`text-white/40`,children:$?`Ajusta los parámetros de tu agente inteligente.`:`Crea una nueva entidad inteligente para tu colmena.`})]})]}),n&&(0,H.jsx)(h,{variant:`ghost`,size:`icon`,onClick:n,className:`text-white/40 hover:text-white hover:bg-white/5`,children:(0,H.jsx)(y,{className:`h-5 w-5`})})]})}),(0,H.jsx)(R,{className:`relative space-y-6 pt-2`,children:(0,H.jsxs)(`form`,{onSubmit:ie,className:`space-y-8`,children:[(0,H.jsxs)(`div`,{className:`grid gap-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(O,{htmlFor:`name`,className:`hive-label--field`,children:`Nombre del Agente`}),(0,H.jsx)(_,{id:`name`,placeholder:`Ej: Analista de Mercado`,className:`hive-input`,value:X.name,onChange:e=>Z({...X,name:e.target.value}),disabled:K,required:!0})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(O,{htmlFor:`description`,className:`hive-label--field`,children:`Descripción / Rol`}),(0,H.jsx)(k,{id:`description`,placeholder:`Describe qué hace este agente y cuáles son sus objetivos...`,className:`hive-textarea`,value:X.description,onChange:e=>Z({...X,description:e.target.value}),disabled:K})]})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsx)(O,{htmlFor:`systemPrompt`,className:`hive-label--field`,children:`System Prompt`}),(0,H.jsxs)(D,{children:[(0,H.jsx)(S,{asChild:!0,children:(0,H.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,H.jsxs)(E,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,H.jsxs)(T,{children:[(0,H.jsx)(ee,{className:`text-xl`,children:`Editar System Prompt`}),(0,H.jsx)(C,{className:`text-sm text-white/50`,children:`El prompt base de comportamiento del agente. Se recomienda formato Markdown.`})]}),(0,H.jsx)(`div`,{className:`py-2`,children:(0,H.jsx)(k,{value:X.systemPrompt||``,onChange:e=>Z({...X,systemPrompt:e.target.value}),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`,disabled:K})}),(0,H.jsx)(x,{children:(0,H.jsx)(w,{asChild:!0,children:(0,H.jsx)(h,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Guardar Cambios`})})})]})]})]}),X.systemPrompt?(0,H.jsxs)(`p`,{className:`text-xs text-white/40 line-clamp-1 italic border border-white/5 bg-white/[0.02] p-2 rounded-md`,children:[`"`,X.systemPrompt,`"`]}):(0,H.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})]}),(0,H.jsxs)(`div`,{className:`space-y-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,H.jsx)(c,{className:`h-4 w-4 text-emerald-400`}),(0,H.jsx)(`h3`,{className:`hive-title-section`,children:`Workspace Directory`})]}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(O,{htmlFor:`workspace`,className:`hive-label--field`,children:`Directorio de Trabajo del Agente`}),(0,H.jsxs)(`div`,{className:`flex gap-2`,children:[(0,H.jsx)(_,{id:`workspace`,placeholder:`Ej: /home/user/proyectos, D:\\Work, /Volumes/USB`,className:`hive-input flex-1 font-mono text-sm`,value:X.workspace,onChange:e=>{Z({...X,workspace:e.target.value}),Q(e.target.value)},disabled:K}),X.workspace&&J.exists&&J.accessible&&(0,H.jsx)(h,{type:`button`,variant:`outline`,size:`icon`,onClick:re,className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10`,title:`Abrir en el explorador`,children:(0,H.jsx)(o,{className:`h-4 w-4`})})]}),(0,H.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente creará archivos, carpetas y ejecutará comandos. Puede ser cualquier ubicación en tu sistema (disco duro, USB, red, etc.).`}),X.workspace&&X.workspace.trim()!==``&&(0,H.jsxs)(`div`,{className:f(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,J.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!J.isValidating&&J.exists&&J.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!J.isValidating&&J.exists&&!J.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!J.isValidating&&!J.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[J.isValidating&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(b,{className:`h-3.5 w-3.5 animate-spin`}),(0,H.jsx)(`span`,{children:`Validando directorio...`})]}),!J.isValidating&&J.exists&&J.accessible&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(r,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`Directorio válido y accesible`})]}),!J.isValidating&&J.exists&&!J.accessible&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(i,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`El directorio existe pero no tiene permisos de lectura/escritura`})]}),!J.isValidating&&!J.exists&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(c,{className:`h-3.5 w-3.5`}),(0,H.jsx)(`span`,{children:J.message||`El directorio no existe`}),!J.error&&(0,H.jsx)(h,{type:`button`,variant:`outline`,size:`sm`,onClick:ne,className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear directorio`})]})]})]})]}),(0,H.jsx)(`div`,{className:`hive-card-divider`}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,H.jsx)(a,{className:`h-4 w-4 text-blue-400`}),(0,H.jsx)(`h3`,{className:`hive-title-section`,children:`Motor de Inteligencia`})]}),(0,H.jsx)(l,{selectedProviderId:X.provider_id||void 0,selectedModelId:X.model_id||void 0,onProviderChange:e=>Z({...X,provider_id:e,model_id:``}),onModelChange:e=>Z({...X,model_id:e}),disabled:K,typeFilter:`llm`})]}),(0,H.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6`,children:[(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(O,{htmlFor:`tone`,className:`hive-label--field`,children:`Tono de Voz`}),(0,H.jsxs)(P,{value:X.tone,onValueChange:e=>Z({...X,tone:e}),disabled:K,children:[(0,H.jsx)(M,{className:`hive-select-trigger`,children:(0,H.jsx)(N,{placeholder:`Selecciona un tono`})}),(0,H.jsx)(j,{className:`hive-select-content`,children:U.map(e=>(0,H.jsx)(A,{value:e.value,className:`hive-select-item`,children:e.label},e.value))})]})]}),(0,H.jsxs)(`div`,{className:`hive-toggle-panel`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(u,{className:`h-3.5 w-3.5 text-purple-400`}),(0,H.jsx)(O,{htmlFor:`role`,className:`text-xs font-medium text-white/70`,children:`Rol`})]}),(0,H.jsxs)(P,{value:X.role,onValueChange:e=>Z({...X,role:e}),disabled:K,children:[(0,H.jsx)(M,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,H.jsx)(N,{})}),(0,H.jsxs)(j,{className:`bg-zinc-900 border-white/10`,children:[(0,H.jsx)(A,{value:`coordinator`,children:`Coordinador`}),(0,H.jsx)(A,{value:`worker`,children:`Worker`})]})]})]}),(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`h-2 w-2 rounded-full ${X.enabled?`bg-blue-400`:`bg-zinc-600`}`}),(0,H.jsx)(O,{htmlFor:`enabled`,className:`text-xs font-medium text-white/70`,children:`Habilitado`})]}),(0,H.jsx)(F,{id:`enabled`,checked:X.enabled,onCheckedChange:e=>Z({...X,enabled:e}),disabled:K})]})]})]}),q&&(0,H.jsx)(`div`,{className:`hive-form-error`,children:q}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 pt-4`,children:[n&&(0,H.jsx)(h,{type:`button`,variant:`outline`,onClick:n,disabled:K,className:`hive-btn--form-cancel`,children:`Cancelar`}),(0,H.jsx)(h,{type:`submit`,disabled:K,className:`hive-btn--form-submit`,children:K?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(b,{className:`mr-2 h-4 w-4 animate-spin`}),`Procesando...`]}):(0,H.jsx)(H.Fragment,{children:$?`Actualizar Agente`:`Desplegar Agente`})})]})]})})]})}export{W as t};
@@ -0,0 +1 @@
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"./createLucideIcon-BRaPSYgN.js";import{t as i}from"./activity-C_GS5wrG.js";import{t as a}from"./calendar-B6x9cw-q.js";import{t as o}from"./check-C8pw-7Fx.js";import{t as s}from"./chevron-left-GK4EQOyZ.js";import{t as c}from"./circle-alert-CtDbK2nl.js";import{t as l}from"./circle-check-BKNT2_q6.js";import{n as u,t as d}from"./earth-BJRGJbVn.js";import{t as f}from"./useProviders-C7FA6z4M.js";import{t as p}from"./external-link-5cujQzfV.js";import{n as m,r as h,t as g}from"./ModelSelector-DfExlPzx.js";import{a as _,i as v,o as ee,r as y,s as b}from"./agentCapabilities-DOeepCty.js";import{t as te}from"./shield-nLNsomh_.js";import{t as x}from"./sparkles-CerRDYxk.js";import{t as S}from"./terminal-C2SUZUAD.js";import{t as ne}from"./zap-Yed86Sh8.js";import{t as re}from"./utils-lc8H6VGT.js";import{c as ie,l as ae}from"./vendor-router-DCsSv_I7.js";import{C,G as w,J as T,O as E,S as D,T as oe,W as O,Z as se,_ as k,j as A,k as j,lt as ce,ot as le,rt as M,w as ue}from"./index-Bi8qEmrK.js";import{t as de}from"./badge-DKpeVCpY.js";import{a as N,c as P,i as F,n as I,o as L,r as R,s as z,t as B}from"./dialog-7E3EoEt3.js";import{t as V}from"./label-C6atPuIh.js";import{t as H}from"./textarea-BH6pI9Ax.js";import{i as U,n as fe,o as pe,s as me,t as he}from"./select-DlCT21_r.js";import{t as ge}from"./switch-CUsGuBNi.js";var W=r(`BookOpenCheck`,[[`path`,{d:`M12 21V7`,key:`gj6g52`}],[`path`,{d:`m16 12 2 2 4-4`,key:`mdajum`}],[`path`,{d:`M22 6V4a1 1 0 0 0-1-1h-5a4 4 0 0 0-4 4 4 4 0 0 0-4-4H3a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h6a3 3 0 0 1 3 3 3 3 0 0 1 3-3h6a1 1 0 0 0 1-1v-1.3`,key:`8arnkb`}]]),_e=r(`CalendarClock`,[[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M17.5 17.5 16 16.3V14`,key:`akvzfd`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),G=r(`FileStack`,[[`path`,{d:`M21 7h-3a2 2 0 0 1-2-2V2`,key:`9rb54x`}],[`path`,{d:`M21 6v6.5c0 .8-.7 1.5-1.5 1.5h-7c-.8 0-1.5-.7-1.5-1.5v-9c0-.8.7-1.5 1.5-1.5H17Z`,key:`1059l0`}],[`path`,{d:`M7 8v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H15`,key:`16874u`}],[`path`,{d:`M3 12v8.8c0 .3.2.6.4.8.2.2.5.4.8.4H11`,key:`k2ox98`}]]),ve=r(`Fingerprint`,[[`path`,{d:`M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4`,key:`1nerag`}],[`path`,{d:`M14 13.12c0 2.38 0 6.38-1 8.88`,key:`o46ks0`}],[`path`,{d:`M17.29 21.02c.12-.6.43-2.3.5-3.02`,key:`ptglia`}],[`path`,{d:`M2 12a10 10 0 0 1 18-6`,key:`ydlgp0`}],[`path`,{d:`M2 16h.01`,key:`1gqxmh`}],[`path`,{d:`M21.8 16c.2-2 .131-5.354 0-6`,key:`drycrb`}],[`path`,{d:`M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2`,key:`1tidbn`}],[`path`,{d:`M8.65 22c.21-.66.45-1.32.57-2`,key:`13wd9y`}],[`path`,{d:`M9 6.8a6 6 0 0 1 9 5.2v2`,key:`1fr1j5`}]]),ye=r(`LayoutGrid`,[[`rect`,{width:`7`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`1g98yp`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`3`,rx:`1`,key:`6d4xhi`}],[`rect`,{width:`7`,height:`7`,x:`14`,y:`14`,rx:`1`,key:`nxv5o0`}],[`rect`,{width:`7`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`1bb6yr`}]]),be=r(`PackageOpen`,[[`path`,{d:`M12 22v-9`,key:`x3hkom`}],[`path`,{d:`M15.17 2.21a1.67 1.67 0 0 1 1.63 0L21 4.57a1.93 1.93 0 0 1 0 3.36L8.82 14.79a1.655 1.655 0 0 1-1.64 0L3 12.43a1.93 1.93 0 0 1 0-3.36z`,key:`2ntwy6`}],[`path`,{d:`M20 13v3.87a2.06 2.06 0 0 1-1.11 1.83l-6 3.08a1.93 1.93 0 0 1-1.78 0l-6-3.08A2.06 2.06 0 0 1 4 16.87V13`,key:`1pmm1c`}],[`path`,{d:`M21 12.43a1.93 1.93 0 0 0 0-3.36L8.83 2.2a1.64 1.64 0 0 0-1.63 0L3 4.57a1.93 1.93 0 0 0 0 3.36l12.18 6.86a1.636 1.636 0 0 0 1.63 0z`,key:`12ttoo`}]]),K=e(t(),1),q=n();function J({icon:e,...t}){return(0,q.jsx)(e,{...t})}function xe({agentId:e}){let{agents:t,updateAgent:n,fetchAgents:r}=k(),{fetchProviders:a}=C(),{fetchModels:s}=D();(0,K.useEffect)(()=>{r(),a(),s()},[r,a,s]);let l=t.find(t=>t.id===e),[u,d]=(0,K.useState)({name:``,description:``,provider_id:``,model_id:``,tone:``,role:`coordinator`,enabled:!0,headers:``,systemPrompt:``,workspace:``}),[f,_]=(0,K.useState)({isValidating:!1,exists:!1,accessible:!1});(0,K.useEffect)(()=>{l&&(d({name:l.name||``,description:l.description||``,provider_id:l.provider_id||l.providerId||``,model_id:l.model_id||l.modelId||``,tone:l.tone||``,role:l.role||`coordinator`,enabled:!!l.enabled,headers:``,systemPrompt:l.systemPrompt||``,workspace:l.workspace||``}),l.workspace&&v(l.workspace))},[l]);let v=async e=>{if(!e||e.trim()===``){_({isValidating:!1,exists:!1,accessible:!1});return}_({isValidating:!0,exists:!1,accessible:!1});try{let t=await E(`/api/workspace/validate`,{method:`POST`,body:{path:e}});_({isValidating:!1,exists:t.exists,accessible:t.accessible,error:t.error,message:t.message})}catch(e){_({isValidating:!1,exists:!1,accessible:!1,error:e.message})}};return l?(0,q.jsx)(`div`,{className:`space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-500`,children:(0,q.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-3 gap-8`,children:[(0,q.jsxs)(`div`,{className:`lg:col-span-1 space-y-6`,children:[(0,q.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`p-2 rounded-xl bg-blue-500/10 border border-blue-500/20`,children:(0,q.jsx)(J,{icon:se,className:`h-4 w-4 text-blue-400`})}),(0,q.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Identidad Base`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(V,{htmlFor:`name`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Nombre Público`}),(0,q.jsx)(O,{id:`name`,value:u.name,onChange:e=>d(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Nombre del nodo`})]}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(V,{htmlFor:`tone`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Tono Cognitivo`}),(0,q.jsx)(O,{id:`tone`,value:u.tone,onChange:e=>d(t=>({...t,tone:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-xl h-11`,placeholder:`Ej: Analítico, Conciso...`})]})]})]}),(0,q.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`p-2 rounded-xl bg-purple-500/10 border border-purple-500/20`,children:(0,q.jsx)(J,{icon:te,className:`h-4 w-4 text-purple-400`})}),(0,q.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Permisos de Red`})]}),(0,q.jsxs)(`div`,{className:`space-y-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsx)(V,{className:`text-sm font-semibold`,children:`Rol`}),(0,q.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Coordinador o Worker`})]}),(0,q.jsxs)(he,{value:u.role,onValueChange:e=>d(t=>({...t,role:e})),children:[(0,q.jsx)(pe,{className:`w-[120px] bg-white/5 border-white/10 text-white`,children:(0,q.jsx)(me,{})}),(0,q.jsxs)(fe,{className:`bg-zinc-900 border-white/10`,children:[(0,q.jsx)(U,{value:`coordinator`,children:`Coordinador`}),(0,q.jsx)(U,{value:`worker`,children:`Worker`})]})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between p-3 rounded-2xl bg-white/5 hover:bg-white/10 transition-colors`,children:[(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsx)(V,{className:`text-sm font-semibold`,children:`Nodo Activo`}),(0,q.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Disponible para la colmena`})]}),(0,q.jsx)(ge,{checked:u.enabled,onCheckedChange:e=>d(t=>({...t,enabled:e}))})]})]})]}),(0,q.jsxs)(`div`,{className:`p-6 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`p-2 rounded-xl bg-emerald-500/10 border border-emerald-500/20`,children:(0,q.jsx)(J,{icon:h,className:`h-4 w-4 text-emerald-400`})}),(0,q.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Workspace Directory`})]}),(0,q.jsx)(`div`,{className:`space-y-4`,children:(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(V,{htmlFor:`workspace`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directorio de Trabajo`}),(0,q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,q.jsx)(O,{id:`workspace`,value:u.workspace,onChange:e=>{d(t=>({...t,workspace:e.target.value})),v(e.target.value)},className:`bg-white/5 border-white/10 focus:border-emerald-500/50 rounded-xl h-11 font-mono text-sm flex-1`,placeholder:`Ej: /home/user/proyectos, D:\\Work`}),u.workspace&&f.exists&&f.accessible&&(0,q.jsx)(w,{type:`button`,variant:`outline`,size:`icon`,onClick:async()=>{if(u.workspace)try{await E(`/api/workspace/open?path=${encodeURIComponent(u.workspace)}`,{method:`GET`})}catch(e){j.fire({icon:`error`,title:e.message})}},className:`shrink-0 border-emerald-500/30 text-emerald-400 hover:bg-emerald-500/10 h-11 w-11`,title:`Abrir en el explorador`,children:(0,q.jsx)(p,{className:`h-4 w-4`})})]}),(0,q.jsx)(`p`,{className:`text-xs text-white/40 leading-relaxed`,children:`Directorio donde el agente operará. Puede ser cualquier ubicación (disco, USB, red).`}),u.workspace&&u.workspace.trim()!==``&&(0,q.jsxs)(`div`,{className:re(`flex items-center gap-2 text-xs p-2.5 rounded-lg border backdrop-blur-md transition-all`,f.isValidating&&`bg-blue-500/10 border-blue-500/20 text-blue-400`,!f.isValidating&&f.exists&&f.accessible&&`bg-emerald-500/10 border-emerald-500/20 text-emerald-400`,!f.isValidating&&f.exists&&!f.accessible&&`bg-amber-500/10 border-amber-500/20 text-amber-400`,!f.isValidating&&!f.exists&&`bg-purple-500/10 border-purple-500/20 text-purple-400`),children:[f.isValidating&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(M,{className:`h-3.5 w-3.5 animate-spin`}),(0,q.jsx)(`span`,{children:`Validando directorio...`})]}),!f.isValidating&&f.exists&&f.accessible&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(o,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:f.message||`Directorio válido y accesible`})]}),!f.isValidating&&f.exists&&!f.accessible&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(c,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:f.message||`Sin permisos de lectura/escritura`})]}),!f.isValidating&&!f.exists&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(h,{className:`h-3.5 w-3.5`}),(0,q.jsx)(`span`,{children:f.message||`El directorio no existe`}),!f.error&&(0,q.jsx)(w,{type:`button`,variant:`outline`,size:`sm`,onClick:async()=>{if(u.workspace)try{await E(`/api/workspace/create`,{method:`POST`,body:{path:u.workspace},showLoader:`Creando directorio...`,showSuccess:`Directorio creado exitosamente`}),await v(u.workspace)}catch(e){j.fire({icon:`error`,title:e.message})}},className:`ml-auto h-6 px-2 text-xs bg-purple-500/20 hover:bg-purple-500/30 text-purple-300 border-purple-500/30`,children:`Crear`})]})]})]})})]})]}),(0,q.jsx)(`div`,{className:`lg:col-span-2 space-y-6`,children:(0,q.jsxs)(`div`,{className:`p-8 rounded-3xl border border-white/10 bg-black/20 backdrop-blur-md space-y-8`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`p-2 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,q.jsx)(J,{icon:x,className:`h-4 w-4 text-amber-400`})}),(0,q.jsx)(`h3`,{className:`font-bold text-white uppercase tracking-wider text-xs`,children:`Configuración Cognitiva`})]}),(0,q.jsxs)(w,{onClick:async()=>{A.show(`Sincronizando configuración del agente...`);try{await n(e,{...u,role:u.role,enabled:+!!u.enabled,workspace:u.workspace||null}),j.fire({icon:`success`,title:`Cambios sincronizados correctamente`})}catch(e){j.fire({icon:`error`,title:e instanceof Error?e.message:`Error al sincronizar cambios`})}finally{A.hide()}},className:`bg-blue-600 hover:bg-blue-500 text-white font-bold rounded-xl px-6 shadow-[0_4px_15px_rgba(37,99,235,0.3)] transition-all active:scale-95 gap-2`,children:[(0,q.jsx)(J,{icon:m,className:`h-4 w-4`}),`Sincronizar Cambios`]})]}),(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsx)(V,{htmlFor:`description`,className:`text-xs text-white/40 uppercase tracking-widest pl-1`,children:`Directiva de Misión (Descripción)`}),(0,q.jsx)(H,{id:`description`,value:u.description,onChange:e=>d(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/10 focus:border-blue-500/50 rounded-2xl min-h-[80px] resize-none`,placeholder:`Define el propósito general de este nodo...`})]}),(0,q.jsxs)(`div`,{className:`space-y-2`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between pl-1`,children:[(0,q.jsx)(V,{className:`text-xs text-white/40 uppercase tracking-widest`,children:`System Prompt (Markdown)`}),(0,q.jsxs)(B,{children:[(0,q.jsx)(P,{asChild:!0,children:(0,q.jsx)(w,{type:`button`,variant:`outline`,size:`sm`,className:`h-7 px-3 text-xs bg-blue-500/10 hover:bg-blue-500/20 text-blue-400 border-blue-500/30 transition-colors`,children:`Modifica acá el System Prompt`})}),(0,q.jsxs)(R,{className:`sm:max-w-3xl bg-[#0a0a0c] border-white/10 text-white shadow-2xl [&>button]:text-white/50 hover:[&>button]:text-white`,children:[(0,q.jsxs)(L,{children:[(0,q.jsx)(z,{className:`text-xl`,children:`Editar System Prompt`}),(0,q.jsx)(F,{className:`text-sm text-white/50`,children:`El comportamiento principal del agente. Se recomienda usar Markdown.`})]}),(0,q.jsx)(`div`,{className:`py-2`,children:(0,q.jsx)(H,{value:u.systemPrompt,onChange:e=>d(t=>({...t,systemPrompt:e.target.value})),className:`min-h-[400px] font-mono text-sm bg-black/40 border-white/10 text-white/90 focus-visible:ring-blue-500/50 resize-y`,placeholder:`Escribe el system prompt detallado aquí...`})}),(0,q.jsx)(N,{children:(0,q.jsx)(I,{asChild:!0,children:(0,q.jsx)(w,{type:`button`,className:`bg-blue-600 hover:bg-blue-500 text-white shadow-[0_0_15px_rgba(37,99,235,0.3)]`,children:`Listo`})})})]})]})]}),u.systemPrompt?(0,q.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4 max-h-[120px] overflow-y-auto custom-scrollbar`,children:(0,q.jsx)(`p`,{className:`text-xs text-white/60 font-mono whitespace-pre-wrap italic`,children:u.systemPrompt})}):(0,q.jsx)(`div`,{className:`bg-white/[0.02] border border-white/5 rounded-2xl p-4`,children:(0,q.jsx)(`p`,{className:`text-xs text-white/30 italic`,children:`Sin system prompt configurado...`})})]}),(0,q.jsx)(g,{selectedProviderId:u.provider_id||void 0,selectedModelId:u.model_id||void 0,onProviderChange:e=>d(t=>({...t,provider_id:e,model_id:``})),onModelChange:e=>d(t=>({...t,model_id:e})),typeFilter:`llm`})]}),(0,q.jsxs)(`div`,{className:`mt-8 p-4 rounded-2xl bg-white/[0.03] border border-white/5 flex items-start gap-4 italic`,children:[(0,q.jsx)(J,{icon:le,className:`h-5 w-5 text-white/20 mt-0.5`}),(0,q.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed`,children:`Las credenciales de acceso y llaves de cifrado para los headers personalizados se gestionan en una capa segura y no son visibles en texto plano para mantener la integridad de la red.`})]})]})})]})}):(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center p-12 text-center space-y-4 rounded-3xl border border-dashed border-white/10 bg-white/5`,children:[(0,q.jsx)(J,{icon:i,className:`h-12 w-12 text-white/10 animate-pulse`}),(0,q.jsx)(`p`,{className:`text-white/40 font-medium`,children:`Buscando nodo en la colmena...`})]})}function Se({agent:e}){let{providers:t}=C(),{models:n}=D(),r=e.role===`coordinator`,o=e.provider_id||e.providerId,s=e.model_id||e.modelId,c=e.created_at||e.createdAt,l=c?_(typeof c==`string`?new Date(c):new Date(c*1e3),`PPP`,{locale:v}):`Fecha desconocida`,u=t.find(e=>e.id===o)?.name||o,d=n.find(e=>e.id===s)?.name||s;return(0,q.jsxs)(`div`,{className:`hive-card--internal group ${e.enabled?`hive-card--internal-active`:`hive-card--internal-disabled`}`,children:[e.enabled&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`absolute -top-24 -right-24 h-64 w-64 bg-blue-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-blue-600/20 transition-all duration-700`}),(0,q.jsx)(`div`,{className:`absolute -bottom-24 -left-24 h-64 w-64 bg-purple-600/10 rounded-full blur-[100px] pointer-events-none group-hover:bg-purple-600/20 transition-all duration-700`})]}),(0,q.jsxs)(`div`,{className:`relative flex flex-col md:flex-row gap-8 items-start justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex-1 space-y-6`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`hive-icon-wrap--internal ${e.enabled?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,q.jsx)(ve,{className:`h-6 w-6 ${e.enabled?`text-blue-400`:`text-white/20`}`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-1`,children:[(0,q.jsx)(`span`,{className:`hive-page-header__label ${!e.enabled&&`text-white/20`}`,children:`Identidad de Nodo`}),r&&(0,q.jsx)(de,{className:`hive-tag--coordinator ${!e.enabled&&`bg-white/5 text-white/20 border-white/10`}`,children:`Coordinador`})]}),(0,q.jsx)(`h1`,{className:`text-4xl font-black tracking-tighter ${e.enabled?`text-white`:`text-white/40`}`,children:e.name})]})]}),(0,q.jsxs)(`p`,{className:`text-lg leading-relaxed max-w-2xl font-light italic ${e.enabled?`text-white/60`:`text-white/20`}`,children:[`"`,e.description||`Este agente no tiene una descripción definida aún.`,`"`]})]}),(0,q.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4`,children:[(0,q.jsx)(Y,{icon:f,label:`Infraestructura`,value:u,subValue:d,color:e.enabled?`text-blue-400`:`text-white/20`,enabled:e.enabled}),(0,q.jsx)(Y,{icon:ne,label:`Personalidad`,value:e.tone||`Neutral`,color:e.enabled?`text-purple-400`:`text-white/20`,enabled:e.enabled}),(0,q.jsx)(Y,{icon:a,label:`Desplegado el`,value:l,color:e.enabled?`text-emerald-400`:`text-white/20`,enabled:e.enabled})]})]}),(0,q.jsxs)(`div`,{className:`flex flex-col items-center md:items-end gap-6 min-w-[200px]`,children:[(0,q.jsxs)(`div`,{className:`text-center md:text-right space-y-2`,children:[(0,q.jsx)(`span`,{className:`hive-label block`,children:`Estado Operativo`}),(0,q.jsx)(ee,{status:e.enabled?e.status:`hibernated`,className:`px-6 py-2 text-sm border-2`})]}),(0,q.jsxs)(`div`,{className:`hive-network-panel md:w-auto`,children:[(0,q.jsxs)(`div`,{className:`flex-1`,children:[(0,q.jsx)(`p`,{className:`hive-label mb-1`,children:`Carga de Red`}),(0,q.jsx)(`div`,{className:`hive-network-track`,children:e.enabled&&(0,q.jsx)(`div`,{className:`hive-network-fill`})})]}),(0,q.jsx)(i,{className:`h-5 w-5 ${e.enabled?`text-blue-400 animate-pulse`:`text-white/10`}`})]})]})]}),(0,q.jsx)(`div`,{className:`hive-strip--bottom ${!e.enabled&&`opacity-20`}`}),(0,q.jsxs)(`div`,{className:`absolute top-4 right-8 hive-mono hidden md:block`,children:[`NODE_UID: `,e.id]})]})}function Y({icon:e,label:t,value:n,subValue:r,color:i,enabled:a}){return(0,q.jsxs)(`div`,{className:`hive-info-card ${a?`hive-info-card--active`:`hive-info-card--disabled`}`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,q.jsx)(e,{className:`h-3.5 w-3.5 ${i}`}),(0,q.jsx)(`span`,{className:`hive-info-card__label`,children:t})]}),(0,q.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,q.jsx)(`p`,{className:`hive-info-card__value ${a?`text-white/80 group-hover/item:text-white`:`text-white/20`}`,children:n}),r&&(0,q.jsx)(`p`,{className:`hive-info-card__sub ${a?`text-white/40`:`text-white/10`}`,children:r})]})]})}var Ce={filesystem:`Archivos`,web:`Web`,cron:`Automatización`,cli:`Terminal`,agents:`Agentes`,canvas:`Canvas`,office:`Office`,mcp:`MCP`,core:`Sistema`};function X(e){return e.startsWith(`fs_`)?`filesystem`:e.startsWith(`browser_`)||e.startsWith(`web_`)||e===`search_knowledge`?`web`:e.startsWith(`cron`)?`cron`:e.startsWith(`office_`)?`office`:e.startsWith(`mcp`)||e.includes(`_mcp`)?`mcp`:e.startsWith(`canvas_`)||e.startsWith(`a2ui_`)?`canvas`:e.startsWith(`cli_`)?`cli`:e.includes(`agent`)||e.includes(`task_`)||e.includes(`acceptance`)?`agents`:`core`}function Z(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function we({agent:e}){let{tools:t,isLoading:n,fetchTools:r}=oe(),{skills:i,isLoading:a,fetchSkills:o}=ue();(0,K.useEffect)(()=>{t.length===0&&r(),i.length===0&&o()},[o,r,i.length,t.length]);let s=(0,K.useMemo)(()=>y(e.toolsJson),[e.toolsJson]),c=(0,K.useMemo)(()=>y(e.skillsJson),[e.skillsJson]),u=(0,K.useMemo)(()=>e.role===`coordinator`?e.minimalTools??[]:[],[e.minimalTools,e.role]),d=(0,K.useMemo)(()=>e.role===`coordinator`?e.minimalSkills??[]:[],[e.minimalSkills,e.role]),f=(0,K.useMemo)(()=>{let e=new Map;return u.forEach(t=>e.set(t,{id:t,source:`base`})),s.forEach(t=>{let n=e.get(t.id);e.set(t.id,{...t,source:n?.source??`assigned`})}),Array.from(e.values()).map(e=>{let n=t.find(t=>t.id===e.id);return{id:e.id,name:n?.name||e.suppliedName||Z(e.id),description:n?.description||`Capacidad disponible en el loadout operativo de este agente.`,category:n?.category||X(e.id),available:n?n.enabled&&n.active!==!1:!0,source:e.source}})},[u,s,t]),p=(0,K.useMemo)(()=>{let e=new Map;return d.forEach(t=>e.set(t.id,{id:t.id,suppliedName:t.name,source:`base`})),c.forEach(t=>{let n=e.get(t.id);e.set(t.id,{...t,source:n?.source??`assigned`})}),Array.from(e.values()).map(e=>{let t=i.find(t=>t.id===e.id),n=d.find(t=>t.id===e.id);return{id:e.id,name:t?.name||n?.name||e.suppliedName||Z(e.id),description:t?.description||n?.description||`Conocimiento operativo incluido en el contexto de este agente.`,category:t?.category||n?.category||`core`,source:e.source}})},[d,c,i]),m=new Set(f.map(e=>e.category)).size,h=e.mcpServers??(e.mcpServerIds??[]).map(e=>({id:e,name:e,status:`unknown`,enabled:!0,toolsCount:0})),g=n&&t.length===0||a&&i.length===0;return(0,q.jsxs)(`section`,{className:`mb-8 overflow-hidden rounded-2xl border border-white/[0.08] bg-[#0b0e14]/75`,children:[(0,q.jsxs)(`div`,{className:`flex flex-col gap-4 border-b border-white/[0.07] px-5 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,q.jsx)(`div`,{className:`flex h-9 w-9 items-center justify-center rounded-lg border border-emerald-500/20 bg-emerald-500/10`,children:(0,q.jsx)(T,{className:`h-4 w-4 text-emerald-400`})}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h2`,{className:`text-sm font-black uppercase tracking-[0.12em] text-white/85`,children:`Loadout operativo`}),(0,q.jsx)(`p`,{className:`mt-0.5 text-[11px] text-white/35`,children:e.role===`coordinator`?`Capacidades mínimas del coordinador y asignaciones adicionales`:`Tools y skills asignadas para ejecutar tareas`})]})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,q.jsx)($,{value:f.length,label:`tools`,color:`text-emerald-400`}),(0,q.jsx)(`div`,{className:`h-7 w-px bg-white/[0.08]`}),(0,q.jsx)($,{value:p.length,label:`skills`,color:`text-amber-400`}),h.length>0&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`div`,{className:`h-7 w-px bg-white/[0.08]`}),(0,q.jsx)($,{value:h.length,label:`MCP`,color:`text-violet-400`})]}),(0,q.jsx)(`div`,{className:`hidden h-7 w-px bg-white/[0.08] sm:block`}),(0,q.jsx)(`div`,{className:`hidden sm:block`,children:(0,q.jsx)($,{value:m,label:`categorías`,color:`text-blue-400`})})]})]}),g&&f.length===0&&p.length===0&&h.length===0?(0,q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-14 text-xs text-white/35`,children:[(0,q.jsx)(M,{className:`h-4 w-4 animate-spin text-emerald-400`}),`Sincronizando loadout…`]}):f.length===0&&p.length===0&&h.length===0?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-5 py-14 text-center`,children:[(0,q.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-xl border border-dashed border-white/10 bg-white/[0.025]`,children:(0,q.jsx)(be,{className:`h-5 w-5 text-white/20`})}),(0,q.jsx)(`p`,{className:`mt-3 text-sm font-semibold text-white/60`,children:`Este agente no tiene capacidades asignadas`}),(0,q.jsx)(`p`,{className:`mt-1 text-xs text-white/30`,children:`Su loadout operativo está vacío.`})]}):(0,q.jsxs)(q.Fragment,{children:[f.length>0&&(0,q.jsxs)(`div`,{className:`p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(T,{className:`h-3.5 w-3.5 text-emerald-400`}),(0,q.jsx)(`h3`,{className:`text-[10px] font-black uppercase tracking-[0.16em] text-white/50`,children:`Tools disponibles`})]}),(0,q.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2 xl:grid-cols-3`,children:f.map(e=>(0,q.jsxs)(`article`,{className:`group rounded-xl border border-white/[0.07] bg-black/20 p-3.5 transition-colors hover:border-emerald-500/20 hover:bg-emerald-500/[0.025]`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-white/[0.07] bg-white/[0.035]`,children:(0,q.jsx)(Te(e.category),{className:`h-3.5 w-3.5 text-emerald-400/80`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h4`,{className:`truncate text-xs font-bold text-white/80`,title:e.name,children:e.name}),(0,q.jsx)(`span`,{title:e.available?`Disponible`:`No disponible`,children:(0,q.jsx)(l,{className:`h-3.5 w-3.5 shrink-0 ${e.available?`text-emerald-400`:`text-white/15`}`})})]}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 min-h-8 text-[10px] leading-4 text-white/30`,children:e.description})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-white/[0.05] pt-2`,children:[(0,q.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-[0.14em] text-emerald-400/65`,children:Ce[e.category]||e.category}),(0,q.jsx)(Q,{source:e.source})]})]},e.id))})]}),h.length>0&&(0,q.jsxs)(`div`,{className:`border-t border-white/[0.07] p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(b,{className:`h-3.5 w-3.5 text-violet-400`}),(0,q.jsx)(`h3`,{className:`text-[10px] font-black uppercase tracking-[0.16em] text-white/50`,children:`Integraciones MCP asignadas`})]}),(0,q.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2 xl:grid-cols-3`,children:h.map(e=>(0,q.jsxs)(`article`,{className:`rounded-xl border border-violet-500/15 bg-violet-500/[0.035] p-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-violet-500/20 bg-violet-500/[0.08]`,children:(0,q.jsx)(b,{className:`h-3.5 w-3.5 text-violet-300`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,q.jsx)(`h4`,{className:`truncate text-xs font-bold text-white/80`,title:e.name,children:e.name}),(0,q.jsx)(`span`,{className:`mt-1 h-2 w-2 shrink-0 rounded-full ${e.enabled?`bg-emerald-400`:`bg-white/20`}`})]}),(0,q.jsxs)(`p`,{className:`mt-1 text-[10px] leading-4 text-white/30`,children:[`Servidor completo · `,e.toolsCount,` tools sincronizadas`]})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-white/[0.05] pt-2`,children:[(0,q.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-[0.14em] text-violet-300/70`,children:e.status}),(0,q.jsx)(`span`,{className:`rounded bg-violet-500/10 px-1.5 py-0.5 text-[7px] font-black uppercase tracking-wider text-violet-200/70`,children:`Persistente`})]})]},e.id))})]}),p.length>0&&(0,q.jsxs)(`div`,{className:`border-t border-white/[0.07] p-4`,children:[(0,q.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,q.jsx)(W,{className:`h-3.5 w-3.5 text-amber-400`}),(0,q.jsx)(`h3`,{className:`text-[10px] font-black uppercase tracking-[0.16em] text-white/50`,children:`Skills en contexto`})]}),(0,q.jsx)(`div`,{className:`grid gap-2.5 sm:grid-cols-2 xl:grid-cols-3`,children:p.map(e=>(0,q.jsxs)(`article`,{className:`rounded-xl border border-amber-500/10 bg-amber-500/[0.025] p-3.5`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,q.jsx)(`div`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-lg border border-amber-500/15 bg-amber-500/[0.07]`,children:(0,q.jsx)(W,{className:`h-3.5 w-3.5 text-amber-400`})}),(0,q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`h4`,{className:`truncate text-xs font-bold text-white/80`,title:e.name,children:e.name}),(0,q.jsx)(`p`,{className:`mt-1 line-clamp-2 min-h-8 text-[10px] leading-4 text-white/30`,children:e.description})]})]}),(0,q.jsxs)(`div`,{className:`mt-3 flex items-center justify-between border-t border-white/[0.05] pt-2`,children:[(0,q.jsx)(`span`,{className:`text-[8px] font-bold uppercase tracking-[0.14em] text-amber-400/65`,children:e.category}),(0,q.jsx)(Q,{source:e.source})]})]},e.id))})]})]})]})}function Q({source:e}){return(0,q.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[7px] font-black uppercase tracking-wider ${e===`base`?`bg-blue-500/10 text-blue-300/70`:`bg-white/5 text-white/25`}`,children:e===`base`?`Minimal · base`:`Asignada`})}function $({value:e,label:t,color:n}){return(0,q.jsxs)(`div`,{className:`text-right`,children:[(0,q.jsx)(`p`,{className:`text-base font-black tabular-nums ${n}`,children:e}),(0,q.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:t})]})}function Te(e){switch(e){case`filesystem`:return G;case`web`:return d;case`cron`:return _e;case`cli`:return S;case`agents`:return ce;case`canvas`:return u;case`mcp`:return b;case`office`:return G;default:return T}}function Ee(){let{id:e}=ae(),t=ie(),n=e??`unknown`,{agents:r,fetchAgents:a}=k();(0,K.useEffect)(()=>{a()},[a]);let o=r.find(e=>e.id===n);return(0,q.jsx)(`div`,{className:`min-h-screen bg-transparent pb-20`,children:(0,q.jsxs)(`div`,{className:`max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 animate-fade-in`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,q.jsxs)(w,{variant:`ghost`,onClick:()=>t(`/agents`),className:`group flex items-center gap-2 text-white/40 hover:text-white hover:bg-white/5 px-4 py-2 rounded-xl transition-colors`,children:[(0,q.jsx)(s,{className:`h-4 w-4 transition-transform group-hover:-translate-x-1`}),(0,q.jsx)(`span`,{className:`text-sm font-bold uppercase tracking-widest`,children:`Volver a la Colmena`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-4 text-white/20`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(ye,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Agentes`})]}),(0,q.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsx)(i,{className:`h-4 w-4`}),(0,q.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,children:`Detalles Operativos`})]})]})]}),o?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Se,{agent:o}),(0,q.jsx)(we,{agent:o}),(0,q.jsx)(`div`,{className:`grid grid-cols-1 gap-8`,children:(0,q.jsx)(xe,{agentId:n})})]}):(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[60vh] text-center space-y-6`,children:[(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`div`,{className:`h-24 w-24 rounded-full border-4 border-t-blue-500 border-white/5 animate-spin`}),(0,q.jsx)(i,{className:`absolute inset-0 m-auto h-8 w-8 text-blue-400 animate-pulse`})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h3`,{className:`text-xl font-bold text-white mb-2`,children:`Sincronizando con el Nodo`}),(0,q.jsx)(`p`,{className:`text-white/40 max-w-xs mx-auto`,children:`Estamos recuperando la configuración cuántica de este agente desde la base de datos central.`})]})]})]})})}export{Ee as AgentDetailPage};
@@ -0,0 +1 @@
1
+ import{o as e}from"./vendor-query-Dj8xYhQD.js";import{t}from"./AgentCreateForm-Bcp3HN8D.js";var n=e();function r(){return(0,n.jsx)(t,{})}export{r as AgentNewPage};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{_ as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,p as u,u as d,v as f,y as p}from"./vendor-radix-DUug7irY.js";import{o as m}from"./vendor-query-Dj8xYhQD.js";import{t as h}from"./createLucideIcon-BRaPSYgN.js";import{t as g}from"./activity-C_GS5wrG.js";import{t as _}from"./arrow-up-right-DWzTsCXj.js";import{t as v}from"./calendar-B6x9cw-q.js";import{t as y}from"./check-C8pw-7Fx.js";import{t as b}from"./chevron-right-BupZqrxu.js";import{t as x}from"./useProviders-CiLSc05q.js";import{t as S}from"./ellipsis-vertical-BOW_iEOO.js";import{t as C}from"./file-text-DNSyNLUh.js";import{r as w}from"./ModelSelector-CrgJQ7DG.js";import{t as ee}from"./gauge-C__zxC3_.js";import{n as te,t as ne}from"./pencil-CUbpCfeG.js";import{a as re,i as ie,n as T,o as ae,s as oe,t as E}from"./agentCapabilities-Dg72UAFj.js";import{t as D}from"./plus-DzvRxH4U.js";import{t as se}from"./refresh-cw-DZXu5FrG.js";import{t as O}from"./shield-BPZZhjCT.js";import{t as ce}from"./sparkles-BViXTAh7.js";import{t as k}from"./trash-2-SgYCWiVk.js";import{t as A}from"./zap-OVVrfEHr.js";import{t as j}from"./utils-SGUggNJc.js";import{c as M}from"./vendor-router-Dsg8fxNQ.js";import{B as le,H as ue,T as N,U as P,_ as F,f as I,rt as de,v as L}from"./index-BHHUQZJd.js";import{t as fe}from"./AgentCreateForm-Dh5W0q_t.js";var R=h(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),pe=h(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),me=h(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),z=h(`Pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),B=e(t(),1),V=m(),he=s,ge=p,_e=B.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,V.jsxs)(f,{ref:i,className:j(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent`,t&&`pl-8`,e),...r,children:[n,(0,V.jsx)(b,{className:`ml-auto h-4 w-4`})]}));_e.displayName=f.displayName;var ve=B.forwardRef(({className:e,...t},r)=>(0,V.jsx)(n,{ref:r,className:j(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));ve.displayName=n.displayName;var H=B.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,V.jsx)(u,{children:(0,V.jsx)(c,{ref:r,sideOffset:t,className:j(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));H.displayName=c.displayName;var U=B.forwardRef(({className:e,inset:t,...n},r)=>(0,V.jsx)(d,{ref:r,className:j(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,t&&`pl-8`,e),...n}));U.displayName=d.displayName;var ye=B.forwardRef(({className:e,children:t,checked:n,...a},o)=>(0,V.jsxs)(r,{ref:o,className:j(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,e),checked:n,...a,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(i,{children:(0,V.jsx)(y,{className:`h-4 w-4`})})}),t]}));ye.displayName=r.displayName;var be=B.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(l,{ref:r,className:j(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,e),...n,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(i,{children:(0,V.jsx)(pe,{className:`h-2 w-2 fill-current`})})}),t]}));be.displayName=l.displayName;var xe=B.forwardRef(({className:e,inset:t,...n},r)=>(0,V.jsx)(a,{ref:r,className:j(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));xe.displayName=a.displayName;var Se=B.forwardRef(({className:e,...t},n)=>(0,V.jsx)(o,{ref:n,className:j(`-mx-1 my-1 h-px bg-muted`,e),...t}));Se.displayName=o.displayName;var Ce=({className:e,...t})=>(0,V.jsx)(`span`,{className:j(`ml-auto text-xs tracking-widest opacity-60`,e),...t});Ce.displayName=`DropdownMenuShortcut`;function we(e){if(!e)return null;try{return re(new Date(e),`dd MMM yyyy`,{locale:ie})}catch{return null}}function Te({agent:e,onEdit:t}){let n=M(),{deleteAgent:r}=I(),{providers:i}=L(),{models:a}=F(),o=t=>{t.target.closest(`[role="menuitem"]`)||t.target.closest(`button`)||n(`/agents/${e.id}`)},s=async t=>{if(t.stopPropagation(),(await N.fire({title:`¿Eliminar Agente?`,text:`¿Estás seguro de que deseas eliminar al agente "${e.name}"? Esta acción eliminará permanentemente su configuración.`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, eliminar`,cancelButtonText:`Cancelar`,reverseButtons:!0,background:`#09090b`,color:`#fff`,customClass:{popup:`border border-white/10 rounded-xl`,confirmButton:`bg-red-500 hover:bg-red-600 text-white`,cancelButton:`bg-white/10 hover:bg-white/20 text-white`}})).isConfirmed)try{await r(e.id)}catch(e){console.error(e)}},c=e.role===`coordinator`,l=e.provider_id||e.providerId,u=e.model_id||e.modelId,d=i.find(e=>e.id===l)?.name||l,f=a.find(e=>e.id===u)?.name||u,p=e.enabled?e.status:`hibernated`,m=T(e).length,h=E(e).length,_=!!e.systemPrompt,y=e.maxIterations||10,b=we(e.created_at||e.createdAt);return(0,V.jsxs)(`div`,{role:`button`,tabIndex:0,className:`group relative overflow-hidden rounded-2xl border bg-black/40 backdrop-blur-xl transition-all duration-500 cursor-pointer flex flex-col h-full
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{_ as n,c as r,d as i,f as a,g as o,h as s,l as c,m as l,p as u,u as d,v as f,y as p}from"./vendor-radix-DUug7irY.js";import{o as m}from"./vendor-query-Dj8xYhQD.js";import{t as h}from"./createLucideIcon-BRaPSYgN.js";import{t as g}from"./activity-C_GS5wrG.js";import{t as _}from"./arrow-up-right-DWzTsCXj.js";import{t as v}from"./calendar-B6x9cw-q.js";import{t as y}from"./check-C8pw-7Fx.js";import{t as b}from"./chevron-right-BupZqrxu.js";import{t as x}from"./useProviders-C7FA6z4M.js";import{t as S}from"./ellipsis-vertical-BOW_iEOO.js";import{t as C}from"./file-text-DNSyNLUh.js";import{r as w}from"./ModelSelector-DfExlPzx.js";import{t as ee}from"./gauge-C__zxC3_.js";import{n as te,t as ne}from"./pencil-CUbpCfeG.js";import{a as re,i as ie,n as T,o as ae,s as oe,t as E}from"./agentCapabilities-DOeepCty.js";import{t as D}from"./plus-DzvRxH4U.js";import{t as se}from"./refresh-cw-DZXu5FrG.js";import{t as O}from"./shield-nLNsomh_.js";import{t as ce}from"./sparkles-CerRDYxk.js";import{t as k}from"./trash-2-BZsMCfso.js";import{t as A}from"./zap-Yed86Sh8.js";import{t as j}from"./utils-lc8H6VGT.js";import{c as M}from"./vendor-router-DCsSv_I7.js";import{A as N,C as P,G as le,J as F,S as I,_ as L,lt as ue,q as de}from"./index-Bi8qEmrK.js";import{t as fe}from"./AgentCreateForm-Bcp3HN8D.js";var R=h(`BrainCircuit`,[[`path`,{d:`M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`,key:`l5xja`}],[`path`,{d:`M9 13a4.5 4.5 0 0 0 3-4`,key:`10igwf`}],[`path`,{d:`M6.003 5.125A3 3 0 0 0 6.401 6.5`,key:`105sqy`}],[`path`,{d:`M3.477 10.896a4 4 0 0 1 .585-.396`,key:`ql3yin`}],[`path`,{d:`M6 18a4 4 0 0 1-1.967-.516`,key:`2e4loj`}],[`path`,{d:`M12 13h4`,key:`1ku699`}],[`path`,{d:`M12 18h6a2 2 0 0 1 2 2v1`,key:`105ag5`}],[`path`,{d:`M12 8h8`,key:`1lhi5i`}],[`path`,{d:`M16 8V5a2 2 0 0 1 2-2`,key:`u6izg6`}],[`circle`,{cx:`16`,cy:`13`,r:`.5`,key:`ry7gng`}],[`circle`,{cx:`18`,cy:`3`,r:`.5`,key:`1aiba7`}],[`circle`,{cx:`20`,cy:`21`,r:`.5`,key:`yhc1fs`}],[`circle`,{cx:`20`,cy:`8`,r:`.5`,key:`1e43v0`}]]),pe=h(`Circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),me=h(`GitBranch`,[[`line`,{x1:`6`,x2:`6`,y1:`3`,y2:`15`,key:`17qcm7`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M18 9a9 9 0 0 1-9 9`,key:`n2h4wq`}]]),z=h(`Pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),B=e(t(),1),V=m(),he=s,ge=p,_e=B.forwardRef(({className:e,inset:t,children:n,...r},i)=>(0,V.jsxs)(f,{ref:i,className:j(`flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none data-[state=open]:bg-accent focus:bg-accent`,t&&`pl-8`,e),...r,children:[n,(0,V.jsx)(b,{className:`ml-auto h-4 w-4`})]}));_e.displayName=f.displayName;var ve=B.forwardRef(({className:e,...t},r)=>(0,V.jsx)(n,{ref:r,className:j(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...t}));ve.displayName=n.displayName;var H=B.forwardRef(({className:e,sideOffset:t=4,...n},r)=>(0,V.jsx)(u,{children:(0,V.jsx)(c,{ref:r,sideOffset:t,className:j(`z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2`,e),...n})}));H.displayName=c.displayName;var U=B.forwardRef(({className:e,inset:t,...n},r)=>(0,V.jsx)(d,{ref:r,className:j(`relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,t&&`pl-8`,e),...n}));U.displayName=d.displayName;var ye=B.forwardRef(({className:e,children:t,checked:n,...a},o)=>(0,V.jsxs)(r,{ref:o,className:j(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,e),checked:n,...a,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(i,{children:(0,V.jsx)(y,{className:`h-4 w-4`})})}),t]}));ye.displayName=r.displayName;var be=B.forwardRef(({className:e,children:t,...n},r)=>(0,V.jsxs)(l,{ref:r,className:j(`relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 focus:bg-accent focus:text-accent-foreground`,e),...n,children:[(0,V.jsx)(`span`,{className:`absolute left-2 flex h-3.5 w-3.5 items-center justify-center`,children:(0,V.jsx)(i,{children:(0,V.jsx)(pe,{className:`h-2 w-2 fill-current`})})}),t]}));be.displayName=l.displayName;var xe=B.forwardRef(({className:e,inset:t,...n},r)=>(0,V.jsx)(a,{ref:r,className:j(`px-2 py-1.5 text-sm font-semibold`,t&&`pl-8`,e),...n}));xe.displayName=a.displayName;var Se=B.forwardRef(({className:e,...t},n)=>(0,V.jsx)(o,{ref:n,className:j(`-mx-1 my-1 h-px bg-muted`,e),...t}));Se.displayName=o.displayName;var Ce=({className:e,...t})=>(0,V.jsx)(`span`,{className:j(`ml-auto text-xs tracking-widest opacity-60`,e),...t});Ce.displayName=`DropdownMenuShortcut`;function we(e){if(!e)return null;try{return re(new Date(e),`dd MMM yyyy`,{locale:ie})}catch{return null}}function Te({agent:e,onEdit:t}){let n=M(),{deleteAgent:r}=L(),{providers:i}=P(),{models:a}=I(),o=t=>{t.target.closest(`[role="menuitem"]`)||t.target.closest(`button`)||n(`/agents/${e.id}`)},s=async t=>{if(t.stopPropagation(),(await N.fire({title:`¿Eliminar Agente?`,text:`¿Estás seguro de que deseas eliminar al agente "${e.name}"? Esta acción eliminará permanentemente su configuración.`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, eliminar`,cancelButtonText:`Cancelar`,reverseButtons:!0,background:`#09090b`,color:`#fff`,customClass:{popup:`border border-white/10 rounded-xl`,confirmButton:`bg-red-500 hover:bg-red-600 text-white`,cancelButton:`bg-white/10 hover:bg-white/20 text-white`}})).isConfirmed)try{await r(e.id)}catch(e){console.error(e)}},c=e.role===`coordinator`,l=e.provider_id||e.providerId,u=e.model_id||e.modelId,d=i.find(e=>e.id===l)?.name||l,f=a.find(e=>e.id===u)?.name||u,p=e.enabled?e.status:`hibernated`,m=T(e).length,h=E(e).length,_=!!e.systemPrompt,y=e.maxIterations||10,b=we(e.created_at||e.createdAt);return(0,V.jsxs)(`div`,{role:`button`,tabIndex:0,className:`group relative overflow-hidden rounded-2xl border bg-black/40 backdrop-blur-xl transition-all duration-500 cursor-pointer flex flex-col h-full
2
2
  ${e.enabled?c?`border-purple-500/20 hover:border-purple-500/50 hover:bg-white/[0.03] hover:shadow-[0_0_30px_rgba(168,85,247,0.15)]`:`border-white/10 hover:border-blue-500/50 hover:bg-white/[0.03] hover:shadow-[0_0_30px_rgba(59,130,246,0.15)]`:`border-white/5 opacity-70 grayscale hover:grayscale-0`}
3
3
  `,onClick:o,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&n(`/agents/${e.id}`)},children:[e.enabled&&(0,V.jsx)(`div`,{className:`absolute top-0 left-0 right-0 h-px bg-gradient-to-r from-transparent ${c?`via-purple-500/60`:`via-blue-500/50`} to-transparent`}),e.enabled&&(0,V.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-br ${c?`from-purple-500/10 via-transparent to-blue-500/5`:`from-blue-500/10 via-transparent to-purple-500/10`} opacity-0 transition-opacity duration-500 group-hover:opacity-100 pointer-events-none`}),(0,V.jsxs)(`div`,{className:`p-5 flex flex-col flex-1 relative z-10`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3 mb-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`w-11 h-11 rounded-xl flex items-center justify-center shrink-0 border transition-colors
4
4
  ${c?`bg-purple-500/10 border-purple-500/20 group-hover:border-purple-500/40`:`bg-blue-500/10 border-blue-500/20 group-hover:border-blue-500/40`}`,children:c?(0,V.jsx)(O,{className:`h-5 w-5 text-purple-400`}):(0,V.jsx)(x,{className:`h-5 w-5 text-blue-400`})}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`h3`,{className:`text-base font-bold tracking-tight transition-colors truncate ${e.enabled?`text-white/95 group-hover:text-white`:`text-white/40`}`,children:e.name}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5 flex-wrap`,children:[(0,V.jsx)(`span`,{className:`text-[9px] px-2 py-0.5 rounded-full font-bold uppercase border
@@ -6,5 +6,5 @@ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-c
6
6
  ${e.enabled?`bg-white/5 border-white/10 text-white/80 group-hover:bg-white/10 group-hover:border-white/20`:`bg-transparent border-white/5 text-white/30`}`,children:[(0,V.jsx)(x,{className:`h-3 w-3`}),d]}),u&&(0,V.jsx)(`div`,{className:`px-2.5 py-1 rounded-md text-[10px] font-medium tracking-wider border backdrop-blur-md transition-colors truncate max-w-[120px]
7
7
  ${e.enabled?`bg-white/5 border-white/10 text-white/80 group-hover:bg-white/10 group-hover:border-white/20`:`bg-transparent border-white/5 text-white/30`}`,title:f,children:f}),e.tone&&(0,V.jsxs)(`div`,{className:`px-2.5 py-1 rounded-md text-[10px] font-medium uppercase tracking-wider flex items-center gap-1.5 border backdrop-blur-md transition-colors
8
8
  ${e.enabled?`bg-white/5 border-white/10 text-white/80 group-hover:bg-white/10 group-hover:border-white/20`:`bg-transparent border-white/5 text-white/30`}`,children:[(0,V.jsx)(g,{className:`h-3 w-3`}),e.tone]}),e.workspace&&(0,V.jsxs)(`div`,{className:`px-2.5 py-1 rounded-md text-[10px] font-medium uppercase tracking-wider flex items-center gap-1.5 border backdrop-blur-md transition-colors
9
- ${e.enabled?`bg-emerald-500/5 border-emerald-500/20 text-emerald-300 group-hover:bg-emerald-500/10 group-hover:border-emerald-500/30`:`bg-transparent border-white/5 text-white/30`}`,title:`Workspace: ${e.workspace}`,children:[(0,V.jsx)(w,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{className:`truncate max-w-[100px]`,children:`Workspace`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-white/5 grid grid-cols-4 gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(P,{className:`h-3 w-3 text-emerald-400/70`}),`Tools`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:m})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(A,{className:`h-3 w-3 text-amber-400/70`}),`Skills`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:h})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(C,{className:`h-3 w-3 text-blue-400/70`}),`Prompt`]}),(0,V.jsx)(`span`,{className:`text-sm font-bold ${e.enabled?_?`text-emerald-400`:`text-white/30`:`text-white/20`}`,children:_?`✓`:`—`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(ee,{className:`h-3 w-3 text-purple-400/70`}),`Iters`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:y})]})]}),e.systemPrompt&&(0,V.jsxs)(`div`,{className:`mt-3 bg-white/[0.02] rounded-lg p-3 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase mb-1.5 flex items-center gap-1.5`,children:[(0,V.jsx)(C,{className:`h-3 w-3 text-blue-400/70`}),`System Prompt`]}),(0,V.jsxs)(`p`,{className:`text-xs text-white/60 font-mono line-clamp-2 leading-relaxed italic`,children:[`"`,e.systemPrompt,`"`]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsx)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase`,children:`Tareas`}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:e.taskCount||0})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsx)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase`,children:`Éxito`}),(0,V.jsxs)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-emerald-400/90`:`text-white/30`}`,children:[e.successRate||0,`%`]})]})]}),(0,V.jsxs)(`div`,{className:`mt-auto pt-5 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`h-2 w-2 rounded-full ${e.enabled?`bg-blue-400 shadow-[0_0_8px_rgba(96,165,250,0.8)] animate-pulse`:`bg-white/20`}`}),(0,V.jsx)(`span`,{className:`text-[10px] font-bold tracking-widest uppercase ${e.enabled?`text-blue-400`:`text-white/30`}`,children:e.enabled?`ACTIVO`:`INACTIVO`})]}),b&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-white/30 font-medium tracking-wider pl-3 border-l border-white/10`,children:[(0,V.jsx)(v,{className:`h-3 w-3`}),b]})]}),(0,V.jsxs)(`div`,{className:`text-xs font-semibold tracking-wide flex items-center gap-1.5 transition-all
10
- ${e.enabled?`text-white/70 group-hover:text-blue-400 translate-x-1 group-hover:translate-x-0`:`text-white/20`}`,children:[`INGRESAR`,(0,V.jsx)(`span`,{className:`transition-transform group-hover:translate-x-1 opacity-0 group-hover:opacity-100 hidden sm:inline-block`,children:`→`})]})]})]})]})}var W=Math.sqrt(3),G=82;function Ee(e,t){return{x:G*1.5*e,y:G*(W/2*e+W*t)}}var K=[{q:1,r:0},{q:1,r:-1},{q:0,r:-1},{q:-1,r:0},{q:-1,r:1},{q:0,r:1}],q=[{q:2,r:0},{q:2,r:-1},{q:2,r:-2},{q:1,r:-2},{q:0,r:-2},{q:-1,r:-1},{q:-2,r:0},{q:-2,r:1},{q:-2,r:2},{q:-1,r:2},{q:0,r:2},{q:1,r:1}];function J(e,t){return t<=0?[]:t>=e.length?e:Array.from({length:t},(n,r)=>e[Math.floor(r*e.length/t)])}var Y=`polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)`,X={active:{bg:`#22c55e22`,dot:`#22c55e`,glow:`0 0 12px #22c55e88`},idle:{bg:`#f59e0b22`,dot:`#f59e0b`,glow:`0 0 12px #f59e0b88`},thinking:{bg:`#6366f122`,dot:`#818cf8`,glow:`0 0 12px #6366f188`},error:{bg:`#ef444422`,dot:`#ef4444`,glow:`0 0 12px #ef444488`},hibernated:{bg:`#1f293700`,dot:`#4b5563`,glow:`none`}};function Z(e){if(!e)return 0;try{let t=JSON.parse(e);return Array.isArray(t)?t.length:0}catch{return 0}}function De({agents:e,onEdit:t,selectedId:n,onSelect:r}){let i=M(),{deleteAgent:a}=I(),[o,s]=(0,B.useState)(null),{coordinator:c,workers:l}=(0,B.useMemo)(()=>{let t=e.find(e=>e.role===`coordinator`)??e[0];return{coordinator:t,workers:e.filter(e=>e.id!==t?.id)}},[e]),u=(0,B.useMemo)(()=>{let e=Math.min(l.length,K.length),t=Math.min(Math.max(l.length-K.length,0),q.length);return[...J(K,e),...J(q,t)].map(({q:e,r:t})=>Ee(e,t))},[l.length]),d=l.slice(0,u.length),f=l.length>6?2:1,p=f===2?700:520,m=f===2?680:500,h=p/2,g=m/2,_=Math.round(164*W/2),v=Math.round(124*W/2),y=async(e,t)=>{if(t.stopPropagation(),(await N.fire({title:`¿Eliminar Agente?`,text:`¿Eliminar "${e.name}"?`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, eliminar`,cancelButtonText:`Cancelar`,background:`#09090b`,color:`#fff`})).isConfirmed)try{await a(e.id)}catch(e){console.error(`No se pudo eliminar el agente:`,e)}},b=c?X[c.enabled?c.status:`hibernated`]??X.hibernated:X.hibernated;return(0,V.jsxs)(`div`,{className:`w-full overflow-x-auto overflow-y-visible py-3`,children:[(0,V.jsxs)(`div`,{className:`relative mx-auto select-none`,style:{width:p,height:m},children:[(0,V.jsx)(`div`,{className:`absolute pointer-events-none rounded-full blur-[80px] opacity-30`,style:{width:260,height:260,left:h-130,top:g-130,background:`radial-gradient(circle, rgba(245,158,11,0.6) 0%, transparent 70%)`}}),(0,V.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:p,height:m,xmlns:`http://www.w3.org/2000/svg`,children:[(0,V.jsxs)(`defs`,{children:[(0,V.jsx)(`pattern`,{id:`hc-hex`,x:`0`,y:`0`,width:`52`,height:`30`,patternUnits:`userSpaceOnUse`,children:(0,V.jsx)(`polygon`,{points:`26,1 51,15.5 51,29 26,29 1,15.5 1,1`,fill:`none`,stroke:`rgba(255,255,255,0.03)`,strokeWidth:`1`})}),(0,V.jsxs)(`radialGradient`,{id:`fade-mask`,cx:`50%`,cy:`50%`,r:`50%`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`white`,stopOpacity:`0.08`}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`white`,stopOpacity:`0`})]})]}),(0,V.jsx)(`rect`,{width:p,height:m,fill:`url(#hc-hex)`}),(0,V.jsx)(`rect`,{width:p,height:m,fill:`url(#fade-mask)`}),d.map((e,t)=>{let r=u[t],i=o===e.id||n===e.id;return(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`line`,{x1:h,y1:g,x2:h+r.x,y2:g+r.y,stroke:i?`rgba(245,158,11,0.5)`:`rgba(245,158,11,0.12)`,strokeWidth:i?2:1,strokeDasharray:`5 5`,style:{transition:`stroke 0.3s ease, stroke-width 0.3s ease`}}),e.enabled&&(0,V.jsx)(`circle`,{r:`3`,fill:`rgba(245,158,11,0.7)`,children:(0,V.jsx)(`animateMotion`,{dur:`${2.5+t*.4}s`,repeatCount:`indefinite`,path:`M ${h} ${g} L ${h+r.x} ${g+r.y}`})})]},`line-${e.id}`)})]}),c&&(0,V.jsxs)(`div`,{className:`absolute z-20 cursor-pointer group outline-none`,style:{left:h-164/2,top:g-_/2,width:164,height:_},onMouseEnter:()=>s(c.id),onMouseLeave:()=>s(null),children:[(0,V.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300/70`,style:{clipPath:Y},onClick:()=>r?.(c.id),"aria-label":`Seleccionar ${c.name}`,"aria-pressed":n===c.id}),(0,V.jsx)(`div`,{className:`absolute inset-[-6px] blur-[10px] transition-opacity duration-500 ${n===c.id?`opacity-90`:`opacity-40 group-hover:opacity-80`}`,style:{clipPath:Y,background:`rgba(245,158,11,0.5)`}}),(0,V.jsx)(`div`,{className:`absolute inset-0 transition-transform duration-300 ${n===c.id?`scale-105`:`group-hover:scale-105`}`,style:{clipPath:Y,background:`rgba(245,158,11,0.55)`},children:(0,V.jsx)(`div`,{className:`absolute inset-[2px]`,style:{clipPath:Y,background:`linear-gradient(145deg, #1c1100 0%, #0d0b00 60%, #120d00 100%)`},children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-1.5 px-3`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(O,{className:`h-8 w-8 text-amber-400 drop-shadow-[0_0_8px_rgba(245,158,11,0.8)]`}),(0,V.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 h-2.5 w-2.5 rounded-full border-2 border-black`,style:{backgroundColor:b.dot,boxShadow:b.glow}})]}),(0,V.jsx)(`span`,{className:`text-[10px] font-black text-amber-300 tracking-[0.12em] text-center leading-tight uppercase line-clamp-2`,children:c.name}),(0,V.jsx)(`span`,{className:`text-[8px] text-amber-500/70 tracking-widest uppercase font-semibold`,children:`Coordinadora`})]})})}),(0,V.jsxs)(`div`,{className:`pointer-events-none absolute -bottom-8 left-1/2 z-30 flex -translate-x-1/2 gap-1 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100`,children:[(0,V.jsx)(`button`,{type:`button`,className:`p-1.5 rounded bg-black/80 border border-amber-500/30 text-amber-400 hover:bg-amber-500/20 transition-colors`,onClick:e=>{e.stopPropagation(),t?.(c)},title:`Editar`,children:(0,V.jsx)(z,{className:`h-3 w-3`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1.5 rounded bg-black/80 border border-white/10 text-white/50 hover:text-white hover:border-white/20 transition-colors`,onClick:e=>{e.stopPropagation(),i(`/agents/${c.id}`)},title:`Ver detalle`,children:(0,V.jsx)(`span`,{className:`text-[9px] px-0.5`,children:`→`})})]})]}),d.map((e,a)=>{let c=u[a],l=h+c.x-124/2,d=g+c.y-v/2,f=X[e.enabled?e.status:`hibernated`]??X.hibernated,p=Z(e.toolsJson),m=Z(e.skillsJson),_=o===e.id,b=n===e.id,S=e.enabled?b?`rgba(245,158,11,0.95)`:_?`rgba(96,165,250,0.9)`:`rgba(59,130,246,0.45)`:`rgba(255,255,255,0.08)`,C=e.enabled?`linear-gradient(145deg, #050d1c 0%, #020912 60%, #040a18 100%)`:`#0a0a0b`;return(0,V.jsxs)(`div`,{className:`absolute z-10 cursor-pointer group outline-none`,style:{left:l,top:d,width:124,height:v},onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),children:[(0,V.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-300/70`,style:{clipPath:Y},onClick:()=>r?.(e.id),"aria-label":`Seleccionar ${e.name}`,"aria-pressed":b}),e.enabled&&(0,V.jsx)(`div`,{className:`absolute inset-[-5px] transition-opacity duration-300 blur-[8px]`,style:{clipPath:Y,background:b?`rgba(245,158,11,0.45)`:`rgba(59,130,246,0.35)`,opacity:b?.9:_?.8:.2}}),(0,V.jsx)(`div`,{className:`absolute inset-0 transition-transform duration-300`,style:{clipPath:Y,background:S,transform:b?`scale(1.08)`:_?`scale(1.06)`:`scale(1)`},children:(0,V.jsx)(`div`,{className:`absolute inset-[1.5px]`,style:{clipPath:Y,background:C},children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-1 px-2`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(x,{className:`h-5 w-5 transition-colors duration-300`,style:{color:b?`#fbbf24`:e.enabled?`#60a5fa`:`#374151`}}),(0,V.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 h-2 w-2 rounded-full border border-[#020912]`,style:{backgroundColor:f.dot,boxShadow:f.glow}})]}),(0,V.jsx)(`span`,{className:`text-[8px] font-bold tracking-wide text-center leading-tight uppercase line-clamp-2 transition-colors duration-300`,style:{color:b?`#fde68a`:e.enabled?`#93c5fd`:`#374151`},children:e.name}),(p>0||m>0)&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[p>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[7px] text-emerald-400/70`,children:[(0,V.jsx)(P,{className:`h-2 w-2`}),p]}),m>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[7px] text-amber-400/70`,children:[(0,V.jsx)(A,{className:`h-2 w-2`}),m]})]})]})})}),(0,V.jsx)(`div`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 z-30 transition-opacity duration-200`,style:{opacity:+!!_,pointerEvents:_?`auto`:`none`},children:(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-blue-500/30 text-blue-400 hover:bg-blue-500/20 transition-colors`,onClick:n=>{n.stopPropagation(),t?.(e)},title:`Editar`,children:(0,V.jsx)(z,{className:`h-2.5 w-2.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-white/10 text-white/50 hover:text-white transition-colors`,onClick:t=>{t.stopPropagation(),i(`/agents/${e.id}`)},title:`Ver`,children:(0,V.jsx)(`span`,{className:`text-[8px]`,children:`→`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-red-500/20 text-red-400/60 hover:text-red-400 transition-colors`,onClick:t=>y(e,t),title:`Eliminar`,children:(0,V.jsx)(k,{className:`h-2.5 w-2.5`})})]})})]},e.id)}),l.length>K.length+q.length&&(0,V.jsxs)(`div`,{className:`absolute bottom-6 right-6 text-[11px] text-white/50 bg-white/5 rounded-full px-3 py-1 border border-white/10 backdrop-blur-sm`,children:[`+`,l.length-K.length-q.length,` agentes en lista`]})]}),l.length>K.length+q.length&&(0,V.jsx)(`div`,{className:`mt-4 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 max-w-[740px] mx-auto px-4`,children:l.slice(K.length+q.length).map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] transition-colors text-left group`,onClick:()=>i(`/agents/${e.id}`),children:[(0,V.jsx)(x,{className:`h-4 w-4 text-blue-400/60 shrink-0`}),(0,V.jsx)(`span`,{className:`text-xs text-white/60 group-hover:text-white/90 truncate transition-colors`,children:e.name})]},e.id))})]})}function Oe({agents:e,onEdit:t,selectedId:n,onSelect:r}){return e.length===0?(0,V.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,V.jsx)(`div`,{className:`p-4 rounded-full bg-white/5 mb-4`,children:(0,V.jsx)(`div`,{className:`h-10 w-10 border-2 border-dashed border-white/20 rounded-full`})}),(0,V.jsx)(`p`,{className:`hive-label uppercase`,children:`No se detectaron nodos activos`}),(0,V.jsx)(`p`,{className:`text-xs text-white/20 mt-1`,children:`Comienza desplegando un nuevo agente en tu red.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`hidden md:block`,children:(0,V.jsx)(De,{agents:e,onEdit:t,selectedId:n,onSelect:r})}),(0,V.jsx)(`div`,{className:`grid gap-6 sm:grid-cols-2 pb-20 md:hidden`,children:e.map(e=>(0,V.jsx)(Te,{agent:e,onEdit:t},e.id))})]})}function ke(){let e=M(),{agents:t,isLoading:n,error:r,fetchAgents:i}=I(),{providers:a,fetchProviders:o}=L(),{models:s,fetchModels:c}=F(),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(),[p,m]=(0,B.useState)();(0,B.useEffect)(()=>{i(),o(),c()},[i,o,c]);let h=(0,B.useMemo)(()=>t.find(e=>e.role===`coordinator`)??t[0],[t]),g=t.find(e=>e.id===p)??h,_=t.filter(e=>e.enabled).length,v=t.filter(e=>e.role===`worker`).length,y=e=>{f(e),u(!0)},b=()=>{f(void 0),u(!0)},x=()=>{u(!1),f(void 0)};return(0,V.jsxs)(`div`,{className:`hive-page min-h-full`,children:[(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-[1480px] px-2 py-4 sm:px-4 lg:px-6 lg:py-6`,children:[(0,V.jsxs)(`header`,{className:`relative overflow-hidden rounded-2xl border border-white/[0.08] bg-[#0b0e14]/80 px-5 py-5 shadow-xl shadow-black/10 sm:px-6`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_85%_0%,rgba(59,130,246,0.10),transparent_28%),radial-gradient(circle_at_8%_100%,rgba(245,158,11,0.08),transparent_32%)]`}),(0,V.jsxs)(`div`,{className:`relative flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2 text-[9px] font-bold uppercase tracking-[0.24em] text-blue-400`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-blue-400 shadow-[0_0_8px_rgba(96,165,250,0.8)]`}),`Nexo central · configuración de agentes`]}),(0,V.jsxs)(`h1`,{className:`text-3xl font-black tracking-[-0.04em] text-white sm:text-4xl`,children:[`Tu colmena `,(0,V.jsx)(`span`,{className:`text-amber-400`,children:`inteligente`})]}),(0,V.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm leading-6 text-white/45`,children:`Selecciona un nodo para revisar su configuración, ajustar su propósito o entrar a su espacio operativo.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col items-start gap-3 lg:items-end`,children:[(0,V.jsxs)(`div`,{className:`hidden items-center gap-4 xl:flex`,children:[(0,V.jsx)(Ae,{value:_,label:`activos`,color:`text-emerald-400`}),(0,V.jsx)(Ae,{value:v,label:`especialistas`,color:`text-blue-400`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(),disabled:n,className:`flex h-10 items-center gap-2 rounded-lg border border-white/10 bg-white/[0.035] px-3.5 text-xs font-semibold text-white/60 transition-colors hover:border-white/20 hover:bg-white/[0.07] hover:text-white disabled:opacity-50`,children:[(0,V.jsx)(se,{className:`h-3.5 w-3.5 text-blue-400 ${n?`animate-spin`:``}`}),`Sincronizar`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:b,className:`flex h-10 items-center gap-2 rounded-lg border border-amber-300/40 bg-amber-400 px-4 text-xs font-bold text-[#181108] shadow-[0_0_20px_rgba(245,158,11,0.16)] transition hover:bg-amber-300`,children:[(0,V.jsx)(D,{className:`h-3.5 w-3.5`}),`Desplegar nodo`]})]})]})]})]}),r?(0,V.jsxs)(`div`,{className:`mt-5 flex items-start gap-3 rounded-xl border border-red-500/20 bg-red-500/[0.07] p-4 text-red-300`,children:[(0,V.jsx)(ue,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-wider`,children:`Error de enlace`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-red-300/60`,children:r})]})]}):n&&t.length===0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-4 lg:grid-cols-[280px_1fr]`,children:[(0,V.jsx)(`div`,{className:`h-[560px] animate-pulse rounded-2xl border border-white/5 bg-white/[0.02]`}),(0,V.jsx)(`div`,{className:`h-[560px] animate-pulse rounded-2xl border border-white/5 bg-white/[0.02]`})]}):t.length===0?(0,V.jsxs)(`div`,{className:`mt-5 flex min-h-[500px] flex-col items-center justify-center rounded-2xl border border-dashed border-white/10 bg-black/20 px-6 text-center`,children:[(0,V.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl border border-amber-500/20 bg-amber-500/10`,children:(0,V.jsx)(de,{className:`h-7 w-7 text-amber-400`})}),(0,V.jsx)(`h2`,{className:`mt-5 text-lg font-bold text-white`,children:`Colmena inactiva`}),(0,V.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-white/40`,children:`Despliega el primer agente para crear el núcleo de tu red.`}),(0,V.jsxs)(`button`,{type:`button`,onClick:b,className:`mt-6 flex h-10 items-center gap-2 rounded-lg bg-amber-400 px-4 text-xs font-bold text-[#181108]`,children:[(0,V.jsx)(D,{className:`h-4 w-4`}),`Desplegar primer nodo`]})]}):(0,V.jsxs)(`div`,{className:`mt-5 grid items-start gap-4 lg:grid-cols-[290px_minmax(0,1fr)]`,children:[(0,V.jsx)(je,{agent:g,providerName:a.find(e=>e.id===(g?.provider_id||g?.providerId))?.name,modelName:s.find(e=>e.id===(g?.model_id||g?.modelId))?.name,totalAgents:t.length,activeCount:_,onEdit:y,onOpen:t=>e(`/agents/${t.id}`)}),(0,V.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-white/[0.08] bg-[#080b11]/75 shadow-2xl shadow-black/15`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-white/[0.07] px-4 py-3.5 sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg border border-blue-500/20 bg-blue-500/10`,children:(0,V.jsx)(oe,{className:`h-4 w-4 text-blue-400`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-white/80`,children:`Mapa de la colmena`}),(0,V.jsx)(`p`,{className:`mt-0.5 text-[10px] text-white/30`,children:`Haz clic en un hexágono para inspeccionarlo`})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] font-semibold uppercase tracking-wider text-white/30`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-400`}),`Coordinación`]}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-blue-400`}),`Especialistas`]})]})]}),(0,V.jsxs)(`div`,{className:`relative min-h-[560px] overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,rgba(245,158,11,0.045),transparent_38%)]`}),(0,V.jsx)(Oe,{agents:t,onEdit:y,selectedId:g?.id,onSelect:m})]})]})]})]}),l&&(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-6`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Cerrar configuración`,className:`absolute inset-0 cursor-default bg-black/75 backdrop-blur-sm`,onClick:x}),(0,V.jsx)(`div`,{className:`relative max-h-[92vh] w-full max-w-4xl overflow-y-auto rounded-2xl border border-white/10 bg-[#09090b] shadow-2xl`,children:(0,V.jsx)(fe,{initialData:d,onSuccess:x,onCancel:x})})]})]})}function Ae({value:e,label:t,color:n}){return(0,V.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-lg font-black tabular-nums ${n}`,children:e}),(0,V.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider text-white/25`,children:t})]})}function je({agent:e,providerName:t,modelName:n,totalAgents:r,activeCount:i,onEdit:a,onOpen:o}){if(!e)return null;let s=e.role===`coordinator`,c=e.provider_id||e.providerId,l=e.model_id||e.modelId,u=T(e).length,d=E(e).length;return(0,V.jsxs)(`aside`,{className:`overflow-hidden rounded-2xl border border-white/[0.08] bg-[#0b0e14]/90 lg:sticky lg:top-4`,children:[(0,V.jsx)(`div`,{className:`h-1 w-full ${s?`bg-amber-400`:`bg-blue-500`}`}),(0,V.jsxs)(`div`,{className:`p-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-xl border ${s?`border-amber-500/20 bg-amber-500/10 text-amber-400`:`border-blue-500/20 bg-blue-500/10 text-blue-400`}`,children:s?(0,V.jsx)(O,{className:`h-5 w-5`}):(0,V.jsx)(R,{className:`h-5 w-5`})}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-full border px-2 py-1 text-[9px] font-bold uppercase tracking-wider ${e.status===`archived`?`border-amber-500/20 bg-amber-500/10 text-amber-400`:e.enabled?`border-emerald-500/20 bg-emerald-500/10 text-emerald-400`:`border-white/10 bg-white/5 text-white/35`}`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${e.status===`archived`?`bg-amber-400`:e.enabled?`bg-emerald-400`:`bg-white/30`}`}),e.status===`archived`?`Archivado`:e.enabled?`Activo`:`Inactivo`]})]}),(0,V.jsx)(`p`,{className:`mt-4 text-[9px] font-bold uppercase tracking-[0.2em] ${s?`text-amber-400`:`text-blue-400`}`,children:s?`Nodo coordinador`:`Nodo especialista`}),(0,V.jsx)(`h2`,{className:`mt-1.5 text-xl font-black leading-tight tracking-tight text-white`,children:e.name}),(0,V.jsx)(`p`,{className:`mt-2 line-clamp-3 min-h-[54px] text-xs leading-[18px] text-white/40`,children:e.description||`Este agente todavía no tiene una descripción de propósito.`}),(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(Q,{icon:R,label:`Motor`,value:t||c||`Sin proveedor`}),(0,V.jsx)(Q,{icon:ce,label:`Modelo`,value:n||l||`Sin modelo`}),(0,V.jsx)(Q,{icon:w,label:`Workspace`,value:e.workspace||`Sin asignar`,mono:!!e.workspace})]}),(0,V.jsxs)(`div`,{className:`mt-4 grid grid-cols-3 gap-1.5`,children:[(0,V.jsx)($,{icon:P,value:u,label:`Tools`,color:`text-emerald-400`}),(0,V.jsx)($,{icon:A,value:d,label:`Skills`,color:`text-amber-400`}),(0,V.jsx)($,{icon:g,value:e.maxIterations||10,label:`Iters`,color:`text-violet-400`})]}),(0,V.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex h-10 items-center justify-center gap-2 rounded-lg text-xs font-bold transition-colors ${s?`bg-amber-400 text-[#181108] hover:bg-amber-300`:`bg-blue-600 text-white hover:bg-blue-500`}`,children:[(0,V.jsx)(ne,{className:`h-3.5 w-3.5`}),`Configurar nodo`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex h-10 items-center justify-center gap-2 rounded-lg border border-white/10 bg-white/[0.03] text-xs font-semibold text-white/60 transition-colors hover:bg-white/[0.07] hover:text-white`,children:[`Abrir perfil`,(0,V.jsx)(_,{className:`h-3.5 w-3.5`})]})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-t border-white/[0.07] bg-white/[0.07]`,children:[(0,V.jsxs)(`div`,{className:`bg-[#0b0e14] px-4 py-3`,children:[(0,V.jsx)(`p`,{className:`text-lg font-black tabular-nums text-white`,children:r}),(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:`Nodos totales`})]}),(0,V.jsxs)(`div`,{className:`bg-[#0b0e14] px-4 py-3`,children:[(0,V.jsx)(`p`,{className:`text-lg font-black tabular-nums text-emerald-400`,children:i}),(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:`En operación`})]})]})]})}function Q({icon:e,label:t,value:n,mono:r=!1}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg border border-white/[0.06] bg-white/[0.025] px-3 py-2.5`,children:[(0,V.jsx)(e,{className:`h-3.5 w-3.5 shrink-0 text-white/30`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:t}),(0,V.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-white/65 ${r?`font-mono`:`font-medium`}`,title:n,children:n})]})]})}function $({icon:e,value:t,label:n,color:r}){return(0,V.jsxs)(`div`,{className:`rounded-lg border border-white/[0.06] bg-black/20 px-2 py-2.5 text-center`,children:[(0,V.jsx)(e,{className:`mx-auto h-3.5 w-3.5 ${r}`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm font-black tabular-nums text-white/80`,children:t}),(0,V.jsx)(`p`,{className:`text-[7px] font-bold uppercase tracking-wider text-white/25`,children:n})]})}export{ke as AgentsPage};
9
+ ${e.enabled?`bg-emerald-500/5 border-emerald-500/20 text-emerald-300 group-hover:bg-emerald-500/10 group-hover:border-emerald-500/30`:`bg-transparent border-white/5 text-white/30`}`,title:`Workspace: ${e.workspace}`,children:[(0,V.jsx)(w,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{className:`truncate max-w-[100px]`,children:`Workspace`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 pt-5 border-t border-white/5 grid grid-cols-4 gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(F,{className:`h-3 w-3 text-emerald-400/70`}),`Tools`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:m})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(A,{className:`h-3 w-3 text-amber-400/70`}),`Skills`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:h})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(C,{className:`h-3 w-3 text-blue-400/70`}),`Prompt`]}),(0,V.jsx)(`span`,{className:`text-sm font-bold ${e.enabled?_?`text-emerald-400`:`text-white/30`:`text-white/20`}`,children:_?`✓`:`—`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col gap-1 items-start bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-white/40 flex items-center gap-1.5`,children:[(0,V.jsx)(ee,{className:`h-3 w-3 text-purple-400/70`}),`Iters`]}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:y})]})]}),e.systemPrompt&&(0,V.jsxs)(`div`,{className:`mt-3 bg-white/[0.02] rounded-lg p-3 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsxs)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase mb-1.5 flex items-center gap-1.5`,children:[(0,V.jsx)(C,{className:`h-3 w-3 text-blue-400/70`}),`System Prompt`]}),(0,V.jsxs)(`p`,{className:`text-xs text-white/60 font-mono line-clamp-2 leading-relaxed italic`,children:[`"`,e.systemPrompt,`"`]})]}),(0,V.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsx)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase`,children:`Tareas`}),(0,V.jsx)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-white/90`:`text-white/30`}`,children:e.taskCount||0})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between bg-white/[0.02] rounded-lg p-2.5 border border-white/5 group-hover:border-white/10 transition-colors`,children:[(0,V.jsx)(`span`,{className:`text-[10px] font-medium tracking-wider text-white/40 uppercase`,children:`Éxito`}),(0,V.jsxs)(`span`,{className:`text-sm font-semibold font-mono ${e.enabled?`text-emerald-400/90`:`text-white/30`}`,children:[e.successRate||0,`%`]})]})]}),(0,V.jsxs)(`div`,{className:`mt-auto pt-5 flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`h-2 w-2 rounded-full ${e.enabled?`bg-blue-400 shadow-[0_0_8px_rgba(96,165,250,0.8)] animate-pulse`:`bg-white/20`}`}),(0,V.jsx)(`span`,{className:`text-[10px] font-bold tracking-widest uppercase ${e.enabled?`text-blue-400`:`text-white/30`}`,children:e.enabled?`ACTIVO`:`INACTIVO`})]}),b&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[10px] text-white/30 font-medium tracking-wider pl-3 border-l border-white/10`,children:[(0,V.jsx)(v,{className:`h-3 w-3`}),b]})]}),(0,V.jsxs)(`div`,{className:`text-xs font-semibold tracking-wide flex items-center gap-1.5 transition-all
10
+ ${e.enabled?`text-white/70 group-hover:text-blue-400 translate-x-1 group-hover:translate-x-0`:`text-white/20`}`,children:[`INGRESAR`,(0,V.jsx)(`span`,{className:`transition-transform group-hover:translate-x-1 opacity-0 group-hover:opacity-100 hidden sm:inline-block`,children:`→`})]})]})]})]})}var W=Math.sqrt(3),G=82;function Ee(e,t){return{x:G*1.5*e,y:G*(W/2*e+W*t)}}var K=[{q:1,r:0},{q:1,r:-1},{q:0,r:-1},{q:-1,r:0},{q:-1,r:1},{q:0,r:1}],q=[{q:2,r:0},{q:2,r:-1},{q:2,r:-2},{q:1,r:-2},{q:0,r:-2},{q:-1,r:-1},{q:-2,r:0},{q:-2,r:1},{q:-2,r:2},{q:-1,r:2},{q:0,r:2},{q:1,r:1}];function J(e,t){return t<=0?[]:t>=e.length?e:Array.from({length:t},(n,r)=>e[Math.floor(r*e.length/t)])}var Y=`polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%)`,X={active:{bg:`#22c55e22`,dot:`#22c55e`,glow:`0 0 12px #22c55e88`},idle:{bg:`#f59e0b22`,dot:`#f59e0b`,glow:`0 0 12px #f59e0b88`},thinking:{bg:`#6366f122`,dot:`#818cf8`,glow:`0 0 12px #6366f188`},error:{bg:`#ef444422`,dot:`#ef4444`,glow:`0 0 12px #ef444488`},hibernated:{bg:`#1f293700`,dot:`#4b5563`,glow:`none`}};function Z(e){if(!e)return 0;try{let t=JSON.parse(e);return Array.isArray(t)?t.length:0}catch{return 0}}function De({agents:e,onEdit:t,selectedId:n,onSelect:r}){let i=M(),{deleteAgent:a}=L(),[o,s]=(0,B.useState)(null),{coordinator:c,workers:l}=(0,B.useMemo)(()=>{let t=e.find(e=>e.role===`coordinator`)??e[0];return{coordinator:t,workers:e.filter(e=>e.id!==t?.id)}},[e]),u=(0,B.useMemo)(()=>{let e=Math.min(l.length,K.length),t=Math.min(Math.max(l.length-K.length,0),q.length);return[...J(K,e),...J(q,t)].map(({q:e,r:t})=>Ee(e,t))},[l.length]),d=l.slice(0,u.length),f=l.length>6?2:1,p=f===2?700:520,m=f===2?680:500,h=p/2,g=m/2,_=Math.round(164*W/2),v=Math.round(124*W/2),y=async(e,t)=>{if(t.stopPropagation(),(await N.fire({title:`¿Eliminar Agente?`,text:`¿Eliminar "${e.name}"?`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, eliminar`,cancelButtonText:`Cancelar`,background:`#09090b`,color:`#fff`})).isConfirmed)try{await a(e.id)}catch(e){console.error(`No se pudo eliminar el agente:`,e)}},b=c?X[c.enabled?c.status:`hibernated`]??X.hibernated:X.hibernated;return(0,V.jsxs)(`div`,{className:`w-full overflow-x-auto overflow-y-visible py-3`,children:[(0,V.jsxs)(`div`,{className:`relative mx-auto select-none`,style:{width:p,height:m},children:[(0,V.jsx)(`div`,{className:`absolute pointer-events-none rounded-full blur-[80px] opacity-30`,style:{width:260,height:260,left:h-130,top:g-130,background:`radial-gradient(circle, rgba(245,158,11,0.6) 0%, transparent 70%)`}}),(0,V.jsxs)(`svg`,{className:`absolute inset-0 pointer-events-none`,width:p,height:m,xmlns:`http://www.w3.org/2000/svg`,children:[(0,V.jsxs)(`defs`,{children:[(0,V.jsx)(`pattern`,{id:`hc-hex`,x:`0`,y:`0`,width:`52`,height:`30`,patternUnits:`userSpaceOnUse`,children:(0,V.jsx)(`polygon`,{points:`26,1 51,15.5 51,29 26,29 1,15.5 1,1`,fill:`none`,stroke:`rgba(255,255,255,0.03)`,strokeWidth:`1`})}),(0,V.jsxs)(`radialGradient`,{id:`fade-mask`,cx:`50%`,cy:`50%`,r:`50%`,children:[(0,V.jsx)(`stop`,{offset:`0%`,stopColor:`white`,stopOpacity:`0.08`}),(0,V.jsx)(`stop`,{offset:`100%`,stopColor:`white`,stopOpacity:`0`})]})]}),(0,V.jsx)(`rect`,{width:p,height:m,fill:`url(#hc-hex)`}),(0,V.jsx)(`rect`,{width:p,height:m,fill:`url(#fade-mask)`}),d.map((e,t)=>{let r=u[t],i=o===e.id||n===e.id;return(0,V.jsxs)(`g`,{children:[(0,V.jsx)(`line`,{x1:h,y1:g,x2:h+r.x,y2:g+r.y,stroke:i?`rgba(245,158,11,0.5)`:`rgba(245,158,11,0.12)`,strokeWidth:i?2:1,strokeDasharray:`5 5`,style:{transition:`stroke 0.3s ease, stroke-width 0.3s ease`}}),e.enabled&&(0,V.jsx)(`circle`,{r:`3`,fill:`rgba(245,158,11,0.7)`,children:(0,V.jsx)(`animateMotion`,{dur:`${2.5+t*.4}s`,repeatCount:`indefinite`,path:`M ${h} ${g} L ${h+r.x} ${g+r.y}`})})]},`line-${e.id}`)})]}),c&&(0,V.jsxs)(`div`,{className:`absolute z-20 cursor-pointer group outline-none`,style:{left:h-164/2,top:g-_/2,width:164,height:_},onMouseEnter:()=>s(c.id),onMouseLeave:()=>s(null),children:[(0,V.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-amber-300/70`,style:{clipPath:Y},onClick:()=>r?.(c.id),"aria-label":`Seleccionar ${c.name}`,"aria-pressed":n===c.id}),(0,V.jsx)(`div`,{className:`absolute inset-[-6px] blur-[10px] transition-opacity duration-500 ${n===c.id?`opacity-90`:`opacity-40 group-hover:opacity-80`}`,style:{clipPath:Y,background:`rgba(245,158,11,0.5)`}}),(0,V.jsx)(`div`,{className:`absolute inset-0 transition-transform duration-300 ${n===c.id?`scale-105`:`group-hover:scale-105`}`,style:{clipPath:Y,background:`rgba(245,158,11,0.55)`},children:(0,V.jsx)(`div`,{className:`absolute inset-[2px]`,style:{clipPath:Y,background:`linear-gradient(145deg, #1c1100 0%, #0d0b00 60%, #120d00 100%)`},children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-1.5 px-3`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(O,{className:`h-8 w-8 text-amber-400 drop-shadow-[0_0_8px_rgba(245,158,11,0.8)]`}),(0,V.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 h-2.5 w-2.5 rounded-full border-2 border-black`,style:{backgroundColor:b.dot,boxShadow:b.glow}})]}),(0,V.jsx)(`span`,{className:`text-[10px] font-black text-amber-300 tracking-[0.12em] text-center leading-tight uppercase line-clamp-2`,children:c.name}),(0,V.jsx)(`span`,{className:`text-[8px] text-amber-500/70 tracking-widest uppercase font-semibold`,children:`Coordinadora`})]})})}),(0,V.jsxs)(`div`,{className:`pointer-events-none absolute -bottom-8 left-1/2 z-30 flex -translate-x-1/2 gap-1 opacity-0 transition-opacity duration-200 group-hover:pointer-events-auto group-hover:opacity-100`,children:[(0,V.jsx)(`button`,{type:`button`,className:`p-1.5 rounded bg-black/80 border border-amber-500/30 text-amber-400 hover:bg-amber-500/20 transition-colors`,onClick:e=>{e.stopPropagation(),t?.(c)},title:`Editar`,children:(0,V.jsx)(z,{className:`h-3 w-3`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1.5 rounded bg-black/80 border border-white/10 text-white/50 hover:text-white hover:border-white/20 transition-colors`,onClick:e=>{e.stopPropagation(),i(`/agents/${c.id}`)},title:`Ver detalle`,children:(0,V.jsx)(`span`,{className:`text-[9px] px-0.5`,children:`→`})})]})]}),d.map((e,a)=>{let c=u[a],l=h+c.x-124/2,d=g+c.y-v/2,f=X[e.enabled?e.status:`hibernated`]??X.hibernated,p=Z(e.toolsJson),m=Z(e.skillsJson),_=o===e.id,b=n===e.id,S=e.enabled?b?`rgba(245,158,11,0.95)`:_?`rgba(96,165,250,0.9)`:`rgba(59,130,246,0.45)`:`rgba(255,255,255,0.08)`,C=e.enabled?`linear-gradient(145deg, #050d1c 0%, #020912 60%, #040a18 100%)`:`#0a0a0b`;return(0,V.jsxs)(`div`,{className:`absolute z-10 cursor-pointer group outline-none`,style:{left:l,top:d,width:124,height:v},onMouseEnter:()=>s(e.id),onMouseLeave:()=>s(null),children:[(0,V.jsx)(`button`,{type:`button`,className:`absolute inset-0 z-10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-300/70`,style:{clipPath:Y},onClick:()=>r?.(e.id),"aria-label":`Seleccionar ${e.name}`,"aria-pressed":b}),e.enabled&&(0,V.jsx)(`div`,{className:`absolute inset-[-5px] transition-opacity duration-300 blur-[8px]`,style:{clipPath:Y,background:b?`rgba(245,158,11,0.45)`:`rgba(59,130,246,0.35)`,opacity:b?.9:_?.8:.2}}),(0,V.jsx)(`div`,{className:`absolute inset-0 transition-transform duration-300`,style:{clipPath:Y,background:S,transform:b?`scale(1.08)`:_?`scale(1.06)`:`scale(1)`},children:(0,V.jsx)(`div`,{className:`absolute inset-[1.5px]`,style:{clipPath:Y,background:C},children:(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-1 px-2`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(x,{className:`h-5 w-5 transition-colors duration-300`,style:{color:b?`#fbbf24`:e.enabled?`#60a5fa`:`#374151`}}),(0,V.jsx)(`div`,{className:`absolute -bottom-0.5 -right-0.5 h-2 w-2 rounded-full border border-[#020912]`,style:{backgroundColor:f.dot,boxShadow:f.glow}})]}),(0,V.jsx)(`span`,{className:`text-[8px] font-bold tracking-wide text-center leading-tight uppercase line-clamp-2 transition-colors duration-300`,style:{color:b?`#fde68a`:e.enabled?`#93c5fd`:`#374151`},children:e.name}),(p>0||m>0)&&(0,V.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-0.5`,children:[p>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[7px] text-emerald-400/70`,children:[(0,V.jsx)(F,{className:`h-2 w-2`}),p]}),m>0&&(0,V.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[7px] text-amber-400/70`,children:[(0,V.jsx)(A,{className:`h-2 w-2`}),m]})]})]})})}),(0,V.jsx)(`div`,{className:`absolute -bottom-7 left-1/2 -translate-x-1/2 z-30 transition-opacity duration-200`,style:{opacity:+!!_,pointerEvents:_?`auto`:`none`},children:(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-blue-500/30 text-blue-400 hover:bg-blue-500/20 transition-colors`,onClick:n=>{n.stopPropagation(),t?.(e)},title:`Editar`,children:(0,V.jsx)(z,{className:`h-2.5 w-2.5`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-white/10 text-white/50 hover:text-white transition-colors`,onClick:t=>{t.stopPropagation(),i(`/agents/${e.id}`)},title:`Ver`,children:(0,V.jsx)(`span`,{className:`text-[8px]`,children:`→`})}),(0,V.jsx)(`button`,{type:`button`,className:`p-1 rounded bg-black/80 border border-red-500/20 text-red-400/60 hover:text-red-400 transition-colors`,onClick:t=>y(e,t),title:`Eliminar`,children:(0,V.jsx)(k,{className:`h-2.5 w-2.5`})})]})})]},e.id)}),l.length>K.length+q.length&&(0,V.jsxs)(`div`,{className:`absolute bottom-6 right-6 text-[11px] text-white/50 bg-white/5 rounded-full px-3 py-1 border border-white/10 backdrop-blur-sm`,children:[`+`,l.length-K.length-q.length,` agentes en lista`]})]}),l.length>K.length+q.length&&(0,V.jsx)(`div`,{className:`mt-4 grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-3 max-w-[740px] mx-auto px-4`,children:l.slice(K.length+q.length).map(e=>(0,V.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-white/10 bg-white/[0.03] hover:bg-white/[0.06] transition-colors text-left group`,onClick:()=>i(`/agents/${e.id}`),children:[(0,V.jsx)(x,{className:`h-4 w-4 text-blue-400/60 shrink-0`}),(0,V.jsx)(`span`,{className:`text-xs text-white/60 group-hover:text-white/90 truncate transition-colors`,children:e.name})]},e.id))})]})}function Oe({agents:e,onEdit:t,selectedId:n,onSelect:r}){return e.length===0?(0,V.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,V.jsx)(`div`,{className:`p-4 rounded-full bg-white/5 mb-4`,children:(0,V.jsx)(`div`,{className:`h-10 w-10 border-2 border-dashed border-white/20 rounded-full`})}),(0,V.jsx)(`p`,{className:`hive-label uppercase`,children:`No se detectaron nodos activos`}),(0,V.jsx)(`p`,{className:`text-xs text-white/20 mt-1`,children:`Comienza desplegando un nuevo agente en tu red.`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`hidden md:block`,children:(0,V.jsx)(De,{agents:e,onEdit:t,selectedId:n,onSelect:r})}),(0,V.jsx)(`div`,{className:`grid gap-6 sm:grid-cols-2 pb-20 md:hidden`,children:e.map(e=>(0,V.jsx)(Te,{agent:e,onEdit:t},e.id))})]})}function ke(){let e=M(),{agents:t,isLoading:n,error:r,fetchAgents:i}=L(),{providers:a,fetchProviders:o}=P(),{models:s,fetchModels:c}=I(),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(),[p,m]=(0,B.useState)();(0,B.useEffect)(()=>{i(),o(),c()},[i,o,c]);let h=(0,B.useMemo)(()=>t.find(e=>e.role===`coordinator`)??t[0],[t]),g=t.find(e=>e.id===p)??h,_=t.filter(e=>e.enabled).length,v=t.filter(e=>e.role===`worker`).length,y=e=>{f(e),u(!0)},b=()=>{f(void 0),u(!0)},x=()=>{u(!1),f(void 0)};return(0,V.jsxs)(`div`,{className:`hive-page min-h-full`,children:[(0,V.jsxs)(`div`,{className:`mx-auto w-full max-w-[1480px] px-2 py-4 sm:px-4 lg:px-6 lg:py-6`,children:[(0,V.jsxs)(`header`,{className:`relative overflow-hidden rounded-2xl border border-white/[0.08] bg-[#0b0e14]/80 px-5 py-5 shadow-xl shadow-black/10 sm:px-6`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_85%_0%,rgba(59,130,246,0.10),transparent_28%),radial-gradient(circle_at_8%_100%,rgba(245,158,11,0.08),transparent_32%)]`}),(0,V.jsxs)(`div`,{className:`relative flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`mb-2.5 flex items-center gap-2 text-[9px] font-bold uppercase tracking-[0.24em] text-blue-400`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-blue-400 shadow-[0_0_8px_rgba(96,165,250,0.8)]`}),`Nexo central · configuración de agentes`]}),(0,V.jsxs)(`h1`,{className:`text-3xl font-black tracking-[-0.04em] text-white sm:text-4xl`,children:[`Tu colmena `,(0,V.jsx)(`span`,{className:`text-amber-400`,children:`inteligente`})]}),(0,V.jsx)(`p`,{className:`mt-2 max-w-2xl text-sm leading-6 text-white/45`,children:`Selecciona un nodo para revisar su configuración, ajustar su propósito o entrar a su espacio operativo.`})]}),(0,V.jsxs)(`div`,{className:`flex flex-col items-start gap-3 lg:items-end`,children:[(0,V.jsxs)(`div`,{className:`hidden items-center gap-4 xl:flex`,children:[(0,V.jsx)(Ae,{value:_,label:`activos`,color:`text-emerald-400`}),(0,V.jsx)(Ae,{value:v,label:`especialistas`,color:`text-blue-400`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>i(),disabled:n,className:`flex h-10 items-center gap-2 rounded-lg border border-white/10 bg-white/[0.035] px-3.5 text-xs font-semibold text-white/60 transition-colors hover:border-white/20 hover:bg-white/[0.07] hover:text-white disabled:opacity-50`,children:[(0,V.jsx)(se,{className:`h-3.5 w-3.5 text-blue-400 ${n?`animate-spin`:``}`}),`Sincronizar`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:b,className:`flex h-10 items-center gap-2 rounded-lg border border-amber-300/40 bg-amber-400 px-4 text-xs font-bold text-[#181108] shadow-[0_0_20px_rgba(245,158,11,0.16)] transition hover:bg-amber-300`,children:[(0,V.jsx)(D,{className:`h-3.5 w-3.5`}),`Desplegar nodo`]})]})]})]})]}),r?(0,V.jsxs)(`div`,{className:`mt-5 flex items-start gap-3 rounded-xl border border-red-500/20 bg-red-500/[0.07] p-4 text-red-300`,children:[(0,V.jsx)(de,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-wider`,children:`Error de enlace`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm text-red-300/60`,children:r})]})]}):n&&t.length===0?(0,V.jsxs)(`div`,{className:`mt-5 grid gap-4 lg:grid-cols-[280px_1fr]`,children:[(0,V.jsx)(`div`,{className:`h-[560px] animate-pulse rounded-2xl border border-white/5 bg-white/[0.02]`}),(0,V.jsx)(`div`,{className:`h-[560px] animate-pulse rounded-2xl border border-white/5 bg-white/[0.02]`})]}):t.length===0?(0,V.jsxs)(`div`,{className:`mt-5 flex min-h-[500px] flex-col items-center justify-center rounded-2xl border border-dashed border-white/10 bg-black/20 px-6 text-center`,children:[(0,V.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-2xl border border-amber-500/20 bg-amber-500/10`,children:(0,V.jsx)(ue,{className:`h-7 w-7 text-amber-400`})}),(0,V.jsx)(`h2`,{className:`mt-5 text-lg font-bold text-white`,children:`Colmena inactiva`}),(0,V.jsx)(`p`,{className:`mt-2 max-w-md text-sm leading-6 text-white/40`,children:`Despliega el primer agente para crear el núcleo de tu red.`}),(0,V.jsxs)(`button`,{type:`button`,onClick:b,className:`mt-6 flex h-10 items-center gap-2 rounded-lg bg-amber-400 px-4 text-xs font-bold text-[#181108]`,children:[(0,V.jsx)(D,{className:`h-4 w-4`}),`Desplegar primer nodo`]})]}):(0,V.jsxs)(`div`,{className:`mt-5 grid items-start gap-4 lg:grid-cols-[290px_minmax(0,1fr)]`,children:[(0,V.jsx)(je,{agent:g,providerName:a.find(e=>e.id===(g?.provider_id||g?.providerId))?.name,modelName:s.find(e=>e.id===(g?.model_id||g?.modelId))?.name,totalAgents:t.length,activeCount:_,onEdit:y,onOpen:t=>e(`/agents/${t.id}`)}),(0,V.jsxs)(`section`,{className:`min-w-0 overflow-hidden rounded-2xl border border-white/[0.08] bg-[#080b11]/75 shadow-2xl shadow-black/15`,children:[(0,V.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-white/[0.07] px-4 py-3.5 sm:flex-row sm:items-center sm:justify-between sm:px-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded-lg border border-blue-500/20 bg-blue-500/10`,children:(0,V.jsx)(oe,{className:`h-4 w-4 text-blue-400`})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xs font-bold uppercase tracking-[0.14em] text-white/80`,children:`Mapa de la colmena`}),(0,V.jsx)(`p`,{className:`mt-0.5 text-[10px] text-white/30`,children:`Haz clic en un hexágono para inspeccionarlo`})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] font-semibold uppercase tracking-wider text-white/30`,children:[(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-400`}),`Coordinación`]}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-blue-400`}),`Especialistas`]})]})]}),(0,V.jsxs)(`div`,{className:`relative min-h-[560px] overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`pointer-events-none absolute inset-0 bg-[radial-gradient(circle_at_50%_50%,rgba(245,158,11,0.045),transparent_38%)]`}),(0,V.jsx)(Oe,{agents:t,onEdit:y,selectedId:g?.id,onSelect:m})]})]})]})]}),l&&(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-6`,children:[(0,V.jsx)(`button`,{type:`button`,"aria-label":`Cerrar configuración`,className:`absolute inset-0 cursor-default bg-black/75 backdrop-blur-sm`,onClick:x}),(0,V.jsx)(`div`,{className:`relative max-h-[92vh] w-full max-w-4xl overflow-y-auto rounded-2xl border border-white/10 bg-[#09090b] shadow-2xl`,children:(0,V.jsx)(fe,{initialData:d,onSuccess:x,onCancel:x})})]})]})}function Ae({value:e,label:t,color:n}){return(0,V.jsxs)(`div`,{className:`flex items-baseline gap-1.5`,children:[(0,V.jsx)(`span`,{className:`text-lg font-black tabular-nums ${n}`,children:e}),(0,V.jsx)(`span`,{className:`text-[9px] font-bold uppercase tracking-wider text-white/25`,children:t})]})}function je({agent:e,providerName:t,modelName:n,totalAgents:r,activeCount:i,onEdit:a,onOpen:o}){if(!e)return null;let s=e.role===`coordinator`,c=e.provider_id||e.providerId,l=e.model_id||e.modelId,u=T(e).length,d=E(e).length;return(0,V.jsxs)(`aside`,{className:`overflow-hidden rounded-2xl border border-white/[0.08] bg-[#0b0e14]/90 lg:sticky lg:top-4`,children:[(0,V.jsx)(`div`,{className:`h-1 w-full ${s?`bg-amber-400`:`bg-blue-500`}`}),(0,V.jsxs)(`div`,{className:`p-5`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsx)(`div`,{className:`flex h-11 w-11 items-center justify-center rounded-xl border ${s?`border-amber-500/20 bg-amber-500/10 text-amber-400`:`border-blue-500/20 bg-blue-500/10 text-blue-400`}`,children:s?(0,V.jsx)(O,{className:`h-5 w-5`}):(0,V.jsx)(R,{className:`h-5 w-5`})}),(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-full border px-2 py-1 text-[9px] font-bold uppercase tracking-wider ${e.status===`archived`?`border-amber-500/20 bg-amber-500/10 text-amber-400`:e.enabled?`border-emerald-500/20 bg-emerald-500/10 text-emerald-400`:`border-white/10 bg-white/5 text-white/35`}`,children:[(0,V.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${e.status===`archived`?`bg-amber-400`:e.enabled?`bg-emerald-400`:`bg-white/30`}`}),e.status===`archived`?`Archivado`:e.enabled?`Activo`:`Inactivo`]})]}),(0,V.jsx)(`p`,{className:`mt-4 text-[9px] font-bold uppercase tracking-[0.2em] ${s?`text-amber-400`:`text-blue-400`}`,children:s?`Nodo coordinador`:`Nodo especialista`}),(0,V.jsx)(`h2`,{className:`mt-1.5 text-xl font-black leading-tight tracking-tight text-white`,children:e.name}),(0,V.jsx)(`p`,{className:`mt-2 line-clamp-3 min-h-[54px] text-xs leading-[18px] text-white/40`,children:e.description||`Este agente todavía no tiene una descripción de propósito.`}),(0,V.jsxs)(`div`,{className:`mt-5 space-y-2`,children:[(0,V.jsx)(Q,{icon:R,label:`Motor`,value:t||c||`Sin proveedor`}),(0,V.jsx)(Q,{icon:ce,label:`Modelo`,value:n||l||`Sin modelo`}),(0,V.jsx)(Q,{icon:w,label:`Workspace`,value:e.workspace||`Sin asignar`,mono:!!e.workspace})]}),(0,V.jsxs)(`div`,{className:`mt-4 grid grid-cols-3 gap-1.5`,children:[(0,V.jsx)($,{icon:F,value:u,label:`Tools`,color:`text-emerald-400`}),(0,V.jsx)($,{icon:A,value:d,label:`Skills`,color:`text-amber-400`}),(0,V.jsx)($,{icon:g,value:e.maxIterations||10,label:`Iters`,color:`text-violet-400`})]}),(0,V.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,V.jsxs)(`button`,{type:`button`,onClick:()=>a(e),className:`flex h-10 items-center justify-center gap-2 rounded-lg text-xs font-bold transition-colors ${s?`bg-amber-400 text-[#181108] hover:bg-amber-300`:`bg-blue-600 text-white hover:bg-blue-500`}`,children:[(0,V.jsx)(ne,{className:`h-3.5 w-3.5`}),`Configurar nodo`]}),(0,V.jsxs)(`button`,{type:`button`,onClick:()=>o(e),className:`flex h-10 items-center justify-center gap-2 rounded-lg border border-white/10 bg-white/[0.03] text-xs font-semibold text-white/60 transition-colors hover:bg-white/[0.07] hover:text-white`,children:[`Abrir perfil`,(0,V.jsx)(_,{className:`h-3.5 w-3.5`})]})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-px border-t border-white/[0.07] bg-white/[0.07]`,children:[(0,V.jsxs)(`div`,{className:`bg-[#0b0e14] px-4 py-3`,children:[(0,V.jsx)(`p`,{className:`text-lg font-black tabular-nums text-white`,children:r}),(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:`Nodos totales`})]}),(0,V.jsxs)(`div`,{className:`bg-[#0b0e14] px-4 py-3`,children:[(0,V.jsx)(`p`,{className:`text-lg font-black tabular-nums text-emerald-400`,children:i}),(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:`En operación`})]})]})]})}function Q({icon:e,label:t,value:n,mono:r=!1}){return(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-lg border border-white/[0.06] bg-white/[0.025] px-3 py-2.5`,children:[(0,V.jsx)(e,{className:`h-3.5 w-3.5 shrink-0 text-white/30`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-[8px] font-bold uppercase tracking-wider text-white/25`,children:t}),(0,V.jsx)(`p`,{className:`mt-0.5 truncate text-[11px] text-white/65 ${r?`font-mono`:`font-medium`}`,title:n,children:n})]})]})}function $({icon:e,value:t,label:n,color:r}){return(0,V.jsxs)(`div`,{className:`rounded-lg border border-white/[0.06] bg-black/20 px-2 py-2.5 text-center`,children:[(0,V.jsx)(e,{className:`mx-auto h-3.5 w-3.5 ${r}`}),(0,V.jsx)(`p`,{className:`mt-1 text-sm font-black tabular-nums text-white/80`,children:t}),(0,V.jsx)(`p`,{className:`text-[7px] font-bold uppercase tracking-wider text-white/25`,children:n})]})}export{ke as AgentsPage};
@@ -1,3 +1,3 @@
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"./chevron-down-8GjmTjLR.js";import{t as i}from"./chevron-right-BupZqrxu.js";import{t as a}from"./circle-check-BKNT2_q6.js";import{t as o}from"./circle-x-DfBjbztU.js";import{t as s}from"./copy-wR7o7Ly8.js";import{t as c}from"./history-BHQWfE-7.js";import{t as l}from"./plus-DzvRxH4U.js";import{t as u}from"./send-DAhlz2i9.js";import{t as d}from"./trash-2-SgYCWiVk.js";import{t as f}from"./utils-SGUggNJc.js";import{B as p,C as ee,et as m,tt as h,z as g}from"./index-BHHUQZJd.js";import{t as te}from"./badge-uRjRSt86.js";import{t as _}from"./scroll-area-DMEaZZUp.js";import{i as v,n as y,r as b,t as x}from"./tabs-gUXIjjZv.js";import{t as S}from"./textarea-DedxQYBx.js";import{i as C,n as ne,o as re,s as w,t as T}from"./select-BBEBtcLm.js";import{a as E,i as D,n as O,t as k}from"./card-DwQizslL.js";var A=e(t(),1),j=n(),ie=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];function M(){return Math.random().toString(36).substring(2,9)}function N(){return{id:M(),key:``,value:``,enabled:!0}}function P(){let[e,t]=(0,A.useState)(`GET`),[n,P]=(0,A.useState)(``),[F,I]=(0,A.useState)([N()]),[L,R]=(0,A.useState)([N()]),[z,B]=(0,A.useState)(``),[V,H]=(0,A.useState)(null),[U,W]=(0,A.useState)(!1),[G,K]=(0,A.useState)(0),[q,J]=(0,A.useState)([]),[Y,ae]=(0,A.useState)(!1),[oe,se]=(0,A.useState)(`body`);(0,A.useEffect)(()=>{try{let e=localStorage.getItem(`hive-api-client-history`);e&&J(JSON.parse(e))}catch{}},[]);let ce=(0,A.useCallback)(e=>{localStorage.setItem(`hive-api-client-history`,JSON.stringify(e.slice(0,50)))},[]),X=(e,t,n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},Z=(e,t)=>{t([...e,N()])},le=(e,t,n)=>{e.length===1?t([N()]):t(e.filter(e=>e.id!==n))},ue=()=>{let e={};for(let t of F)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},de=()=>{let e={};for(let t of L)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},Q=async()=>{if(!n.trim())return;W(!0),H(null);let t=performance.now();try{let r={method:e,url:n.trim(),headers:ue(),query_params:de()};z.trim()&&e!==`GET`&&e!==`HEAD`&&(r.body=z.trim());let i=await ee(`/api/http-request`,{method:`POST`,body:r,showError:!1});K(Math.round(performance.now()-t)),H(i);let a=[{id:M(),method:e,url:n.trim(),timestamp:Date.now(),status:i.status,ok:i.ok},...q];J(a),ce(a)}catch(e){K(Math.round(performance.now()-t)),H({ok:!1,error:e.message||`Request failed`})}finally{W(!1)}},fe=e=>{t(e.method),P(e.url),H(null)},pe=e=>{navigator.clipboard.writeText(e)},me=e=>{if(e==null)return``;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}return JSON.stringify(e,null,2)},he=e=>e?e>=200&&e<300?`bg-green-500`:e>=300&&e<400?`bg-yellow-500`:e>=400&&e<500?`bg-orange-500`:`bg-red-500`:`bg-gray-500`,$=(e,t,n,r)=>(0,j.jsxs)(`div`,{className:`space-y-2`,children:[e.map(i=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:n=>X(e,t,i.id,`enabled`,n.target.checked),className:`h-4 w-4 rounded border-white/20 bg-background`}),(0,j.jsx)(g,{placeholder:n,value:i.key,onChange:n=>X(e,t,i.id,`key`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(g,{placeholder:r,value:i.value,onChange:n=>X(e,t,i.id,`value`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(p,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-red-400`,onClick:()=>le(e,t,i.id),children:(0,j.jsx)(d,{className:`h-3.5 w-3.5`})})]},i.id)),(0,j.jsxs)(p,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground hover:text-primary`,onClick:()=>Z(e,t),children:[(0,j.jsx)(l,{className:`h-3.5 w-3.5 mr-1`}),`Agregar`]})]});return(0,j.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,j.jsx)(`div`,{className:`hive-page-header mb-6`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,j.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center text-purple-400`,children:(0,j.jsx)(m,{className:`h-6 w-6`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`API Client`}),(0,j.jsx)(`p`,{className:`hive-subtitle`,children:`Cliente HTTP para probar endpoints REST directamente desde Hive.`})]})]})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-6`,children:[(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(k,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(O,{className:`p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(T,{value:e,onValueChange:t,children:[(0,j.jsx)(re,{className:`w-[110px] h-10 text-xs font-bold tracking-wider`,children:(0,j.jsx)(w,{})}),(0,j.jsx)(ne,{children:ie.map(e=>(0,j.jsx)(C,{value:e,className:`text-xs font-bold`,children:e},e))})]}),(0,j.jsx)(g,{placeholder:`https://api.example.com/endpoint`,value:n,onChange:e=>P(e.target.value),onKeyDown:e=>e.key===`Enter`&&Q(),className:`h-10 text-sm bg-background/50 font-mono`}),(0,j.jsxs)(p,{onClick:Q,disabled:U||!n.trim(),className:`h-10 px-6 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs tracking-wider`,children:[U?(0,j.jsx)(h,{className:`h-4 w-4 animate-spin mr-2`}):(0,j.jsx)(u,{className:`h-4 w-4 mr-2`}),`ENVIAR`]})]})})}),(0,j.jsx)(k,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(O,{className:`p-4`,children:(0,j.jsxs)(x,{defaultValue:`headers`,className:`w-full`,children:[(0,j.jsxs)(b,{className:`bg-background/50 h-8`,children:[(0,j.jsxs)(v,{value:`headers`,className:`text-xs h-7`,children:[`Headers (`,F.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsxs)(v,{value:`query`,className:`text-xs h-7`,children:[`Query Params (`,L.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsx)(v,{value:`body`,className:`text-xs h-7`,children:`Body`})]}),(0,j.jsx)(y,{value:`headers`,className:`mt-3`,children:$(F,I,`Header`,`Value`)}),(0,j.jsx)(y,{value:`query`,className:`mt-3`,children:$(L,R,`Key`,`Value`)}),(0,j.jsxs)(y,{value:`body`,className:`mt-3`,children:[(0,j.jsx)(S,{placeholder:`{
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"./chevron-down-8GjmTjLR.js";import{t as i}from"./chevron-right-BupZqrxu.js";import{t as a}from"./circle-check-BKNT2_q6.js";import{t as o}from"./circle-x-DfBjbztU.js";import{t as s}from"./copy-wR7o7Ly8.js";import{t as c}from"./history-BHQWfE-7.js";import{t as l}from"./plus-DzvRxH4U.js";import{t as u}from"./send-xi8HzUdc.js";import{t as d}from"./trash-2-BZsMCfso.js";import{t as f}from"./utils-lc8H6VGT.js";import{G as p,O as ee,W as m,ot as h,st as g}from"./index-Bi8qEmrK.js";import{t as te}from"./badge-DKpeVCpY.js";import{t as _}from"./scroll-area-CSoG2z53.js";import{i as v,n as y,r as b,t as x}from"./tabs-Ckfc7DGG.js";import{t as S}from"./textarea-BH6pI9Ax.js";import{i as C,n as ne,o as re,s as w,t as T}from"./select-DlCT21_r.js";import{a as E,i as D,n as O,t as k}from"./card-Cag15G4h.js";var A=e(t(),1),j=n(),ie=[`GET`,`POST`,`PUT`,`DELETE`,`PATCH`,`HEAD`,`OPTIONS`];function M(){return Math.random().toString(36).substring(2,9)}function N(){return{id:M(),key:``,value:``,enabled:!0}}function P(){let[e,t]=(0,A.useState)(`GET`),[n,P]=(0,A.useState)(``),[F,I]=(0,A.useState)([N()]),[L,R]=(0,A.useState)([N()]),[z,B]=(0,A.useState)(``),[V,H]=(0,A.useState)(null),[U,W]=(0,A.useState)(!1),[G,K]=(0,A.useState)(0),[q,J]=(0,A.useState)([]),[Y,ae]=(0,A.useState)(!1),[oe,se]=(0,A.useState)(`body`);(0,A.useEffect)(()=>{try{let e=localStorage.getItem(`hive-api-client-history`);e&&J(JSON.parse(e))}catch{}},[]);let ce=(0,A.useCallback)(e=>{localStorage.setItem(`hive-api-client-history`,JSON.stringify(e.slice(0,50)))},[]),X=(e,t,n,r,i)=>{t(e.map(e=>e.id===n?{...e,[r]:i}:e))},Z=(e,t)=>{t([...e,N()])},le=(e,t,n)=>{e.length===1?t([N()]):t(e.filter(e=>e.id!==n))},ue=()=>{let e={};for(let t of F)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},de=()=>{let e={};for(let t of L)t.enabled&&t.key.trim()&&(e[t.key.trim()]=t.value);return e},Q=async()=>{if(!n.trim())return;W(!0),H(null);let t=performance.now();try{let r={method:e,url:n.trim(),headers:ue(),query_params:de()};z.trim()&&e!==`GET`&&e!==`HEAD`&&(r.body=z.trim());let i=await ee(`/api/http-request`,{method:`POST`,body:r,showError:!1});K(Math.round(performance.now()-t)),H(i);let a=[{id:M(),method:e,url:n.trim(),timestamp:Date.now(),status:i.status,ok:i.ok},...q];J(a),ce(a)}catch(e){K(Math.round(performance.now()-t)),H({ok:!1,error:e.message||`Request failed`})}finally{W(!1)}},fe=e=>{t(e.method),P(e.url),H(null)},pe=e=>{navigator.clipboard.writeText(e)},me=e=>{if(e==null)return``;if(typeof e==`string`)try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}return JSON.stringify(e,null,2)},he=e=>e?e>=200&&e<300?`bg-green-500`:e>=300&&e<400?`bg-yellow-500`:e>=400&&e<500?`bg-orange-500`:`bg-red-500`:`bg-gray-500`,$=(e,t,n,r)=>(0,j.jsxs)(`div`,{className:`space-y-2`,children:[e.map(i=>(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:n=>X(e,t,i.id,`enabled`,n.target.checked),className:`h-4 w-4 rounded border-white/20 bg-background`}),(0,j.jsx)(m,{placeholder:n,value:i.key,onChange:n=>X(e,t,i.id,`key`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(m,{placeholder:r,value:i.value,onChange:n=>X(e,t,i.id,`value`,n.target.value),className:`h-8 text-xs bg-background/50`}),(0,j.jsx)(p,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-muted-foreground hover:text-red-400`,onClick:()=>le(e,t,i.id),children:(0,j.jsx)(d,{className:`h-3.5 w-3.5`})})]},i.id)),(0,j.jsxs)(p,{variant:`ghost`,size:`sm`,className:`text-xs text-muted-foreground hover:text-primary`,onClick:()=>Z(e,t),children:[(0,j.jsx)(l,{className:`h-3.5 w-3.5 mr-1`}),`Agregar`]})]});return(0,j.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,j.jsx)(`div`,{className:`hive-page-header mb-6`,children:(0,j.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,j.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-purple-500/10 border border-purple-500/20 flex items-center justify-center text-purple-400`,children:(0,j.jsx)(h,{className:`h-6 w-6`})}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`API Client`}),(0,j.jsx)(`p`,{className:`hive-subtitle`,children:`Cliente HTTP para probar endpoints REST directamente desde Hive.`})]})]})}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-[1fr_320px] gap-6`,children:[(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsx)(k,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(O,{className:`p-4`,children:(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsxs)(T,{value:e,onValueChange:t,children:[(0,j.jsx)(re,{className:`w-[110px] h-10 text-xs font-bold tracking-wider`,children:(0,j.jsx)(w,{})}),(0,j.jsx)(ne,{children:ie.map(e=>(0,j.jsx)(C,{value:e,className:`text-xs font-bold`,children:e},e))})]}),(0,j.jsx)(m,{placeholder:`https://api.example.com/endpoint`,value:n,onChange:e=>P(e.target.value),onKeyDown:e=>e.key===`Enter`&&Q(),className:`h-10 text-sm bg-background/50 font-mono`}),(0,j.jsxs)(p,{onClick:Q,disabled:U||!n.trim(),className:`h-10 px-6 bg-purple-600 hover:bg-purple-500 text-white font-bold text-xs tracking-wider`,children:[U?(0,j.jsx)(g,{className:`h-4 w-4 animate-spin mr-2`}):(0,j.jsx)(u,{className:`h-4 w-4 mr-2`}),`ENVIAR`]})]})})}),(0,j.jsx)(k,{className:`border-white/10 bg-card/50`,children:(0,j.jsx)(O,{className:`p-4`,children:(0,j.jsxs)(x,{defaultValue:`headers`,className:`w-full`,children:[(0,j.jsxs)(b,{className:`bg-background/50 h-8`,children:[(0,j.jsxs)(v,{value:`headers`,className:`text-xs h-7`,children:[`Headers (`,F.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsxs)(v,{value:`query`,className:`text-xs h-7`,children:[`Query Params (`,L.filter(e=>e.enabled&&e.key.trim()).length,`)`]}),(0,j.jsx)(v,{value:`body`,className:`text-xs h-7`,children:`Body`})]}),(0,j.jsx)(y,{value:`headers`,className:`mt-3`,children:$(F,I,`Header`,`Value`)}),(0,j.jsx)(y,{value:`query`,className:`mt-3`,children:$(L,R,`Key`,`Value`)}),(0,j.jsxs)(y,{value:`body`,className:`mt-3`,children:[(0,j.jsx)(S,{placeholder:`{
2
2
  "key": "value"
3
3
  }`,value:z,onChange:e=>B(e.target.value),className:`min-h-[140px] font-mono text-xs bg-background/50`}),(0,j.jsx)(`p`,{className:`text-[10px] text-muted-foreground mt-2`,children:`Se enviará como string crudo. Para JSON, asegurate de que sea válido.`})]})]})})}),V&&(0,j.jsxs)(k,{className:f(`border-white/10`,V.ok?`bg-green-500/[0.02]`:`bg-red-500/[0.02]`),children:[(0,j.jsx)(D,{className:`pb-3`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,j.jsx)(E,{className:`text-sm font-bold tracking-wider`,children:`RESPUESTA`}),V.status!==void 0&&(0,j.jsxs)(te,{variant:`outline`,className:f(`text-xs font-bold border-none`,he(V.status),`text-white`),children:[V.status,` `,V.statusText||``]}),V.ok?(0,j.jsx)(a,{className:`h-4 w-4 text-green-500`}):(0,j.jsx)(o,{className:`h-4 w-4 text-red-500`}),(0,j.jsxs)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:[G,`ms`]})]}),(0,j.jsxs)(p,{variant:`ghost`,size:`sm`,className:`h-7 text-xs`,onClick:()=>pe(JSON.stringify(V,null,2)),children:[(0,j.jsx)(s,{className:`h-3 w-3 mr-1`}),`Copiar`]})]})}),(0,j.jsx)(O,{className:`pt-0`,children:(0,j.jsxs)(x,{value:oe,onValueChange:se,children:[(0,j.jsxs)(b,{className:`bg-background/50 h-8`,children:[(0,j.jsx)(v,{value:`body`,className:`text-xs h-7`,children:`Body`}),(0,j.jsx)(v,{value:`headers`,className:`text-xs h-7`,children:`Headers`}),(0,j.jsx)(v,{value:`raw`,className:`text-xs h-7`,children:`Raw`})]}),(0,j.jsx)(y,{value:`body`,className:`mt-3`,children:(0,j.jsx)(_,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-green-400 whitespace-pre-wrap`,children:me(V.body??V)})})}),(0,j.jsx)(y,{value:`headers`,className:`mt-3`,children:(0,j.jsx)(_,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:V.headers?(0,j.jsx)(`div`,{className:`space-y-1`,children:Object.entries(V.headers).map(([e,t])=>(0,j.jsxs)(`div`,{className:`flex gap-2 text-xs font-mono`,children:[(0,j.jsxs)(`span`,{className:`text-purple-400 shrink-0`,children:[e,`:`]}),(0,j.jsx)(`span`,{className:`text-white/70`,children:String(t)})]},e))}):(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No headers disponibles`})})}),(0,j.jsx)(y,{value:`raw`,className:`mt-3`,children:(0,j.jsx)(_,{className:`h-[300px] w-full rounded-md border bg-black/40 p-3`,children:(0,j.jsx)(`pre`,{className:`font-mono text-xs text-white/60 whitespace-pre-wrap`,children:JSON.stringify(V,null,2)})})})]})})]})]}),(0,j.jsx)(`div`,{children:(0,j.jsxs)(k,{className:`border-white/10 bg-card/50`,children:[(0,j.jsx)(D,{className:`pb-3`,children:(0,j.jsxs)(`button`,{onClick:()=>ae(!Y),className:`flex items-center justify-between w-full`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),(0,j.jsx)(E,{className:`text-xs font-bold tracking-wider`,children:`HISTORIAL`})]}),Y?(0,j.jsx)(r,{className:`h-4 w-4 text-muted-foreground`}):(0,j.jsx)(i,{className:`h-4 w-4 text-muted-foreground`})]})}),Y&&(0,j.jsxs)(O,{className:`pt-0`,children:[q.length===0?(0,j.jsx)(`p`,{className:`text-xs text-muted-foreground text-center py-4`,children:`No hay requests en el historial`}):(0,j.jsx)(_,{className:`h-[calc(100vh-300px)]`,children:(0,j.jsx)(`div`,{className:`space-y-1`,children:q.map(e=>(0,j.jsxs)(`button`,{onClick:()=>fe(e),className:`w-full text-left p-2 rounded-lg hover:bg-white/5 transition-colors group`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`span`,{className:f(`text-[10px] font-bold px-1.5 py-0.5 rounded`,e.ok?`bg-green-500/20 text-green-400`:`bg-red-500/20 text-red-400`),children:e.method}),e.status&&(0,j.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.status})]}),(0,j.jsx)(`p`,{className:`text-[10px] text-white/50 truncate mt-1 font-mono`,children:e.url}),(0,j.jsx)(`p`,{className:`text-[9px] text-white/30 mt-0.5`,children:new Date(e.timestamp).toLocaleTimeString()})]},e.id))})}),q.length>0&&(0,j.jsxs)(p,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-[10px] text-muted-foreground hover:text-red-400`,onClick:()=>{J([]),localStorage.removeItem(`hive-api-client-history`)},children:[(0,j.jsx)(d,{className:`h-3 w-3 mr-1`}),`Limpiar historial`]})]})]})})]})]})}export{P as ApiClientPage};
@@ -0,0 +1,8 @@
1
+ import{r as e,t}from"./rolldown-runtime-S-ySWqyJ.js";import{f as n}from"./vendor-charts-K3xcRl0X.js";import{o as r}from"./vendor-query-Dj8xYhQD.js";import{t as i}from"./createLucideIcon-BRaPSYgN.js";import{t as a}from"./circle-alert-CtDbK2nl.js";import{t as o}from"./circle-check-BKNT2_q6.js";import{n as s,t as c}from"./eye-sRPY5qOa.js";import{t as l}from"./plus-DzvRxH4U.js";import{t as u}from"./refresh-cw-DZXu5FrG.js";import{t as d}from"./settings-pV0cF8Kf.js";import{t as f}from"./zap-Yed86Sh8.js";import{c as p}from"./vendor-router-DCsSv_I7.js";import{C as m,E as h,G as g,O as _,S as v,W as y,it as b,nt as x,q as S,rt as C,v as ee}from"./index-Bi8qEmrK.js";import{t as w}from"./label-C6atPuIh.js";import{a as te,i as T,n as E,o as D,r as ne,s as O,t as k}from"./select-DlCT21_r.js";import{t as A}from"./switch-CUsGuBNi.js";import{n as re,t as ie}from"./alert-Cj4DpKv6.js";var ae=i(`QrCode`,[[`rect`,{width:`5`,height:`5`,x:`3`,y:`3`,rx:`1`,key:`1tu5fj`}],[`rect`,{width:`5`,height:`5`,x:`16`,y:`3`,rx:`1`,key:`1v8r4q`}],[`rect`,{width:`5`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`1x03jg`}],[`path`,{d:`M21 16h-3a2 2 0 0 0-2 2v3`,key:`177gqh`}],[`path`,{d:`M21 21v.01`,key:`ents32`}],[`path`,{d:`M12 7v3a2 2 0 0 1-2 2H7`,key:`8crl2c`}],[`path`,{d:`M3 12h.01`,key:`nlz23k`}],[`path`,{d:`M12 3h.01`,key:`n36tog`}],[`path`,{d:`M12 16v.01`,key:`133mhm`}],[`path`,{d:`M16 12h1`,key:`1slzba`}],[`path`,{d:`M21 12v.01`,key:`1lwtk9`}],[`path`,{d:`M12 21v-1`,key:`1880an`}]]),j=e(n(),1),M=r();function N({channel:e,onEdit:t,onToggle:n}){e.status;let r=e.isConfigured===!1,i=e.status===`connected`||e.status===`connecting`;return(0,M.jsxs)(`div`,{onClick:()=>t(e),className:`hive-card group transition-all duration-500 cursor-pointer ${i?`hive-card--active border-emerald-500/20`:r?`opacity-50 border-dashed hover:opacity-80 hover:border-blue-500/30`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,M.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between mb-8`,children:[(0,M.jsx)(`div`,{className:`h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-500 ${i?`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 shadow-[0_0_15px_rgba(16,185,129,0.2)]`:r?`bg-blue-500/5 border-blue-500/20 text-blue-400/40`:`bg-white/5 border-white/10 text-white/30`}`,children:(0,M.jsx)(x,{className:`h-6 w-6`})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[i&&(0,M.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-emerald-500 shadow-emerald-glow`,children:e.status===`connecting`?`CONECTANDO`:`CONECTADO`}),r?(0,M.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-blue-400/60 uppercase`,children:`DISPONIBLE`}):(0,M.jsx)(A,{checked:e.enabled,onCheckedChange:t=>n(e.id,t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-emerald-500 scale-75 origin-right`})]})]}),(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-xl font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-emerald-400 transition-colors`,children:e.type}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/20 font-black tracking-[0.2em] mb-4`,children:r?`CLICK PARA CONFIGURAR`:`ID: ${e.id.substring(0,12).toUpperCase()}`})]}),(0,M.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-6`,children:[(0,M.jsxs)(`div`,{className:`hive-stat`,children:[(0,M.jsx)(`span`,{className:`hive-stat__label`,children:`VOZ`}),(0,M.jsx)(`span`,{className:`hive-stat__value ${e.voice_enabled?`text-emerald-500`:`text-white/20`}`,children:e.voice_enabled?`ON`:`OFF`})]}),(0,M.jsxs)(`div`,{className:`hive-stat`,children:[(0,M.jsx)(`span`,{className:`hive-stat__label`,children:`SÍNTESIS`}),(0,M.jsx)(`span`,{className:`hive-stat__value ${e.tts_enabled?`text-emerald-500`:`text-white/20`}`,children:e.tts_enabled?`ON`:`OFF`})]})]})]}),i&&(0,M.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--emerald -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,M.jsx)(`div`,{className:`hive-strip--bottom ${i?`bg-emerald-500`:r?`bg-blue-500/30`:`bg-white/10`}`})]})}var oe=t(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),P=t((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),F=t((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),se=t(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),ce=t(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),le=t((e=>{var t=P().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),ue=t((e=>{var t=P().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),I=t((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),L=t((e=>{var t=F(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),R=t((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),de=t((e=>{var t=R();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),z=t(((e,t)=>{var n=de();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),B=t((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),V=t((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
+ ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),H=t((e=>{var t=B(),n=V();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),fe=t((e=>{var t=P(),n=L(),r=F(),i=H(),a=B(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),pe=t((e=>{var t=P(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),me=t(((e,t)=>{var n=H();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),he=t(((e,t)=>{var n=H(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),U=t(((e,t)=>{var n=H();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),ge=t(((e,t)=>{var n=H(),r=P();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
+ Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),_e=t(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),ve=t((e=>{var t=H(),n=me(),r=he(),i=U(),a=ge(),o=V(),s=P(),c=_e();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
+ Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),ye=t((e=>{var t=P(),n=F(),r=se(),i=ce(),a=le(),o=ue(),s=I(),c=L(),l=z(),u=fe(),d=pe(),f=H(),p=ve();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
+ The chosen QR Code version cannot contain this amount of data.
6
+ Minimum version required to store current data is: `+c+`.
7
+ `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),W=t((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),be=t((e=>{var t=W();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),G=t((e=>{var t=W();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
+ `;return typeof a==`function`&&a(null,p),p}})),K=e(t((e=>{var t=oe(),n=ye(),r=be(),i=G();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}))(),1),xe=[{id:`gemini`,name:`Google Gemini`,provider:`gemini`},{id:`openai`,name:`OpenAI`,provider:`openai`},{id:`anthropic`,name:`Anthropic Claude`,provider:`anthropic`}];function Se({data:e}){let t=(0,j.useRef)(null);return(0,j.useEffect)(()=>{!e||!t.current||K.toCanvas(t.current,e,{width:220,margin:2,color:{dark:`#000000`,light:`#ffffff`}}).catch(console.error)},[e]),(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`rounded-xl overflow-hidden border-4 border-white shadow-lg`,children:(0,M.jsx)(`canvas`,{ref:t})}),(0,M.jsx)(`p`,{className:`text-xs text-white/40 text-center`,children:`Abre WhatsApp → Ajustes → Dispositivos vinculados → Vincular dispositivo`})]})}function q({channel:e,isOpen:t,onClose:n,onSave:r}){let i=p(),{createChannel:f,reconnectChannel:b,fetchChannels:x}=ee(),{configuredVoiceProviders:N,fetchConfiguredVoiceProviders:oe}=h(),{models:P}=v(),{providers:F}=m(),se=e=>e.provider_id||e.providerId||``,ce=(0,j.useMemo)(()=>P.filter(e=>e.model_type===`stt`&&N[se(e)]),[P,N]),le=(0,j.useMemo)(()=>{let e=new Map;for(let t of P){if(t.model_type!==`tts`)continue;let n=se(t);N[n]&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}return Array.from(e.entries()).map(([e,t])=>({provider:e,group:F.find(t=>t.id===e)?.name||e,models:t}))},[P,F,N]),ue=(0,j.useCallback)(e=>{let t=P.find(t=>t.id===e);return t?se(t):F.some(t=>t.id===e)?e:null},[P,F]),[I,L]=(0,j.useState)(e?`settings`:`type`),[R,de]=(0,j.useState)(`telegram`),[z,B]=(0,j.useState)(``),[V,H]=(0,j.useState)(``),[fe,pe]=(0,j.useState)(``),[me,he]=(0,j.useState)(!1),[U,ge]=(0,j.useState)(!1),[_e,ve]=(0,j.useState)(null),[ye,W]=(0,j.useState)(null),[be,G]=(0,j.useState)(!1),[K,q]=(0,j.useState)(null),[J,Ce]=(0,j.useState)(!1),we=(0,j.useRef)(null),[Y,X]=(0,j.useState)({}),[Te,Ee]=(0,j.useState)(!1),[De,Oe]=(0,j.useState)([]),[ke,Ae]=(0,j.useState)(!1),[je,Me]=(0,j.useState)(!1),[Ne,Pe]=(0,j.useState)(``),[Fe,Ie]=(0,j.useState)(!1),[Le,Re]=(0,j.useState)(!0),[ze,Be]=(0,j.useState)(!1),[Ve,He]=(0,j.useState)(`open`),[Ue,We]=(0,j.useState)([]),[Ge,Ke]=(0,j.useState)(``),[qe,Je]=(0,j.useState)(5),[Ye,Xe]=(0,j.useState)(1e3),[Ze,Qe]=(0,j.useState)(!1),$e=e&&e.status!==`connected`,Z=e&&e.isConfigured===!1;(0,j.useEffect)(()=>{t?e?(L($e?`reconnect`:`settings`),de(e.type),B(``),H(``),pe(``),ve(e.id),W(null),G(!1),q(null),X(e),Me(!1),Pe(``),Ie(!1)):(L(`type`),de(`telegram`),B(``),H(``),pe(``),ve(null),W(null),G(!1),q(null)):Q()},[t,e]),(0,j.useEffect)(()=>{oe()},[oe]),(0,j.useEffect)(()=>{if(!t||!e||e.type!==`whatsapp`){Qe(!1);return}let n=!1;return _(`/api/channels/whatsapp/${e.id}/details`,{showError:!1}).then(e=>{n||(Re(e.selfMessagesOnly??!0),Be(e.acceptGroups??!1),He(e.dmPolicy??`open`),We(e.allowFrom??[]),Je(e.reconnectMaxAttempts??5),Xe(e.reconnectBaseDelayMs??1e3),Qe(!0))}).catch(()=>Qe(!1)),()=>{n=!0}},[t,e]),(0,j.useEffect)(()=>{let e=Y.tts_provider?ue(Y.tts_provider):null;if(!e){Oe([]);return}Ae(!0),_(`/api/voice/${e}/voices`,{showError:!1}).then(e=>Oe(e.voices||[])).catch(()=>Oe([])).finally(()=>Ae(!1))},[Y.tts_provider,ue]);let Q=(0,j.useCallback)(()=>{we.current&&=(clearInterval(we.current),null)},[]),et=(0,j.useCallback)((e,t)=>{Q(),we.current=setInterval(async()=>{try{let n=await _(`/api/channels/${e}/${t}/status`,{showError:!1});n.status===`qr`&&n.qrCode?(W(n.qrCode),G(!1),L(`qr`)):n.status===`connected`?(Q(),await x(),L(`success`)):n.status===`error`?(Q(),q(`Error de conexión. Intenta de nuevo.`),L(`credentials`)):(n.status===`disconnected`||n.status===`not_found`)&&G(!0)}catch{}},2e3)},[Q,x]),tt=async()=>{if(e){Ce(!0),q(null);try{let t={};R===`telegram`&&z.trim()&&(t.botToken=z),R===`discord`&&(z.trim()&&(t.botToken=z),V.trim()&&(t.applicationId=V)),await b(e.id,Object.keys(t).length>0?t:void 0),L(`connecting`),et(R,e.id)}catch(e){q(e.message||`Error al reconectar`)}finally{Ce(!1)}}},nt=async()=>{Ce(!0),q(null);try{let e={};R===`telegram`&&(e.botToken=z),R===`discord`&&(e.botToken=z,e.applicationId=V),R===`slack`&&(e.botToken=z,e.signingSecret=fe);let{id:t}=await f(R,e);ve(t),R===`whatsapp`?(L(`connecting`),et(`whatsapp`,t)):(L(`connecting`),et(R,t))}catch(e){q(e.message||`Error al conectar`)}finally{Ce(!1)}},rt=async()=>{if(e?.id){Ee(!0);try{if(Ne.trim().length>10&&(e.type===`telegram`||e.type===`discord`)){let t={botToken:Ne.trim()};await b(e.id,t)}await r(e.id,Y),e.type===`whatsapp`&&await _(`/api/channels/whatsapp/${e.id}/config`,{method:`PUT`,body:{selfMessagesOnly:Le,acceptGroups:ze,dmPolicy:Ve,allowFrom:Ue,reconnectMaxAttempts:qe,reconnectBaseDelayMs:Ye}}),n()}catch(e){console.error(`Save failed`,e)}finally{Ee(!1)}}},$=()=>{Q(),n()},it=R===`whatsapp`||R===`webchat`||R===`telegram`&&z.trim().length>10||R===`discord`&&z.trim().length>10&&V.trim().length>0||R===`slack`&&z.trim().length>10&&fe.trim().length>10,at=()=>I===`reconnect`?(0,M.jsxs)(`div`,{className:`space-y-4 py-2`,children:[K&&(0,M.jsxs)(ie,{variant:`destructive`,className:`bg-red-500/10 border-red-500/30`,children:[(0,M.jsx)(a,{className:`h-4 w-4`}),(0,M.jsx)(re,{children:K})]}),(0,M.jsxs)(`div`,{className:`p-4 rounded-xl ${Z?`bg-blue-500/10 border border-blue-500/20`:`bg-amber-500/10 border border-amber-500/20`}`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold uppercase tracking-widest mb-1 ${Z?`text-blue-300`:`text-amber-300`}`,children:Z?`Canal no configurado`:`Canal desconectado`}),(0,M.jsx)(`p`,{className:`text-xs ${Z?`text-blue-200/70`:`text-amber-200/70`}`,children:Z?R===`whatsapp`?`Haz clic en Conectar para generar el código QR.`:R===`webchat`?`Haz clic en Conectar para activar el canal web.`:`Ingresa las credenciales para activar este canal.`:R===`whatsapp`?`Haz clic en Reconectar para generar un nuevo código QR.`:R===`webchat`?`Haz clic en Reconectar para activar el canal.`:`Puedes reconectar con las credenciales existentes o ingresar un nuevo token.`})]}),(R===`telegram`||R===`discord`)&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsx)(`p`,{className:`text-[10px] text-white/30 uppercase tracking-widest`,children:Z?`Credenciales`:`Actualizar credenciales (opcional)`}),(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50`,children:`Bot Token`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(y,{type:U?`text`:`password`,value:z,onChange:e=>B(e.target.value),placeholder:Z?R===`telegram`?`123456789:AAF...`:`MTA5NDY...`:`Dejar vacío para usar el token actual`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:U?(0,M.jsx)(s,{className:`h-4 w-4`}):(0,M.jsx)(c,{className:`h-4 w-4`})})]})]}),R===`discord`&&(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50`,children:`Application ID`}),(0,M.jsx)(y,{value:V,onChange:e=>H(e.target.value),placeholder:Z?`123456789012345678`:`Dejar vacío para usar el actual`,className:`bg-white/5 border-white/10 font-mono text-sm`})]})]})]}):I===`type`?(0,M.jsxs)(`div`,{className:`space-y-4 py-2`,children:[(0,M.jsx)(`p`,{className:`text-sm text-white/50`,children:`Selecciona el tipo de canal a conectar:`}),(0,M.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:[{id:`telegram`,label:`Telegram`,icon:`✈️`},{id:`whatsapp`,label:`WhatsApp`,icon:`💬`},{id:`discord`,label:`Discord`,icon:`🎮`},{id:`slack`,label:`Slack`,icon:`💼`},{id:`webchat`,label:`WebChat`,icon:`🌐`}].map(e=>(0,M.jsxs)(`button`,{onClick:()=>de(e.id),className:`p-4 rounded-xl border text-left transition-all duration-200 ${R===e.id?`border-blue-500 bg-blue-500/10 text-white`:`border-white/10 bg-white/5 text-white/50 hover:border-white/20 hover:text-white/70`}`,children:[(0,M.jsx)(`div`,{className:`text-2xl mb-1`,children:e.icon}),(0,M.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label})]},e.id))})]}):I===`credentials`?(0,M.jsxs)(`div`,{className:`space-y-4 py-2`,children:[K&&(0,M.jsxs)(ie,{variant:`destructive`,className:`bg-red-500/10 border-red-500/30`,children:[(0,M.jsx)(a,{className:`h-4 w-4`}),(0,M.jsx)(re,{children:K})]}),R===`whatsapp`&&(0,M.jsx)(`div`,{className:`p-4 rounded-xl bg-emerald-500/10 border border-emerald-500/20 text-sm text-emerald-300`,children:`WhatsApp no requiere token. Haz clic en "Conectar" y escanea el código QR con tu teléfono.`}),R===`webchat`&&(0,M.jsx)(`div`,{className:`p-4 rounded-xl bg-blue-500/10 border border-blue-500/20 text-sm text-blue-300`,children:`WebChat no requiere configuración. Haz clic en "Conectar" para activarlo.`}),(R===`telegram`||R===`discord`||R===`slack`)&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Bot Token`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(y,{type:U?`text`:`password`,value:z,onChange:e=>B(e.target.value),placeholder:R===`telegram`?`123456789:AAF...`:R===`slack`?`xoxb-...`:`MTA5NDY...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>ge(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:U?(0,M.jsx)(s,{className:`h-4 w-4`}):(0,M.jsx)(c,{className:`h-4 w-4`})})]})]}),R===`discord`&&(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Application ID`}),(0,M.jsx)(y,{value:V,onChange:e=>H(e.target.value),placeholder:`123456789012345678`,className:`bg-white/5 border-white/10 font-mono text-sm`})]}),R===`slack`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Signing Secret`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(y,{type:me?`text`:`password`,value:fe,onChange:e=>pe(e.target.value),placeholder:`a1b2c3d4e5f6...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>he(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:me?(0,M.jsx)(s,{className:`h-4 w-4`}):(0,M.jsx)(c,{className:`h-4 w-4`})})]})]}),(0,M.jsxs)(`div`,{className:`p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-xs text-amber-200/80`,children:[`Slack requiere una URL pública para webhooks. Usa ngrok, cloudflared o Tailscale y configura la Request URL en tu Slack App: `,(0,M.jsx)(`span`,{className:`font-mono`,children:`https://tu-url/slack/events`})]})]})]})]}):I===`connecting`?(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,M.jsx)(`div`,{className:`relative`,children:(0,M.jsx)(`div`,{className:`h-16 w-16 rounded-full border-2 border-white/10 flex items-center justify-center`,children:(0,M.jsx)(C,{className:`h-8 w-8 animate-spin text-blue-400`})})}),(0,M.jsx)(`p`,{className:`text-sm text-white/60 text-center`,children:R===`whatsapp`?`Iniciando WhatsApp... Generando código QR`:`Conectando canal...`}),(0,M.jsx)(`p`,{className:`text-xs text-white/30`,children:`Esto puede tardar unos segundos`})]}):I===`qr`?(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-4`,children:[(0,M.jsxs)(`div`,{className:`relative`,children:[ye?(0,M.jsx)(Se,{data:ye}):(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-6`,children:[(0,M.jsx)(ae,{className:`h-16 w-16 text-white/20`}),(0,M.jsx)(`p`,{className:`text-xs text-white/40`,children:`Generando QR...`})]}),be&&(0,M.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center rounded-xl bg-zinc-950/80 backdrop-blur-sm gap-2`,children:[(0,M.jsx)(C,{className:`h-8 w-8 animate-spin text-amber-400`}),(0,M.jsx)(`p`,{className:`text-xs text-amber-300 font-medium`,children:`QR expirado, renovando...`})]})]}),(0,M.jsx)(`div`,{className:`flex items-center gap-2 text-xs text-white/30`,children:be?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-amber-400 animate-pulse`}),`Renovando código QR...`]}):(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse`}),`Esperando escaneo...`]})}),(0,M.jsx)(`p`,{className:`text-[11px] text-white/30 text-center`,children:`Abre WhatsApp → Ajustes → Dispositivos vinculados → Vincular dispositivo`})]}):I===`success`?(0,M.jsxs)(`div`,{className:`flex flex-col items-center gap-4 py-8`,children:[(0,M.jsx)(`div`,{className:`h-16 w-16 rounded-full bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-center`,children:(0,M.jsx)(o,{className:`h-8 w-8 text-emerald-400`})}),(0,M.jsxs)(`div`,{className:`text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-white`,children:`Canal conectado`}),(0,M.jsxs)(`p`,{className:`text-xs text-white/40 mt-1`,children:[R.charAt(0).toUpperCase()+R.slice(1),` está activo y listo para recibir mensajes.`]})]})]}):null,ot=()=>(0,M.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[e?.type===`whatsapp`&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`space-y-2 pb-2 border-b border-white/10`,children:[(0,M.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,M.jsx)(w,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Número Vinculado`})}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-white/5 border border-white/10`,children:[(0,M.jsx)(`span`,{className:`font-mono text-sm text-white/70`,children:e.accountId?`+${e.accountId}`:`No conectado`}),(0,M.jsx)(`span`,{className:`text-[10px] text-white/40 ml-auto`,children:e.status===`connected`?`✓`:`sin conexión`})]})]}),(0,M.jsxs)(`div`,{className:`space-y-3 pb-2 border-b border-white/10`,children:[(0,M.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-widest text-green-400`,children:`Recepción de Mensajes`}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/60`,children:`Solo mensajes propios`}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Solo se procesan los mensajes enviados por la propia cuenta`})]}),(0,M.jsx)(A,{checked:Le,onCheckedChange:Re})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,M.jsx)(w,{className:`text-xs text-white/60`,children:`Aceptar mensajes de grupo`}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Procesar mensajes provenientes de conversaciones grupales`})]}),(0,M.jsx)(A,{checked:ze,onCheckedChange:Be})]}),!Le&&(0,M.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,M.jsx)(w,{className:`text-xs text-white/60 uppercase tracking-widest`,children:`Política de DM (WhatsApp)`}),(0,M.jsxs)(k,{value:Ve,onValueChange:e=>He(e),children:[(0,M.jsx)(D,{className:`bg-white/5 border-white/10`,children:(0,M.jsx)(O,{})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(T,{value:`open`,children:(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`span`,{children:`Abierto`}),(0,M.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Cualquiera puede iniciar chat`})]})}),(0,M.jsx)(T,{value:`allowlist`,children:(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`span`,{children:`Lista permitida`}),(0,M.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Solo números autorizados`})]})}),(0,M.jsx)(T,{value:`pairing`,children:(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`span`,{children:`Emparejamiento`}),(0,M.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`Requiere vinculación manual`})]})})]})]}),(Ve===`allowlist`||Ve===`pairing`)&&(0,M.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,M.jsx)(w,{className:`text-xs text-white/60 uppercase tracking-widest`,children:`Números permitidos`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(y,{value:Ge,onChange:e=>Ke(e.target.value),placeholder:`Ej. +521234567890`,className:`bg-white/5 border-white/10 font-mono text-sm`,onKeyDown:e=>{if(e.key===`Enter`){e.preventDefault();let t=Ge.trim();t&&!Ue.includes(t)&&(We(e=>[...e,t]),Ke(``))}}}),(0,M.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,disabled:!Ge.trim(),onClick:()=>{let e=Ge.trim();e&&!Ue.includes(e)&&(We(t=>[...t,e]),Ke(``))},className:`h-9 w-9 p-0 shrink-0 hover:bg-blue-500/10`,children:(0,M.jsx)(l,{className:`h-4 w-4`})})]}),Ue.length>0?(0,M.jsx)(`div`,{className:`space-y-1.5`,children:Ue.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between h-9 px-3 rounded-lg bg-white/5 border border-white/10`,children:[(0,M.jsx)(`span`,{className:`text-sm font-mono font-medium`,children:e}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>We(t=>t.filter(t=>t!==e)),className:`text-white/30 hover:text-red-400 transition-colors`,children:(0,M.jsx)(S,{className:`h-3.5 w-3.5`})})]},e))}):(0,M.jsx)(`p`,{className:`text-[10px] text-white/30 italic`,children:`No hay números en la lista permitida`})]})]})]}),(0,M.jsxs)(`div`,{className:`space-y-3 pb-2 border-b border-white/10`,children:[(0,M.jsx)(`p`,{className:`text-xs font-bold uppercase tracking-widest text-amber-400`,children:`Reconexión`}),(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Intentos máx.`}),(0,M.jsx)(y,{type:`number`,min:0,value:qe,onChange:e=>Je(parseInt(e.target.value,10)||0),className:`col-span-3 bg-white/5 border-white/10 text-sm`})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Retardo base (ms)`}),(0,M.jsx)(y,{type:`number`,min:0,value:Ye,onChange:e=>Xe(parseInt(e.target.value,10)||0),className:`col-span-3 bg-white/5 border-white/10 text-sm`})]}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Backoff exponencial usando el retardo base configurado.`})]})]}),(e?.type===`telegram`||e?.type===`discord`)&&(0,M.jsxs)(`div`,{className:`space-y-2 pb-2 border-b border-white/10`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(w,{className:`text-xs text-white/50 uppercase tracking-widest`,children:`Bot Token`}),!je&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>Me(!0),className:`text-[11px] text-blue-400 hover:text-blue-300 transition-colors`,children:`Cambiar token`})]}),je?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(y,{type:Fe?`text`:`password`,value:Ne,onChange:e=>Pe(e.target.value),placeholder:e?.type===`telegram`?`123456789:AAF...`:`MTA5NDY...`,className:`bg-white/5 border-white/10 pr-10 font-mono text-sm`,autoFocus:!0}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Ie(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/40 hover:text-white/70`,children:Fe?(0,M.jsx)(s,{className:`h-4 w-4`}):(0,M.jsx)(c,{className:`h-4 w-4`})})]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>{Me(!1),Pe(``),Ie(!1)},className:`text-[11px] text-white/40 hover:text-white/60 transition-colors`,children:`Cancelar`}),Ne.trim().length>0&&(0,M.jsx)(`span`,{className:`text-[11px] text-amber-400/70`,children:`Se aplicará al guardar`})]})]}):(0,M.jsx)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-white/5 border border-white/10`,children:(0,M.jsx)(`span`,{className:`font-mono text-sm text-white/30 tracking-widest select-none`,children:`••••••••••••••••••••••••`})})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Voz (STT)`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 col-span-3`,children:[(0,M.jsx)(A,{checked:Y.voice_enabled,onCheckedChange:e=>X(t=>({...t,voice_enabled:e}))}),(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Procesar notas de voz`})]})]}),(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`TTS`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 col-span-3`,children:[(0,M.jsx)(A,{checked:Y.tts_enabled,onCheckedChange:e=>X(t=>({...t,tts_enabled:e}))}),(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Responder por voz`})]})]}),Y.voice_enabled&&(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Modelo STT`}),(0,M.jsxs)(k,{value:Y.stt_provider||``,onValueChange:e=>X(t=>({...t,stt_provider:e})),children:[(0,M.jsx)(D,{className:`col-span-3`,children:(0,M.jsx)(O,{placeholder:`Selecciona modelo STT`})}),(0,M.jsx)(E,{children:ce.map(e=>(0,M.jsx)(T,{value:e.id,children:e.name},e.id))})]})]}),Y.tts_enabled&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Modelo TTS`}),(0,M.jsxs)(k,{value:Y.tts_provider||``,onValueChange:e=>X(t=>({...t,tts_provider:e,tts_voice_id:``})),children:[(0,M.jsx)(D,{className:`col-span-3`,children:(0,M.jsx)(O,{placeholder:`Selecciona modelo TTS`})}),(0,M.jsx)(E,{children:le.map(e=>(0,M.jsxs)(ne,{children:[(0,M.jsx)(te,{children:e.group}),e.models.map(e=>(0,M.jsx)(T,{value:e.id,children:e.name},e.id))]},e.provider))})]})]}),Y.tts_provider&&(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`Voz`}),(0,M.jsxs)(k,{value:Y.tts_voice_id||``,onValueChange:e=>X(t=>({...t,tts_voice_id:e})),disabled:ke||De.length===0,children:[(0,M.jsx)(D,{className:`col-span-3`,children:(0,M.jsx)(O,{placeholder:ke?`Cargando...`:`Selecciona una voz`})}),(0,M.jsx)(E,{children:De.map(e=>(0,M.jsx)(T,{value:e.id,children:e.name},e.id))})]})]}),!N.elevenlabs&&!N.openai&&!N.gemini&&!N.qwen&&!N.piper&&(0,M.jsxs)(ie,{variant:`destructive`,className:`bg-yellow-500/10 border-yellow-500/30 text-yellow-200`,children:[(0,M.jsx)(a,{className:`h-4 w-4`}),(0,M.jsxs)(re,{className:`text-yellow-200/80`,children:[`Configura un provider TTS.`,` `,(0,M.jsx)(`button`,{className:`underline`,onClick:()=>{n(),i(`/settings/voz`)},children:`Ir a Configuración de Voz`})]})]})]}),Y.type!==`webchat`&&(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-start gap-4`,children:[(0,M.jsx)(w,{className:`text-right text-xs pt-2`,children:`Narración`}),(0,M.jsxs)(`div`,{className:`col-span-3 space-y-1`,children:[(0,M.jsxs)(k,{value:Y.step_delivery_mode===`off`||Y.step_delivery_mode===`all`?Y.step_delivery_mode:`milestones`,onValueChange:e=>X(t=>({...t,step_delivery_mode:e})),children:[(0,M.jsx)(D,{children:(0,M.jsx)(O,{placeholder:`Modo de narración`})}),(0,M.jsxs)(E,{children:[(0,M.jsx)(T,{value:`off`,children:`Sin narración`}),(0,M.jsx)(T,{value:`milestones`,children:`Solo hitos`}),(0,M.jsx)(T,{value:`all`,children:`Todo el detalle`})]})]}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Cuántos mensajes de avance envía el agente mientras trabaja. "Todo el detalle" narra cada herramienta y puede generar decenas de mensajes por consulta.`})]})]}),(0,M.jsxs)(`div`,{className:`pt-4 mt-2 border-t border-white/5 space-y-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,M.jsx)(w,{className:`text-xs font-bold uppercase tracking-wider text-blue-400`,children:`Visión / Multimodal`}),(0,M.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Procesamiento de imágenes y documentos`})]}),(0,M.jsx)(A,{checked:Y.vision_enabled,onCheckedChange:e=>X(t=>({...t,vision_enabled:e}))})]}),Y.vision_enabled&&(0,M.jsxs)(`div`,{className:`grid grid-cols-4 items-center gap-4 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,M.jsx)(w,{className:`text-right text-xs`,children:`OCR Fallback`}),(0,M.jsxs)(k,{value:Y.ocr_provider||``,onValueChange:e=>X(t=>({...t,ocr_provider:e})),children:[(0,M.jsx)(D,{className:`col-span-3`,children:(0,M.jsx)(O,{placeholder:`Selecciona provider de OCR`})}),(0,M.jsx)(E,{children:xe.map(e=>(0,M.jsx)(T,{value:e.id,children:e.name},e.id))})]}),(0,M.jsx)(`div`,{className:`col-start-2 col-span-3 text-[10px] text-white/30 italic`,children:`Se usa cuando el modelo del agente no soporta visión nativa.`})]})]})]}),st=R===`whatsapp`||R===`webchat`||!Z||R===`telegram`&&z.trim().length>10||R===`discord`&&z.trim().length>10&&V.trim().length>0,ct=()=>e&&I===`settings`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{variant:`outline`,onClick:$,disabled:Te,children:`Cancelar`}),(0,M.jsx)(g,{onClick:rt,disabled:Te,children:Te?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{className:`h-4 w-4 animate-spin mr-2`}),`Guardando...`]}):`Guardar Cambios`})]}):I===`reconnect`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{variant:`outline`,onClick:$,children:`Cancelar`}),(0,M.jsx)(g,{onClick:tt,disabled:J||!st,children:J?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{className:`h-4 w-4 animate-spin mr-2`}),`Conectando...`]}):Z?`Conectar`:`Reconectar`})]}):I===`type`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{variant:`outline`,onClick:$,children:`Cancelar`}),(0,M.jsx)(g,{onClick:()=>L(`credentials`),children:`Siguiente →`})]}):I===`credentials`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(g,{variant:`outline`,onClick:()=>L(`type`),children:`← Atrás`}),(0,M.jsx)(g,{onClick:nt,disabled:J||!it,children:J?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(C,{className:`h-4 w-4 animate-spin mr-2`}),`Conectando...`]}):`Conectar`})]}):I===`connecting`?(0,M.jsx)(g,{variant:`outline`,onClick:$,children:`Cancelar`}):I===`qr`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(g,{variant:`outline`,size:`sm`,onClick:()=>{_e&&et(R,_e)},children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5 mr-2`}),`Actualizar QR`]}),(0,M.jsx)(g,{variant:`outline`,onClick:$,children:`Cancelar`})]}):I===`success`?(0,M.jsx)(g,{onClick:$,children:`Cerrar`}):null,lt=()=>({type:`Nuevo Canal`,credentials:`Conectar ${R.charAt(0).toUpperCase()+R.slice(1)}`,reconnect:Z?`Configurar ${R.charAt(0).toUpperCase()+R.slice(1)}`:`Reconectar ${R.charAt(0).toUpperCase()+R.slice(1)}`,connecting:`Conectando...`,qr:`Escanea el código QR`,success:`¡Canal conectado!`,settings:`Configurar ${e?.type??`canal`}`})[I]??`Nuevo Canal`;if(!t)return null;let ut=ct();return(0,M.jsx)(`div`,{className:`fixed inset-0 z-9999 bg-black/80 flex items-center justify-center p-4`,onClick:$,children:(0,M.jsxs)(`div`,{className:`relative flex max-h-[calc(100dvh-2rem)] w-full max-w-[480px] flex-col hive-card border-white/10`,onClick:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{onClick:$,className:`absolute right-4 top-4 z-20 text-white/40 hover:text-white transition-colors`,children:(0,M.jsx)(S,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`shrink-0 p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,M.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,M.jsxs)(`h2`,{className:`text-xl font-black text-white uppercase tracking-tighter relative z-10 flex items-center gap-2`,children:[(0,M.jsx)(d,{className:`h-4 w-4 text-blue-400`}),lt()]}),(0,M.jsx)(`p`,{className:`text-xs text-white/40 font-medium mt-1 relative z-10`,children:I===`settings`?`Ajusta el comportamiento y las opciones de voz del canal.`:I===`qr`?`Abre WhatsApp en tu teléfono y escanea el código para vincular el dispositivo.`:I===`reconnect`?Z?`Ingresa las credenciales para activar este canal.`:`Reconecta el canal con las credenciales existentes o actualízalas.`:`Conecta un nuevo canal de comunicación a Hive.`})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:e&&I===`settings`?ot():at()}),ut&&(0,M.jsx)(`div`,{className:`shrink-0 border-t border-white/5 p-6 pt-4 flex gap-2`,children:ut})]})})}function J(){let{channels:e,activeChannels:t,fetchChannels:n,isLoading:r,toggleChannel:i,updateChannel:a}=ee(),[o,s]=(0,j.useState)(`all`),[c,d]=(0,j.useState)(null),[p,m]=(0,j.useState)(!1);(0,j.useEffect)(()=>{n()},[]);let h=(0,j.useMemo)(()=>o===`all`?e:o===`active`?e.filter(e=>e.active):o===`inactive`?e.filter(e=>!e.active):e,[e,o]),g=e=>{d(e),m(!0)},_=()=>{d(null),m(!0)};return(0,M.jsxs)(`div`,{className:`hive-page-container animate-fade-in mt-10`,children:[(0,M.jsx)(`div`,{className:`hive-page-header`,children:(0,M.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-6`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,M.jsx)(`div`,{className:`h-10 w-10 rounded-xl bg-blue-500/10 border border-blue-500/20 flex items-center justify-center text-blue-400`,children:(0,M.jsx)(b,{className:`h-6 w-6`})}),(0,M.jsx)(`h1`,{className:`text-3xl font-black text-white uppercase tracking-tighter`,children:`Canales`})]}),(0,M.jsx)(`p`,{className:`hive-subtitle`,children:`Gestiona tus puntos de entrada y salida de comunicación en la red Hive.`})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,M.jsxs)(`button`,{onClick:()=>n(),disabled:r,className:`hive-btn hive-btn--ghost px-6 text-[10px]`,children:[(0,M.jsx)(u,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`SINCRONIZAR`]}),(0,M.jsxs)(`button`,{onClick:_,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),`NUEVO CANAL`]})]})]})}),(0,M.jsxs)(`div`,{className:`hive-card border-blue-500/10 !bg-blue-500/[0.02] mb-8 overflow-hidden relative`,children:[(0,M.jsxs)(`div`,{className:`hive-card-body py-4 px-6 flex items-center justify-between relative z-10`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,M.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-blue-500/10 flex items-center justify-center text-blue-400`,children:(0,M.jsx)(f,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-[10px] font-black tracking-widest text-blue-500/50 uppercase`,children:`Estado Operativo`}),(0,M.jsxs)(`p`,{className:`text-xs text-white/60`,children:[`Actualmente tienes `,(0,M.jsx)(`span`,{className:`text-blue-400 font-black`,children:t.length}),` canales procesando datos.`]})]})]}),(0,M.jsx)(`div`,{className:`text-[10px] text-white/20 font-black tracking-widest uppercase`,children:`HIVE NODE SECURE`})]}),(0,M.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-10`})]}),(0,M.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5 mb-8`,children:[{id:`all`,label:`TODOS (${e.length})`},{id:`active`,label:`ACTIVOS (${e.filter(e=>e.active).length})`},{id:`inactive`,label:`INACTIVOS (${e.filter(e=>!e.active).length})`}].map(e=>(0,M.jsx)(`button`,{onClick:()=>s(e.id),className:`px-8 py-2.5 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${o===e.id?`bg-blue-500 text-white shadow-blue-glow`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e.label},e.id))}),(0,M.jsx)(`div`,{className:`animate-fade-in`,children:h.length>0?(0,M.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:h.map(e=>(0,M.jsx)(N,{channel:e,onEdit:g,onToggle:i},e.id))}):(0,M.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,M.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-20 px-4`,children:[(0,M.jsx)(`div`,{className:`h-20 w-20 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,M.jsx)(b,{className:`h-10 w-10 text-white/10`})}),(0,M.jsxs)(`div`,{className:`text-center`,children:[(0,M.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`No se detectaron canales`}),(0,M.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:`Configura tu primer punto de enlace para empezar a recibir datos en tiempo real.`}),(0,M.jsx)(`button`,{onClick:_,className:`hive-btn hive-btn--primary px-10 text-[10px]`,children:`ESTABLECER CONEXIÓNHORA`})]})]})})}),(0,M.jsx)(q,{channel:c,isOpen:p,onClose:()=>m(!1),onSave:async(e,t)=>{await a(e,t)}})]})}export{J as ChannelsPage};