@johpaz/hive-agents 1.0.4 → 1.1.0
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.
- package/README.md +5 -5
- package/dist/hive.js +88127 -103024
- package/dist/tool-worker.js +13243 -17002
- package/dist/ui/assets/A2UIPage-CS0VPY6a.js +8 -0
- package/dist/ui/assets/AgentCreateForm-DXkjtXaS.js +1 -0
- package/dist/ui/assets/AgentDetailPage-DUIX_cuQ.js +1 -0
- package/dist/ui/assets/AgentNewPage-SNXz2wik.js +1 -0
- package/dist/ui/assets/AgentsPage-CGsdgx5F.js +10 -0
- package/dist/ui/assets/{ApiClientPage-6a6KFwsQ.js → ApiClientPage-MNMjfSDs.js} +2 -2
- package/dist/ui/assets/ChannelsPage-BEwxWUcE.js +8 -0
- package/dist/ui/assets/DashboardPage-D6cRFKWW.js +6 -0
- package/dist/ui/assets/LoginPage-ByYmIa2p.js +1 -0
- package/dist/ui/assets/LogsPage-Bmk9rohg.js +1 -0
- package/dist/ui/assets/MeetingPage-Dm97Mbiw.js +1 -0
- package/dist/ui/assets/ModelSelector-gubC8j_Q.js +1 -0
- package/dist/ui/assets/NotFound-PUg3gEO0.js +1 -0
- package/dist/ui/assets/{Office3DPage-C3SIzd2H.css → Office3DPage-31AMJ-LN.css} +1 -1
- package/dist/ui/assets/Office3DPage-Bfi-S2kG.js +727 -0
- package/dist/ui/assets/ProvidersPage-CSo0MYxd.js +1 -0
- package/dist/ui/assets/RecoverPage-YY2QU-qh.js +1 -0
- package/dist/ui/assets/SettingsPage-DrafhhKw.js +9 -0
- package/dist/ui/assets/SetupPage-LXnd2XbV.js +1 -0
- package/dist/ui/assets/Vignette-BcPWkNhm.js +4302 -0
- package/dist/ui/assets/VoicePage-p-hTMAq7.js +307 -0
- package/dist/ui/assets/VoicePage-uLWdtoD4.css +1 -0
- package/dist/ui/assets/WebChatPage-B61ZDjQ8.js +29 -0
- package/dist/ui/assets/agentCapabilities-PfTEVxG1.js +1 -0
- package/dist/ui/assets/alert-CjiX20jI.js +1 -0
- package/dist/ui/assets/badge-B5AKge1b.js +1 -0
- package/dist/ui/assets/bia-4LFKOyxR.webp +0 -0
- package/dist/ui/assets/bia-BFcUpOu3.glb +0 -0
- package/dist/ui/assets/card-mTJ4oZbL.js +1 -0
- package/dist/ui/assets/conversationsStore-BlwA3yd2.js +1 -0
- package/dist/ui/assets/dialog-B04KpdNt.js +1 -0
- package/dist/ui/assets/dist-js-Dh18rcg9.js +1 -0
- package/dist/ui/assets/{dist-js-CLxM1g2B.js → dist-js-q7C_AB0j.js} +1 -1
- package/dist/ui/assets/index-ByTufXPh.css +2 -0
- package/dist/ui/assets/index-DKJFLL3a.js +116 -0
- package/dist/ui/assets/label-D_fvqJyD.js +1 -0
- package/dist/ui/assets/lock-3IApZyVy.js +1 -0
- package/dist/ui/assets/{square-psq7k_CB.js → mic-CpDU_2as.js} +1 -1
- package/dist/ui/assets/pencil-L3Li7_pz.js +1 -0
- package/dist/ui/assets/rotate-ccw-LoM1AuqK.js +1 -0
- package/dist/ui/assets/scroll-area-CbH8FOo8.js +1 -0
- package/dist/ui/assets/select-v_3QBYrD.js +1 -0
- package/dist/ui/assets/slider-DXS4h1LB.js +1 -0
- package/dist/ui/assets/square-D5zdNkAY.js +1 -0
- package/dist/ui/assets/switch-ndx8VCpm.js +1 -0
- package/dist/ui/assets/tabs-epu-3Tl4.js +1 -0
- package/dist/ui/assets/textarea-BgZJFZTX.js +1 -0
- package/dist/ui/assets/useAudioDevices-B2stUHvr.js +41 -0
- package/dist/ui/assets/useHiveAgentsModelLoad-B4EjHvj4.js +1 -0
- package/dist/ui/assets/useOfficeModel-BaDn7U-X.js +1 -0
- package/dist/ui/assets/{useProviders-CiLSc05q.js → useProviders-B1NS24md.js} +1 -1
- package/dist/ui/assets/vendor-react-kUOwxn0g.js +1 -0
- package/dist/ui/assets/volume-2-EaA0JRvD.js +1 -0
- package/dist/ui/assets/volume-x-CROXNMGT.js +1 -0
- package/dist/ui/index.html +6 -6
- package/package.json +10 -6
- package/packages/cli/src/adapters/config.ts +11 -3
- package/packages/cli/src/commands/causal.ts +1 -1
- package/packages/cli/src/commands/doctor.ts +101 -46
- package/packages/cli/src/commands/onboard.ts +4 -2
- package/packages/core/src/agent/agent-catalog.ts +47 -47
- package/packages/core/src/agent/agent-loop.ts +67 -14
- package/packages/core/src/agent/capability-search.ts +2 -1
- package/packages/core/src/agent/compaction.ts +19 -7
- package/packages/core/src/agent/context-compiler.ts +166 -28
- package/packages/core/src/agent/conversation-store.ts +26 -2
- package/packages/core/src/agent/goal-runner.ts +2 -2
- package/packages/core/src/agent/jev-decisions.ts +148 -0
- package/packages/core/src/agent/jev-planner.ts +293 -0
- package/packages/core/src/agent/llm-client.ts +29 -7
- package/packages/core/src/agent/llm-providers/ollama.ts +17 -4
- package/packages/core/src/agent/llm-providers/openai-compat-base.ts +27 -12
- package/packages/core/src/agent/llm-providers/opencode-go.ts +37 -0
- package/packages/core/src/agent/prompt-builder.ts +1 -1
- package/packages/core/src/agent/realtime-providers/gemini-live.ts +233 -0
- package/packages/core/src/agent/realtime-providers/index.ts +29 -0
- package/packages/core/src/agent/realtime-providers/interface.ts +108 -0
- package/packages/core/src/agent/skill-selector.ts +5 -3
- package/packages/core/src/agent/thread-id.ts +71 -0
- package/packages/core/src/agent/thread-store.ts +230 -0
- package/packages/core/src/agent/tool-selector.ts +2 -0
- package/packages/core/src/agent/tracer.ts +2 -0
- package/packages/core/src/canvas/canvas-manager.ts +145 -27
- package/packages/core/src/canvas/emitter.ts +24 -0
- package/packages/core/src/channels/telegram.ts +19 -1
- package/packages/core/src/channels/webchat.ts +47 -45
- package/packages/core/src/config/loader.ts +9 -6
- package/packages/core/src/events/tool-narration.ts +1 -0
- package/packages/core/src/gateway/channel-notify.ts +24 -5
- package/packages/core/src/gateway/delegation-groups.ts +5 -5
- package/packages/core/src/gateway/delegation-notify.ts +34 -5
- package/packages/core/src/gateway/durable-queue.ts +22 -0
- package/packages/core/src/gateway/failure-notify.ts +8 -2
- package/packages/core/src/gateway/initializer.ts +17 -10
- package/packages/core/src/gateway/job-executors.ts +3 -3
- package/packages/core/src/gateway/realtime/bridge-tools.ts +470 -0
- package/packages/core/src/gateway/realtime/index.ts +305 -0
- package/packages/core/src/gateway/realtime/prompt.ts +182 -0
- package/packages/core/src/gateway/realtime/protocol.ts +60 -0
- package/packages/core/src/gateway/realtime/voice-session.ts +442 -0
- package/packages/core/src/gateway/resolver.ts +31 -4
- package/packages/core/src/gateway/routes/artifacts.ts +13 -0
- package/packages/core/src/gateway/routes/chat.ts +20 -4
- package/packages/core/src/gateway/routes/conversations.ts +121 -0
- package/packages/core/src/gateway/routes/providers.ts +16 -1
- package/packages/core/src/gateway/routes/setup.ts +25 -14
- package/packages/core/src/gateway/routes/system.ts +4 -2
- package/packages/core/src/gateway/routes/tts-local.ts +2 -1
- package/packages/core/src/gateway/server.ts +171 -13
- package/packages/core/src/gateway/slash-commands.ts +48 -10
- package/packages/core/src/gateway/tts/src/server.ts +2 -1
- package/packages/core/src/gateway/webchat-turn.ts +68 -10
- package/packages/core/src/index.ts +2 -0
- package/packages/core/src/scheduler/CronScheduler.ts +20 -8
- package/packages/core/src/scheduler/cron/cron-engine.test.ts +295 -0
- package/packages/core/src/scheduler/cron/expression.ts +165 -0
- package/packages/core/src/scheduler/cron/index.ts +10 -0
- package/packages/core/src/scheduler/cron/job.ts +340 -0
- package/packages/core/src/scheduler/cron/next-run.ts +121 -0
- package/packages/core/src/scheduler/cron/zoned-time.ts +139 -0
- package/packages/core/src/scheduler/integration.ts +16 -5
- package/packages/core/src/scheduler/types.ts +3 -18
- package/packages/core/src/storage/bootstrap.ts +23 -0
- package/packages/core/src/storage/collections.ts +38 -1
- package/packages/core/src/storage/crypto.ts +23 -12
- package/packages/core/src/storage/onboarding.ts +39 -39
- package/packages/core/src/storage/reconcile.ts +6 -1
- package/packages/core/src/storage/seed.ts +82 -8
- package/packages/core/src/storage/usage.ts +53 -1
- package/packages/core/src/tool-runtime/index.ts +19 -1
- package/packages/core/src/tools/a2ui/index.ts +65 -1
- package/packages/core/src/tools/agents/get-available-models.ts +3 -1
- package/packages/core/src/tools/core/index.ts +39 -4
- package/packages/core/src/tools/cron/index.ts +4 -4
- package/packages/core/src/tools/index.ts +2 -1
- package/packages/core/src/tools/office/office-escribir-xlsx.ts +2 -1
- package/packages/core/src/tools/office/office-leer-xlsx.ts +2 -1
- package/packages/core/src/tools/office/xlsx-loader.ts +19 -0
- package/packages/core/src/tools/web/browser-backend.ts +141 -44
- package/packages/core/src/tools/web/browser-click.ts +2 -2
- package/packages/core/src/tools/web/browser-extract.ts +2 -2
- package/packages/core/src/tools/web/browser-navigate.ts +2 -2
- package/packages/core/src/tools/web/browser-screenshot.ts +12 -5
- package/packages/core/src/tools/web/browser-script.ts +2 -2
- package/packages/core/src/tools/web/browser-service.ts +63 -384
- package/packages/core/src/tools/web/browser-session.ts +125 -0
- package/packages/core/src/tools/web/browser-type.ts +2 -2
- package/packages/core/src/tools/web/browser-wait.ts +2 -2
- package/packages/core/src/tools/web/computer-use.ts +553 -0
- package/packages/core/src/tools/web/index.ts +5 -1
- package/packages/core/src/tools/web/webview-backend.ts +559 -21
- package/packages/core/src/utils/port.ts +33 -0
- package/packages/core/src/voice/index.ts +2 -1
- package/packages/mcp/src/config.ts +2 -1
- package/packages/mcp/src/manager.ts +9 -0
- package/packages/mcp/src/transports/index.ts +42 -1
- package/packages/mcp/src/transports/sse.ts +11 -5
- package/packages/skills/src/bundled/a2ui/a2ui_dashboard/SKILL.md +2 -2
- package/packages/skills/src/bundled/a2ui/a2ui_form/SKILL.md +2 -2
- package/packages/skills/src/bundled/a2ui/a2ui_interactive/SKILL.md +4 -4
- package/packages/skills/src/bundled/agents/agent_spawner/SKILL.md +7 -7
- package/packages/skills/src/bundled/agents/memory_manager/SKILL.md +9 -9
- package/packages/skills/src/bundled/agents/research_and_remember/SKILL.md +8 -8
- package/packages/skills/src/bundled/agents/task_orchestrator/SKILL.md +8 -8
- package/packages/skills/src/bundled/artifacts/artifact_reader/SKILL.md +104 -0
- package/packages/skills/src/bundled/cli/cli_pipeline/SKILL.md +6 -6
- package/packages/skills/src/bundled/cli/cli_safe_exec/SKILL.md +5 -5
- package/packages/skills/src/bundled/cron_manager/SKILL.md +29 -19
- package/packages/skills/src/bundled/cron_reminder/SKILL.md +5 -5
- package/packages/skills/src/bundled/filesystem/file_manager/SKILL.md +4 -4
- package/packages/skills/src/bundled/filesystem/file_read_and_summarize/SKILL.md +7 -7
- package/packages/skills/src/bundled/filesystem/file_writer/SKILL.md +10 -10
- package/packages/skills/src/bundled/search_knowledge/capability_discovery/SKILL.md +8 -8
- package/packages/skills/src/bundled/web/browser_automate/SKILL.md +21 -12
- package/packages/skills/src/bundled/web/browser_scrape/SKILL.md +28 -13
- package/packages/skills/src/bundled/web/web_monitor/SKILL.md +6 -6
- package/packages/skills/src/bundled/web/web_research/SKILL.md +5 -5
- package/packages/skills/src/bundled-data.generated.ts +837 -783
- package/dist/ui/assets/A2UIPage-7Ry5rHh9.js +0 -8
- package/dist/ui/assets/AgentCreateForm-Dh5W0q_t.js +0 -1
- package/dist/ui/assets/AgentDetailPage-CIoPjtsS.js +0 -1
- package/dist/ui/assets/AgentNewPage-BNsZcJQf.js +0 -1
- package/dist/ui/assets/AgentsPage-YZrDmgNI.js +0 -10
- package/dist/ui/assets/ChannelsPage-Dice4dkJ.js +0 -8
- package/dist/ui/assets/DashboardPage-B9r0sc0F.js +0 -6
- package/dist/ui/assets/LoginPage-BkAAX_tu.js +0 -1
- package/dist/ui/assets/LogsPage-8-H1OJs3.js +0 -1
- package/dist/ui/assets/MeetingPage-14JoQo71.js +0 -1
- package/dist/ui/assets/ModelSelector-CrgJQ7DG.js +0 -1
- package/dist/ui/assets/NotFound-B06kVW7N.js +0 -1
- package/dist/ui/assets/Office3DPage-BMUZWkFS.js +0 -4614
- package/dist/ui/assets/ProvidersPage-BiL3QxCs.js +0 -1
- package/dist/ui/assets/RecoverPage-D1o8yxNz.js +0 -1
- package/dist/ui/assets/SettingsPage-GP8UwQIL.js +0 -9
- package/dist/ui/assets/SetupPage-B_gU1YQU.js +0 -1
- package/dist/ui/assets/WebChatPage-Yahufnth.js +0 -29
- package/dist/ui/assets/agentCapabilities-Dg72UAFj.js +0 -1
- package/dist/ui/assets/alert-DChoEVJw.js +0 -1
- package/dist/ui/assets/badge-uRjRSt86.js +0 -1
- package/dist/ui/assets/card-DwQizslL.js +0 -1
- package/dist/ui/assets/dialog--mljnfAi.js +0 -1
- package/dist/ui/assets/dist-js-B0s_TDau.js +0 -1
- package/dist/ui/assets/index-BHHUQZJd.js +0 -116
- package/dist/ui/assets/index-CEFhf4dF.css +0 -2
- package/dist/ui/assets/label-BceoUB2w.js +0 -1
- package/dist/ui/assets/pencil-CUbpCfeG.js +0 -1
- package/dist/ui/assets/scroll-area-DMEaZZUp.js +0 -1
- package/dist/ui/assets/select-BBEBtcLm.js +0 -1
- package/dist/ui/assets/slider-DcmBdvYD.js +0 -1
- package/dist/ui/assets/switch-CgiDezVR.js +0 -1
- package/dist/ui/assets/tabs-gUXIjjZv.js +0 -1
- package/dist/ui/assets/textarea-DedxQYBx.js +0 -1
- package/dist/ui/assets/useHiveAgentsModelLoad-C7bhWPDG.js +0 -1
- package/dist/ui/assets/useOfficeModel-BAFasrg8.js +0 -1
- package/dist/ui/assets/vendor-react-DYyYpuMy.js +0 -1
- package/dist/ui/assets/volume-x-BDlMCDYT.js +0 -1
- /package/dist/ui/assets/{core-Sjunb8Z1.js → core-B_5cyOSV.js} +0 -0
- /package/dist/ui/assets/{download-D0aDV8Y_.js → download-BQXrpH0m.js} +0 -0
- /package/dist/ui/assets/{ellipsis-vertical-BOW_iEOO.js → ellipsis-vertical-D7uFJLGh.js} +0 -0
- /package/dist/ui/assets/{external-link-5cujQzfV.js → external-link-6oTH9pUM.js} +0 -0
- /package/dist/ui/assets/{eye-sRPY5qOa.js → eye-CxvxtQT5.js} +0 -0
- /package/dist/ui/assets/{file-text-DNSyNLUh.js → file-text-D5ZJEx3E.js} +0 -0
- /package/dist/ui/assets/{gateway-url-BZj_2-jf.js → gateway-url-BALS_wVh.js} +0 -0
- /package/dist/ui/assets/{gauge-C__zxC3_.js → gauge-CEu7PhTW.js} +0 -0
- /package/dist/ui/assets/{history-BHQWfE-7.js → history-DLK5rTlP.js} +0 -0
- /package/dist/ui/assets/{info-CG1VohyH.js → info-8ReWzubE.js} +0 -0
- /package/dist/ui/assets/{key-BC28VCjO.js → key-DPkOY-J0.js} +0 -0
- /package/dist/ui/assets/{lock-open-Bhp0UJlL.js → lock-open-v0EphssG.js} +0 -0
- /package/dist/ui/assets/{mail-Biwn8WrV.js → mail-vwCEHyhQ.js} +0 -0
- /package/dist/ui/assets/{pause-C2l5G2Py.js → pause-Cm9LzIZK.js} +0 -0
- /package/dist/ui/assets/{play-CMAscR3a.js → play-zqogwA2l.js} +0 -0
- /package/dist/ui/assets/{plus-DzvRxH4U.js → plus-Bm08ABhc.js} +0 -0
- /package/dist/ui/assets/{radio-DfGzov4y.js → radio-Cii1BjMt.js} +0 -0
- /package/dist/ui/assets/{refresh-cw-DZXu5FrG.js → refresh-cw-DXv3XgEt.js} +0 -0
- /package/dist/ui/assets/{search-ykSx-zZU.js → search-BMwCI-pX.js} +0 -0
- /package/dist/ui/assets/{send-DAhlz2i9.js → send-D6fgWV7m.js} +0 -0
- /package/dist/ui/assets/{settings-DL0REysC.js → settings-qV3kVkeG.js} +0 -0
- /package/dist/ui/assets/{shield-BPZZhjCT.js → shield-CIarwBvx.js} +0 -0
- /package/dist/ui/assets/{sparkles-BViXTAh7.js → sparkles-DVvY6jDT.js} +0 -0
- /package/dist/ui/assets/{terminal-CzxPKG-h.js → terminal-BEcTK780.js} +0 -0
- /package/dist/ui/assets/{trash-2-SgYCWiVk.js → trash-2-D6oziYAK.js} +0 -0
- /package/dist/ui/assets/{utils-SGUggNJc.js → utils-DEmd_M8c.js} +0 -0
- /package/dist/ui/assets/{vendor-router-Dsg8fxNQ.js → vendor-router-DP84b3LQ.js} +0 -0
- /package/dist/ui/assets/{wifi-CyPHteEm.js → wifi-BUJuOcgP.js} +0 -0
- /package/dist/ui/assets/{zap-OVVrfEHr.js → zap-DSoX9NDk.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./createLucideIcon-BRaPSYgN.js";import{t as i}from"./check-C8pw-7Fx.js";import{t as a}from"./chevron-down-8GjmTjLR.js";import{t as o}from"./chevron-right-BupZqrxu.js";import{t as s}from"./circle-check-BKNT2_q6.js";import{t as c}from"./useProviders-CiLSc05q.js";import{t as l}from"./download-D0aDV8Y_.js";import{n as u,t as d}from"./eye-sRPY5qOa.js";import{n as f,t as p}from"./key-BC28VCjO.js";import{t as m}from"./lock-open-Bhp0UJlL.js";import{n as h,t as g}from"./pencil-CUbpCfeG.js";import{n as _,t as v}from"./square-psq7k_CB.js";import{t as y}from"./play-CMAscR3a.js";import{t as b}from"./plus-DzvRxH4U.js";import{t as x}from"./refresh-cw-DZXu5FrG.js";import{t as S}from"./search-ykSx-zZU.js";import{t as C}from"./settings-DL0REysC.js";import{t as w}from"./terminal-CzxPKG-h.js";import{t as T}from"./trash-2-SgYCWiVk.js";import{n as E,t as D}from"./wifi-CyPHteEm.js";import{t as O}from"./utils-SGUggNJc.js";import{B as k,C as A,T as j,Y as M,Z as N,_ as P,et as F,h as I,m as L,v as R,x as ee,z}from"./index-BHHUQZJd.js";import{t as B}from"./badge-uRjRSt86.js";import{t as V}from"./scroll-area-DMEaZZUp.js";import{i as te,n as ne,r as re,t as ie}from"./tabs-gUXIjjZv.js";import{c as ae,i as H,o as oe,r as U,s as W,t as G}from"./dialog--mljnfAi.js";import{t as K}from"./label-BceoUB2w.js";import{i as se,n as ce,o as le,s as ue,t as de}from"./select-BBEBtcLm.js";import{t as fe}from"./switch-CgiDezVR.js";import{a as pe,i as me,n as he,r as ge,t as _e}from"./card-DwQizslL.js";var ve=r(`BookOpen`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),ye=r(`Package`,[[`path`,{d:`M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z`,key:`1a0edw`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}],[`path`,{d:`m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7`,key:`yx3hmr`}],[`path`,{d:`m7.5 4.27 9 5.15`,key:`1c824w`}]]),q=e(t(),1);function be(e=720){let[t,n]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let t=!1;return A(`/api/usage-stats?hours=${e}`).then(e=>{t||n(e.byProvider??{})}).catch(()=>{t||n(null)}),()=>{t=!0}},[e]),t}function xe(e){return e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Se(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${Math.round(e/1e3)}K`:String(e)}var J=n();function Ce({provider:e,onSave:t,onCancel:n}){let[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(``),[c,l]=(0,q.useState)(e?.baseUrl||e?.base_url||``),[f,p]=(0,q.useState)(e?.config?.headers?JSON.stringify(e.config.headers,null,2):``),[m,h]=(0,q.useState)(e?.num_ctx?String(e.num_ctx):``),g=c||e?.baseUrl||e?.base_url||``,_=e?.id===`ollama`||g.includes(`localhost`)||g.includes(`127.0.0.1`),v=!!e?.has_api_key,y=!!e?.has_headers;return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`API Key`}),v&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,J.jsx)(s,{className:`h-3 w-3`}),`Configurada`]})]}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(z,{type:r?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:v?`•••••••••••••••• (dejar vacío para conservar)`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,J.jsx)(k,{variant:`ghost`,size:`icon`,className:`absolute right-0 top-0 h-8 w-8 text-white/40 hover:text-white`,onClick:()=>i(!r),children:r?(0,J.jsx)(u,{className:`h-3 w-3`}):(0,J.jsx)(d,{className:`h-3 w-3`})})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Base URL (opcional)`}),(0,J.jsx)(z,{value:c,onChange:e=>l(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),_&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,J.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,J.jsx)(z,{type:`number`,value:m,onChange:e=>h(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,J.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Custom Headers (JSON)`}),y&&(0,J.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,J.jsx)(s,{className:`h-3 w-3`}),`Configurados`]})]}),(0,J.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value),placeholder:y?`{ ... } (dejar vacío para conservar)`:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,J.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,J.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:n,children:`Cancelar`}),(0,J.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{let e;if(f.trim())try{e=JSON.parse(f.trim())}catch{j.fire(`Error`,`JSON de Headers inválido`,`error`);return}t&&t({apiKey:a,baseUrl:c||void 0,headers:e,numCtx:m.trim()?Number(m.trim()):null})},children:`Guardar`})]}),(0,J.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}function we(e){let t=e.input_per_1m??e.inputPer1M,n=e.output_per_1m??e.outputPer1M;return typeof t!=`number`||typeof n!=`number`?null:{input:t,output:n}}function Te(e){return e.input===0&&e.output===0}function Ee(e){return e===0?`$0`:e<.01?`$${e.toFixed(3)}`:e<1?`$${e.toFixed(2)}`:`$${e%1==0?e:e.toFixed(2)}`}function De(e){let t=e.map(we).filter(e=>e!==null);if(t.length===0)return null;if(t.every(Te))return{label:`Gratis`,allFree:!0};let n=t.filter(e=>!Te(e));return{label:`desde ${Ee(Math.min(...n.map(e=>e.input)))}/1M`,allFree:!1}}function Oe({model:e,showContext:t=!1}){let n=we(e),r=e.contextWindow??e.context_window,i=t&&r?`${r>=1e6?`${(r/1e6).toFixed(r%1e6==0?0:1)}M`:`${Math.round(r/1e3)}K`} ctx`:null;return(0,J.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] leading-tight font-mono`,children:[n===null?(0,J.jsx)(`span`,{className:`text-white/25`,title:`Este modelo no tiene tarifa en el catálogo: su consumo se contabiliza como $0`,children:`Sin tarifa`}):Te(n)?(0,J.jsx)(`span`,{className:`text-emerald-400/70`,children:`Gratis`}):(0,J.jsxs)(`span`,{className:`text-white/40`,title:`USD por millón de tokens (entrada / salida)`,children:[(0,J.jsx)(`span`,{className:`text-white/55`,children:Ee(n.input)}),(0,J.jsx)(`span`,{className:`text-white/25`,children:` / `}),(0,J.jsx)(`span`,{className:`text-white/55`,children:Ee(n.output)}),(0,J.jsx)(`span`,{className:`text-white/25`,children:` /1M`})]}),i&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-white/15`,children:`·`}),(0,J.jsx)(`span`,{className:`text-white/30`,children:i})]})]})}var ke=[{value:`llm`,label:`LLM (texto)`},{value:`vision`,label:`Visión`},{value:`stt`,label:`STT (voz → texto)`},{value:`tts`,label:`TTS (texto → voz)`},{value:`embedding`,label:`Embeddings`}],Ae=[`chat`,`code`,`vision`,`reasoning`,`function_calling`,`json_mode`,`streaming`,`transcription`,`tts`,`speech`];function je(e){if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t.map(String):[]}catch{return[]}}function Me(e){let t=e.trim();if(t===``)return null;let n=Number(t);return Number.isFinite(n)&&n>=0?n:null}function Ne({open:e,onOpenChange:t,providerId:n,model:r,onSubmit:i,onOpenGuide:a,isFreeProvider:o}){let s=!!r,[c,l]=(0,q.useState)(`manual`),[u,d]=(0,q.useState)(null),[f,p]=(0,q.useState)(null),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(``),[v,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(``),[S,C]=(0,q.useState)(`llm`),[w,T]=(0,q.useState)(``),[E,D]=(0,q.useState)(``),[O,k]=(0,q.useState)(``),[j,M]=(0,q.useState)([]),[N,P]=(0,q.useState)(!1),[F,I]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(!e)return;I(null),y(r?r.wire_id??r.id:``),x(r?.name??``),C(r?.model_type??`llm`);let t=r?.contextWindow??r?.context_window;T(t?String(t):``);let n=r?.input_per_1m??r?.inputPer1M,i=r?.output_per_1m??r?.outputPer1M,a=!r&&o?`0`:``;D(typeof n==`number`?String(n):a),k(typeof i==`number`?String(i):a),M(je(r?.capabilities)),l(r?`manual`:`discover`),_(``),d(null),p(null)},[e,r,n,o]),(0,q.useEffect)(()=>{!e||c!==`discover`||u!==null||m||(h(!0),p(null),A(`/api/providers/${encodeURIComponent(n)}/available-models`).then(e=>d(e.models??[])).catch(e=>p(e.message||`No se pudo consultar el provider.`)).finally(()=>h(!1)))},[e,c,n,u,m]);let L=(0,q.useMemo)(()=>{if(!u)return[];let e=g.trim().toLowerCase();return e?u.filter(t=>t.wire_id.toLowerCase().includes(e)):u},[u,g]),R=e=>{y(e.wire_id),x(e.wire_id.split(`/`).pop()||e.wire_id),l(`manual`)},ee=e=>{M(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},z=async()=>{let e=v.trim();if(!e){I(`El ID del modelo en la API es obligatorio.`);return}let n=Number(w.trim());if(w.trim()&&(!Number.isFinite(n)||n<=0)){I(`El contexto debe ser un número mayor que cero.`);return}P(!0),I(null);try{await i({id:e,name:b.trim()||e,model_type:S,context_window:w.trim()?n:void 0,input_per_1m:Me(E),output_per_1m:Me(O),capabilities:j.length?j:null}),t(!1)}catch(e){I(e.message||`No se pudo guardar el modelo.`)}finally{P(!1)}},B=`w-full bg-white/5 border border-white/10 rounded-md px-2.5 h-8 text-xs text-white/80 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`,V=`block text-[10px] font-black uppercase tracking-widest text-white/40 mb-1`;return(0,J.jsx)(G,{open:e,onOpenChange:t,children:(0,J.jsxs)(U,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-lg bg-[#09090b]`,children:[(0,J.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,J.jsx)(W,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:s?`Editar modelo`:`Nuevo modelo`}),(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(H,{className:`text-xs text-white/40 font-medium mt-0.5`,children:[n,` — los precios alimentan el costo del dashboard.`]}),a&&(0,J.jsx)(`button`,{type:`button`,onClick:a,className:`shrink-0 h-6 px-2 rounded-md bg-white/5 border border-white/10 text-white/50 text-[10px] font-black uppercase tracking-widest hover:text-white hover:bg-white/10 transition-colors`,children:`? Guía`})]})]}),!s&&(0,J.jsx)(`div`,{className:`flex gap-1 px-5 pt-3`,children:[[`discover`,`Descubrir`],[`manual`,`Manual`]].map(([e,t])=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>l(e),className:`h-7 px-3 rounded-md text-[10px] font-black uppercase tracking-widest border transition-colors ${c===e?`bg-blue-500/15 border-blue-500/30 text-blue-300`:`bg-transparent border-white/10 text-white/35 hover:text-white/70`}`,children:t},e))}),!s&&c===`discover`&&(0,J.jsxs)(`div`,{className:`p-5 space-y-3 max-h-[65vh] overflow-y-auto hive-scroll`,children:[(0,J.jsxs)(`p`,{className:`text-[11px] text-white/40 leading-relaxed`,children:[`Modelos que `,(0,J.jsx)(`span`,{className:`text-white/70`,children:n}),` sirve en este momento. Elegir de acá evita guardar un ID que no existe o que fue retirado — eso no falla al guardar, falla después en plena conversación.`]}),(0,J.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:`Buscar modelo…`,className:`${B} font-mono`}),m&&(0,J.jsx)(`p`,{className:`text-[11px] text-white/30 py-4 text-center`,children:`Consultando al provider…`}),f&&(0,J.jsxs)(`div`,{className:`text-[11px] text-amber-400/80 bg-amber-400/10 border border-amber-400/20 rounded-md px-2.5 py-2`,children:[f,(0,J.jsx)(`p`,{className:`text-white/40 mt-1`,children:`Este provider puede no publicar su lista de modelos. Usá la pestaña Manual.`})]}),u&&!m&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`text-[10px] text-white/30`,children:[L.length,` de `,u.length,` modelos`]}),(0,J.jsxs)(`div`,{className:`flex flex-col gap-0.5 max-h-72 overflow-y-auto hive-scroll pr-1`,children:[L.map(e=>(0,J.jsxs)(`button`,{type:`button`,disabled:e.already_added,onClick:()=>R(e),className:`flex items-center justify-between gap-2 text-left rounded-md px-2.5 py-1.5 border transition-colors ${e.already_added?`border-transparent opacity-35 cursor-not-allowed`:`border-transparent hover:bg-white/5 hover:border-white/10`}`,children:[(0,J.jsx)(`span`,{className:`font-mono text-[11px] text-white/70 truncate`,children:e.wire_id}),e.already_added&&(0,J.jsx)(`span`,{className:`shrink-0 text-[9px] font-black uppercase tracking-widest text-emerald-400/70`,children:`ya está`})]},e.id)),L.length===0&&(0,J.jsx)(`p`,{className:`text-[11px] text-white/25 py-3 text-center`,children:`Ningún modelo coincide.`})]})]})]}),(s||c===`manual`)&&(0,J.jsxs)(`div`,{className:`p-5 space-y-3.5 max-h-[65vh] overflow-y-auto hive-scroll`,children:[(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:V,children:`ID en la API *`}),(0,J.jsx)(`input`,{className:`${B} font-mono`,value:v,onChange:e=>y(e.target.value),placeholder:`claude-sonnet-5`}),(0,J.jsx)(`p`,{className:`text-[10px] text-white/25 mt-1`,children:`Tal cual lo espera el provider.`})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:V,children:`Nombre visible`}),(0,J.jsx)(`input`,{className:B,value:b,onChange:e=>x(e.target.value),placeholder:`Claude Sonnet 5`})]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:V,children:`Tipo`}),(0,J.jsx)(`select`,{className:B,value:S,onChange:e=>C(e.target.value),children:ke.map(e=>(0,J.jsx)(`option`,{value:e.value,className:`bg-[#09090b]`,children:e.label},e.value))})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:V,children:`Contexto (tokens)`}),(0,J.jsx)(`input`,{type:`number`,min:0,className:`${B} font-mono`,value:w,onChange:e=>T(e.target.value),placeholder:`200000`})]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-baseline justify-between mb-1`,children:[(0,J.jsx)(`span`,{className:`${V} mb-0`,children:`Costo — USD por millón de tokens`}),(0,J.jsx)(`span`,{className:`text-[10px] text-white/25`,children:`Vacío = sin tarifa`})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,J.jsx)(`div`,{children:(0,J.jsx)(`input`,{type:`number`,min:0,step:`0.001`,className:`${B} font-mono`,value:E,onChange:e=>D(e.target.value),placeholder:`Entrada — 3`})}),(0,J.jsx)(`div`,{children:(0,J.jsx)(`input`,{type:`number`,min:0,step:`0.001`,className:`${B} font-mono`,value:O,onChange:e=>k(e.target.value),placeholder:`Salida — 15`})})]}),(0,J.jsxs)(`p`,{className:`text-[10px] text-white/25 mt-1`,children:[`Poné `,(0,J.jsx)(`span`,{className:`font-mono text-white/40`,children:`0`}),` si el endpoint es gratuito: dejarlo vacío marca el modelo como “sin tarifa” y su consumo se contabiliza como $0 sin avisar en el dashboard.`]})]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`label`,{className:V,children:`Capacidades`}),(0,J.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Ae.map(e=>(0,J.jsx)(`button`,{type:`button`,onClick:()=>ee(e),className:`text-[10px] font-mono rounded px-2 py-1 leading-none border transition-colors ${j.includes(e)?`bg-blue-500/15 border-blue-500/30 text-blue-300`:`bg-white/5 border-white/10 text-white/30 hover:text-white/60`}`,children:e},e))})]}),F&&(0,J.jsx)(`p`,{className:`text-[11px] text-red-400 bg-red-500/10 border border-red-500/20 rounded-md px-2.5 py-1.5`,children:F})]}),(s||c===`manual`)&&(0,J.jsxs)(`div`,{className:`px-5 py-3 border-t border-white/5 flex items-center justify-end gap-2`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`hive-btn hive-btn--ghost h-8 px-3 text-[10px] font-black uppercase tracking-widest text-white/40`,children:`Cancelar`}),(0,J.jsx)(`button`,{type:`button`,onClick:z,disabled:N||!v.trim(),className:`h-8 px-3.5 rounded-md bg-blue-500/15 border border-blue-500/30 text-blue-300 text-[10px] font-black uppercase tracking-widest hover:bg-blue-500/25 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:N?`Guardando…`:s?`Guardar`:`Agregar`})]})]})})}var Pe=C,Fe=a,Ie=o,Le=c,Re=b,ze=f,Be=F,Ve=x,He=g,Ue=T;function We({provider:e,updateProvider:t,onManageModels:n,usage:r,onOpenGuide:i}){let[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),{models:h,toggleModel:g,createModel:_,syncModels:v,deleteModel:y,updateModel:b}=P(),{toggleProvider:x}=R(),S=(0,q.useMemo)(()=>{let t=h.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[h,e.id,e.models]),C=S.filter(e=>e.enabled||e.active),w=(0,q.useMemo)(()=>De(S),[S]),T=n=>{t(e.id,n),o(!1)},E=async t=>{try{await x(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},D=async(e,t)=>{try{await g(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},O=async()=>{u(!0);try{await v(e.id),c(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{u(!1)}},k=async t=>{p?.model?await b(p.model.id,t):await _(e.id,t)},A=async e=>{f(e.id);try{await y(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{f(null)}},j=!!e.active,M=e.base_url||e.baseUrl,N=e.id===`ollama`||M?.includes(`localhost`)||M?.includes(`127.0.0.1`);return(0,J.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${j?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,J.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,J.jsx)(`div`,{className:`shrink-0 h-10 w-10 sm:h-11 sm:w-11 rounded-xl flex items-center justify-center border transition-all duration-500 ${j?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_16px_rgba(59,130,246,0.15)]`:`bg-white/5 border-white/10 text-white/30`}`,children:(0,J.jsx)(Le,{className:`h-5 w-5`})}),(0,J.jsxs)(`div`,{className:`min-w-0`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,J.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),j&&(0,J.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,J.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,J.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${j?`text-blue-400`:`text-white/30`}`,children:j?`ON`:`OFF`}),(0,J.jsx)(fe,{checked:j,onCheckedChange:E,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,J.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(ze,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:N?`text-amber-400`:`text-white/20`}`}),(0,J.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,J.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,J.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):N?(0,J.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,J.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),M&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(Be,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,J.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:M})]}),N&&(0,J.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,J.jsx)(Le,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,J.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,J.jsx)(`span`,{className:e.num_ctx?`text-amber-400/70`:`text-white/25`,children:e.num_ctx?`${e.num_ctx.toLocaleString()} tokens`:`32 768 (default)`})]})]})]}),(0,J.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`flex items-center gap-2 flex-1 text-left text-[10px] font-black uppercase tracking-widest text-white/40 hover:text-white transition-colors`,onClick:()=>c(!s),children:[s?(0,J.jsx)(Fe,{className:`h-3 w-3`}):(0,J.jsx)(Ie,{className:`h-3 w-3`}),`MODELOS`,(0,J.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[C.length,`/`,S.length]})]}),w&&(0,J.jsx)(`span`,{className:`text-[9px] font-mono font-semibold rounded px-1.5 py-0.5 leading-none whitespace-nowrap border ${w.allFree?`text-emerald-400/80 bg-emerald-400/10 border-emerald-400/20`:`text-white/45 bg-white/5 border-white/10`}`,title:w.allFree?`Todos los modelos de este provider son gratuitos`:`Precio del modelo más barato, en USD por millón de tokens de entrada`,children:w.label}),N&&(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`text-[9px] font-semibold text-amber-400/70 bg-amber-400/10 border border-amber-400/20 rounded px-1.5 py-0.5 leading-none whitespace-nowrap`,children:`Actualiza modelos locales`}),(0,J.jsx)(`button`,{type:`button`,onClick:O,disabled:l,title:`Sincronizar modelos instalados en Ollama`,className:`h-6 w-6 flex items-center justify-center rounded-md text-white/30 hover:text-amber-400 hover:bg-amber-400/10 disabled:opacity-40 transition-colors`,children:(0,J.jsx)(Ve,{className:`h-3 w-3 ${l?`animate-spin`:``}`})})]})]}),!s&&S.length>0&&(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[S.slice(0,3).map(e=>(0,J.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),S.length>3&&(0,J.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,S.length-3]})]}),s&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[S.length===0&&(0,J.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),S.map(e=>{let t=e.enabled||!!e.active;return(0,J.jsx)(`div`,{className:`rounded-lg transition-colors ${t?`bg-white/5`:`bg-transparent opacity-40`}`,children:(0,J.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,J.jsxs)(`div`,{className:`min-w-0 flex-1 mr-2`,children:[(0,J.jsx)(`span`,{className:`block text-[11px] font-medium text-white truncate`,children:e.name}),(0,J.jsx)(Oe,{model:e,showContext:!0})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,J.jsx)(`button`,{type:`button`,onClick:()=>m({model:e}),title:`Editar modelo — ID, contexto, costo y capacidades`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-blue-400 hover:bg-blue-400/10 transition-colors`,children:(0,J.jsx)(He,{className:`h-3 w-3`})}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>A(e),disabled:d===e.id,title:`Eliminar modelo`,className:`h-5 w-5 flex items-center justify-center rounded text-white/25 hover:text-red-400 hover:bg-red-400/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:(0,J.jsx)(Ue,{className:`h-3 w-3`})}),(0,J.jsx)(fe,{checked:t,onCheckedChange:t=>D(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,J.jsxs)(`button`,{type:`button`,onClick:()=>m({}),className:`w-full mt-1.5 h-7 flex items-center justify-center gap-1 rounded-md bg-blue-500/10 border border-blue-500/20 text-blue-400 text-[10px] font-black uppercase tracking-wider hover:bg-blue-500/20 transition-colors`,children:[(0,J.jsx)(Re,{className:`h-3 w-3`}),`Agregar modelo`]})]})]}),(0,J.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,J.jsxs)(`div`,{className:`hive-stat shrink-0`,title:`Gasto acumulado en los últimos 30 días`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Gasto 30d`}),(0,J.jsx)(`span`,{className:`hive-stat__value ${r&&r.costUsd>0?`text-amber-400`:`text-white/30`}`,children:r?xe(r.costUsd):`—`})]}),(0,J.jsxs)(`div`,{className:`hive-stat shrink-0`,title:`Tokens consumidos en los últimos 30 días`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Tokens`}),(0,J.jsx)(`span`,{className:`hive-stat__value ${r&&r.tokens>0?`text-white/60`:`text-white/30`}`,children:r?Se(r.tokens):`—`})]}),(0,J.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,J.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,J.jsx)(`span`,{className:`hive-stat__value ${j?`text-emerald-400`:`text-white/30`}`,children:j?`Activo`:`Inactivo`})]})]}),(0,J.jsxs)(G,{open:a,onOpenChange:o,children:[(0,J.jsx)(ae,{asChild:!0,children:(0,J.jsxs)(`button`,{className:`hive-btn hive-btn--ghost h-8 px-2.5 text-[10px] font-black uppercase tracking-widest text-blue-400 shrink-0 flex items-center gap-1.5`,children:[(0,J.jsx)(Pe,{className:`h-3 w-3`}),(0,J.jsx)(`span`,{children:`CONFIG`})]})}),(0,J.jsxs)(U,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,J.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,J.jsx)(W,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,J.jsx)(H,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,J.jsx)(`div`,{className:`p-5`,children:(0,J.jsx)(Ce,{provider:e,onSave:T,onCancel:()=>o(!1)})})]})]})]}),(0,J.jsx)(Ne,{open:p!==null,onOpenChange:e=>{e||m(null)},providerId:e.id,model:p?.model,onSubmit:k,onOpenGuide:i,isFreeProvider:w?.allFree??!1}),(0,J.jsx)(`div`,{className:`hive-strip--bottom ${j?``:`opacity-20`}`})]})}function Ge({onOpenGuide:e}){let{providers:t,updateProvider:n}=R(),r=be(),i=t.filter(e=>(e.category??`llm`)===`llm`),a=i.filter(e=>e.active).length;return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),(0,J.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[a,` activos / `,i.length,` total`]})]}),(0,J.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`,children:[i.map(t=>(0,J.jsx)(We,{provider:t,updateProvider:n,usage:r?.[t.id],onOpenGuide:e},t.id)),i.length===0&&(0,J.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`})]})]})}function Ke({onSave:e,onCancel:t}){let[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(``),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(``),[g,_]=(0,q.useState)(``),v=o.toLowerCase()===`ollama`||f.includes(`localhost`)||f.includes(`127.0.0.1`);return(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Nombre del Provider`}),(0,J.jsx)(z,{value:i,onChange:e=>a(e.target.value),placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),(0,J.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Tipo de Provider`}),(0,J.jsx)(z,{value:o,onChange:e=>s(e.target.value),placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),(0,J.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,J.jsx)(K,{className:`hive-label`,children:`API Key`})}),(0,J.jsxs)(`div`,{className:`relative`,children:[(0,J.jsx)(z,{type:n?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:v?`Opcional para providers locales`:`sk-...`,className:`hive-input !h-8 text-xs pr-8`}),(0,J.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`absolute right-0 top-0 h-8 w-8 flex items-center justify-center text-white/40 hover:text-white`,children:n?(0,J.jsx)(u,{className:`h-3 w-3`}):(0,J.jsx)(d,{className:`h-3 w-3`})})]})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Base URL (opcional)`}),(0,J.jsx)(z,{value:f,onChange:e=>p(e.target.value),placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),v&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(K,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,J.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,J.jsx)(z,{type:`number`,value:g,onChange:e=>_(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,J.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),(0,J.jsxs)(`div`,{className:`space-y-1`,children:[(0,J.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,J.jsx)(K,{className:`hive-label`,children:`Custom Headers (JSON)`})}),(0,J.jsx)(`textarea`,{value:m,onChange:e=>h(e.target.value),placeholder:`{ "x-custom-header": "value" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-white/70 focus:outline-none focus:border-blue-500/50 transition-all font-mono`})]}),(0,J.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,J.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:t,children:`Cancelar`}),(0,J.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{if(!i.trim()){j.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){j.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){j.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(m.trim())try{t=JSON.parse(m.trim())}catch{j.fire(`Error`,`JSON de Headers inválido`,`error`);return}e({id:i.trim().toLowerCase().replace(/\s+/g,`-`),name:i.trim(),type:o,apiKey:c.trim()||``,baseUrl:f.trim()||void 0,headers:t,numCtx:g.trim()?Number(g.trim()):null})},children:`Crear Provider`})]}),(0,J.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var qe={chat:`Chat`,vision:`Vision`,json_mode:`JSON`,function_calling:`Functions`,streaming:`Stream`,embeddings:`Embed`,image_generation:`Imagen`,code:`Codigo`,reasoning:`Razonamiento`,transcription:`STT`,translation:`Traduccion`,tts:`TTS`,speech:`Voz`,high_quality:`HQ`,ocr:`OCR`};function Je({capabilities:e}){let t=[];if(typeof e==`string`)try{t=JSON.parse(e)}catch{t=[]}else Array.isArray(e)&&(t=e);return t.length===0?null:(0,J.jsx)(J.Fragment,{children:t.map(e=>(0,J.jsx)(B,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:qe[e]??e},e))})}function Ye({model:e}){let{toggleModel:t}=P();return(0,J.jsx)(_e,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,J.jsxs)(he,{className:`flex items-center gap-4 p-3`,children:[(0,J.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsx)(`p`,{className:`text-sm font-semibold`,children:e.name}),(0,J.jsx)(B,{variant:`secondary`,className:`text-[10px]`,children:e.providerId||e.provider_id})]}),(0,J.jsx)(Oe,{model:e,showContext:!0}),(0,J.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,J.jsx)(Je,{capabilities:e.capabilities})})]}),(0,J.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,J.jsx)(fe,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,J.jsx)(B,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function Xe(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ze(){let{availableModels:e,activeProviders:t}=R(),n=L(e=>e.fetchAll),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{n(!0)},[n]);let s=(0,q.useMemo)(()=>e.filter(e=>{let t=Xe(e.capabilities),n=t.includes(`vision`)||t.includes(`image_generation`)||t.includes(`ocr`),i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),o=a===`all`||e.providerId===a||e.provider_id===a;return n&&i&&o}),[e,r,a]);return(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),(0,J.jsx)(B,{variant:`secondary`,children:s.length})]}),(0,J.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Estos modelos pueden procesar imagenes y documentos visuales. Si el agente usa uno de estos modelos, las imagenes se envian directamente. Si no, se usa OCR para extraer el texto.`}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(S,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,J.jsx)(z,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>i(e.target.value)})]}),(0,J.jsxs)(de,{value:a,onValueChange:o,children:[(0,J.jsx)(le,{className:`h-8 w-40 text-sm`,children:(0,J.jsx)(ue,{placeholder:`Provider`})}),(0,J.jsxs)(ce,{children:[(0,J.jsx)(se,{value:`all`,children:`Todos`}),t.map(e=>(0,J.jsx)(se,{value:e.id,children:e.name},e.id))]})]})]}),(0,J.jsx)(V,{className:`h-[calc(100vh-26rem)]`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[s.map(e=>(0,J.jsx)(Ye,{model:e},e.id)),s.length===0&&(0,J.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,J.jsx)(d,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,J.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,J.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]})]})})]})}var Qe=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`div`,{className:`relative w-full overflow-auto`,children:(0,J.jsx)(`table`,{ref:n,className:O(`w-full caption-bottom text-sm`,e),...t})}));Qe.displayName=`Table`;var $e=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`thead`,{ref:n,className:O(`[&_tr]:border-b`,e),...t}));$e.displayName=`TableHeader`;var et=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`tbody`,{ref:n,className:O(`[&_tr:last-child]:border-0`,e),...t}));et.displayName=`TableBody`;var tt=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`tfoot`,{ref:n,className:O(`border-t bg-muted/50 font-medium [&>tr]:last:border-b-0`,e),...t}));tt.displayName=`TableFooter`;var nt=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`tr`,{ref:n,className:O(`border-b transition-colors data-[state=selected]:bg-muted hover:bg-muted/50`,e),...t}));nt.displayName=`TableRow`;var Y=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`th`,{ref:n,className:O(`h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0`,e),...t}));Y.displayName=`TableHead`;var X=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`td`,{ref:n,className:O(`p-4 align-middle [&:has([role=checkbox])]:pr-0`,e),...t}));X.displayName=`TableCell`;var rt=q.forwardRef(({className:e,...t},n)=>(0,J.jsx)(`caption`,{ref:n,className:O(`mt-4 text-sm text-muted-foreground`,e),...t}));rt.displayName=`TableCaption`;function it({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:a,isDownloadingModel:o,downloadLogs:s,fetchDownloadLogs:c}=I(),[u,d]=(0,q.useState)(!1);(0,q.useEffect)(()=>{e&&f()},[e]);let f=async()=>{d(!0),await r(),d(!1)},p=async e=>{await a(e)},m=e=>{switch(e){case`high`:return`bg-green-500/20 text-green-400 border-green-500/30`;case`medium`:return`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`;case`low`:return`bg-zinc-500/20 text-zinc-400 border-zinc-500/30`}};return(0,J.jsx)(G,{open:e,onOpenChange:t,children:(0,J.jsxs)(U,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,J.jsxs)(oe,{children:[(0,J.jsx)(W,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,J.jsx)(H,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),(0,J.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,J.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,J.jsxs)(B,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,J.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:f,disabled:u||o,className:`gap-2`,children:[(0,J.jsx)(x,{className:`h-4 w-4 ${u?`animate-spin`:``}`}),`Actualizar`]})]}),u&&!n.length?(0,J.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,J.jsx)(N,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):n.length===0?(0,J.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,J.jsxs)(Qe,{children:[(0,J.jsx)($e,{children:(0,J.jsxs)(nt,{children:[(0,J.jsx)(Y,{children:`Modelo`}),(0,J.jsx)(Y,{children:`Idioma`}),(0,J.jsx)(Y,{children:`Calidad`}),(0,J.jsx)(Y,{children:`Tamaño`}),(0,J.jsx)(Y,{children:`Estado`}),(0,J.jsx)(Y,{className:`text-right`,children:`Acciones`})]})}),(0,J.jsx)(et,{children:n.map(e=>(0,J.jsxs)(nt,{children:[(0,J.jsx)(X,{className:`font-medium`,children:e.name}),(0,J.jsx)(X,{children:e.language}),(0,J.jsx)(X,{children:(0,J.jsx)(B,{className:m(e.quality),children:e.quality})}),(0,J.jsx)(X,{className:`text-muted-foreground`,children:e.size}),(0,J.jsx)(X,{children:e.installed?(0,J.jsxs)(B,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,J.jsx)(i,{className:`h-3 w-3`}),`Instalado`]}):o&&s.some(t=>t.includes(e.name))?(0,J.jsxs)(B,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,J.jsx)(N,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,J.jsx)(B,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,J.jsx)(X,{className:`text-right`,children:e.installed?(0,J.jsxs)(k,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,J.jsx)(i,{className:`h-4 w-4`}),`Instalado`]}):(0,J.jsxs)(k,{size:`sm`,onClick:()=>p(e.id),disabled:o,className:`gap-2`,children:[(0,J.jsx)(l,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),s.length>0&&(0,J.jsxs)(`div`,{className:`mt-4`,children:[(0,J.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,J.jsx)(`div`,{className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-32 overflow-y-auto font-mono text-xs text-zinc-300`,children:s.map((e,t)=>(0,J.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})})}function at(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=I(),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(!1),[u,d]=(0,q.useState)([]),[f,p]=(0,q.useState)(``),[m,h]=(0,q.useState)(!1),g=(0,q.useRef)(null),_=(0,q.useRef)(null);(0,q.useEffect)(()=>{t()},[t]),(0,q.useEffect)(()=>(e.installing?g.current=setInterval(()=>{t(),s&&b()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,s,t]),(0,q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[u]);let b=async()=>{try{let e=await A(`/api/tts-local/logs`);d(e.logs),p(e.ttsRoot)}catch{}},S=async()=>{o(!0),c(!0);try{await n(),await b()}finally{o(!1)}},C=async()=>{o(!0);try{await r()}finally{o(!1)}},T=async()=>{o(!0);try{await i()}finally{o(!1)}},O=async()=>{c(e=>!e),s||await b()},{installed:j,running:M,piperExists:N,voiceExists:P,port:F}=e,L=e.installing;return(0,J.jsxs)(_e,{className:`relative overflow-hidden col-span-full ${M?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,J.jsx)(me,{children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(pe,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,J.jsx)(B,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,J.jsx)(ge,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[L?(0,J.jsxs)(B,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,J.jsx)(x,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):j?(0,J.jsx)(B,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,J.jsx)(B,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),j&&(M?(0,J.jsxs)(B,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,J.jsx)(D,{className:`h-3 w-3`}),`Servidor :`,F]}):(0,J.jsxs)(B,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,J.jsx)(E,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,J.jsxs)(he,{className:`space-y-4`,children:[!j&&!L&&(0,J.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 ${N?`text-green-400`:``}`,children:[(0,J.jsx)(`span`,{children:N?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-1.5 ${P?`text-green-400`:``}`,children:[(0,J.jsx)(`span`,{children:P?`✓`:`○`}),` Voz española (~60 MB)`]})]}),j&&(0,J.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,J.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,J.jsx)(`code`,{className:`text-zinc-300`,children:F}),` · Configurable con`,` `,(0,J.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,J.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,J.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!j&&!L&&(0,J.jsxs)(k,{size:`sm`,onClick:S,disabled:a,className:`gap-2`,children:[(0,J.jsx)(l,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),L&&(0,J.jsxs)(k,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,J.jsx)(x,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),j&&!M&&(0,J.jsxs)(k,{size:`sm`,onClick:C,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,J.jsx)(y,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),M&&(0,J.jsxs)(k,{size:`sm`,variant:`outline`,onClick:T,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,J.jsx)(v,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),j&&(0,J.jsxs)(k,{size:`sm`,variant:`outline`,onClick:()=>h(!0),disabled:a,className:`gap-2`,children:[(0,J.jsx)(ye,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,J.jsx)(B,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,J.jsx)(k,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,J.jsx)(x,{className:`h-3.5 w-3.5`})}),(0,J.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:O,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,J.jsx)(w,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),L&&(0,J.jsx)(`p`,{className:`text-xs text-yellow-400/80`,children:`Descargando binario y modelo de voz… puede tardar 1-3 min. El estado se actualiza automáticamente.`}),s&&(0,J.jsxs)(`div`,{className:`space-y-1`,children:[f&&(0,J.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,f]}),(0,J.jsx)(`div`,{ref:_,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-40 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:u.length===0?(0,J.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):u.map((e,t)=>(0,J.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,J.jsx)(it,{open:m,onOpenChange:h})]})]})}var ot={groq:{logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{logo:`🖥️`}};function st(){let{providers:e,availableModels:t,activeProviders:n}=R(),{voiceProviders:r,configuredVoiceProviders:a,fetchVoiceProviders:o,fetchConfiguredVoiceProviders:s,saveVoiceProviderKey:c}=ee(),l=L(e=>e.fetchAll),[u,d]=(0,q.useState)(null),[f,g]=(0,q.useState)(``),[v,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(!1),[C,w]=(0,q.useState)(``),[T,E]=(0,q.useState)(`all`);(0,q.useEffect)(()=>{o(),s(),l(!0)},[o,s,l]);let D=async e=>{if(f.trim()){y(!0);try{await c(e,f.trim()),await s(),d(null),g(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{y(!1)}}},O=t=>{let n=e.find(e=>e.id===t),r=(n?.models||[]).filter(e=>e.model_type===`stt`||e.model_type===`tts`),i=r.some(e=>e.model_type===`stt`),a=r.some(e=>e.model_type===`tts`),o=r.some(e=>Xe(e.capabilities).includes(`local`)),s=ot[t]||{logo:`🔌`};return{name:n?.name||t,description:[i&&`STT (Speech-to-Text)`,a&&`TTS (Text-to-Speech)`].filter(Boolean).join(` / `),logo:s.logo,consoleUrl:s.consoleUrl,noApiKey:o}},A=r.filter(e=>!O(e).noApiKey),j=(0,q.useMemo)(()=>t.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=Xe(e.capabilities),r=n.includes(`transcription`)||n.includes(`tts`)||n.includes(`speech`),i=e.name.toLowerCase().includes(C.toLowerCase())||e.id.toLowerCase().includes(C.toLowerCase()),a=T===`all`||e.providerId===T||e.provider_id===T;return(t||r)&&i&&a}),[t,C,T]);return(0,J.jsxs)(`div`,{className:`space-y-6`,children:[(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,J.jsx)(B,{variant:`secondary`,children:j.length})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsxs)(`div`,{className:`relative flex-1`,children:[(0,J.jsx)(S,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,J.jsx)(z,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,J.jsxs)(de,{value:T,onValueChange:E,children:[(0,J.jsx)(le,{className:`h-8 w-40 text-sm`,children:(0,J.jsx)(ue,{placeholder:`Provider`})}),(0,J.jsxs)(ce,{children:[(0,J.jsx)(se,{value:`all`,children:`Todos`}),n.map(e=>(0,J.jsx)(se,{value:e.id,children:e.name},e.id))]})]})]}),(0,J.jsx)(V,{className:`h-60`,children:(0,J.jsxs)(`div`,{className:`space-y-2`,children:[j.map(e=>(0,J.jsx)(Ye,{model:e},e.id)),j.length===0&&(0,J.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,J.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,J.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,J.jsxs)(`div`,{className:`space-y-4`,children:[(0,J.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,J.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,J.jsx)(at,{}),A.map(e=>{let t=O(e),n=a[e]===!0,r=u===e;return(0,J.jsxs)(_e,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,J.jsx)(me,{children:(0,J.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,J.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(pe,{className:`text-lg`,children:t.name}),(0,J.jsx)(ge,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,J.jsx)(B,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,J.jsxs)(B,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,J.jsx)(i,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,J.jsx)(B,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,J.jsx)(he,{className:`space-y-4`,children:t.noApiKey?(0,J.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):r?(0,J.jsxs)(`div`,{className:`space-y-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(K,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,J.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,J.jsx)(z,{id:`api-key-${e}`,type:b?`text`:`password`,placeholder:`sk-...`,value:f,onChange:e=>g(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,J.jsx)(k,{variant:`outline`,size:`icon`,onClick:()=>x(!b),title:b?`Ocultar`:`Mostrar`,children:b?(0,J.jsx)(h,{className:`h-4 w-4`}):(0,J.jsx)(m,{className:`h-4 w-4`})})]})]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[(0,J.jsx)(k,{size:`sm`,onClick:()=>D(e),disabled:v||!f.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,J.jsx)(k,{size:`sm`,variant:`outline`,onClick:()=>{d(null),g(``)},children:`Cancelar`})]})]}):(0,J.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,J.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,J.jsx)(p,{className:`h-4 w-4`}),(0,J.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,J.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,J.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,J.jsxs)(k,{size:`sm`,variant:`outline`,onClick:()=>{d(e),g(``)},className:`flex-1`,children:[(0,J.jsx)(p,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,J.jsxs)(k,{size:`sm`,onClick:()=>{d(e),g(``)},className:`flex-1`,children:[(0,J.jsx)(p,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),t.consoleUrl&&(0,J.jsx)(k,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,J.jsxs)(_e,{children:[(0,J.jsxs)(me,{children:[(0,J.jsx)(pe,{className:`text-lg`,children:`Como funciona?`}),(0,J.jsx)(ge,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,J.jsxs)(he,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,J.jsx)(`div`,{className:`pt-2 border-t`,children:(0,J.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}var ct=[{id:`configurar`,title:`Configurar un provider`,blurb:`API key, endpoint y activación`},{id:`gratuitos`,title:`Providers gratuitos`,blurb:`Cuáles no cobran por token`},{id:`agregar`,title:`Agregar un modelo`,blurb:`Descubrir vs. cargar a mano`},{id:`ollama`,title:`Modelos de Ollama`,blurb:`Cómo se nombran los modelos locales`},{id:`modelscope`,title:`ModelScope y Qwen`,blurb:`El dominio correcto y los créditos`},{id:`costos`,title:`Cómo se calcula el costo`,blurb:`Precios, «sin tarifa» y el dashboard`}],Z=`text-[12px] leading-relaxed text-white/55`,Q=`text-[11px] font-black uppercase tracking-widest text-white/70 mt-4 mb-1.5 first:mt-0`,$=`font-mono text-[11px] bg-white/5 border border-white/10 rounded px-1 py-0.5 text-white/70`;function lt({open:e,onOpenChange:t,providers:n,models:r,initialGuide:i}){let[a,o]=(0,q.useState)(i??`configurar`),s=(0,q.useMemo)(()=>{let e=new Map;for(let t of r){let n=t.providerId||t.provider_id;n&&(e.has(n)||e.set(n,[]),e.get(n).push(t))}return[...e.entries()].filter(([,e])=>{let t=e.map(we).filter(e=>e!==null);return t.length>0&&t.every(Te)}).map(([e])=>n.find(t=>t.id===e)?.name||e).sort()},[r,n]),c=n.filter(e=>e.has_api_key).length;return(0,J.jsx)(G,{open:e,onOpenChange:t,children:(0,J.jsxs)(U,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-3xl bg-[#09090b]`,children:[(0,J.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,J.jsx)(W,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:`Guía de providers`}),(0,J.jsxs)(H,{className:`text-xs text-white/40 font-medium mt-0.5`,children:[n.length,` providers · `,c,` con API key · `,r.length,` modelos`]})]}),(0,J.jsxs)(`div`,{className:`flex flex-col sm:flex-row max-h-[65vh]`,children:[(0,J.jsx)(`nav`,{className:`sm:w-56 shrink-0 border-b sm:border-b-0 sm:border-r border-white/5 p-2 flex sm:flex-col gap-1 overflow-x-auto`,children:ct.map(e=>(0,J.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),className:`text-left rounded-md px-2.5 py-2 transition-colors shrink-0 ${a===e.id?`bg-blue-500/10 border border-blue-500/25`:`border border-transparent hover:bg-white/5`}`,children:[(0,J.jsx)(`span`,{className:`block text-[11px] font-bold ${a===e.id?`text-blue-300`:`text-white/70`}`,children:e.title}),(0,J.jsx)(`span`,{className:`block text-[10px] text-white/30 mt-0.5 whitespace-nowrap sm:whitespace-normal`,children:e.blurb})]},e.id))}),(0,J.jsxs)(`div`,{className:`flex-1 p-5 overflow-y-auto hive-scroll`,children:[a===`configurar`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`1. Activá el provider`}),(0,J.jsx)(`p`,{className:Z,children:`El switch de la tarjeta activa el provider y, en cascada, sus modelos. Un provider apagado no se ofrece a los agentes aunque tenga la key cargada.`}),(0,J.jsx)(`h4`,{className:Q,children:`2. Cargá la API key`}),(0,J.jsxs)(`p`,{className:Z,children:[`Botón `,(0,J.jsx)(`span`,{className:$,children:`CONFIG`}),`. La key se guarda cifrada, separada del resto de la configuración, y nunca se devuelve entera: la tarjeta sólo muestra una versión enmascarada.`]}),(0,J.jsx)(`h4`,{className:Q,children:`3. Endpoint`}),(0,J.jsxs)(`p`,{className:Z,children:[`Cada provider trae su `,(0,J.jsx)(`span`,{className:$,children:`base_url`}),` por defecto. Cambialo sólo si usás un proxy propio o un gateway corporativo. El verificador de key y el descubrimiento de modelos usan ese mismo endpoint, así que apuntar a un proxy funciona de punta a punta.`]}),(0,J.jsx)(`h4`,{className:Q,children:`Providers locales`}),(0,J.jsxs)(`p`,{className:Z,children:[`Ollama y otros en `,(0,J.jsx)(`span`,{className:$,children:`localhost`}),` no necesitan API key. En esos aparece además el campo `,(0,J.jsx)(`span`,{className:$,children:`num_ctx`}),`, que fija el contexto que el servidor local reserva por request.`]})]}),a===`gratuitos`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`Sin costo por token`}),s.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:Z,children:`Según el catálogo cargado, estos providers tienen todos sus modelos a precio cero:`}),(0,J.jsx)(`ul`,{className:`mt-2 space-y-1`,children:s.map(e=>(0,J.jsxs)(`li`,{className:`flex items-center gap-2 text-[12px] text-emerald-400/80`,children:[(0,J.jsx)(`span`,{className:`h-1 w-1 rounded-full bg-emerald-400/60`}),e]},e))}),(0,J.jsx)(`p`,{className:`${Z} mt-3`,children:`Esta lista sale de los precios guardados en la base, así que se actualiza sola cuando cambia el catálogo. Gratis no significa sin límites: suelen tener cuotas de uso por cuenta.`})]}):(0,J.jsx)(`p`,{className:Z,children:`Ningún provider del catálogo actual tiene todos sus modelos a precio cero.`}),(0,J.jsx)(`h4`,{className:Q,children:`Ojo con el $0 engañoso`}),(0,J.jsxs)(`p`,{className:Z,children:[`Un modelo `,(0,J.jsx)(`em`,{children:`sin tarifa cargada`}),` también suma $0 al dashboard, pero no porque sea gratis sino porque falta el dato. En la lista de modelos se distinguen: `,(0,J.jsx)(`span`,{className:$,children:`Gratis`}),` en verde contra `,(0,J.jsx)(`span`,{className:$,children:`Sin tarifa`}),` en gris.`]})]}),a===`agregar`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`Descubrir (recomendado)`}),(0,J.jsxs)(`p`,{className:Z,children:[`Trae la lista real de modelos que el provider sirve en este momento y elegís de ahí. Es la forma segura: un ID escrito a mano puede estar mal o haber sido retirado, y eso no falla al guardar — falla mucho después, en plena conversación, con un `,(0,J.jsx)(`span`,{className:$,children:`404`}),` o un`,` `,(0,J.jsx)(`span`,{className:$,children:`410 Gone`}),`.`]}),(0,J.jsx)(`p`,{className:`${Z} mt-2`,children:`Los modelos que ya tenés cargados aparecen marcados para que no los dupliques.`}),(0,J.jsx)(`h4`,{className:Q,children:`Manual`}),(0,J.jsx)(`p`,{className:Z,children:`Para providers que no publican su lista de modelos. Campos:`}),(0,J.jsxs)(`ul`,{className:`${Z} mt-2 space-y-1.5 list-disc pl-4`,children:[(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`b`,{className:`text-white/70`,children:`ID en la API`}),` — el nombre exacto que espera el provider.`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`b`,{className:`text-white/70`,children:`Nombre visible`}),` — sólo para la UI.`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`b`,{className:`text-white/70`,children:`Contexto`}),` — tokens de entrada máximos; también decide cuándo se compacta la conversación.`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`b`,{className:`text-white/70`,children:`Costo`}),` — USD por millón de tokens.`]}),(0,J.jsxs)(`li`,{children:[(0,J.jsx)(`b`,{className:`text-white/70`,children:`Capacidades`}),` — `,(0,J.jsx)(`span`,{className:$,children:`function_calling`}),` es la que habilita herramientas.`]})]}),(0,J.jsx)(`p`,{className:`${Z} mt-3`,children:`Los modelos que agregues a mano sobreviven a las actualizaciones del catálogo: no se borran al actualizar la lista de modelos que trae Hive.`})]}),a===`ollama`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`Cómo se llaman`}),(0,J.jsxs)(`p`,{className:Z,children:[`Ollama identifica cada modelo como `,(0,J.jsx)(`span`,{className:$,children:`nombre:tag`}),`, donde el tag es la variante o el tamaño. Ejemplos: `,(0,J.jsx)(`span`,{className:$,children:`llama3.3:8b`}),`,`,` `,(0,J.jsx)(`span`,{className:$,children:`qwen3:14b`}),`, `,(0,J.jsx)(`span`,{className:$,children:`mistral:7b`}),`. Sin tag, Ollama asume `,(0,J.jsx)(`span`,{className:$,children:`:latest`}),`.`]}),(0,J.jsx)(`h4`,{className:Q,children:`No los escribas a mano`}),(0,J.jsxs)(`p`,{className:Z,children:[`El botón de sincronizar de la tarjeta lee los modelos que ya tenés instalados y los carga solo. Si un modelo no aparece, primero bajalo en tu máquina con`,` `,(0,J.jsx)(`span`,{className:$,children:`ollama pull llama3.3:8b`}),` y volvé a sincronizar.`]}),(0,J.jsx)(`h4`,{className:Q,children:`Contexto`}),(0,J.jsx)(`p`,{className:Z,children:`Los modelos descubiertos entran con contexto 0 porque Ollama no lo reporta en el listado. Editalo con el valor real del modelo: si queda en 0, Hive usa un valor por defecto que puede no corresponder al que tenés cargado.`}),(0,J.jsx)(`h4`,{className:Q,children:`Costo`}),(0,J.jsxs)(`p`,{className:Z,children:[`Corren en tu máquina, así que entran en `,(0,J.jsx)(`span`,{className:$,children:`0`}),`. No consumen presupuesto.`]})]}),a===`modelscope`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`El error que casi nadie encuentra: .ai vs .cn`}),(0,J.jsxs)(`p`,{className:Z,children:[`ModelScope tiene dos endpoints con `,(0,J.jsx)(`b`,{className:`text-white/70`,children:`cuentas y tokens separados`}),`:`,` `,(0,J.jsx)(`span`,{className:$,children:`api-inference.modelscope.ai`}),` (internacional) y`,` `,(0,J.jsx)(`span`,{className:$,children:`api-inference.modelscope.cn`}),` (China). Un token de uno responde`,` `,(0,J.jsx)(`span`,{className:$,children:`401`}),` en el otro.`]}),(0,J.jsxs)(`p`,{className:`${Z} mt-2`,children:[`Lo confuso: `,(0,J.jsx)(`b`,{className:`text-white/70`,children:`el listado de modelos responde 200 en los dos`}),`, porque es público y no valida la key. El 401 aparece recién al invocar un modelo. Si te pasa eso, no es la key — es el dominio. Hive viene apuntando al internacional (`,(0,J.jsx)(`span`,{className:$,children:`.ai`}),`); cambialo desde CONFIG si tu cuenta es la china.`]}),(0,J.jsx)(`h4`,{className:Q,children:`ModelScope no es DashScope`}),(0,J.jsxs)(`p`,{className:Z,children:[`Son plataformas distintas de Alibaba, con cuentas y créditos separados. El provider`,` `,(0,J.jsx)(`span`,{className:$,children:`ModelScope Qwen`}),` usa un token de modelscope.cn → Access Tokens. El provider `,(0,J.jsx)(`span`,{className:$,children:`Qwen (Alibaba)`}),` usa una API key de Model Studio / DashScope. Una no sirve para el otro.`]}),(0,J.jsx)(`h4`,{className:Q,children:`Cuota`}),(0,J.jsxs)(`p`,{className:Z,children:[`El endpoint es gratuito dentro de límite: 2000 llamadas por día y hasta 500 por modelo. Por eso sus modelos figuran con costo `,(0,J.jsx)(`span`,{className:$,children:`0`}),`.`]}),(0,J.jsx)(`h4`,{className:Q,children:`Modelos de embajador`}),(0,J.jsxs)(`p`,{className:Z,children:[`Los `,(0,J.jsx)(`span`,{className:$,children:`Qwen-Ambassador/*`}),` (3.7-Plus, 3.7-Max, 3.8-Max) aparecen en el listado para todo el mundo, pero sólo los puede invocar una cuenta del programa de embajadores. Si no sos parte, el provider devuelve un error de autorización al usarlos.`]})]}),a===`costos`&&(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`h4`,{className:Q,children:`De dónde sale el número`}),(0,J.jsx)(`p`,{className:Z,children:`Cada modelo guarda su precio de entrada y de salida en USD por millón de tokens. Cuando un agente responde, se registran los tokens reales de esa llamada y se multiplican por el precio de ese modelo. No hay tabla de precios aparte: lo que ves en la tarjeta es lo mismo que factura el dashboard.`}),(0,J.jsx)(`h4`,{className:Q,children:`Entrada y salida no valen igual`}),(0,J.jsxs)(`p`,{className:Z,children:[`La salida suele costar entre 3 y 6 veces más que la entrada. Por eso se muestran los dos números:`,` `,(0,J.jsx)(`span`,{className:$,children:`$3 / $15`}),` es entrada / salida.`]}),(0,J.jsx)(`h4`,{className:Q,children:`«Sin tarifa» vs. 0`}),(0,J.jsxs)(`p`,{className:Z,children:[`Dejar el precio vacío marca el modelo como sin tarifa y su consumo se cuenta como $0 — lo cual ensucia el total sin avisar. Si el endpoint es realmente gratuito, poné`,` `,(0,J.jsx)(`span`,{className:$,children:`0`}),` explícito.`]}),(0,J.jsx)(`h4`,{className:Q,children:`Gasto por provider`}),(0,J.jsxs)(`p`,{className:Z,children:[`El pie de cada tarjeta muestra el gasto y los tokens de los últimos 30 días de ese provider. Un`,` `,(0,J.jsx)(`span`,{className:$,children:`—`}),` significa que todavía no hay registros de uso.`]})]})]})]}),(0,J.jsx)(`div`,{className:`px-5 py-3 border-t border-white/5 flex justify-end`,children:(0,J.jsx)(`button`,{type:`button`,onClick:()=>t(!1),className:`h-8 px-3.5 rounded-md bg-white/5 border border-white/10 text-white/60 text-[10px] font-black uppercase tracking-widest hover:bg-white/10 transition-colors`,children:`Cerrar`})})]})})}var ut=b,dt=d,ft=_,pt=M,mt=ve;function ht(){let{providers:e,createProvider:t}=R(),{models:n}=P(),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),[s,c]=(0,q.useState)(`providers`);return(0,J.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[(0,J.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,J.jsxs)(`div`,{children:[(0,J.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,J.jsx)(`div`,{className:`hive-page-header__dot`}),(0,J.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),(0,J.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,J.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),(0,J.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,J.jsxs)(`button`,{type:`button`,onClick:()=>o(!0),className:`hive-btn hive-btn--ghost`,title:`Cómo configurar providers, cuáles son gratis, cómo agregar modelos`,children:[(0,J.jsx)(mt,{className:`mr-1 h-4 w-4`}),`Guía`]}),(0,J.jsxs)(G,{open:r,onOpenChange:e=>{i(e)},children:[(0,J.jsx)(ae,{asChild:!0,children:(0,J.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,J.jsx)(ut,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,J.jsxs)(U,{className:`max-w-md`,children:[(0,J.jsxs)(oe,{className:`p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,J.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,J.jsx)(W,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,J.jsx)(H,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),(0,J.jsx)(`div`,{className:`p-6`,children:(0,J.jsx)(Ke,{onSave:async e=>{try{await t({id:e.id,name:e.name,base_url:e.baseUrl,api_key:e.apiKey,headers:e.headers,num_ctx:e.numCtx}),i(!1)}catch(e){console.error(`Error creating provider:`,e)}},onCancel:()=>i(!1)})})]})]})]})]}),(0,J.jsx)(lt,{open:a,onOpenChange:o,providers:e,models:n}),(0,J.jsxs)(ie,{value:s,onValueChange:c,className:`w-full`,children:[(0,J.jsxs)(re,{className:`w-full grid grid-cols-3 h-10`,children:[(0,J.jsxs)(te,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,J.jsx)(pt,{className:`h-3.5 w-3.5`}),`Providers`]}),(0,J.jsxs)(te,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,J.jsx)(dt,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,J.jsxs)(te,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,J.jsx)(ft,{className:`h-3.5 w-3.5`}),`Voz`]})]}),(0,J.jsx)(ne,{value:`providers`,className:`mt-4`,children:(0,J.jsx)(Ge,{onOpenGuide:()=>o(!0)})}),(0,J.jsx)(ne,{value:`vision`,className:`mt-4`,children:(0,J.jsx)(Ze,{})}),(0,J.jsx)(ne,{value:`voice`,className:`mt-4`,children:(0,J.jsx)(st,{})})]})]})}export{ht as ProvidersPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{o as n}from"./vendor-query-Dj8xYhQD.js";import{t as r}from"./arrow-left-WyDPYZXU.js";import{n as i,t as a}from"./eye-sRPY5qOa.js";import{c as o}from"./vendor-router-Dsg8fxNQ.js";import{B as s,Z as c,z as l}from"./index-BHHUQZJd.js";import{t as u}from"./label-BceoUB2w.js";var d=e(t(),1),f=n();function p(){let e=o(),[t,n]=(0,d.useState)(``),[p,m]=(0,d.useState)(``),[h,g]=(0,d.useState)(``),[_,v]=(0,d.useState)(!1),[y,b]=(0,d.useState)(!1),[x,S]=(0,d.useState)(``);async function C(n){if(n.preventDefault(),S(``),p!==h){S(`Las contraseñas no coinciden`);return}if(p.length<8){S(`La contraseña debe tener al menos 8 caracteres`);return}b(!0);try{let n=await fetch(`/api/auth/recover`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recoveryKey:t,newPassword:p})}),r=await n.json();if(!n.ok){S(r.error||`Recovery key inválido`);return}localStorage.setItem(`hive-auth-token`,r.authToken),e(`/`,{replace:!0})}catch{S(`No se pudo conectar al servidor`)}finally{b(!1)}}return(0,f.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-background`,children:(0,f.jsxs)(`div`,{className:`w-full max-w-sm space-y-6 p-8`,children:[(0,f.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,f.jsx)(`div`,{className:`text-4xl`,children:`🐝`}),(0,f.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Recuperar acceso`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Usa tu recovery key para restablecer la contraseña`})]}),(0,f.jsxs)(`form`,{onSubmit:C,className:`space-y-4`,children:[(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`recoveryKey`,children:`Recovery Key`}),(0,f.jsx)(l,{id:`recoveryKey`,type:`text`,placeholder:`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`,value:t,onChange:e=>n(e.target.value),required:!0,disabled:y,className:`font-mono text-sm`}),(0,f.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Encuéntralo en `,(0,f.jsx)(`code`,{className:`bg-muted px-1 rounded`,children:`~/.hive/.auth_token`})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`newPassword`,children:`Nueva contraseña`}),(0,f.jsxs)(`div`,{className:`relative`,children:[(0,f.jsx)(l,{id:`newPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:p,onChange:e=>m(e.target.value),required:!0,disabled:y,className:`pr-10`}),(0,f.jsx)(`button`,{type:`button`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>v(e=>!e),tabIndex:-1,children:_?(0,f.jsx)(i,{className:`h-4 w-4`}):(0,f.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,f.jsxs)(`div`,{className:`space-y-2`,children:[(0,f.jsx)(u,{htmlFor:`confirmPassword`,children:`Confirmar contraseña`}),(0,f.jsx)(l,{id:`confirmPassword`,type:_?`text`:`password`,placeholder:`••••••••`,value:h,onChange:e=>g(e.target.value),required:!0,disabled:y})]}),x&&(0,f.jsx)(`p`,{className:`text-sm text-destructive`,children:x}),(0,f.jsxs)(s,{type:`submit`,className:`w-full`,disabled:y,children:[y&&(0,f.jsx)(c,{className:`mr-2 h-4 w-4 animate-spin`}),`Recuperar acceso`]})]}),(0,f.jsx)(`div`,{className:`text-center`,children:(0,f.jsxs)(`button`,{type:`button`,onClick:()=>e(`/login`),className:`text-sm text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,f.jsx)(r,{className:`h-3 w-3`}),`Volver al login`]})})]})})}export{p as default};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{n,o as r}from"./vendor-query-Dj8xYhQD.js";import{t as i}from"./createLucideIcon-BRaPSYgN.js";import{t as a}from"./activity-C_GS5wrG.js";import{t as o}from"./calendar-B6x9cw-q.js";import{t as s}from"./check-C8pw-7Fx.js";import{t as c}from"./chevron-down-8GjmTjLR.js";import{t as l}from"./chevron-up-DZrzJIW8.js";import{t as u}from"./circle-alert-CtDbK2nl.js";import{t as d}from"./circle-check-BKNT2_q6.js";import{n as f,t as p}from"./earth-BJRGJbVn.js";import{t as m}from"./copy-wR7o7Ly8.js";import{t as h}from"./useProviders-CiLSc05q.js";import{n as g,t as _}from"./eye-sRPY5qOa.js";import{t as v}from"./history-BHQWfE-7.js";import{t as y}from"./info-CG1VohyH.js";import{n as b,t as x}from"./key-BC28VCjO.js";import{n as S,t as C}from"./pencil-CUbpCfeG.js";import{t as w}from"./mail-Biwn8WrV.js";import{t as T}from"./pause-C2l5G2Py.js";import{t as E}from"./play-CMAscR3a.js";import{t as D}from"./plus-DzvRxH4U.js";import{t as O}from"./refresh-cw-DZXu5FrG.js";import{t as k}from"./search-ykSx-zZU.js";import{t as A}from"./send-DAhlz2i9.js";import{t as j}from"./shield-BPZZhjCT.js";import{t as M}from"./sparkles-BViXTAh7.js";import{t as N}from"./terminal-CzxPKG-h.js";import{t as ee}from"./trash-2-SgYCWiVk.js";import{t as P}from"./zap-OVVrfEHr.js";import{n as te}from"./utils-SGUggNJc.js";import{l as F}from"./vendor-router-Dsg8fxNQ.js";import{r as ne}from"./gateway-url-BZj_2-jf.js";import{$ as re,B as I,C as L,E as R,G as z,H as ie,J as ae,K as oe,S as se,T as ce,U as le,W as ue,X as de,Y as fe,Z as B,b as pe,et as V,g as me,it as he,n as ge,nt as _e,q as ve,r as ye,rt as be,t as xe,tt as Se,w as H,y as Ce,z as U}from"./index-BHHUQZJd.js";import{t as W}from"./badge-uRjRSt86.js";import{t as we}from"./scroll-area-DMEaZZUp.js";import{a as Te,c as Ee,i as G,o as De,r as Oe,s as ke,t as Ae}from"./dialog--mljnfAi.js";import{t as K}from"./label-BceoUB2w.js";import{t as je}from"./textarea-DedxQYBx.js";import{i as q,n as J,o as Y,s as X,t as Z}from"./select-BBEBtcLm.js";import{t as Me}from"./switch-CgiDezVR.js";import{a as Ne,i as Pe,n as Fe,r as Ie,t as Le}from"./card-DwQizslL.js";var Re=i(`Briefcase`,[[`path`,{d:`M16 20V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16`,key:`jecpp`}],[`rect`,{width:`20`,height:`14`,x:`2`,y:`6`,rx:`2`,key:`i6l2r4`}]]),ze=i(`ChartColumn`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`M18 17V9`,key:`2bz60n`}],[`path`,{d:`M13 17V5`,key:`1frdt8`}],[`path`,{d:`M8 17v-3`,key:`17ska0`}]]),Be=i(`Code`,[[`polyline`,{points:`16 18 22 12 16 6`,key:`z7tu5w`}],[`polyline`,{points:`8 6 2 12 8 18`,key:`1eg1df`}]]),Ve=i(`Hammer`,[[`path`,{d:`m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9`,key:`eefl8a`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`b7pghm`}]]),He=i(`Languages`,[[`path`,{d:`m5 8 6 6`,key:`1wu5hv`}],[`path`,{d:`m4 14 6-6 2-3`,key:`1k1g8d`}],[`path`,{d:`M2 5h12`,key:`or177f`}],[`path`,{d:`M7 2h1`,key:`1t2jsx`}],[`path`,{d:`m22 22-5-10-5 10`,key:`don7ne`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ue=i(`LockKeyhole`,[[`circle`,{cx:`12`,cy:`16`,r:`1`,key:`1au0dj`}],[`rect`,{x:`3`,y:`10`,width:`18`,height:`12`,rx:`2`,key:`6s8ecr`}],[`path`,{d:`M7 10V7a5 5 0 0 1 10 0v3`,key:`1pqi11`}]]),We=i(`MessageCircle`,[[`path`,{d:`M7.9 20A9 9 0 1 0 4 16.1L2 22Z`,key:`vv11sd`}]]),Ge=i(`Power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),Ke=i(`Settings2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),qe=i(`ShieldCheck`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),Je=i(`ShieldOff`,[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]),Q=e(t(),1),Ye=ne((e,t)=>({isLoading:!1,error:null,configs:[],setLoading:t=>e({isLoading:t}),setError:t=>e({error:t}),fetchEthics:async()=>{e({isLoading:!0,error:null});try{let t=(await L(`/api/ethics`)).ethics||[],n=t.find(e=>e.active)||t[0];return e({configs:t,isLoading:!1}),n?.content||``}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to fetch ethics`}),t}},saveEthics:async n=>{e({isLoading:!0,error:null});try{let r=t(),i=r.configs.find(e=>e.active)||r.configs[0],a;return a=i?await L(`/api/ethics/${i.id}`,{method:`PUT`,body:{content:n}}):await L(`/api/ethics`,{method:`POST`,body:{name:`Default`,content:n,active:!0}}),e({isLoading:!1}),a.message||`Guardado correctamente`}catch(t){throw e({isLoading:!1,error:t instanceof Error?t.message:`Failed to save ethics`}),t}},updateConfig:(t,n)=>{e(e=>({configs:e.configs.map(e=>e.id===t?{...e,...n,updatedAt:new Date().toISOString(),version:e.version+1}:e)}))},addConfig:t=>{let n={...t,id:te(),version:1,createdAt:new Date().toISOString(),updatedAt:new Date().toISOString()};e(e=>({configs:[...e.configs,n]}))},removeConfig:t=>{e(e=>({configs:e.configs.filter(e=>e.id!==t)}))}})),$=r();function Xe(){let{configs:e,fetchEthics:t,isLoading:n}=Ye(),[r,i]=(0,Q.useState)(null),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)({name:``,description:``,content:``}),[l,u]=(0,Q.useState)(!1),d=(0,Q.useRef)(null),f=()=>{let e=d.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{a&&setTimeout(f,0)},[a,s.content]),(0,Q.useEffect)(()=>{t().catch(console.error)},[t]),(0,Q.useEffect)(()=>{if(e.length===0)return;let t=e,n=t.find(e=>e.active)||t[0];r||(i(n.id),c({name:n.name,description:n.description||``,content:n.content}))},[e,r]);let p=e.find(e=>e.id===r),m=e=>{i(e.id),c({name:e.name,description:e.description||``,content:e.content}),o(!0)},h=async n=>{R.show(`Activando registro de ética...`);let r=e;try{let e=await Promise.all(r.map(e=>L(`/api/ethics/${e.id}`,{method:`PUT`,body:{active:+(e.id===n)}}).catch(()=>({}))));await t();let i=e.find((e,t)=>r[t].id===n);H.fire({icon:`success`,title:i?.message||`Registro de ética activado`})}catch(e){H.fire({icon:`error`,title:e instanceof Error?e.message:`Error al activar registro`})}finally{R.hide()}};return n&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(B,{className:`h-8 w-8 animate-spin text-amber-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`hive-label`,children:`Cargando lineamientos operativos...`})]}):(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Protocolos Éticos`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[e.length,` REGISTROS`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Define la capa moral y los límites operacionales de tus agentes inteligentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(j,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Configuración del Núcleo`})]})]}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(oe,{className:`h-8 w-8 text-white/20`})}),(0,$.jsxs)(`div`,{className:`text-center`,children:[(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`Sin Protocolos Base`}),(0,$.jsxs)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed`,children:[`No se detectaron lineamientos éticos en el sistema. Esto no debería ocurrir en una instalación completa — verifica la conexión con el gateway o ejecuta `,(0,$.jsx)(`code`,{children:`hive doctor`}),`.`]})]})]})}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:e.map(e=>{let t=!!e.active,n=r===e.id;return(0,$.jsxs)(`div`,{onClick:()=>m(e),className:`hive-card group transition-all duration-500 cursor-pointer ${n?`hive-card--active`:`opacity-60 grayscale-[0.8] hover:opacity-100 hover:grayscale-0`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal ${n?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:(0,$.jsx)(ae,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[t&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`ACTIVO`}),(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors text-ellipsis`,children:e.name}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 font-medium leading-relaxed line-clamp-1 h-4`,children:e.description||`Sin descripción adicional`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`CONFIG`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:e.is_default?`DEFAULT`:`CUSTOM`})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`PRECEDENCIA`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:t?`ALTA`:`NORMAL`})]})]})]}),n&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Ae,{open:a,onOpenChange:o,children:(0,$.jsx)(Oe,{className:`max-w-4xl border-white/10 !bg-[#09090b] p-0 overflow-hidden shadow-2xl`,children:p&&(0,$.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-6 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`hive-glow-blob hive-glow-blob--blue -top-10 -right-10 h-32 w-32 opacity-20`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 relative z-10`,children:[(0,$.jsx)(`div`,{className:`hive-icon-wrap--internal hive-icon-wrap--internal-active`,children:(0,$.jsx)(j,{className:`h-6 w-6`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ke,{className:`hive-title-page !text-2xl uppercase tracking-tighter`,children:p.name}),(0,$.jsx)(G,{className:`hive-subtitle !mt-0`,children:`Sintonización de la capa moral y operativa del agente.`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-3 relative z-10`,children:!p.active&&(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>h(p.id),children:`ESTABLECER COMO ACTIVO`})})]}),(0,$.jsx)(`div`,{className:`p-6 space-y-4 border-b border-white/5`,children:(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`hive-label uppercase !text-[10px]`,children:`Nombre del Protocolo`}),(0,$.jsx)(U,{value:s.name,onChange:e=>c(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white font-bold`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`hive-label uppercase !text-[10px]`,children:`Descripción / Meta`}),(0,$.jsx)(U,{value:s.description,onChange:e=>c(t=>({...t,description:e.target.value})),className:`bg-white/5 border-white/5 focus-visible:ring-blue-500/30 text-white/60 text-xs italic`})]})]})}),(0,$.jsxs)(`div`,{className:`p-0 bg-[#09090b]`,children:[(0,$.jsx)(`div`,{className:`px-6 pt-4`,children:(0,$.jsx)(K,{className:`hive-label uppercase !text-[10px]`,children:`Lineamientos de Capa (Markdown)`})}),(0,$.jsx)(je,{ref:d,placeholder:`Define los lineamientos éticos del agente...`,value:s.content,onChange:e=>{c(t=>({...t,content:e.target.value})),f()},className:`hive-textarea w-full !bg-zinc-950/50 border-none focus-visible:ring-0 text-amber-50/90 font-mono text-xs leading-relaxed min-h-[400px] p-8 resize-none placeholder:text-white/10 overflow-hidden`})]}),(0,$.jsxs)(`div`,{className:`p-6 bg-white/[0.02] border-t border-white/5 flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-6`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`IDENTIFICADOR`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:p.id})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO DE CAPA`}),(0,$.jsx)(`span`,{className:`hive-stat__value hive-stat__value--active`,children:p.active?`SISTEMA ACTIVO`:`PENDIENTE`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--ghost px-6 text-[10px]`,onClick:()=>o(!1),children:`CANCELAR`}),(0,$.jsx)(`button`,{onClick:async()=>{if(p){u(!0),R.show(`Guardando lineamientos éticos...`);try{let e=await L(`/api/ethics/${p.id}`,{method:`PUT`,body:s});await t(),H.fire({icon:`success`,title:e.message||`Contenido ético guardado`})}catch(e){H.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{u(!1),R.hide(),o(!1)}}},disabled:l,className:`hive-btn hive-btn--primary px-8 text-[10px]`,children:l?`SINCRONIZANDO...`:`GUARDAR LINEAMIENTOS`})]})]})]})})})]})}var Ze={filesystem:`Sistema de archivos`,web:`Web`,cron:`Cron`,cli:`CLI`,agents:`Agentes`};function Qe(){let{tools:e,isLoading:t,fetchTools:n,toggleTool:r,updateTool:i}=pe(),[a,o]=(0,Q.useState)(`all`),[s,c]=(0,Q.useState)(null),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{n()},[n]);let m=async(e,t)=>{if(!l){u(e);try{await r(e,t),n(),H.fire({icon:`success`,title:`Herramienta ${t?`activada`:`desactivada`}`})}catch{H.fire({icon:`error`,title:`Error al actualizar estado de la herramienta`})}finally{u(null)}}},h=async()=>{if(s){f(!0),R.show(`Guardando herramienta...`);try{await i(s.id,{name:s.name,description:s.description}),H.fire({icon:`success`,title:`Herramienta actualizada`}),n(),c(null)}catch{H.fire({icon:`error`,title:`Error al guardar cambios`})}finally{f(!1),R.hide()}}};if(t&&e.length===0)return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 border border-white/5 bg-zinc-950/30 rounded-2xl`,children:[(0,$.jsx)(B,{className:`h-8 w-8 animate-spin text-violet-500 mb-4 opacity-50`}),(0,$.jsx)(`span`,{className:`text-xs uppercase font-bold tracking-[0.2em] text-zinc-500`,children:`Cargando herramientas...`})]});let g=e.filter(e=>a===`all`?!0:e.category===a);return(0,$.jsxs)(`div`,{className:`space-y-8 animate-fade-in`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg !text-white/80`,children:`Herramientas`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/40 border-white/10`,children:[g.length,` DISPONIBLES`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona las capacidades externas y el arsenal tecnológico de tu agente.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] uppercase tracking-widest font-black text-white/20 bg-white/5 px-4 py-2 rounded-xl border border-white/5`,children:[(0,$.jsx)(le,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Arsenal Operativo`})]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-white/5 rounded-2xl w-fit border border-white/5`,children:[`all`,`filesystem`,`web`,`cron`,`cli`,`agents`,`a2ui`].map(e=>(0,$.jsx)(`button`,{onClick:()=>o(e),className:`px-6 py-2 rounded-xl text-[10px] font-black tracking-widest uppercase transition-all duration-300 ${a===e?`bg-blue-600 text-white shadow-btn-primary`:`text-white/20 hover:text-white/40 hover:bg-white/5`}`,children:e===`all`?`TODAS`:Ze[e]||e},e))}),g.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-violet-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(oe,{className:`h-8 w-8 text-zinc-700 group-hover:text-violet-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`Sin herramientas en esta categoría.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6`,children:g.map(e=>{let t=e.active,n=e.core;return(0,$.jsxs)(`div`,{onClick:()=>c({...e}),className:`hive-card group cursor-pointer transition-all duration-500 ${t?`hive-card--active`:`hive-card--disabled`}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body relative overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,$.jsxs)(`div`,{className:`hive-icon-wrap--internal ${t?`hive-icon-wrap--internal-active`:`hive-icon-wrap--internal-disabled`}`,children:[e.category===`filesystem`&&(0,$.jsx)(p,{className:`h-6 w-6`}),e.category===`web`&&(0,$.jsx)(p,{className:`h-6 w-6`}),e.category===`cron`&&(0,$.jsx)(k,{className:`h-6 w-6`}),e.category===`cli`&&(0,$.jsx)(N,{className:`h-6 w-6`}),e.category===`agents`&&(0,$.jsx)(Ke,{className:`h-6 w-6`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n&&(0,$.jsx)(`span`,{className:`hive-status-label--active`,children:`NATIVO`}),(0,$.jsx)(Me,{checked:t,onCheckedChange:()=>m(e.id,!t),onClick:e=>e.stopPropagation(),className:`data-[state=checked]:bg-blue-500 scale-75 origin-right`})]})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-black text-white uppercase tracking-tighter mb-1 line-clamp-1 group-hover:text-blue-400 transition-colors`,children:e.name}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-[11px] h-8 line-clamp-2`,children:e.description||`Sin descripción disponible`})]}),(0,$.jsxs)(`div`,{className:`pt-4 border-t border-white/5 flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`TIPO`}),(0,$.jsx)(`span`,{className:`hive-stat__value truncate max-w-[80px]`,children:e.category})]}),(0,$.jsxs)(`div`,{className:`hive-stat`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`ESTADO`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:t?`hive-status-dot--active`:`hive-status-dot--disabled`}),(0,$.jsx)(`span`,{className:t?`hive-status-label--active`:`hive-status-label--disabled`,children:t?`ACTIVE`:`STANDBY`})]})]})]})]}),t&&(0,$.jsx)(`div`,{className:`hive-glow-blob--card hive-glow-blob--blue -bottom-10 -right-10 h-24 w-24 opacity-20`})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${t?``:`opacity-20`}`})]},e.id)})}),(0,$.jsx)(Ae,{open:!!s,onOpenChange:e=>!e&&c(null),children:(0,$.jsxs)(Oe,{className:`sm:max-w-sm bg-zinc-950 border-white/10`,children:[(0,$.jsxs)(De,{children:[(0,$.jsxs)(ke,{className:`flex items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg bg-violet-500/10 text-violet-400`,children:(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`})}),`Editar herramienta`]}),(0,$.jsx)(G,{className:`text-[10px] text-zinc-500 font-medium`,children:`Modifica los parámetros y la descripción de la herramienta seleccionada.`})]}),(0,$.jsxs)(`div`,{className:`space-y-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(K,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Nombre`}),(0,$.jsx)(U,{value:s?.name||``,onChange:e=>c({...s,name:e.target.value}),className:`h-9 text-sm bg-white/5 border-white/10 focus:border-violet-500/50`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(K,{className:`text-[10px] text-zinc-500 uppercase tracking-widest font-bold`,children:`Descripción`}),(0,$.jsx)(je,{value:s?.description||``,onChange:e=>c({...s,description:e.target.value}),className:`text-sm min-h-[80px] resize-none bg-white/5 border-white/10 focus:border-violet-500/50 font-mono`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pt-1 border-t border-white/5`,children:[(0,$.jsx)(`span`,{className:`font-mono text-[10px] bg-zinc-900 border border-white/5 text-zinc-500 px-2 py-0.5 rounded truncate max-w-[180px]`,children:s?.id}),(0,$.jsx)(W,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-500 uppercase`,children:s?.category})]})]}),(0,$.jsxs)(Te,{className:`gap-2 sm:gap-0`,children:[(0,$.jsx)(I,{variant:`outline`,size:`sm`,onClick:()=>c(null),className:`hive-btn--form-cancel h-10`,children:`Cancelar`}),(0,$.jsxs)(I,{size:`sm`,onClick:h,disabled:d,className:`hive-btn--form-submit h-10`,children:[d&&(0,$.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}),`Guardar Cambios`]})]})]})})]})}function $e({server:e,onClick:t,isConnected:n,isLoading:r}){let i=n||e.status===`connected`,a=e.transport===`stdio`;return(0,$.jsxs)(Le,{onClick:t,className:`group relative overflow-hidden transition-all hover:border-cyan-500/50 hover:shadow-lg hover:shadow-cyan-500/5 cursor-pointer border-white/5 bg-zinc-950/50 backdrop-blur-sm ${i?`border-cyan-500/20 bg-cyan-500/[0.02]`:`opacity-80 grayscale-[0.2]`} ${r?`pointer-events-none opacity-50`:``}`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-1 h-full transition-colors ${i?`bg-cyan-500`:`bg-zinc-800`}`}),(0,$.jsxs)(Pe,{className:`pb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between mb-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg transition-colors ${i?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:a?(0,$.jsx)(h,{className:`h-5 w-5`}):(0,$.jsx)(V,{className:`h-5 w-5`})}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:i?(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 px-2 py-0.5 rounded-full bg-cyan-500/10 border border-cyan-500/20`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-cyan-500 uppercase tracking-wider`,children:`LIVE`})]}):(0,$.jsx)(W,{variant:`outline`,className:`text-[10px] border-zinc-800 text-zinc-500 uppercase tracking-tighter`,children:`OFFLINE`})})]}),(0,$.jsx)(Ne,{className:`text-sm font-bold truncate group-hover:text-cyan-400 transition-colors`,children:e.name}),(0,$.jsx)(Ie,{className:`text-[10px] font-mono opacity-50 truncate mt-0.5`,children:e.url||`stdio: ${e.transport}`})]}),(0,$.jsxs)(Fe,{className:`pt-0 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mt-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Transport`}),(0,$.jsx)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:e.transport})]}),(0,$.jsx)(`div`,{className:`h-4 w-px bg-white/10`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[9px] text-zinc-500 uppercase font-bold tracking-widest`,children:`Tools`}),(0,$.jsxs)(`span`,{className:`text-xs font-semibold text-zinc-300`,children:[e.tools?.length||e.tools_count||0,` expuestas`]})]})]}),e.builtin&&(0,$.jsx)(W,{variant:`outline`,className:`mt-3 text-[9px] border-amber-500/20 text-amber-500/70 bg-amber-500/5`,children:`BUILTIN`})]}),i&&(0,$.jsx)(`div`,{className:`absolute -bottom-6 -right-6 w-12 h-12 bg-cyan-500/10 blur-2xl rounded-full`})]})}function et({serverId:e,serverName:t,tools:n=[]}){let[r,i]=(0,Q.useState)(``),a=n.filter(e=>e.name.toLowerCase().includes(r.toLowerCase())||e.description.toLowerCase().includes(r.toLowerCase()));return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 relative`,children:[(0,$.jsx)(k,{className:`absolute left-2.5 top-2.5 h-3.5 w-3.5 text-zinc-500`}),(0,$.jsx)(U,{placeholder:`Buscar herramientas...`,className:`pl-8 h-8 text-[11px] bg-white/5 border-white/10 focus:border-cyan-500/30`,value:r,onChange:e=>i(e.target.value)})]}),(0,$.jsx)(`div`,{className:`space-y-2 max-h-[300px] overflow-y-auto pr-1 custom-scrollbar`,children:a.length===0?(0,$.jsx)(`div`,{className:`py-8 text-center text-[10px] text-zinc-500 italic`,children:r?`No se encontraron herramientas que coincidan.`:`Este servidor no expone herramientas actualmente.`}):a.map(e=>(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900/50 border border-white/5 hover:border-cyan-500/20 transition-all group`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded bg-cyan-500/5 text-cyan-400 group-hover:bg-cyan-500/10 transition-colors`,children:(0,$.jsx)(Ve,{className:`h-3.5 w-3.5`})}),(0,$.jsx)(`h5`,{className:`text-[11px] font-bold text-zinc-200 group-hover:text-cyan-400 transition-colors`,children:e.name})]}),e.inputSchema&&(0,$.jsx)(W,{variant:`outline`,className:`text-[9px] border-zinc-800 text-zinc-600 h-4`,children:`JSON Schema`})]}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px] text-zinc-500 leading-relaxed line-clamp-2`,children:e.description})]},e.name))}),(0,$.jsxs)(`div`,{className:`p-2 rounded bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-2`,children:[(0,$.jsx)(y,{className:`h-3 w-3 text-cyan-500`}),(0,$.jsxs)(`span`,{className:`text-[9px] text-cyan-200/50`,children:[`Estas herramientas son gestionadas directamente por `,(0,$.jsx)(`span`,{className:`text-cyan-400 font-mono`,children:t}),`.`]})]})]})}function tt(e){return e?e[`x-api-key`]?{authType:`api-key`,authToken:e[`x-api-key`]}:e.Authorization?.startsWith(`Bearer `)?{authType:`bearer`,authToken:e.Authorization.replace(`Bearer `,``)}:Object.keys(e).length>0?{authType:`custom`,authToken:``}:{authType:`none`,authToken:``}:{authType:`none`,authToken:``}}function nt({server:e,onClose:t}){let{updateMCPServer:n,toggleMCPServer:r,deleteMCPServer:i,fetchMCPServers:a}=me(),[o,s]=(0,Q.useState)(e.transport||`stdio`),[c,l]=(0,Q.useState)(e.command||``),[u,d]=(0,Q.useState)(e.args?.join(` `)||``),[f,p]=(0,Q.useState)(e.url||``),[m,h]=(0,Q.useState)(()=>tt(e.headers).authType),[g,_]=(0,Q.useState)(()=>tt(e.headers).authToken),[v,y]=(0,Q.useState)(e.headers?JSON.stringify(e.headers,null,2):``),[b,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(!0),[A,j]=(0,Q.useState)(!1),[M,P]=(0,Q.useState)(`config`),[te,F]=(0,Q.useState)(e.status),[ne,re]=(0,Q.useState)(e.active),z=te===`connected`||ne===1||ne===!0;return(0,Q.useEffect)(()=>{let t=!1;return(async()=>{k(!0);try{let n=await L(`/api/mcp/servers/${e.id}`);if(t)return;s(n.transport||`stdio`),l(n.command||``),d(Array.isArray(n.args)?n.args.join(` `):``),p(n.url||``);let r=tt(n.headers);h(r.authType),_(r.authToken),y(n.headers?JSON.stringify(n.headers,null,2):``),F(n.status||e.status),re(+!!n.enabled)}catch{}finally{t||k(!1)}})(),()=>{t=!0}},[e.id]),(0,$.jsx)(Ae,{open:!0,onOpenChange:e=>!e&&t(),children:(0,$.jsxs)(Oe,{className:`sm:max-w-[500px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl p-0 overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-transparent via-cyan-500/50 to-transparent`}),(0,$.jsxs)(De,{className:`p-6 pb-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg ${z?`bg-cyan-500/10 text-cyan-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Ke,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(ke,{className:`text-white flex items-center gap-2`,children:[`Configurar `,e.name,z&&(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full bg-cyan-500 animate-pulse`})]}),(0,$.jsxs)(G,{className:`text-[10px] font-mono opacity-50 uppercase tracking-widest mt-0.5`,children:[`ID: `,e.id,` • `,e.transport]})]})]}),!e.builtin&&(0,$.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>j(!0),disabled:w||A,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors`,title:`Eliminar Servidor`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mt-6 border-b border-white/5`,children:[(0,$.jsxs)(`button`,{onClick:()=>P(`config`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${M===`config`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Configuración`,M===`config`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]}),(0,$.jsxs)(`button`,{onClick:()=>P(`tools`),className:`px-4 py-2 text-[10px] uppercase font-bold tracking-widest transition-all relative ${M===`tools`?`text-cyan-400`:`text-zinc-500 hover:text-zinc-300`}`,children:[`Herramientas`,M===`tools`&&(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 w-full h-0.5 bg-cyan-500`})]})]})]}),A&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-bold`,children:e.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>j(!1),disabled:w,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(I,{size:`sm`,onClick:async()=>{T(!0);try{await L(`/api/mcp/servers/${e.id}`,{method:`DELETE`,showLoader:`Eliminando servidor...`,showError:!0}),await a(),t()}catch{}finally{T(!1),j(!1)}},disabled:w,className:`h-7 px-3 text-[10px] font-bold uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:w?(0,$.jsx)(B,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsx)(`div`,{className:`p-6`,children:M===`config`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in duration-300`,children:[O&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-zinc-500`,children:[(0,$.jsx)(B,{className:`h-3 w-3 animate-spin`}),(0,$.jsx)(`span`,{children:`Cargando configuración...`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Transporte`}),(0,$.jsxs)(Z,{value:o,onValueChange:s,children:[(0,$.jsx)(Y,{className:`bg-white/5 border-white/10 h-9`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(q,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(q,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),o===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando`}),(0,$.jsx)(U,{value:c,onChange:e=>l(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(U,{value:u,onChange:e=>d(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(U,{value:f,onChange:e=>p(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{className:`bg-white/5 border-white/10 focus:border-cyan-500/50 h-9`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`bg-zinc-900 border-white/10`,children:[(0,$.jsx)(q,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(q,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(q,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(q,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(S,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{value:v,onChange:e=>y(e.target.value),placeholder:`{ "x-custom-auth": "secret" }`,rows:3,className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-zinc-900 border border-white/5 flex items-center justify-between mt-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-full ${z?`bg-green-500/10 text-green-400`:`bg-zinc-800 text-zinc-500`}`,children:(0,$.jsx)(Ge,{className:`h-3.5 w-3.5 ${z?`animate-pulse`:``}`})}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-[10px] font-bold text-zinc-300 uppercase tracking-tight`,children:`Estado del Nodo`}),(0,$.jsx)(`span`,{className:`text-[9px] font-mono ${z?`text-green-500`:`text-zinc-500`}`,children:z?`ACTIVE_CONNECTION`:`INACTIVE_NODE`})]})]}),(0,$.jsx)(I,{size:`sm`,variant:z?`outline`:`default`,onClick:async()=>{D(!0),R.show(z?`Desconectando servidor...`:`Conectando servidor...`);try{await r(e.id,!z),re(+!z),F(z?`disconnected`:`connected`),H.fire({icon:`success`,title:z?`Servidor desconectado`:`Servidor conectado`}),setTimeout(a,1500)}catch{H.fire({icon:`error`,title:`Error al cambiar estado de conexión`})}finally{D(!1),R.hide()}},disabled:E,className:`h-7 px-4 text-[10px] font-bold uppercase tracking-wider ${z?`border-zinc-800 text-zinc-400 hover:bg-zinc-800`:`bg-cyan-600 hover:bg-cyan-500 text-white`}`,children:E?(0,$.jsx)(B,{className:`h-3 w-3 animate-spin`}):z?`Desconectar`:`Conectar`})]})]}):(0,$.jsx)(`div`,{className:`animate-in fade-in duration-300`,children:(0,$.jsx)(et,{serverId:e.id,serverName:e.name,tools:e.tools||[]})})}),(0,$.jsxs)(Te,{className:`p-6 bg-white/[0.02] border-t border-white/5`,children:[(0,$.jsx)(I,{variant:`ghost`,onClick:t,className:`text-zinc-500 hover:text-white`,children:`Cerrar`}),M===`config`&&(0,$.jsx)(I,{onClick:async()=>{C(!0),R.show(`Actualizando configuración...`);try{let t={transport:o};if(o===`stdio`){if(!c){H.fire({icon:`warning`,title:`El comando es obligatorio`});return}t.command=c;let e=u.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else if(o===`sse`){if(!f){H.fire({icon:`warning`,title:`La URL es obligatoria`});return}t.url=f;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{H.fire({icon:`error`,title:`JSON de Headers inválido`});return}Object.keys(e).length>0&&(t.headers=e)}await n(e.id,t),await a(),H.fire({icon:`success`,title:`Configuración actualizada`})}catch(e){H.fire({icon:`error`,title:e instanceof Error?e.message:`Error al actualizar configuración`})}finally{C(!1),R.hide()}},disabled:b,className:`bg-cyan-600 hover:bg-cyan-500 text-white min-w-[120px]`,children:b?(0,$.jsx)(B,{className:`h-4 w-4 animate-spin`}):`Guardar Cambios`})]})]})})}function rt(){let{fetchMCPServers:e}=me(),[t,n]=(0,Q.useState)(!1),[r,i]=(0,Q.useState)(``),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(`stdio`),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`none`),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,C]=(0,Q.useState)(!1);return(0,$.jsxs)(Ae,{open:t,onOpenChange:n,children:[(0,$.jsx)(Ee,{asChild:!0,children:(0,$.jsxs)(I,{className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 gap-2`,children:[(0,$.jsx)(D,{className:`h-4 w-4`}),`Añadir Servidor MCP`]})}),(0,$.jsxs)(Oe,{className:`sm:max-w-[425px] border-cyan-500/20 bg-zinc-950/95 backdrop-blur-xl`,children:[(0,$.jsxs)(De,{children:[(0,$.jsxs)(ke,{className:`flex items-center gap-2 text-white`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-md bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(fe,{className:`h-4 w-4`})}),`Nuevo Servidor MCP`]}),(0,$.jsx)(G,{className:`text-zinc-400`,children:`Conecta una nueva fuente de herramientas para tus agentes mediante el protocolo MCP.`})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`mcp-name`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Nombre Identificador`}),(0,$.jsx)(U,{id:`mcp-name`,placeholder:`github-tools`,value:r,onChange:e=>i(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Protocolo de Transporte`}),(0,$.jsxs)(Z,{value:l,onValueChange:u,children:[(0,$.jsx)(Y,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(X,{placeholder:`Seleccionar transporte`})}),(0,$.jsxs)(J,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(q,{value:`stdio`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`stdio (Binario Local)`})]})}),(0,$.jsx)(q,{value:`sse`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`SSE (Remote HTTP)`})]})})]})]})]}),l===`stdio`?(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`mcp-cmd`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Comando Ejecutable`}),(0,$.jsx)(U,{id:`mcp-cmd`,placeholder:`npx`,value:a,onChange:e=>o(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`mcp-args`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Argumentos`}),(0,$.jsx)(U,{id:`mcp-args`,placeholder:`-y @modelcontextprotocol/server-github`,value:s,onChange:e=>c(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-4 animate-in fade-in slide-in-from-top-2 duration-300`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`mcp-url`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Endpoint URL`}),(0,$.jsx)(U,{id:`mcp-url`,placeholder:`https://mcp-server.com/sse`,value:f,onChange:e=>p(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9`})]}),(0,$.jsxs)(`div`,{className:`space-y-4 pt-2 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Autenticación`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{className:`bg-zinc-900/80 border-white/10 text-white focus:border-cyan-500/50 hover:bg-zinc-900 transition-all h-9 cursor-pointer`,children:(0,$.jsx)(X,{placeholder:`Seleccionar autenticación`})}),(0,$.jsxs)(J,{position:`popper`,className:`bg-zinc-900 border-white/10 z-[99999]`,sideOffset:4,children:[(0,$.jsx)(q,{value:`none`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(V,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Ninguna`})]})}),(0,$.jsx)(q,{value:`api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`API Key (x-api-key)`})]})}),(0,$.jsx)(q,{value:`bearer`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Bearer Token (Authorization)`})]})}),(0,$.jsx)(q,{value:`google-api-key`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(x,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Google API Key (X-Goog-Api-Key)`})]})}),(0,$.jsx)(q,{value:`custom`,className:`focus:bg-cyan-500/20 focus:text-cyan-400 cursor-pointer`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Be,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{children:`Custom Headers (JSON)`})]})})]})]})]}),(m===`api-key`||m===`google-api-key`||m===`bearer`)&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(K,{htmlFor:`mcp-token`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:m===`api-key`?`API Key`:m===`google-api-key`?`Google API Key`:`Bearer Token`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{id:`mcp-token`,type:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`bg-white/5 border-white/10 focus:border-cyan-500/50 transition-all h-9 pl-9`}),(0,$.jsx)(S,{className:`absolute left-3 top-2.5 h-3.5 w-3.5 text-zinc-500`})]})]}),m===`custom`&&(0,$.jsxs)(`div`,{className:`space-y-2 animate-in fade-in slide-in-from-top-1 duration-200`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(K,{htmlFor:`mcp-headers`,className:`text-[10px] font-bold text-zinc-500 uppercase tracking-widest`,children:`Headers JSON`})}),(0,$.jsx)(`textarea`,{id:`mcp-headers`,placeholder:`{ "x-custom-auth": "secret" }`,rows:3,value:v,onChange:e=>{let t=e.target.value;y(t);try{t.trim()&&JSON.parse(t.trim()),e.target.style.borderColor=``}catch{t.trim()?e.target.style.borderColor=`rgba(239, 68, 68, 0.5)`:e.target.style.borderColor=``}},className:`w-full bg-white/5 border border-white/10 rounded-md p-2 text-xs text-zinc-300 focus:outline-none focus:border-cyan-500/50 transition-all font-mono`})]})]})]}),(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-cyan-500/5 border border-cyan-500/10 flex items-center gap-3`,children:[(0,$.jsx)(d,{className:`h-5 w-5 text-cyan-500 shrink-0`}),(0,$.jsx)(`div`,{className:`text-[10px] text-cyan-200/70`,children:`El servidor se inicializará y validará inmediatamente después de ser añadido.`})]})]}),(0,$.jsxs)(Te,{children:[(0,$.jsx)(I,{variant:`ghost`,onClick:()=>n(!1),className:`hover:bg-white/5 text-zinc-400 h-9 text-xs`,children:`Cancelar`}),(0,$.jsx)(I,{onClick:async()=>{if(!r){H.fire({icon:`error`,title:`El nombre es obligatorio`});return}C(!0);try{let t={transport:l};if(l===`stdio`){if(!a){H.fire({icon:`error`,title:`El comando es obligatorio para transporte stdio`}),C(!1);return}t.command=a;let e=s.trim();if(e.startsWith(`[`)&&e.endsWith(`]`))try{t.args=JSON.parse(e)}catch{t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else t.args=e.match(/"[^"]*"|'[^']*'|[^\\s,]+/g)?.map(e=>e.replace(/^["']|["']$/g,``).replace(/,$/,``).trim()).filter(Boolean)||[]}else{if(!f){H.fire({icon:`error`,title:`La URL es obligatoria para transporte SSE`}),C(!1);return}t.url=f;let e={};if(m===`api-key`&&g)e[`x-api-key`]=g;else if(m===`google-api-key`&&g)e[`X-Goog-Api-Key`]=g;else if(m===`bearer`&&g)e.Authorization=`Bearer ${g}`;else if(m===`custom`&&v.trim())try{e=JSON.parse(v.trim())}catch{ce.fire(`Error`,`JSON de Headers inválido`,`error`),C(!1);return}Object.keys(e).length>0&&(t.headers=e)}await L(`/api/mcp/servers`,{method:`POST`,body:{name:r,config:t},showLoader:`Conectando servidor MCP...`,showError:!0}),H.fire({icon:`success`,title:`Servidor "${r}" añadido correctamente`}),i(``),o(``),c(``),p(``),h(`none`),_(``),y(``),n(!1),await e()}catch{}finally{C(!1)}},disabled:b,className:`bg-cyan-600 hover:bg-cyan-500 text-white shadow-lg shadow-cyan-600/20 h-9 text-xs px-6`,children:b?`Conectando...`:`Conectar Servidor`})]})]})]})}function it(){let{servers:e,activeServers:t,isLoading:n,fetchMCPServers:r}=me(),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{r()},[r]);let c=e.filter(e=>e.name.toLowerCase().includes(o.toLowerCase())),l=e=>{a({...e,args:typeof e.args==`string`?JSON.parse(e.args):e.args})};return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-white/5 pb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-lg bg-cyan-500/10 text-cyan-400`,children:(0,$.jsx)(fe,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h4`,{className:`text-sm font-bold text-white uppercase tracking-wider`,children:`MCP Ecosystem`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:`Model Context Protocol Servers`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(k,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-zinc-500 group-focus-within:text-cyan-400 transition-colors`}),(0,$.jsx)(U,{placeholder:`Buscar servidor...`,value:o,onChange:e=>s(e.target.value),className:`pl-9 bg-zinc-900/50 border-white/5 focus:border-cyan-500/30 transition-all h-9 w-[260px] text-xs`})]}),(0,$.jsx)(rt,{})]})]}),c.length===0?(0,$.jsxs)(`div`,{className:`py-16 flex flex-col items-center justify-center border border-dashed border-white/10 rounded-2xl bg-zinc-950/20 group hover:border-cyan-500/20 transition-colors`,children:[(0,$.jsx)(`div`,{className:`p-4 rounded-full bg-zinc-900 mb-4 group-hover:scale-110 transition-transform`,children:(0,$.jsx)(oe,{className:`h-8 w-8 text-zinc-700 group-hover:text-cyan-500/50 transition-colors`})}),(0,$.jsx)(`p`,{className:`text-xs text-zinc-500 font-medium`,children:`No se detectan servidores MCP configurados.`}),(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-600 mt-1`,children:`Añade uno para expandir las capacidades de tus agentes.`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:c.map(e=>(0,$.jsx)($e,{server:e,isConnected:e.status===`connected`||e.active===!0,onClick:()=>l(e)},e.id))}),i&&(0,$.jsx)(nt,{server:i,onClose:()=>a(null)})]})}var at=ne((e,t)=>({notes:[],scheduledTasks:[],taskHistory:{},cronChannels:[],cronRecommended:`webchat`,cronUserPreference:`auto`,isLoading:!1,error:null,fetchNotes:async()=>{e({isLoading:!0,error:null});try{e({notes:(await L(`/api/notes`)).notes,isLoading:!1})}catch(t){e({error:t.message,isLoading:!1})}},fetchScheduledTasks:async t=>{e({isLoading:!0,error:null});try{e({scheduledTasks:(await L(t?`/api/cron?status=${t}`:`/api/cron`)).tasks??[],isLoading:!1})}catch(t){e({error:t.message,isLoading:!1,scheduledTasks:[]})}},pauseTask:async t=>{try{await L(`/api/cron/${t}/pause`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`paused`}:e)}))}catch(t){e({error:t.message})}},resumeTask:async t=>{try{await L(`/api/cron/${t}/resume`,{method:`POST`}),e(e=>({scheduledTasks:e.scheduledTasks.map(e=>e.id===t?{...e,status:`active`}:e)}))}catch(t){e({error:t.message})}},deleteTask:async t=>{try{await L(`/api/cron/${t}`,{method:`DELETE`}),e(e=>({scheduledTasks:e.scheduledTasks.filter(e=>e.id!==t)}))}catch(t){e({error:t.message})}},triggerTask:async t=>{try{await L(`/api/cron/${t}/trigger`,{method:`POST`})}catch(t){e({error:t.message})}},fetchTaskHistory:async(t,n=10)=>{try{let r=await L(`/api/cron/${t}/history?limit=${n}`);e(e=>({taskHistory:{...e.taskHistory,[t]:r.history??[]}}))}catch(t){e({error:t.message})}},fetchCronChannels:async()=>{try{let t=await L(`/api/cron/channels`),n=[];Array.isArray(t.channels)&&(n=t.channels.map(e=>typeof e==`string`?{id:e,type:e,active:!0,recommended:e===`webchat`||e===`telegram`}:e)),e({cronChannels:n,cronRecommended:`webchat`,cronUserPreference:t.preference??`auto`})}catch{}},saveCronChannelPreference:async t=>{try{await L(`/api/user/settings`,{method:`PATCH`,body:{preferred_cron_channel:t}}),e({cronUserPreference:t})}catch(t){e({error:t.message})}}}));function ot({email:e,profileEditing:t=!1}){let[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),[o,c]=(0,Q.useState)(!0),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),[p,h]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{j()},[]);async function j(){c(!0);try{let e=await L(`/api/auth/status`);r(e.hasCredentials),a(e.email??``)}catch{}finally{c(!1)}}async function M(){if(!t){u(!0);try{f((await L(`/api/auth/recovery-key`)).recoveryKey)}catch{}}}function N(){y(``),S(``),w(``)}async function ee(e){if(e.preventDefault(),v!==x){await ce.fire({icon:`error`,title:`Error`,text:`Las contraseñas no coinciden`});return}if(v.length<8){await ce.fire({icon:`error`,title:`Error`,text:`La contraseña debe tener al menos 8 caracteres`});return}A(!0);try{n?await L(`/api/auth/change-password`,{method:`POST`,body:{currentPassword:C,newPassword:v}}):await L(`/api/auth/setup-credentials`,{method:`POST`,body:{password:v}}),await ce.fire({icon:`success`,title:n?`Contraseña actualizada`:`Protección activada`,timer:2200,showConfirmButton:!1,toast:!0,position:`top-end`}),N(),u(!1),await j()}catch{}finally{A(!1)}}async function P(){if((await ce.fire({title:`¿Desactivar protección?`,text:`Cualquiera con acceso a la URL podrá usar Hive sin contraseña.`,icon:`warning`,showCancelButton:!0,confirmButtonText:`Sí, desactivar`,cancelButtonText:`Cancelar`})).isConfirmed)try{await L(`/api/auth/disable`,{method:`POST`}),await ce.fire({icon:`success`,title:`Protección desactivada`,timer:1800,showConfirmButton:!1,toast:!0,position:`top-end`}),r(!1),a(``),N(),u(!1)}catch{}}async function te(){d&&(await navigator.clipboard.writeText(d),h(!0),window.setTimeout(()=>h(!1),2e3))}let F=i||e.trim().toLowerCase();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border p-3.5 sm:flex-row sm:items-center sm:justify-between`,style:{background:`hsl(var(--hive-glass))`,borderColor:n?`hsl(var(--hive-green) / 0.25)`:`hsl(var(--hive-border-base))`},children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`mt-0.5 rounded-lg border p-2`,style:{color:n?`hsl(var(--hive-green))`:`hsl(var(--hive-amber))`,background:n?`hsl(var(--hive-green) / 0.08)`:`hsl(var(--hive-amber) / 0.08)`,borderColor:n?`hsl(var(--hive-green) / 0.18)`:`hsl(var(--hive-amber) / 0.18)`},children:n?(0,$.jsx)(qe,{className:`h-4 w-4`}):(0,$.jsx)(Je,{className:`h-4 w-4`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-xs font-bold text-white`,children:`Acceso con contraseña`}),(0,$.jsx)(`p`,{className:`mt-0.5 truncate text-[11px]`,style:{color:`hsl(var(--hive-text-muted))`},children:o?`Comprobando protección…`:n?`Protegido · ${F}`:F?`Sin contraseña · ${F}`:`Guarda un correo válido para activar la protección`})]})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>void M(),disabled:o||t||!F,className:`flex h-9 flex-shrink-0 items-center justify-center gap-1.5 rounded-lg px-3 text-[11px] font-bold transition-colors disabled:cursor-not-allowed disabled:opacity-45`,style:{background:`hsl(var(--hive-amber) / 0.12)`,border:`1px solid hsl(var(--hive-amber) / 0.3)`,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(b,{className:`h-3.5 w-3.5`}),t?`Guarda el perfil primero`:n?`Gestionar acceso`:`Crear contraseña`]})]}),(0,$.jsx)(Ae,{open:l,onOpenChange:e=>{u(e),e||N()},children:(0,$.jsxs)(Oe,{className:`overflow-hidden rounded-2xl p-0`,style:{background:`hsl(var(--hive-surface))`,borderColor:`hsl(var(--hive-border-base))`},children:[(0,$.jsx)(`div`,{className:`border-b px-6 py-5`,style:{background:`linear-gradient(135deg, hsl(var(--hive-amber) / 0.12), transparent 65%)`,borderColor:`hsl(var(--hive-border-subtle))`},children:(0,$.jsxs)(De,{children:[(0,$.jsx)(`div`,{className:`mb-2 flex h-10 w-10 items-center justify-center rounded-xl border`,style:{color:`hsl(var(--hive-amber))`,background:`hsl(var(--hive-amber) / 0.1)`,borderColor:`hsl(var(--hive-amber) / 0.25)`},children:(0,$.jsx)(Ue,{className:`h-5 w-5`})}),(0,$.jsx)(ke,{children:n?`Cambiar contraseña`:`Proteger tu instancia`}),(0,$.jsxs)(G,{children:[`Tu identidad de acceso será `,(0,$.jsx)(`span`,{className:`font-semibold text-foreground`,children:F}),`.`]})]})}),(0,$.jsxs)(`form`,{onSubmit:ee,className:`space-y-4 px-6 pb-6`,children:[n&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-current-password`,children:`Contraseña actual`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{id:`profile-current-password`,type:T?`text`:`password`,autoComplete:`current-password`,value:C,onChange:e=>w(e.target.value),required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":T?`Ocultar contraseña actual`:`Mostrar contraseña actual`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>E(e=>!e),children:T?(0,$.jsx)(g,{className:`h-4 w-4`}):(0,$.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-new-password`,children:n?`Nueva contraseña`:`Contraseña`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{id:`profile-new-password`,type:D?`text`:`password`,autoComplete:`new-password`,placeholder:`Mínimo 8 caracteres`,value:v,onChange:e=>y(e.target.value),minLength:8,required:!0,disabled:k,className:`pr-10`}),(0,$.jsx)(`button`,{type:`button`,"aria-label":D?`Ocultar contraseña nueva`:`Mostrar contraseña nueva`,className:`absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground transition-colors hover:text-foreground`,onClick:()=>O(e=>!e),children:D?(0,$.jsx)(g,{className:`h-4 w-4`}):(0,$.jsx)(_,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(K,{htmlFor:`profile-confirm-password`,children:`Confirmar contraseña`}),(0,$.jsx)(U,{id:`profile-confirm-password`,type:D?`text`:`password`,autoComplete:`new-password`,value:x,onChange:e=>S(e.target.value),minLength:8,required:!0,disabled:k})]}),d&&(0,$.jsxs)(`div`,{className:`rounded-xl border p-3`,style:{background:`hsl(var(--hive-glass))`,borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsx)(`p`,{className:`text-[11px] font-bold`,children:`Clave de recuperación`}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground`,children:`Guárdala fuera de este equipo por si olvidas tu contraseña.`}),(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,$.jsx)(`code`,{className:`min-w-0 flex-1 truncate rounded-md bg-black/20 px-2.5 py-2 text-[10px]`,children:d}),(0,$.jsx)(I,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Copiar clave de recuperación`,onClick:()=>void te(),children:p?(0,$.jsx)(s,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(m,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(Te,{className:`gap-2 pt-1 sm:justify-between`,children:[n?(0,$.jsx)(I,{type:`button`,variant:`ghost`,className:`text-destructive`,onClick:()=>void P(),disabled:k,children:`Desactivar protección`}):(0,$.jsx)(`span`,{}),(0,$.jsxs)(I,{type:`submit`,disabled:k,children:[k&&(0,$.jsx)(B,{className:`mr-2 h-4 w-4 animate-spin`}),n?`Actualizar contraseña`:`Activar protección`]})]})]})]})})]})}var st=()=>(0,$.jsxs)(`svg`,{"aria-hidden":!0,className:`absolute inset-0 w-full h-full pointer-events-none`,xmlns:`http://www.w3.org/2000/svg`,style:{opacity:.05,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(`defs`,{children:(0,$.jsx)(`pattern`,{id:`hc-profile`,x:`0`,y:`0`,width:`30`,height:`34`,patternUnits:`userSpaceOnUse`,children:(0,$.jsx)(`polygon`,{points:`15,2 28,9.5 28,24.5 15,32 2,24.5 2,9.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})})}),(0,$.jsx)(`rect`,{width:`100%`,height:`100%`,fill:`url(#hc-profile)`})]}),ct=({initials:e,size:t=`lg`})=>{let n=t===`sm`?`w-14 h-14`:`w-20 h-20`,r=t===`sm`?`text-lg`:`text-2xl`;return(0,$.jsxs)(`div`,{className:`relative ${n} flex-shrink-0`,children:[(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-white font-black ${r} tracking-tight select-none`,style:{clipPath:`polygon(50% 0%, 95% 25%, 95% 75%, 50% 100%, 5% 75%, 5% 25%)`,background:`linear-gradient(135deg, hsl(var(--hive-amber)) 0%, hsl(var(--hive-orange)) 100%)`,boxShadow:`0 0 24px hsl(var(--hive-amber) / 0.4)`},children:e}),(0,$.jsx)(`span`,{className:`absolute bottom-0.5 right-1 h-3.5 w-3.5 rounded-full border-2 animate-pulse`,style:{background:`hsl(var(--hive-green))`,borderColor:`hsl(var(--background))`,boxShadow:`0 0 8px hsl(var(--hive-green) / 0.6)`}})]})},lt=({children:e})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2.5`,children:[(0,$.jsx)(re,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(--hive-amber))`,fill:`hsl(var(--hive-amber) / 0.2)`}}),(0,$.jsx)(`p`,{className:`text-[10px] font-black uppercase tracking-[0.18em]`,style:{color:`hsl(var(--hive-amber) / 0.85)`},children:e})]}),ut=()=>(0,$.jsx)(`div`,{className:`h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.18),transparent)`}}),dt=({icon:e,label:t,colorVar:n})=>(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-0.5 rounded-full text-[10px] font-medium border`,style:{background:`hsl(var(${n}) / 0.08)`,borderColor:`hsl(var(${n}) / 0.2)`,color:`hsl(var(${n}))`},children:[(0,$.jsx)(e,{className:`h-2.5 w-2.5 flex-shrink-0`}),t]}),ft=({label:e,icon:t,editing:n,children:r})=>(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] font-bold uppercase tracking-widest transition-colors`,style:{color:n?`hsl(var(--hive-text-muted))`:`hsl(var(--hive-text-placeholder))`},children:[(0,$.jsx)(t,{className:`h-3 w-3 opacity-60`}),e]}),r]});function pt(e){return e.split(` `).map(e=>e[0]).slice(0,2).join(``).toUpperCase()||`?`}function mt(){let{fetchUser:e,saveUser:t,isLoading:n}=se(),{cronChannels:r,fetchCronChannels:i}=at(),[a,o]=(0,Q.useState)(!1),[c,l]=(0,Q.useState)({name:``,email:``,occupation:``,language:``,timezone:``,preferred_cron_channel:`auto`,notes:``}),[u,d]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{e().then(e=>{if(!e)return;let t={name:e.name||``,email:e.email||``,occupation:e.occupation||``,language:e.language||``,timezone:e.timezone||``,preferred_cron_channel:e.preferred_cron_channel||`auto`,notes:e.notes||``};l(t),d(t)}).catch(console.error),i()},[e,i]);let f=(e,t)=>l(n=>({...n,[e]:t})),p=()=>{u&&l(u),o(!1)},m=async()=>{let e=c.email.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){H.fire({icon:`error`,title:`Ingresa un correo válido`});return}R.show(`Guardando perfil...`);try{let n={...c,email:e},r=await t(n);l(n),d(n),H.fire({icon:`success`,title:r}),o(!1)}catch(e){H.fire({icon:`error`,title:e instanceof Error?e.message:`Error al guardar`})}finally{R.hide()}},h=r.filter(e=>e.active),g=c.preferred_cron_channel===`auto`?`Auto — detectar mejor canal`:h.find(e=>e.id===c.preferred_cron_channel)?.type??c.preferred_cron_channel,_=pt(c.name);return(0,$.jsxs)(`div`,{className:`relative overflow-hidden rounded-2xl border flex flex-col lg:flex-row`,style:{background:`hsl(var(--hive-surface)/0.7)`,borderColor:`hsl(var(--hive-border-base))`,backdropFilter:`blur(16px)`,boxShadow:`0 0 60px hsl(var(--hive-amber)/0.05)`},children:[(0,$.jsxs)(`div`,{className:`relative overflow-hidden flex-shrink-0 lg:w-[40%] lg:flex-col lg:items-center lg:text-center
|
|
2
|
-
|
|
3
|
-
/* mobile: horizontal compact row */
|
|
4
|
-
flex flex-row items-center gap-4 p-4
|
|
5
|
-
/* tablet: slightly more padding */
|
|
6
|
-
sm:p-5
|
|
7
|
-
/* desktop: vertical centered column */
|
|
8
|
-
lg:flex-col lg:items-center lg:text-center lg:gap-4 lg:p-6`,style:{background:`hsl(220 15% 10% / 0.85)`},children:[(0,$.jsx)(st,{}),(0,$.jsx)(`div`,{className:`absolute -top-16 -left-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-amber)/0.1)`}}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px lg:hidden`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-amber)/0.3),transparent)`}}),(0,$.jsx)(`div`,{className:`absolute top-0 right-0 bottom-0 w-px hidden lg:block`,style:{background:`linear-gradient(to bottom,transparent,hsl(var(--hive-amber)/0.25),transparent)`}}),(0,$.jsxs)(`div`,{className:`relative w-full hidden lg:flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-1.5 rounded-full animate-pulse`,style:{background:`hsl(var(--hive-amber))`,boxShadow:`0 0 6px hsl(var(--hive-amber))`}}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-[0.25em] uppercase`,style:{color:`hsl(var(--hive-amber)/0.7)`},children:`HIVE OS`})]}),(0,$.jsx)(`span`,{className:`text-[8px] font-mono uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`v1.0`})]}),(0,$.jsxs)(`div`,{className:`relative flex-shrink-0 lg:mx-auto`,children:[(0,$.jsx)(`div`,{className:`block lg:hidden`,children:(0,$.jsx)(ct,{initials:_,size:`sm`})}),(0,$.jsx)(`div`,{className:`hidden lg:block`,children:(0,$.jsx)(ct,{initials:_,size:`lg`})})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 lg:flex-none lg:w-full space-y-1 lg:text-center`,children:[(0,$.jsx)(`h3`,{className:`text-sm sm:text-base font-bold text-white leading-tight`,children:c.name||(0,$.jsx)(`span`,{className:`text-sm font-normal italic`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Sin nombre`})}),c.occupation&&(0,$.jsx)(`p`,{className:`text-xs`,style:{color:`hsl(var(--hive-text-muted))`},children:c.occupation}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 lg:justify-center pt-0.5`,children:[c.language&&(0,$.jsx)(dt,{icon:V,label:c.language,colorVar:`--hive-blue`}),c.timezone&&(0,$.jsx)(dt,{icon:Se,label:c.timezone,colorVar:`--hive-blue`}),c.preferred_cron_channel!==`auto`&&(0,$.jsx)(dt,{icon:he,label:c.preferred_cron_channel,colorVar:`--hive-purple`})]})]}),(0,$.jsx)(`div`,{className:`relative hidden sm:grid sm:grid-cols-2 lg:grid-cols-1 lg:w-full gap-x-4 gap-y-2
|
|
9
|
-
sm:mt-0 lg:mt-auto lg:pt-4 lg:border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[{icon:be,label:`Agente`,value:`Activo`,colorVar:`--hive-green`},{icon:V,label:`Idioma`,value:c.language||`—`,colorVar:`--hive-blue`},{icon:Se,label:`Zona`,value:c.timezone||`—`,colorVar:`--hive-blue`},{icon:P,label:`Canal`,value:g.split(`—`)[0].trim(),colorVar:`--hive-amber`}].map(({icon:e,label:t,value:n,colorVar:r})=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(e,{className:`h-3 w-3 flex-shrink-0`,style:{color:`hsl(var(${r}))`}}),(0,$.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-widest`,style:{color:`hsl(var(--hive-text-placeholder))`},children:t})]}),(0,$.jsx)(`span`,{className:`text-[10px] font-semibold truncate max-w-[90px] text-right`,style:{color:`hsl(var(--hive-surface-foreground)/0.7)`},children:n})]},t))})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 flex flex-col overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -bottom-16 -right-16 w-48 h-48 rounded-full blur-[80px] pointer-events-none`,style:{background:`hsl(var(--hive-blue)/0.07)`}}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 sm:px-5 pt-4 pb-3 border-b`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`div`,{className:`p-1.5 rounded-lg border flex-shrink-0`,style:{background:`hsl(var(--hive-amber)/0.1)`,borderColor:`hsl(var(--hive-amber)/0.2)`,color:`hsl(var(--hive-amber))`},children:(0,$.jsx)(z,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-[11px] font-black uppercase tracking-[0.18em] truncate`,style:{color:`hsl(var(--hive-amber))`},children:`Perfil de usuario`}),(0,$.jsx)(`p`,{className:`text-[9px] mt-0.5 hidden sm:block`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`Configuración personal y preferencias del agente`})]})]}),(0,$.jsxs)(`button`,{onClick:()=>a?p():o(!0),className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-semibold transition-all duration-200 flex-shrink-0 ml-2`,style:a?{background:`hsl(var(--hive-red-dark)/0.15)`,border:`1px solid hsl(var(--hive-red)/0.3)`,color:`hsl(var(--hive-red))`}:{background:`hsl(var(--hive-glass))`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[a?(0,$.jsx)(ie,{className:`h-3 w-3`}):(0,$.jsx)(C,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:a?`Cancelar`:`Editar`})]})]}),(0,$.jsxs)(`div`,{className:`relative flex-1 overflow-y-auto p-4 sm:p-5 space-y-4`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(lt,{children:`Identidad`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(ft,{label:`Nombre completo`,icon:z,editing:a,children:(0,$.jsx)(U,{placeholder:`John Doe`,value:c.name,disabled:!a,onChange:e=>f(`name`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(ft,{label:`Ocupación`,icon:Re,editing:a,children:(0,$.jsx)(U,{placeholder:`AI Engineer`,value:c.occupation,disabled:!a,onChange:e=>f(`occupation`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,$.jsx)(ft,{label:`Correo propio`,icon:w,editing:a,children:(0,$.jsx)(U,{type:`email`,autoComplete:`email`,placeholder:`tu@correo.com`,maxLength:254,required:!0,value:c.email,disabled:!a,onChange:e=>f(`email`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(`p`,{className:`mt-1.5 text-[10px]`,style:{color:`hsl(var(--hive-text-placeholder))`},children:`El coordinador lo usa como destinatario cuando dices «envíame».`})]})]})]}),(0,$.jsx)(ut,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(lt,{children:`Acceso y seguridad`}),(0,$.jsx)(ot,{email:c.email,profileEditing:a})]}),(0,$.jsx)(ut,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(lt,{children:`Localización`}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2.5`,children:[(0,$.jsx)(ft,{label:`Idioma`,icon:V,editing:a,children:(0,$.jsx)(U,{placeholder:`Spanish`,value:c.language,disabled:!a,onChange:e=>f(`language`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})}),(0,$.jsx)(ft,{label:`Zona horaria`,icon:Se,editing:a,children:(0,$.jsx)(U,{placeholder:`America/Bogota`,value:c.timezone,disabled:!a,onChange:e=>f(`timezone`,e.target.value),className:`hive-input h-9 text-sm rounded-lg disabled:opacity-50 disabled:cursor-default`})})]})]}),(0,$.jsx)(ut,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(lt,{children:`Notificaciones`}),(0,$.jsx)(ft,{label:`Canal para Cron Jobs`,icon:he,editing:a,children:(0,$.jsxs)(Z,{value:c.preferred_cron_channel,onValueChange:e=>f(`preferred_cron_channel`,e),disabled:!a,children:[(0,$.jsx)(Y,{className:`hive-select-trigger h-9 text-sm rounded-lg disabled:opacity-50`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{className:`hive-select-content`,children:[(0,$.jsx)(q,{value:`auto`,className:`hive-select-item text-sm`,children:`Auto — detectar mejor canal`}),h.map(e=>(0,$.jsx)(q,{value:e.id,className:`hive-select-item text-sm`,children:e.id===`webchat`?`Web Chat`:e.id===`telegram`?`Telegram`:e.id===`discord`?`Discord`:e.id===`slack`?`Slack`:e.id===`whatsapp`?`WhatsApp`:e.id},e.id))]})]})})]}),(0,$.jsx)(ut,{}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(lt,{children:`Contexto para el agente`}),(0,$.jsx)(je,{placeholder:`Describe tu perfil, preferencias de trabajo, estilo de comunicación...`,value:c.notes,disabled:!a,onChange:e=>f(`notes`,e.target.value),className:`hive-textarea text-sm rounded-lg min-h-[80px] disabled:opacity-50 disabled:cursor-default`})]})]}),(0,$.jsx)(`div`,{className:`px-4 sm:px-5 py-3 flex items-center justify-end gap-2 border-t`,style:{borderColor:`hsl(var(--hive-border-subtle))`},children:a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:p,className:`flex items-center gap-1.5 h-9 px-3 sm:px-4 rounded-lg text-xs font-semibold transition-all`,style:{background:`transparent`,border:`1px solid hsl(var(--hive-border-base))`,color:`hsl(var(--hive-text-muted))`},children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Cancelar`})]}),(0,$.jsxs)(`button`,{onClick:m,disabled:n,className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold text-white transition-all disabled:opacity-60`,style:{background:`hsl(var(--hive-blue-dark))`,boxShadow:`var(--shadow-btn-primary)`},children:[n?(0,$.jsx)(B,{className:`h-3.5 w-3.5 animate-spin`}):(0,$.jsx)(s,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Guardar cambios`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Guardar`})]})]}):(0,$.jsxs)(`button`,{onClick:()=>o(!0),className:`flex items-center gap-1.5 h-9 px-4 sm:px-5 rounded-lg text-xs font-bold transition-all`,style:{background:`hsl(var(--hive-amber)/0.12)`,border:`1px solid hsl(var(--hive-amber)/0.3)`,color:`hsl(var(--hive-amber))`},children:[(0,$.jsx)(C,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Editar perfil`}),(0,$.jsx)(`span`,{className:`sm:hidden`,children:`Editar`})]})}),(0,$.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-px`,style:{background:`linear-gradient(90deg,transparent,hsl(var(--hive-blue)/0.3),transparent)`}})]})]})}var ht=e=>{let t=e.toLowerCase();return t.includes(`code`)||t.includes(`program`)?(0,$.jsx)(f,{className:`h-5 w-5`}):t.includes(`research`)||t.includes(`investiga`)?(0,$.jsx)(k,{className:`h-5 w-5`}):t.includes(`write`)||t.includes(`escrib`)?(0,$.jsx)(de,{className:`h-5 w-5`}):t.includes(`data`)||t.includes(`anal`)||t.includes(`estad`)?(0,$.jsx)(ze,{className:`h-5 w-5`}):t.includes(`trans`)||t.includes(`traduc`)?(0,$.jsx)(He,{className:`h-5 w-5`}):t.includes(`web`)||t.includes(`glob`)||t.includes(`scrape`)?(0,$.jsx)(V,{className:`h-5 w-5`}):t.includes(`tool`)||t.includes(`herram`)?(0,$.jsx)(le,{className:`h-5 w-5`}):t.includes(`cpu`)||t.includes(`proc`)?(0,$.jsx)(h,{className:`h-5 w-5`}):(0,$.jsx)(P,{className:`h-5 w-5`})},gt=e=>e?e.split(`,`).filter(Boolean).length:0,_t=e=>e?e.split(`,`).filter(Boolean).length:0;function vt({skill:e,onClick:t,className:n}){let r=!!e.active,i=gt(e.tools),a=_t(e.triggers);return(0,$.jsxs)(`div`,{onClick:t,className:`hive-card group cursor-pointer transition-all duration-300 hover:scale-[1.02] ${r?`hive-card--active`:`hive-card--disabled`} ${n}`,children:[(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest text-white/30 bg-white/5 border border-white/5 rounded-full px-2.5 py-1`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),e.category||`GENERAL`]}),r&&(0,$.jsxs)(`span`,{className:`flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute h-2 w-2 rounded-full bg-blue-400 opacity-40`}),(0,$.jsx)(`span`,{className:`relative h-2 w-2 rounded-full bg-blue-500`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,$.jsx)(`div`,{className:`shrink-0 h-12 w-12 rounded-xl flex items-center justify-center border transition-all duration-300 ${r?`bg-blue-500/10 border-blue-500/30 text-blue-400 shadow-[0_0_12px_hsl(217_91%_60%/0.2)]`:`bg-white/5 border-white/10 text-white/25`}`,children:ht(e.name)}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-black uppercase tracking-tight line-clamp-1 transition-colors ${r?`text-white group-hover:text-blue-400`:`text-white/40`}`,children:e.name}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/30 leading-relaxed line-clamp-2 mt-1`,children:e.body?.substring(0,90)||`Sin descripción`})]})]}),(0,$.jsxs)(`div`,{className:`pt-3 border-t border-white/5 flex items-center gap-2 flex-wrap`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-amber-400/70 bg-amber-500/5 border border-amber-500/10 rounded px-2 py-0.5`,children:[`v`,e.version??1]}),i>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-cyan-400/70 bg-cyan-500/5 border border-cyan-500/10 rounded px-2 py-0.5`,children:[i,` TOOLS`]}),a>0&&(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-black tracking-widest uppercase text-purple-400/70 bg-purple-500/5 border border-purple-500/10 rounded px-2 py-0.5`,children:[a,` TRIGGERS`]}),(0,$.jsx)(`div`,{className:`ml-auto opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,$.jsx)(M,{className:`h-3 w-3 text-blue-400`})})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${r?`bg-blue-500`:`bg-white/5`}`})]})}var yt={name:``,body:``,tools:``,triggers:``,category:``,version:1,active:!0};function bt(){let{skills:e,isLoading:t,fetchSkills:n,toggleSkill:r,updateSkill:i}=Ce(),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(`TODOS`),[l,u]=(0,Q.useState)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(yt),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),O=(0,Q.useRef)(null),A=()=>{let e=O.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight}px`)};(0,Q.useEffect)(()=>{if(!l&&!d)return;let e=setTimeout(A,0);return()=>clearTimeout(e)},[l,d,p.body]),(0,Q.useEffect)(()=>{n()},[n]),(0,Q.useEffect)(()=>{if(e.length>0)return;let t=!1;return L(`/api/system/runtime`,{showError:!1}).then(e=>{t||E(e)}).catch(()=>{t||E(null)}),()=>{t=!0}},[e.length]);let j=(0,Q.useMemo)(()=>{let t=new Set(e.map(e=>(e.category||`GENERAL`).toUpperCase()));return[`TODOS`,...Array.from(t).sort()]},[e]),N=(0,Q.useMemo)(()=>{let t=a.toLowerCase();return e.filter(e=>{let n=!t||e.name.toLowerCase().includes(t)||(e.category||``).toLowerCase().includes(t)||(e.body||``).toLowerCase().includes(t),r=s===`TODOS`||(e.category||`GENERAL`).toUpperCase()===s;return n&&r})},[e,a,s]),P=e.filter(e=>e.active).length,te=async(e,t)=>{if(!g){_(e);try{await r(e,t),await n(),H.fire({icon:`success`,title:t?`Skill habilitado`:`Skill deshabilitado`})}catch{H.fire({icon:`error`,title:`Error al cambiar estado del skill`})}finally{_(null)}}},F=async()=>{if(l){w(!0);try{await L(`/api/skills/${l.id}`,{method:`DELETE`,showError:!0}),H.fire({icon:`success`,title:`Skill eliminado`}),n(),u(null)}catch{H.fire({icon:`error`,title:`Error al eliminar skill`})}finally{w(!1),S(!1)}}},ne=e=>{f(!1),S(!1),u(e),m({name:e.name,body:e.body||``,tools:e.tools||``,triggers:e.triggers||``,category:e.category||``,version:Number(e.version)||1,active:!!e.active})},re=()=>{u(null),S(!1),m(yt),f(!0)},z=()=>{u(null),f(!1),S(!1)},ae=async()=>{b(!0),R.show(d?`Creando skill...`:`Guardando skill...`);try{d?(await L(`/api/skills`,{method:`POST`,body:p,showError:!0}),H.fire({icon:`success`,title:`Skill creado correctamente`})):l&&(await i(l.id,p),H.fire({icon:`success`,title:`Skill actualizado correctamente`})),n(),z()}catch{H.fire({icon:`error`,title:d?`Error al crear skill`:`Error al actualizar skill`})}finally{b(!1),R.hide()}},oe=!!l||d;return t&&e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(B,{className:`h-10 w-10 animate-spin text-primary/40`}),(0,$.jsx)(M,{className:`h-4 w-4 text-primary absolute -top-1 -right-1 animate-pulse`})]}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground animate-pulse`,children:`Cargando habilidades del sistema...`})]}):(0,$.jsxs)(`div`,{className:`space-y-6 animate-in fade-in duration-500`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-start justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-1.5`,children:[(0,$.jsx)(ue,{className:`h-4 w-4 text-blue-400`}),(0,$.jsx)(`h3`,{className:`hive-title-section !text-lg`,children:`Habilidades del Sistema`}),(0,$.jsxs)(`span`,{className:`hive-tag bg-blue-500/10 text-blue-400 border-blue-500/20`,children:[P,` ACTIVAS`]}),(0,$.jsxs)(`span`,{className:`hive-tag bg-white/5 text-white/30 border-white/5`,children:[e.length,` TOTAL`]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle !mt-0 !text-xs`,children:`Gestiona los módulos cognitivos que otorgan capacidades autónomas a tus agentes.`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(k,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-white/20`}),(0,$.jsx)(U,{value:a,onChange:e=>o(e.target.value),placeholder:`Buscar habilidad...`,className:`pl-8 pr-8 h-8 w-52 bg-white/5 border-white/10 text-white text-xs placeholder:text-white/20 focus-visible:ring-blue-500/30`}),a&&(0,$.jsx)(`button`,{type:`button`,"aria-label":`Limpiar búsqueda`,onClick:()=>o(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-white/20 hover:text-white/60 transition-colors`,children:(0,$.jsx)(ie,{className:`h-3 w-3`})})]}),(0,$.jsxs)(I,{onClick:re,className:`h-8 bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest uppercase px-4 shadow-btn-primary`,children:[(0,$.jsx)(D,{className:`h-3.5 w-3.5 mr-1.5`}),`Nueva Habilidad`]})]})]}),e.length>0&&(0,$.jsx)(`div`,{className:`flex items-center gap-2 overflow-x-auto pb-1 scrollbar-none`,children:j.map(t=>{let n=t===`TODOS`?e.length:e.filter(e=>(e.category||`GENERAL`).toUpperCase()===t).length,r=s===t;return(0,$.jsxs)(`button`,{onClick:()=>c(t),className:`shrink-0 inline-flex items-center gap-1.5 text-[9px] font-black uppercase tracking-widest px-3 py-1.5 rounded-full border transition-all duration-200 ${r?`bg-blue-500/15 border-blue-500/40 text-blue-400 shadow-[0_0_8px_hsl(217_91%_60%/0.15)]`:`bg-white/5 border-white/10 text-white/30 hover:text-white/60 hover:border-white/20`}`,children:[(0,$.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-blue-400`:`bg-white/20`}`}),t,(0,$.jsxs)(`span`,{className:`text-[8px] ${r?`text-blue-300/70`:`text-white/20`}`,children:[`(`,n,`)`]})]},t)})}),e.length===0?(0,$.jsx)(`div`,{className:`hive-card border-dashed border-white/10 bg-white/[0.02]`,children:(0,$.jsxs)(`div`,{className:`hive-card-body flex flex-col items-center justify-center py-16 px-4`,children:[(0,$.jsx)(`div`,{className:`h-16 w-16 rounded-2xl bg-white/5 flex items-center justify-center mb-6`,children:(0,$.jsx)(ue,{className:`h-8 w-8 text-white/20`})}),(0,$.jsx)(`p`,{className:`hive-title-section text-center mb-2`,children:`No se detectan habilidades`}),(0,$.jsx)(`p`,{className:`text-xs text-white/40 mb-8 max-w-[300px] mx-auto leading-relaxed text-center`,children:`El repositorio de habilidades está vacío. Revisa el estado del gateway antes de crear una habilidad.`}),T&&(0,$.jsxs)(`div`,{className:`mb-8 max-w-xl rounded-lg border border-amber-500/20 bg-amber-500/5 px-4 py-3 text-left text-[11px] text-amber-100/70`,children:[(0,$.jsxs)(`p`,{className:`font-semibold text-amber-200`,children:[`Diagnóstico del runtime `,T.version]}),(0,$.jsxs)(`p`,{className:`mt-1 font-mono break-all`,children:[`HIVE_HOME: `,T.hiveHome]}),(0,$.jsxs)(`p`,{className:`mt-1`,children:[T.skills.total,` skills detectadas, `,T.skills.active,` activas.`,!T.healthy&&` Faltan dependencias del catálogo A2UI.`]}),(0,$.jsxs)(`p`,{className:`mt-1`,children:[`Requeridas ausentes/inactivas: `,T.skills.required.reduce((e,t)=>((!t.present||!t.active)&&e.push(t.name),e),[]).join(`, `)||`ninguna`]})]}),(0,$.jsxs)(I,{onClick:re,className:`hive-btn hive-btn--primary px-8`,children:[(0,$.jsx)(D,{className:`h-4 w-4 mr-2`}),`Crear Habilidad`]})]})}):N.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-16 space-y-3 text-center`,children:[(0,$.jsx)(k,{className:`h-8 w-8 text-white/10`}),(0,$.jsx)(`p`,{className:`text-sm font-bold text-white/30 uppercase tracking-widest`,children:`Sin resultados`}),(0,$.jsxs)(`p`,{className:`text-xs text-white/20`,children:[`No hay habilidades que coincidan con “`,a,`”`,s!==`TODOS`&&` en la categoría ${s}`,`.`]}),(0,$.jsx)(`button`,{onClick:()=>{o(``),c(`TODOS`)},className:`text-[10px] font-black uppercase tracking-widest text-blue-400/60 hover:text-blue-400 transition-colors mt-2`,children:`Limpiar filtros`})]}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-5`,children:N.map(e=>(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(vt,{skill:e,onClick:()=>ne(e)}),(0,$.jsxs)(`div`,{className:`absolute top-5 right-5 z-20 pointer-events-auto flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${e.active?`text-blue-400`:`text-white/20`}`,children:e.active?`ON`:`OFF`}),(0,$.jsx)(Me,{checked:!!e.active,disabled:g===e.id,onClick:e=>e.stopPropagation(),onCheckedChange:t=>te(e.id,t),className:`scale-75 data-[state=checked]:bg-blue-500`})]})]},e.id))}),(0,$.jsx)(Ae,{open:oe,onOpenChange:e=>{e||z()},children:(0,$.jsxs)(Oe,{className:`max-w-3xl bg-zinc-950 border-white/10 text-white p-0 overflow-hidden shadow-2xl`,children:[(0,$.jsx)(`div`,{className:`p-6 border-b border-white/5 bg-white/[0.03]`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`div`,{className:`h-10 w-10 rounded-lg flex items-center justify-center border ${d?`bg-blue-500/10 border-blue-500/20 text-blue-400`:`bg-white/5 border-white/10 text-white/60`}`,children:d?(0,$.jsx)(D,{className:`h-5 w-5`}):(0,$.jsx)(h,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ke,{className:`text-sm font-black text-white uppercase tracking-tight`,children:d?`Nueva Habilidad`:`Propiedades del Nodo`}),(0,$.jsx)(G,{className:`text-[10px] text-white/30`,children:d?`Define las propiedades del nuevo módulo cognitivo.`:`Editor granular de capacidades cognitivas y herramientas vinculadas.`})]})]}),!d&&(0,$.jsx)(I,{variant:`ghost`,size:`icon`,onClick:()=>S(!0),disabled:C||x,className:`text-zinc-600 hover:text-red-400 hover:bg-red-400/10 h-8 w-8 transition-colors shrink-0`,title:`Eliminar Skill`,children:(0,$.jsx)(ee,{className:`h-4 w-4`})})]})}),x&&(0,$.jsxs)(`div`,{className:`mx-6 mt-4 p-3 rounded-lg bg-red-500/10 border border-red-500/30 animate-in fade-in slide-in-from-top-2 duration-200`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-red-400 font-medium mb-3`,children:[`¿Eliminar `,(0,$.jsx)(`span`,{className:`font-black`,children:l?.name}),`? Esta acción no se puede deshacer.`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,$.jsx)(I,{variant:`ghost`,size:`sm`,onClick:()=>S(!1),disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider text-zinc-400 hover:text-white`,children:`Cancelar`}),(0,$.jsx)(I,{size:`sm`,onClick:F,disabled:C,className:`h-7 px-3 text-[10px] font-black uppercase tracking-wider bg-red-600 hover:bg-red-500 text-white`,children:C?(0,$.jsx)(B,{className:`h-3 w-3 animate-spin`}):`Sí, eliminar`})]})]}),(0,$.jsxs)(`div`,{className:`p-6 space-y-7 max-h-[65vh] overflow-y-auto custom-scrollbar`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Información General`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(K,{htmlFor:`skill-name`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Nombre del Nodo`}),(0,$.jsx)(U,{id:`skill-name`,value:p.name,onChange:e=>m(t=>({...t,name:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white font-medium`,placeholder:`Ej: a2ui_dashboard`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(K,{htmlFor:`skill-category`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Categoría Funcional`}),(0,$.jsx)(U,{id:`skill-category`,value:p.category,onChange:e=>m(t=>({...t,category:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/70`,placeholder:`Ej: visualización, análisis...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Capacidades y Activación`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(K,{htmlFor:`skill-tools`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-cyan-400/60`,children:`Herramientas Vinculadas`}),` (CSV)`]}),(0,$.jsx)(U,{id:`skill-tools`,value:p.tools,onChange:e=>m(t=>({...t,tools:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-cyan-500/30 text-white/80 font-mono text-[11px]`,placeholder:`tool1, tool2, tool3...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(K,{htmlFor:`skill-triggers`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-purple-400/60`,children:`Triggers`}),` de Activación (CSV)`]}),(0,$.jsx)(U,{id:`skill-triggers`,value:p.triggers,onChange:e=>m(t=>({...t,triggers:e.target.value})),className:`bg-white/5 border-white/10 focus-visible:ring-purple-500/30 text-white/80 font-mono text-[11px]`,placeholder:`mostrar panel, dashboard...`})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest text-white/20 uppercase px-2`,children:`Cuerpo / Lógica del Nodo`}),(0,$.jsx)(`div`,{className:`h-px flex-1 bg-white/5`})]}),(0,$.jsx)(je,{ref:O,value:p.body,onChange:e=>{m(t=>({...t,body:e.target.value})),A()},className:`min-h-[140px] resize-none bg-white/5 border-white/10 focus-visible:ring-blue-500/30 text-white/80 text-sm overflow-hidden font-sans leading-relaxed p-4`,placeholder:`Instrucciones detalladas y lógica de ejecución del módulo cognitivo...`})]}),(0,$.jsxs)(`section`,{className:`grid grid-cols-1 md:grid-cols-2 gap-6 pt-4 border-t border-white/5`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(K,{htmlFor:`skill-version`,className:`text-[10px] uppercase tracking-widest text-white/40`,children:[(0,$.jsx)(`span`,{className:`text-amber-400/60`,children:`Versión`}),` del Skill`]}),(0,$.jsx)(U,{id:`skill-version`,type:`number`,step:`0.1`,min:`0.1`,value:p.version,onChange:e=>m(t=>({...t,version:Number(e.target.value)})),className:`bg-white/5 border-white/10 focus-visible:ring-amber-500/20 text-white w-32`})]}),(0,$.jsxs)(`div`,{className:`flex flex-col justify-center space-y-2`,children:[(0,$.jsx)(K,{className:`text-[10px] uppercase tracking-widest text-white/40`,children:`Estado del Nodo`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 bg-white/5 p-3 rounded-xl border border-white/10 w-fit`,children:[(0,$.jsx)(`div`,{className:`h-2 w-2 rounded-full transition-colors ${p.active?`bg-blue-500 shadow-[0_0_6px_hsl(217_91%_60%/0.8)] animate-pulse`:`bg-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[9px] font-black tracking-widest ${p.active?`text-white`:`text-white/30`}`,children:p.active?`OPERATIVO / ACTIVO`:`FUERA DE LÍNEA / INACTIVO`}),(0,$.jsx)(Me,{checked:p.active,onCheckedChange:e=>m(t=>({...t,active:e})),className:`data-[state=checked]:bg-blue-500`})]})]})]})]}),(0,$.jsxs)(Te,{className:`p-5 bg-white/[0.02] flex items-center justify-between gap-3 border-t border-white/5 sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[9px] font-black tracking-widest text-white/15 uppercase`,children:[(0,$.jsx)(y,{className:`h-3 w-3`}),d?`Nueva habilidad`:`ID: ${l?.id?.substring(0,8)}...`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(I,{variant:`ghost`,className:`text-[10px] font-black tracking-widest hover:bg-white/5 hover:text-white text-white/30 uppercase`,onClick:z,children:`Cancelar`}),(0,$.jsx)(I,{className:`bg-blue-600 hover:bg-blue-500 text-white font-black text-[10px] tracking-widest px-6 rounded-lg shadow-btn-primary uppercase`,onClick:ae,disabled:v||!p.name.trim(),children:v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`h-3 w-3 animate-spin mr-2`}),`PROCESANDO...`]}):d?`Crear Habilidad`:`Sincronizar Propiedades`})]})]})]})})]})}var xt=()=>{let{notes:e,isLoading:t,fetchNotes:n}=at();return(0,Q.useEffect)(()=>{n()},[n]),(0,$.jsxs)(Le,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden group border border-white/10`,children:[(0,$.jsx)(Pe,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(ve,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ne,{className:`text-xl font-bold tracking-tight`,children:`Notas`}),(0,$.jsx)(Ie,{children:`Scratchpad del agente`})]})]}),t&&(0,$.jsx)(B,{className:`w-4 h-4 animate-spin text-muted-foreground`})]})}),(0,$.jsx)(Fe,{children:(0,$.jsx)(we,{className:`h-[350px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[250px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(ve,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`No hay notas guardadas`}),(0,$.jsx)(`p`,{className:`text-[10px] opacity-70`,children:`El agente guardará notas con save_note`})]}):e.map(e=>(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-300 relative overflow-hidden`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm mb-1.5 line-clamp-1`,children:e.key}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-3 leading-relaxed`,children:e.value}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between`,children:[(0,$.jsx)(W,{variant:`secondary`,className:`text-[10px] px-2 py-0.5 bg-primary/10 text-primary border-none font-medium font-mono truncate max-w-[120px]`,children:e.thread_id.slice(-8)}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground font-mono`,children:new Date(e.updated_at*1e3).toLocaleDateString()})]})]},e.id))})})})]})};function St(e){if(!e)return`—`;try{return new Date(e).toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}catch{return e}}function Ct({status:e}){let t={active:{label:`Activa`,className:`bg-green-500/10 text-green-400 border-green-500/20`},paused:{label:`Pausada`,className:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`},completed:{label:`Completada`,className:`bg-blue-500/10 text-blue-400 border-blue-500/20`},failed:{label:`Fallida`,className:`bg-red-500/10 text-red-400 border-red-500/20`},cancelled:{label:`Cancelada`,className:`bg-muted/30 text-muted-foreground border-white/10`}},{label:n,className:r}=t[e]??t.cancelled;return(0,$.jsx)(`span`,{className:`inline-flex items-center text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${r}`,children:n})}function wt({type:e}){let t=e===`recurring`;return(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full border ${t?`bg-violet-500/10 text-violet-400 border-violet-500/20`:`bg-teal-500/10 text-teal-400 border-teal-500/20`}`,children:[t?(0,$.jsx)(O,{className:`w-2.5 h-2.5`}):(0,$.jsx)(o,{className:`w-2.5 h-2.5`}),t?`Recurrente`:`Una vez`]})}function Tt({channel:e}){return!e||e===`system`?(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:`System`}):e===`webchat`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-blue-500/10 text-blue-400 border border-blue-500/20`,children:[(0,$.jsx)(We,{className:`w-2.5 h-2.5`}),`Web`]}):e===`telegram`?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-sky-500/10 text-sky-400 border border-sky-500/20`,children:[(0,$.jsx)(A,{className:`w-2.5 h-2.5`}),`Telegram`]}):(0,$.jsx)(`span`,{className:`inline-flex items-center gap-1 text-[9px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded-full bg-muted/30 text-muted-foreground border border-white/10`,children:e})}function Et({status:e}){return(0,$.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full ${{running:`bg-blue-400 animate-pulse`,success:`bg-green-400`,failed:`bg-red-400`,timeout:`bg-amber-400`}[e]??`bg-muted-foreground`}`})}function Dt(e,t){let n=e===`telegram`?`Telegram`:e===`webchat`?`Web Chat`:e;return e===t?`${n} (recomendado)`:n}function Ot({taskId:e,history:t}){return t?t.length===0?(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Sin ejecuciones registradas.`}):(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,$.jsx)(Et,{status:e.status}),(0,$.jsx)(`span`,{className:`font-mono`,children:St(e.started_at)}),e.duration_ms!=null&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[e.duration_ms,`ms`]}),e.error_message&&(0,$.jsx)(`span`,{className:`text-red-400 truncate max-w-[160px]`,children:e.error_message})]},e.id))}):(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground px-1`,children:`Cargando historial…`})}function kt({task:e,onPause:t,onResume:n,onDelete:r,onTrigger:i,onLoadHistory:s,history:d}){let[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(!1),g=e.status===`active`,_=e.status===`active`||e.status===`paused`;function y(){!f&&!d&&s(e.id),p(e=>!e)}function b(){m?r(e.id):(h(!0),setTimeout(()=>h(!1),3e3))}return(0,$.jsxs)(`div`,{className:`p-4 rounded-2xl border border-white/5 bg-card/40 hover:bg-card/60 transition-all duration-200`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h4`,{className:`font-semibold text-sm truncate`,children:e.name}),e.description&&(0,$.jsx)(`p`,{className:`text-[10px] text-muted-foreground truncate mt-0.5`,children:e.description})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:(0,$.jsx)(Ct,{status:e.status})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap mb-2`,children:[(0,$.jsx)(wt,{type:e.task_type}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] text-primary font-bold uppercase tracking-wider bg-primary/5 px-2 py-0.5 rounded-full`,children:[(0,$.jsx)(o,{className:`w-3 h-3`}),e.task_type===`recurring`?e.cron_expression??`—`:e.fire_at?St(e.fire_at):`—`]}),(0,$.jsx)(Tt,{channel:e.channel})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-2`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(a,{className:`w-3 h-3`}),e.run_count,` runs`]}),e.error_count>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-red-400`,children:[(0,$.jsx)(u,{className:`w-3 h-3`}),e.error_count,` errores`]}),e.timezone&&e.timezone!==`UTC`&&(0,$.jsx)(`span`,{className:`font-mono`,children:e.timezone})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground mb-3`,children:[e.last_run_at&&(0,$.jsxs)(`span`,{children:[`Último: `,St(e.last_run_at)]}),e.next_run_at&&e.status===`active`&&(0,$.jsxs)(`span`,{className:`text-primary/70`,children:[`Próximo: `,St(e.next_run_at)]})]}),e.last_error&&(0,$.jsx)(`div`,{className:`mb-2 text-[10px] text-red-400 bg-red-500/5 border border-red-500/20 rounded-lg px-2 py-1 truncate`,children:e.last_error}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[_&&(g?(0,$.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-yellow-500/10 hover:text-yellow-400 hover:border-yellow-500/20`,onClick:()=>t(e.id),children:[(0,$.jsx)(T,{className:`w-3 h-3 mr-1`}),`Pausar`]}):(0,$.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-green-500/10 hover:text-green-400 hover:border-green-500/20`,onClick:()=>n(e.id),children:[(0,$.jsx)(E,{className:`w-3 h-3 mr-1`}),`Reanudar`]})),g&&(0,$.jsxs)(I,{size:`sm`,variant:`outline`,className:`h-6 text-[10px] px-2 border-white/10 hover:bg-primary/10 hover:text-primary hover:border-primary/20`,onClick:()=>i(e.id),title:`Ejecutar ahora (sin afectar el schedule)`,children:[(0,$.jsx)(P,{className:`w-3 h-3 mr-1`}),`Ejecutar`]}),(0,$.jsxs)(I,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 text-muted-foreground hover:text-foreground`,onClick:y,children:[(0,$.jsx)(v,{className:`w-3 h-3 mr-1`}),`Historial`,f?(0,$.jsx)(l,{className:`w-3 h-3 ml-1`}):(0,$.jsx)(c,{className:`w-3 h-3 ml-1`})]}),(0,$.jsxs)(I,{size:`sm`,variant:`ghost`,className:`h-6 text-[10px] px-2 ml-auto ${m?`text-red-400 bg-red-500/10 border border-red-500/20`:`text-muted-foreground hover:text-red-400`}`,onClick:b,title:m?`Confirmar eliminación`:`Eliminar tarea`,children:[(0,$.jsx)(ee,{className:`w-3 h-3 mr-1`}),m?`Confirmar`:`Eliminar`]})]}),f&&(0,$.jsx)(`div`,{className:`mt-2 pt-2 border-t border-white/5`,children:(0,$.jsx)(Ot,{taskId:e.id,history:d})})]})}var At=()=>{let{scheduledTasks:e,taskHistory:t,cronChannels:n,cronRecommended:r,cronUserPreference:i,isLoading:a,fetchScheduledTasks:o,fetchCronChannels:s,pauseTask:c,resumeTask:l,deleteTask:u,triggerTask:d,fetchTaskHistory:f,saveCronChannelPreference:p}=at(),[m,h]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{o(),s()},[o,s]);let g=m===`all`?e:e.filter(e=>e.status===m),_=(n??[]).filter(e=>e.active),v=g.filter(e=>!e.name.startsWith(`_hive_`));return(0,$.jsxs)(Le,{className:`border-none bg-background/50 backdrop-blur-xl shadow-2xl overflow-hidden border border-white/10`,children:[(0,$.jsx)(Pe,{className:`pb-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-xl bg-primary/10 text-primary`,children:(0,$.jsx)(Se,{className:`w-5 h-5`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Ne,{className:`text-xl font-bold tracking-tight`,children:`Tareas Programadas`}),(0,$.jsx)(Ie,{children:`Scheduler basado en Croner`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[a&&(0,$.jsx)(B,{className:`w-4 h-4 animate-spin text-muted-foreground`}),(0,$.jsxs)(Z,{value:m,onValueChange:h,children:[(0,$.jsx)(Y,{className:`h-7 text-[10px] w-[110px] border-white/10 bg-card/40`,children:(0,$.jsx)(X,{})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(q,{value:`all`,className:`text-xs`,children:`Todas`}),(0,$.jsx)(q,{value:`active`,className:`text-xs`,children:`Activas`}),(0,$.jsx)(q,{value:`paused`,className:`text-xs`,children:`Pausadas`}),(0,$.jsx)(q,{value:`completed`,className:`text-xs`,children:`Completadas`}),(0,$.jsx)(q,{value:`failed`,className:`text-xs`,children:`Fallidas`})]})]}),_.length>1&&(0,$.jsxs)(Z,{value:i,onValueChange:p,children:[(0,$.jsx)(Y,{className:`h-7 text-[10px] w-[130px] border-white/10 bg-card/40`,children:(0,$.jsx)(X,{placeholder:`Canal`})}),(0,$.jsxs)(J,{children:[(0,$.jsx)(q,{value:`auto`,className:`text-xs`,children:`Auto`}),_.map(e=>(0,$.jsx)(q,{value:e.id,className:`text-xs`,children:Dt(e.id,r)},e.id))]})]}),(0,$.jsx)(I,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 text-muted-foreground hover:text-foreground`,onClick:()=>o(m===`all`?void 0:m),disabled:a,title:`Refrescar`,children:(0,$.jsx)(O,{className:`w-3.5 h-3.5`})})]})]})}),(0,$.jsx)(Fe,{children:(0,$.jsx)(we,{className:`h-[420px] pr-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:v.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-[280px] text-muted-foreground space-y-2`,children:[(0,$.jsx)(Se,{className:`w-12 h-12 opacity-20`}),(0,$.jsx)(`p`,{className:`text-sm`,children:`Sin tareas programadas`}),(0,$.jsxs)(`p`,{className:`text-[10px] opacity-70`,children:[`Crea tareas desde el chat o con `,(0,$.jsx)(`code`,{className:`font-mono`,children:`hive cron add`})]})]}):v.map(e=>(0,$.jsx)(kt,{task:e,onPause:c,onResume:l,onDelete:u,onTrigger:d,onLoadHistory:f,history:t[e.id]},e.id))})})})]})},jt=`https://github.com/johpaz/hive/releases/latest`;function Mt(){let{phase:e,update:t,percent:r,error:i,check:a,install:o}=ge(),{data:s}=n({queryKey:[`version-check`],queryFn:()=>L(`/api/version`),retry:1}),c=xe(),l=e===`checking`||e===`downloading`||e===`installing`||e===`restarting`;return(0,$.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-border/60 bg-card/50 p-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:`Versión instalada`}),(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Hive `,s?.current??`—`,s?.installationType?` · ${s.installationType}`:``]})]}),e===`up-to-date`&&(0,$.jsxs)(W,{variant:`secondary`,className:`gap-1`,children:[(0,$.jsx)(d,{className:`h-3.5 w-3.5`}),` Al día`]}),t&&(0,$.jsxs)(W,{className:`gap-1`,children:[(0,$.jsx)(_e,{className:`h-3.5 w-3.5`}),` `,t.version,` disponible`]})]}),!c&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Esta instalación no se actualiza desde acá. Con npm o bun:`,` `,(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`bun install -g @johpaz/hive-agents@latest`}),`. Con Docker:`,` `,(0,$.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`docker compose pull`}),`.`]}),c&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`La app revisa si hay versión nueva al abrirse y cada 6 horas. Cuando la instalás, se descarga, se verifica su firma y Hive se reinicia solo. Tus datos y agentes no se tocan.`}),e===`downloading`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(ye,{value:r}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r>0?`Descargando… ${r}%`:`Preparando la descarga…`})]}),e===`installing`&&(0,$.jsx)(`p`,{className:`text-sm`,children:`Instalando… no cierres la aplicación.`}),e===`restarting`&&(0,$.jsx)(`p`,{className:`text-sm`,children:`Listo. Reiniciando Hive…`}),e===`unsupported`&&(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-sm`,children:[(0,$.jsx)(oe,{className:`mt-0.5 h-4 w-4 shrink-0 text-amber-500`}),(0,$.jsxs)(`span`,{children:[`La actualización automática de Linux se publica como .deb, y este sistema no puede instalarlo. Descargá el .rpm desde`,` `,(0,$.jsx)(`a`,{className:`underline`,href:jt,target:`_blank`,rel:`noreferrer`,children:`la página de releases`}),` `,`e instalalo encima: conserva tus datos, agentes y claves.`]})]}),e===`error`&&(0,$.jsxs)(`p`,{className:`flex items-start gap-2 text-sm text-destructive`,children:[(0,$.jsx)(oe,{className:`mt-0.5 h-4 w-4 shrink-0`}),(0,$.jsxs)(`span`,{children:[i,` `,(0,$.jsx)(`a`,{className:`underline`,href:jt,target:`_blank`,rel:`noreferrer`,children:`Instalar manualmente`})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(I,{variant:`outline`,disabled:l,onClick:()=>void a({manual:!0}),children:e===`checking`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(B,{className:`mr-2 h-4 w-4 animate-spin`}),` Buscando…`]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(O,{className:`mr-2 h-4 w-4`}),` Buscar actualizaciones`]})}),t&&e===`available`&&(0,$.jsxs)(I,{onClick:()=>void o(),children:[(0,$.jsx)(_e,{className:`mr-2 h-4 w-4`}),` Instalar `,t.version]})]})]})]})}function Nt(e){if(e.includes(` & `)){let[t,n]=e.split(` & `,2);return{lead:t,accent:`& ${n}`}}let[t,...n]=e.split(` `);return{lead:t,accent:n.join(` `)}}function Pt({panel:e}){switch(e){case`etica`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Xe,{})});case`herramientas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Qe,{})});case`mcp`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(it,{})});case`skills`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(bt,{})});case`perfil`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(mt,{})});case`notas`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(xt,{})});case`cron-jobs`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(At,{})});case`actualizaciones`:return(0,$.jsx)(`div`,{className:`p-4`,children:(0,$.jsx)(Mt,{})});default:return null}}var Ft=[`etica`,`herramientas`,`mcp`,`skills`,`perfil`,`notas`,`cron-jobs`,`actualizaciones`];function It({forcePanel:e}){let{panel:t}=F(),{fetchSkills:n}=Ce(),{fetchTools:r}=pe(),{fetchMCPServers:i}=me();(0,Q.useEffect)(()=>{n(),r(),i()},[n,r,i]);let a=t===`seguridad`?`perfil`:t,o=e||(Ft.includes(a)?a:`herramientas`),{title:s,subtitle:c,eyebrow:l}={etica:{eyebrow:`PROTOCOLOS DE CONDUCTA`,title:`Ética & Alineación`,subtitle:`Configura los límites morales y el comportamiento base de tus agentes.`},herramientas:{eyebrow:`CAPACIDADES DINÁMICAS`,title:`Gestión de Herramientas`,subtitle:`Habilita y configura las funciones que tus agentes pueden ejecutar.`},mcp:{eyebrow:`CONECTIVIDAD EXTERNA`,title:`Servidores MCP`,subtitle:`Conecta Hive con fuentes de datos externas y herramientas de terceros.`},skills:{eyebrow:`HABILIDADES ESPECIALIZADAS`,title:`Galería de Skills`,subtitle:`Nodos cognitivos preconfigurados para tareas específicas de alto nivel.`},perfil:{eyebrow:`IDENTIDAD DEL OPERADOR`,title:`Perfil de Usuario`,subtitle:`Gestiona tu información personal y preferencias de la interfaz.`},notas:{eyebrow:`MEMORIA OPERATIVA`,title:`Notas del Sistema`,subtitle:`Registro de información persistente y recordatorios del enjambre.`},"cron-jobs":{eyebrow:`AUTOMATIZACIÓN TEMPORAL`,title:`Tareas Programadas`,subtitle:`Gestión de ejecuciones recurrentes y disparadores cron.`},actualizaciones:{eyebrow:`MANTENIMIENTO`,title:`Actualizaciones`,subtitle:`Consultá tu versión, buscá una nueva e instalala sin salir de la app.`}}[o],u=Nt(s);return(0,$.jsxs)(`div`,{className:`hive-page-container`,children:[(0,$.jsx)(`div`,{className:`hive-page-header`,children:(0,$.jsxs)(`div`,{className:`relative z-10`,children:[(0,$.jsxs)(`div`,{className:`hive-page-header__eyebrow`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:l})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[u.lead,u.accent&&(0,$.jsxs)($.Fragment,{children:[` `,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:u.accent})]})]}),(0,$.jsx)(`p`,{className:`hive-subtitle`,children:c})]})}),(0,$.jsx)(`div`,{className:`animate-fade-in`,children:(0,$.jsx)(Pt,{panel:o})})]})}export{It as SettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{f as t}from"./vendor-charts-K3xcRl0X.js";import{a as n,i as r,n as i,o as a,r as o,s,t as c}from"./vendor-radix-DUug7irY.js";import{o as l}from"./vendor-query-Dj8xYhQD.js";import{t as u}from"./check-C8pw-7Fx.js";import{t as d}from"./chevron-down-8GjmTjLR.js";import{t as f}from"./circle-check-BKNT2_q6.js";import{t as ee}from"./circle-x-DfBjbztU.js";import{t as p}from"./sparkles-BViXTAh7.js";import{t as m}from"./utils-SGUggNJc.js";import{c as te}from"./vendor-router-Dsg8fxNQ.js";import{t as h}from"./gateway-url-BZj_2-jf.js";import{$ as g,B as _,C as v,D as ne,Z as y,r as re,z as b}from"./index-BHHUQZJd.js";import{t as x}from"./badge-uRjRSt86.js";import{t as S}from"./label-BceoUB2w.js";import{i as C,n as w,o as T,s as E,t as D}from"./select-BBEBtcLm.js";import{t as ie}from"./switch-CgiDezVR.js";import{a as O,i as k,n as A,r as j,t as M}from"./card-DwQizslL.js";import{t as ae}from"./useHiveAgentsModelLoad-C7bhWPDG.js";import{n as N,t as oe}from"./alert-DChoEVJw.js";var P=e(t(),1),F=l(),se=a,I=P.forwardRef(({className:e,...t},r)=>(0,F.jsx)(n,{ref:r,className:m(`border-b`,e),...t}));I.displayName=`AccordionItem`;var ce=P.forwardRef(({className:e,children:t,...n},i)=>(0,F.jsx)(r,{className:`flex`,children:(0,F.jsxs)(s,{ref:i,className:m(`flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180`,e),...n,children:[t,(0,F.jsx)(d,{className:`h-4 w-4 shrink-0 transition-transform duration-200`})]})}));ce.displayName=s.displayName;var le=P.forwardRef(({className:e,children:t,...n},r)=>(0,F.jsx)(o,{ref:r,className:`overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down`,...n,children:(0,F.jsx)(`div`,{className:m(`pb-4 pt-0`,e),children:t})}));le.displayName=o.displayName;var L=P.forwardRef(({className:e,...t},n)=>(0,F.jsx)(c,{ref:n,className:m(`peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,F.jsx)(i,{className:m(`flex items-center justify-center text-current`),children:(0,F.jsx)(u,{className:`h-4 w-4`})})}));L.displayName=c.displayName;var ue={gemini:`🔵`,anthropic:`🟠`,openai:`🟢`,groq:`🔴`,ollama:`🟣`,openrouter:`🟡`,deepseek:`🔷`,mistral:`🔸`,kimi:`🌙`},R={gemini:`https://aistudio.google.com/app/apikey`,anthropic:`https://console.anthropic.com/keys`,openai:`https://platform.openai.com/api-keys`,groq:`https://console.groq.com/keys`,openrouter:`https://openrouter.ai/keys`,deepseek:`https://platform.deepseek.com/api_keys`,mistral:`https://console.mistral.ai/api-keys`,kimi:`https://platform.moonshot.cn/console/api-keys`},z=[{id:`webchat`,name:`WebChat`,description:`Chat web integrado`,icon:`💬`,required:!0},{id:`telegram`,name:`Telegram`,description:`Bot de Telegram`,icon:`✈️`,required:!1},{id:`discord`,name:`Discord`,description:`Bot de Discord`,icon:`🎮`,required:!1},{id:`whatsapp`,name:`WhatsApp`,description:`Bot de WhatsApp`,icon:`📱`,required:!1},{id:`slack`,name:`Slack`,description:`Bot de Slack`,icon:`💼`,required:!1}],B=`hive_setup_wizard_data`,V=6;function de(){try{let e=sessionStorage.getItem(B);if(e){let t=JSON.parse(e);return{...U(),...t}}}catch(e){console.error(`Failed to load wizard data:`,e)}return null}function fe(e){try{sessionStorage.setItem(B,JSON.stringify(e))}catch(e){console.error(`Failed to save wizard data:`,e)}}function H(){try{sessionStorage.removeItem(B)}catch(e){console.error(`Failed to clear wizard data:`,e)}}function U(){return{userName:``,userEmail:``,userLanguage:`es`,userTimezone:Intl.DateTimeFormat().resolvedOptions().timeZone||`UTC`,userOccupation:``,userNotes:``,agentName:`Bee`,agentDescription:``,agentTone:`friendly`,provider:``,apiKey:``,model:``,apiKeyVerified:!1,channels:{webchat:{enabled:!0},telegram:{enabled:!1},discord:{enabled:!1},whatsapp:{enabled:!1},slack:{enabled:!1}},ethicsRules:{},customRules:[]}}function W(){let e=te(),[t,n]=(0,P.useState)(1),[r,i]=(0,P.useState)(()=>de()||U()),[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(!1),{showLoader:l,hideLoader:u}=ne(),[d,B]=(0,P.useState)(`idle`),[W,G]=(0,P.useState)(null),[K,pe]=(0,P.useState)([]),[q,J]=(0,P.useState)(null),[Y,X]=(0,P.useState)(!1),[me,he]=(0,P.useState)(!1),[ge,Z]=(0,P.useState)(null),{load:_e}=ae(),[Q,ve]=(0,P.useState)([]);(0,P.useEffect)(()=>{fetch(`${h()}/api/setup/providers`).then(e=>e.json()).then(e=>{Array.isArray(e)&&pe(e)}).catch(()=>{}),fetch(`${h()}/api/setup/ethics`).then(e=>e.json()).then(e=>{Array.isArray(e)&&(ve(e),i(t=>Object.keys(t.ethicsRules).length===0?{...t,ethicsRules:Object.fromEntries(e.map(e=>[e.id,!0]))}:t))}).catch(()=>{})},[]),(0,P.useEffect)(()=>{fe(r)},[r]),(0,P.useEffect)(()=>{fetch(`${h()}/api/setup/status`).then(e=>e.json()).then(t=>{t.configured&&e(`/ui`)}).catch(()=>{})},[e]);let $=e=>{G(null),i(t=>({...t,...e}))},ye=()=>{switch(t){case 1:return r.userName.trim()?r.userName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:r.userEmail.trim()?/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r.userEmail.trim())?null:`Ingresa un correo válido.`:`El correo es obligatorio.`:`El nombre es obligatorio.`;case 2:return r.agentName.trim()?r.agentName.trim().length<2?`El nombre debe tener al menos 2 caracteres.`:null:`El nombre del agente es obligatorio.`;case 3:return r.provider?r.provider!==`ollama`&&!r.apiKey?`Ingresa tu API key.`:r.provider!==`ollama`&&!r.apiKeyVerified?`Verifica tu API key antes de continuar.`:r.model?null:`Selecciona un modelo.`:`Selecciona un proveedor LLM.`;default:return null}},be=()=>{let e=ye();if(e){G(e);return}G(null),t<V&&n(e=>e+1)},xe=()=>{t>1&&n(e=>e-1)},Se=()=>{confirm(`¿Estás seguro de que quieres reiniciar la configuración? Se perderá todo el progreso.`)&&(H(),i(U()),n(1))},Ce=async()=>{if(!(!r.apiKey||!r.provider)){B(`verifying`);try{(await v(`/api/setup/verify-provider`,{method:`POST`,body:{provider:r.provider,apiKey:r.apiKey},showLoader:`Verificando conexión...`,showError:!1})).success?(B(`success`),$({apiKeyVerified:!0})):(B(`error`),$({apiKeyVerified:!1}))}catch{B(`error`),$({apiKeyVerified:!1})}}},we=async()=>{o(!0);try{let t=await v(`/api/setup/complete`,{method:`POST`,body:r,showLoader:`Finalizando configuración...`,showError:!0});if(t.success){let n=t.authToken;n&&localStorage.setItem(`hive-auth-token`,n),c(!0),H(),(async()=>{await new Promise(e=>setTimeout(e,1500)),l(`Iniciando a ${r.agentName}... esto toma unos segundos`);for(let t=0;t<40;t++){try{let t=await fetch(`${h()}/api/setup/status`);if(t.ok){let{configured:r}=await t.json();if(r){u(),e(n?`/?token=${n}`:`/`);return}}}catch{}await new Promise(e=>setTimeout(e,1e3))}u(),e(n?`/?token=${n}`:`/`)})()}}catch{}finally{o(!1)}},Te=()=>{switch(t){case 1:return Ee();case 2:return De();case 3:return Oe();case 4:return ke();case 5:return Ae();case 6:return je();default:return null}},Ee=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-4`,children:[(0,F.jsx)(`div`,{className:`flex justify-center`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(g,{className:`w-24 h-24 text-amber-500`,fill:`currentColor`}),(0,F.jsx)(p,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2`})]})}),(0,F.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Bienvenido a Hive`}),(0,F.jsx)(`p`,{className:`text-muted-foreground max-w-md mx-auto`,children:`Hive es tu colmena de agentes IA. Local-first. Multi-canal. Open source. En los próximos minutos configurarás tu agente personal Bee.`})]}),(0,F.jsxs)(M,{children:[(0,F.jsxs)(k,{children:[(0,F.jsx)(O,{children:`Tu información`}),(0,F.jsx)(j,{children:`Comencemos con tus datos básicos`})]}),(0,F.jsxs)(A,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`userName`,children:`Tu nombre`}),(0,F.jsx)(b,{id:`userName`,placeholder:`¿Cómo te llamas?`,value:r.userName,onChange:e=>$({userName:e.target.value})})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`userEmail`,children:`Tu correo`}),(0,F.jsx)(b,{id:`userEmail`,type:`email`,autoComplete:`email`,placeholder:`tu@correo.com`,maxLength:254,required:!0,value:r.userEmail,onChange:e=>$({userEmail:e.target.value})}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Hive lo usará cuando digas «envíame». También será tu usuario de acceso si después activas una contraseña.`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`userLanguage`,children:`Idioma preferido`}),(0,F.jsxs)(D,{value:r.userLanguage,onValueChange:e=>$({userLanguage:e}),children:[(0,F.jsx)(T,{children:(0,F.jsx)(E,{})}),(0,F.jsxs)(w,{children:[(0,F.jsx)(C,{value:`es`,children:`Español`}),(0,F.jsx)(C,{value:`en`,children:`English`}),(0,F.jsx)(C,{value:`pt`,children:`Português`}),(0,F.jsx)(C,{value:`fr`,children:`Français`})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`userTimezone`,children:`Zona horaria`}),(0,F.jsx)(b,{id:`userTimezone`,value:r.userTimezone,onChange:e=>$({userTimezone:e.target.value}),placeholder:`America/Bogota`}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Detectada automáticamente: `,Intl.DateTimeFormat().resolvedOptions().timeZone]})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(S,{htmlFor:`userOccupation`,children:[`Ocupación `,(0,F.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,F.jsx)(b,{id:`userOccupation`,value:r.userOccupation,onChange:e=>$({userOccupation:e.target.value}),placeholder:`Ej: Desarrollador de software, diseñador, estudiante...`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsxs)(S,{htmlFor:`userNotes`,children:[`Preferencias de comunicación `,(0,F.jsx)(`span`,{className:`text-muted-foreground font-normal`,children:`(opcional)`})]}),(0,F.jsx)(`textarea`,{id:`userNotes`,className:`w-full min-h-[80px] p-3 border rounded-md bg-background resize-none text-sm`,value:r.userNotes,onChange:e=>$({userNotes:e.target.value}),placeholder:`Ej: Prefiero respuestas cortas y directas. Usa ejemplos de código cuando expliques conceptos técnicos...`})]})]})]})]}),De=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Tu agente`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Personaliza a Bee, tu agente personal`})]}),(0,F.jsxs)(M,{children:[(0,F.jsx)(k,{children:(0,F.jsx)(O,{children:`Identidad del agente`})}),(0,F.jsxs)(A,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`agentName`,children:`Nombre del agente`}),(0,F.jsx)(b,{id:`agentName`,value:r.agentName,onChange:e=>$({agentName:e.target.value}),placeholder:`Bee`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`agentDescription`,children:`Descripción / Personalidad`}),(0,F.jsx)(`textarea`,{id:`agentDescription`,className:`w-full min-h-[100px] p-3 border rounded-md bg-background resize-none`,value:r.agentDescription,onChange:e=>$({agentDescription:e.target.value}),placeholder:`Ej: Eres un asistente útil y amable. Respondes de forma concisa pero completa. Te especializas en ayudar con tareas de programación y productividad...`})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`agentTone`,children:`Tono de comunicación`}),(0,F.jsxs)(D,{value:r.agentTone,onValueChange:e=>$({agentTone:e}),children:[(0,F.jsx)(T,{children:(0,F.jsx)(E,{placeholder:`Selecciona un tono`})}),(0,F.jsxs)(w,{children:[(0,F.jsx)(C,{value:`friendly`,children:`Amigable y cercano`}),(0,F.jsx)(C,{value:`professional`,children:`Profesional y formal`}),(0,F.jsx)(C,{value:`direct`,children:`Directo y conciso`}),(0,F.jsx)(C,{value:`casual`,children:`Casual y relajado`})]})]}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Define cómo se comunicará tu agente contigo`})]})]})]})]}),Oe=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Proveedor LLM`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Selecciona el cerebro de tu agente`})]}),(0,F.jsx)(`div`,{className:`grid gap-3`,children:K.map(e=>(0,F.jsx)(M,{className:m(`cursor-pointer transition-all hover:shadow-md`,r.provider===e.id&&`border-amber-500 ring-2 ring-amber-500`),onClick:()=>{$({provider:e.id,model:``,apiKeyVerified:!1}),e.id===`ollama`&&J(null)},children:(0,F.jsxs)(A,{className:`flex items-center gap-4 p-4`,children:[(0,F.jsx)(`span`,{className:`text-3xl`,children:ue[e.id]??`🤖`}),(0,F.jsxs)(`div`,{className:`flex-1`,children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e.name}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[e.models.length,` modelo`,e.models.length===1?``:`s`,` disponible`,e.models.length===1?``:`s`]})]}),r.provider===e.id&&(0,F.jsx)(f,{className:`w-5 h-5 text-amber-500`})]})},e.id))}),r.provider&&(()=>{let e=K.find(e=>e.id===r.provider);return(0,F.jsxs)(M,{className:`mt-4`,children:[(0,F.jsx)(k,{children:(0,F.jsxs)(O,{children:[`Configuración de `,e?.name]})}),(0,F.jsxs)(A,{className:`space-y-4`,children:[r.provider!==`ollama`&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`apiKey`,children:`API Key`}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(b,{id:`apiKey`,type:`password`,value:r.apiKey,onChange:e=>$({apiKey:e.target.value,apiKeyVerified:!1}),placeholder:`sk-...`,className:m(W?.includes(`API key`)&&!r.apiKey&&`border-red-500`)}),(0,F.jsx)(_,{variant:`outline`,onClick:Ce,disabled:!r.apiKey||d===`verifying`,children:d===`verifying`?(0,F.jsx)(y,{className:`w-4 h-4 animate-spin`}):d===`success`?(0,F.jsx)(f,{className:`w-4 h-4 text-green-500`}):d===`error`?(0,F.jsx)(ee,{className:`w-4 h-4 text-red-500`}):`Verificar`})]}),d===`success`&&(0,F.jsxs)(`p`,{className:`text-sm text-green-600 flex items-center gap-1`,children:[(0,F.jsx)(f,{className:`w-4 h-4`}),` API key verificada correctamente`]}),d===`error`&&(0,F.jsxs)(`p`,{className:`text-sm text-red-600 flex items-center gap-1`,children:[(0,F.jsx)(ee,{className:`w-4 h-4`}),` API key inválida o error de conexión`]}),R[r.provider]&&(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`¿No tienes tu API key?`,` `,(0,F.jsx)(`a`,{href:R[r.provider],target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtener aquí`})]})]}),r.provider===`ollama`&&(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(_,{type:`button`,variant:`outline`,size:`sm`,disabled:Y,onClick:()=>{J(null),X(!0),$({model:``}),fetch(`${h()}/api/setup/ollama-models`).then(e=>e.json()).then(e=>{J(e.models??[]),X(!1)}).catch(()=>{J([]),X(!1)})},children:Y?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(y,{className:`w-3 h-3 animate-spin mr-1`}),`Detectando...`]}):`🔍 Detectar modelos`}),!Y&&q!==null&&(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:q.length>0?`${q.length} modelo${q.length===1?``:`s`} encontrado${q.length===1?``:`s`}`:`Sin modelos — instala uno con ollama pull`})]}),q&&q.length>0&&(0,F.jsxs)(`div`,{className:`space-y-1`,children:[(0,F.jsx)(S,{htmlFor:`model`,children:`Modelo`}),(0,F.jsxs)(D,{value:r.model,onValueChange:e=>$({model:e}),children:[(0,F.jsx)(T,{className:m(!r.model&&W?.includes(`modelo`)&&`border-red-500`),children:(0,F.jsx)(E,{placeholder:`Selecciona un modelo`})}),(0,F.jsx)(w,{children:q.map((e,t)=>(0,F.jsxs)(C,{value:e.id,children:[e.name,t===0?` (Recomendado)`:``]},e.id))})]})]}),!Y&&q!==null&&q.length===0&&(0,F.jsxs)(`p`,{className:`text-xs text-amber-600`,children:[`Asegúrate que Ollama esté corriendo (`,(0,F.jsx)(`code`,{children:`ollama serve`}),`) y tengas modelos (`,(0,F.jsx)(`code`,{children:`ollama pull llama3.2`}),`).`]})]}),r.provider!==`ollama`&&r.apiKeyVerified&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`model`,children:`Modelo`}),(0,F.jsxs)(D,{value:r.model,disabled:me,onValueChange:async t=>{if(Z(null),r.provider===`hiveagents`){let n=e?.models.find(e=>e.id===t)?.context_window;if(!n){Z(`No se pudo determinar el context_window del modelo.`);return}he(!0);let r=await _e(t,n);if(he(!1),!r){Z(`No se pudo confirmar la carga del modelo. Intentá de nuevo.`);return}}$({model:t})},children:[(0,F.jsx)(T,{className:m(!r.model&&W?.includes(`modelo`)&&`border-red-500`),children:(0,F.jsx)(E,{placeholder:`Selecciona un modelo`})}),(0,F.jsx)(w,{children:(e?.models??[]).map((e,t)=>(0,F.jsxs)(C,{value:e.id,children:[e.name||e.id,t===0?` (Recomendado)`:``]},e.id))})]}),me&&(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-1`,children:[(0,F.jsx)(y,{className:`w-3 h-3 animate-spin`}),` Cargando modelo en HiveAgents…`]}),ge&&(0,F.jsx)(`p`,{className:`text-xs text-red-600`,children:ge})]})]})]})})()]}),ke=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Canales`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`¿Dónde quieres que Bee esté disponible?`})]}),(0,F.jsx)(`div`,{className:`grid gap-3`,children:z.map(e=>(0,F.jsx)(M,{className:m(`transition-all`,r.channels[e.id]?.enabled&&`border-amber-500`),children:(0,F.jsxs)(A,{className:`p-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`text-2xl`,children:e.icon}),(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`h3`,{className:`font-semibold flex items-center gap-2`,children:[e.name,e.required&&(0,F.jsx)(x,{variant:`secondary`,className:`text-xs`,children:`Requerido`})]}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description})]})]}),(0,F.jsx)(ie,{checked:r.channels[e.id]?.enabled,onCheckedChange:t=>{e.required&&!t||$({channels:{...r.channels,[e.id]:{enabled:t}}})},disabled:e.required})]}),!e.required&&r.channels[e.id]?.enabled&&(0,F.jsx)(se,{type:`single`,collapsible:!0,className:`mt-4`,children:(0,F.jsxs)(I,{value:`config`,children:[(0,F.jsx)(ce,{children:`Configuración`}),(0,F.jsx)(le,{children:(0,F.jsxs)(`div`,{className:`space-y-3 pt-2`,children:[e.id===`telegram`&&(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`telegramToken`,children:`Token del Bot`}),(0,F.jsx)(b,{id:`telegramToken`,placeholder:`123456789:ABCdefGHIjklMNOpqrsTUVwxyz`,value:r.channels.telegram.config?.botToken||``,onChange:e=>$({channels:{...r.channels,telegram:{enabled:!0,config:{botToken:e.target.value}}}})}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,F.jsx)(`a`,{href:`https://t.me/BotFather`,target:`_blank`,rel:`noopener noreferrer`,className:`text-amber-500 hover:underline`,children:`Obtén tu token en BotFather`})})]})}),e.id===`discord`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`discordToken`,children:`Token del Bot`}),(0,F.jsx)(b,{id:`discordToken`,placeholder:`MTIzNDU2Nzg5MDEyMzQ1Njc4OQ.GJKlMn.OpQrStUvWxYz`,value:r.channels.discord.config?.botToken||``,onChange:e=>$({channels:{...r.channels,discord:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`discordClientId`,children:`Client ID`}),(0,F.jsx)(b,{id:`discordClientId`,placeholder:`1234567890123456789`,value:r.channels.discord.config?.clientId||``,onChange:e=>$({channels:{...r.channels,discord:{enabled:!0,config:{clientId:e.target.value}}}})})]})]}),e.id===`whatsapp`&&(0,F.jsx)(F.Fragment,{children:(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`whatsappToken`,children:`Token de la API`}),(0,F.jsx)(b,{id:`whatsappToken`,placeholder:`...`,value:r.channels.whatsapp.config?.apiToken||``,onChange:e=>$({channels:{...r.channels,whatsapp:{enabled:!0,config:{apiToken:e.target.value}}}})})]})}),e.id===`slack`&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`slackToken`,children:`Bot Token`}),(0,F.jsx)(b,{id:`slackToken`,placeholder:`xoxb-...`,value:r.channels.slack.config?.botToken||``,onChange:e=>$({channels:{...r.channels,slack:{enabled:!0,config:{botToken:e.target.value}}}})})]}),(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{htmlFor:`slackSigningSecret`,children:`Signing Secret`}),(0,F.jsx)(b,{id:`slackSigningSecret`,placeholder:`...`,value:r.channels.slack.config?.signingSecret||``,onChange:e=>$({channels:{...r.channels,slack:{enabled:!0,config:{signingSecret:e.target.value}}}})})]})]})]})})]})})]})},e.id))})]}),Ae=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Reglas éticas`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Define los límites de tu agente`})]}),(0,F.jsx)(oe,{children:(0,F.jsxs)(N,{className:`text-sm`,children:[`Las reglas de categoría `,(0,F.jsx)(`strong`,{className:`text-red-500`,children:`NUNCA`}),` son las protecciones más importantes. Desactivarlas puede comprometer la seguridad.`]})}),(0,F.jsxs)(`div`,{className:`space-y-3`,children:[Q.map(e=>{let t=r.ethicsRules[e.id]!==!1;return(0,F.jsx)(M,{className:m(!t&&`opacity-60`),children:(0,F.jsx)(A,{className:`p-4`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(L,{checked:t,onCheckedChange:t=>{e.isDefault&&!t&&!confirm(`¿Estás seguro de desactivar los lineamientos éticos por defecto?`)||$({ethicsRules:{...r.ethicsRules,[e.id]:t}})}}),(0,F.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`h3`,{className:`font-medium`,children:e.name}),e.isDefault&&(0,F.jsx)(x,{className:`text-xs bg-blue-500/10 text-blue-500`,children:`Por defecto`})]}),e.description&&(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,F.jsxs)(`details`,{className:`mt-2`,children:[(0,F.jsx)(`summary`,{className:`text-xs text-muted-foreground cursor-pointer hover:text-foreground`,children:`Ver contenido`}),(0,F.jsx)(`pre`,{className:`text-xs mt-2 p-2 bg-muted rounded whitespace-pre-wrap font-mono`,children:e.content})]})]})]})})},e.id)}),Q.length===0&&(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`Cargando lineamientos éticos...`})]}),(0,F.jsx)(_,{variant:`outline`,className:`w-full`,onClick:()=>{let e=prompt(`Ingresa tu regla personalizada:`);if(e){let t=prompt(`Categoría (SIEMPRE/NUNCA/CONFIRMAR):`,`CONFIRMAR`);t&&[`SIEMPRE`,`NUNCA`,`CONFIRMAR`].includes(t.toUpperCase())&&$({customRules:[...r.customRules,{text:e,category:t.toUpperCase()}]})}},children:`+ Añadir regla personalizada`}),r.customRules.length>0&&(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(S,{children:`Reglas personalizadas`}),r.customRules.map((e,t)=>(0,F.jsx)(M,{children:(0,F.jsxs)(A,{className:`p-4 flex items-center justify-between`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`font-medium`,children:e.text}),(0,F.jsx)(x,{className:m(`text-xs mt-1`,e.category===`NUNCA`&&`text-red-500 bg-red-500/10`,e.category===`SIEMPRE`&&`text-green-500 bg-green-500/10`,e.category===`CONFIRMAR`&&`text-amber-500 bg-amber-500/10`),children:e.category})]}),(0,F.jsx)(_,{variant:`ghost`,size:`sm`,onClick:()=>{$({customRules:r.customRules.filter((e,n)=>n!==t)})},children:`Eliminar`})]})},t))]})]}),je=()=>(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,F.jsx)(`h2`,{className:`text-2xl font-bold`,children:`¡Todo listo!`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Revisa tu configuración antes de continuar`})]}),s?(0,F.jsx)(M,{className:`border-green-500 bg-green-500/10`,children:(0,F.jsxs)(A,{className:`p-8 text-center space-y-4`,children:[(0,F.jsx)(`div`,{className:`flex justify-center`,children:(0,F.jsxs)(`div`,{className:`relative`,children:[(0,F.jsx)(g,{className:`w-24 h-24 text-amber-500 animate-pulse`,fill:`currentColor`}),(0,F.jsx)(p,{className:`w-8 h-8 text-amber-300 absolute -top-2 -right-2 animate-bounce`})]})}),(0,F.jsx)(`h3`,{className:`text-xl font-bold`,children:`¡Bienvenido a Hive!`}),(0,F.jsxs)(`p`,{className:`text-muted-foreground`,children:[r.agentName,` está listo para ayudarte.`]})]})}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(M,{children:[(0,F.jsxs)(k,{children:[(0,F.jsxs)(O,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`div`,{className:`w-10 h-10 rounded-lg flex items-center justify-center bg-amber-500`,children:(0,F.jsx)(g,{className:`w-6 h-6 text-white`,fill:`currentColor`})}),r.agentName]}),(0,F.jsx)(j,{children:r.agentDescription||`Sin descripción`})]}),(0,F.jsxs)(A,{className:`space-y-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(S,{className:`text-sm text-muted-foreground`,children:`Tu correo`}),(0,F.jsx)(`p`,{className:`font-medium`,children:r.userEmail.trim().toLowerCase()})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(S,{className:`text-sm text-muted-foreground`,children:`Proveedor`}),(0,F.jsxs)(`p`,{className:`font-medium`,children:[K.find(e=>e.id===r.provider)?.name||r.provider,` — `,r.model]})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(S,{className:`text-sm text-muted-foreground`,children:`Canales activos`}),(0,F.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(r.channels).filter(([e,t])=>t.enabled).map(([e])=>{let t=z.find(t=>t.id===e);return(0,F.jsxs)(x,{variant:`secondary`,children:[t?.icon,` `,t?.name]},e)})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(S,{className:`text-sm text-muted-foreground`,children:`Reglas éticas activas`}),(0,F.jsx)(`div`,{className:`flex gap-2 flex-wrap mt-1`,children:Object.entries(r.ethicsRules).filter(([e,t])=>t).map(([e])=>(0,F.jsx)(x,{variant:`outline`,children:Q.find(t=>t.id===e)?.name??e},e))})]})]})]}),(0,F.jsx)(_,{className:`w-full h-14 text-lg bg-amber-500 hover:bg-amber-600`,onClick:we,disabled:a,children:a?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(y,{className:`w-5 h-5 mr-2 animate-spin`}),`Configurando...`]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(p,{className:`w-5 h-5 mr-2`}),`Iniciar a `,r.agentName]})})]})]});return(0,F.jsx)(`div`,{className:`min-h-screen bg-gradient-to-b from-background to-muted/20`,children:(0,F.jsxs)(`div`,{className:`container max-w-2xl mx-auto py-8 px-4`,children:[(0,F.jsxs)(`div`,{className:`mb-8 space-y-2`,children:[(0,F.jsxs)(`div`,{className:`flex justify-between text-sm text-muted-foreground`,children:[(0,F.jsxs)(`span`,{children:[`Paso `,t,` de `,V]}),(0,F.jsx)(`button`,{onClick:Se,className:`text-xs text-muted-foreground hover:text-foreground`,children:`Reiniciar configuración`})]}),(0,F.jsx)(re,{value:t/V*100,className:`h-2`})]}),Te(),W&&(0,F.jsx)(oe,{variant:`destructive`,className:`mt-6`,children:(0,F.jsx)(N,{children:W})}),!s&&(0,F.jsxs)(`div`,{className:`flex justify-between mt-6 pt-6 border-t`,children:[(0,F.jsx)(_,{variant:`outline`,onClick:xe,disabled:t===1,children:`← Anterior`}),t<V?(0,F.jsx)(_,{onClick:be,className:`bg-amber-500 hover:bg-amber-600`,children:`Siguiente →`}):(0,F.jsx)(`div`,{})]})]})})}export{W as default};
|