@johpaz/hive-agents 0.0.37 → 0.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +16 -16
  2. package/dist/hive.js +107 -105
  3. package/dist/tool-worker.js +25 -36
  4. package/dist/ui/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
  5. package/dist/ui/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
  6. package/dist/ui/assets/AgentNewPage-B3n0LUck.js +1 -0
  7. package/dist/ui/{dist/assets/AgentsPage-YvSgWRiw.js → assets/AgentsPage-DGNLDXjR.js} +1 -1
  8. package/dist/ui/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
  9. package/dist/ui/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
  10. package/dist/ui/{dist/assets/DashboardPage-ghl1ZguH.js → assets/DashboardPage-VyXXp3U1.js} +1 -1
  11. package/dist/ui/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
  12. package/dist/ui/{dist/assets/LogsPage-DAPBHkwK.js → assets/LogsPage-B2lY9maY.js} +1 -1
  13. package/dist/ui/{dist/assets/MeetingPage-WjjGOqqU.js → assets/MeetingPage-2ky_hKiG.js} +1 -1
  14. package/dist/ui/{dist/assets/ProvidersPage-Ct6HsAi1.js → assets/ProvidersPage-CEyUM2tD.js} +1 -1
  15. package/dist/ui/{dist/assets/RecoverPage-DpW3l-yv.js → assets/RecoverPage-B-hDZUM2.js} +1 -1
  16. package/dist/ui/{dist/assets/SettingsPage-DBJ7_E6C.js → assets/SettingsPage-eO0i3g8p.js} +1 -1
  17. package/dist/ui/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
  18. package/dist/ui/assets/WebChatPage-BuGT2AL0.js +16 -0
  19. package/dist/ui/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
  20. package/dist/ui/{dist/assets/alert-dialog-C5mzbHdP.js → assets/alert-dialog-DQvltYmf.js} +1 -1
  21. package/dist/ui/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
  22. package/dist/ui/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
  23. package/dist/ui/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
  24. package/dist/ui/{dist/assets/index-DMCjjdqf.js → assets/index-CQ7fn00w.js} +2 -2
  25. package/dist/ui/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
  26. package/dist/ui/assets/useProviders-CnlC_qCS.js +1 -0
  27. package/dist/ui/dist/assets/{AgentCreateForm-tJZv9FZC.js → AgentCreateForm-0oFbN3gj.js} +1 -1
  28. package/dist/ui/dist/assets/{AgentDetailPage-Du-mRcAX.js → AgentDetailPage-BJ4L2fNJ.js} +1 -1
  29. package/dist/ui/dist/assets/AgentNewPage-B3n0LUck.js +1 -0
  30. package/dist/ui/{assets/AgentsPage-YvSgWRiw.js → dist/assets/AgentsPage-DGNLDXjR.js} +1 -1
  31. package/dist/ui/dist/assets/{CanvasPage-DtMwGvxf.js → CanvasPage-CnMO1FN8.js} +1 -1
  32. package/dist/ui/dist/assets/{ChannelsPage-BdBXWHjj.js → ChannelsPage-fbF8K4MR.js} +1 -1
  33. package/dist/ui/{assets/DashboardPage-ghl1ZguH.js → dist/assets/DashboardPage-VyXXp3U1.js} +1 -1
  34. package/dist/ui/dist/assets/{LoginPage-CAmSI9Vy.js → LoginPage-DPj2s2Qq.js} +1 -1
  35. package/dist/ui/{assets/LogsPage-DAPBHkwK.js → dist/assets/LogsPage-B2lY9maY.js} +1 -1
  36. package/dist/ui/{assets/MeetingPage-WjjGOqqU.js → dist/assets/MeetingPage-2ky_hKiG.js} +1 -1
  37. package/dist/ui/{assets/ProvidersPage-Ct6HsAi1.js → dist/assets/ProvidersPage-CEyUM2tD.js} +1 -1
  38. package/dist/ui/{assets/RecoverPage-DpW3l-yv.js → dist/assets/RecoverPage-B-hDZUM2.js} +1 -1
  39. package/dist/ui/{assets/SettingsPage-DBJ7_E6C.js → dist/assets/SettingsPage-eO0i3g8p.js} +1 -1
  40. package/dist/ui/dist/assets/{SetupPage-DKmLVUaj.js → SetupPage-ByYqTELb.js} +1 -1
  41. package/dist/ui/dist/assets/WebChatPage-BuGT2AL0.js +16 -0
  42. package/dist/ui/dist/assets/{alert-C-NE-P3s.js → alert-Bq6awLlW.js} +1 -1
  43. package/dist/ui/{assets/alert-dialog-C5mzbHdP.js → dist/assets/alert-dialog-DQvltYmf.js} +1 -1
  44. package/dist/ui/dist/assets/{badge-ChpACfWO.js → badge-DXUDdTed.js} +1 -1
  45. package/dist/ui/dist/assets/{dialog-QnZ0ad8O.js → dialog-bI9jImCS.js} +1 -1
  46. package/dist/ui/dist/assets/{es-NQNoaWDx.js → es-Cg8zdT52.js} +1 -1
  47. package/dist/ui/{assets/index-DMCjjdqf.js → dist/assets/index-CQ7fn00w.js} +2 -2
  48. package/dist/ui/dist/assets/{label-D2H1IR_J.js → label-CrH0Jj3v.js} +1 -1
  49. package/dist/ui/dist/assets/useProviders-CnlC_qCS.js +1 -0
  50. package/dist/ui/dist/index.html +1 -1
  51. package/dist/ui/index.html +1 -1
  52. package/package.json +1 -1
  53. package/packages/cli/src/commands/gateway.ts +1 -1
  54. package/packages/cli/src/commands/onboard.ts +1 -1
  55. package/packages/core/src/agent/agent-loop.ts +4 -14
  56. package/packages/core/src/agent/context-compiler.ts +1 -1
  57. package/packages/core/src/agent/conversation-store.ts +4 -5
  58. package/packages/core/src/agent/providers/index.ts +3 -4
  59. package/packages/core/src/agent/tool-selector.ts +3 -4
  60. package/packages/core/src/gateway/resolver.ts +5 -1
  61. package/packages/core/src/gateway/routes/chat.ts +16 -16
  62. package/packages/core/src/gateway/server.ts +44 -45
  63. package/packages/core/src/storage/seed.ts +39 -33
  64. package/packages/core/src/tool-runtime/index.ts +20 -0
  65. package/dist/ui/assets/AgentNewPage-DIFYd_Ys.js +0 -1
  66. package/dist/ui/assets/WebChatPage-CVRcKept.js +0 -16
  67. package/dist/ui/assets/useProviders-C6_QHsEi.js +0 -1
  68. package/dist/ui/dist/assets/AgentNewPage-DIFYd_Ys.js +0 -1
  69. package/dist/ui/dist/assets/WebChatPage-CVRcKept.js +0 -16
  70. package/dist/ui/dist/assets/useProviders-C6_QHsEi.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{t as i}from"./activity-c3pNngT_.js";import{t as a}from"./pause-BUqah9Bi.js";import{t as o}from"./play-NcZ4swwL.js";import{t as s}from"./refresh-cw-DaYdjQFk.js";import{n as c,t as l}from"./scroll-area-DkeyX32e.js";import{t as u}from"./trash-2-CNjMkoq6.js";import{M as d,j as f,x as p}from"./index-DMCjjdqf.js";import{t as m}from"./badge-ChpACfWO.js";import{n as h,t as g}from"./card-CNf6BS2e.js";var _=e(t(),1),v=n();function y(){let[e,t]=(0,_.useState)([]),[n,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)([`info`,`warn`,`error`]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),O=(0,_.useRef)(null),{url:k,status:A,subscribe:j,send:M}=p();(0,_.useEffect)(()=>{if(A!==`connected`)return;M({type:`logs_subscribe`});let e=j(`log`,e=>{w||e.logEntry&&t(t=>[...t,e.logEntry].slice(-2e3))});return()=>{M({type:`logs_unsubscribe`}),e()}},[A,j,M,w]),(0,_.useEffect)(()=>{if(E&&O.current){let e=O.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[e,E]);let N=e=>{C(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},P=(0,_.useMemo)(()=>e.filter(e=>{let t=S.includes(e.level),n=e.message.toLowerCase().includes(b.toLowerCase())||e.meta&&JSON.stringify(e.meta).toLowerCase().includes(b.toLowerCase());return t&&n}),[e,S,b]),F=e=>{switch(e){case`error`:return`bg-red-500/10 text-red-500 border-red-500/20`;case`warn`:return`bg-yellow-500/10 text-yellow-500 border-yellow-500/20`;case`debug`:return`bg-slate-500/10 text-slate-500 border-slate-500/20`;default:return`bg-blue-500/10 text-blue-500 border-blue-500/20`}};return(0,v.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-8rem)] space-y-4 mt-10`,children:[(0,v.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Logs del Sistema`}),(0,v.jsx)(`p`,{className:`text-muted-foreground`,children:`Monitoreo en tiempo real de la actividad del enjambre.`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>T(!w),className:w?`text-yellow-500 border-yellow-500/50 hover:bg-yellow-500/10`:``,children:[w?(0,v.jsx)(o,{className:`h-4 w-4 mr-2`}):(0,v.jsx)(a,{className:`h-4 w-4 mr-2`}),w?`Renaudar`:`Pausar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>t([]),children:[(0,v.jsx)(u,{className:`h-4 w-4 mr-2`}),`Limpiar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>{},disabled:!0,className:`opacity-50`,children:[(0,v.jsx)(s,{className:`h-4 w-4 mr-2`}),`Sincronizado via WS`]})]})]}),(0,v.jsx)(g,{className:`bg-muted/30`,children:(0,v.jsxs)(h,{className:`p-3 flex flex-wrap items-center gap-4`,children:[(0,v.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,v.jsx)(c,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,v.jsx)(f,{placeholder:`Buscar en logs...`,className:`pl-9 h-9 bg-background`,value:b,onChange:e=>x(e.target.value)})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-background rounded-md border text-xs`,children:[`debug`,`info`,`warn`,`error`].map(e=>(0,v.jsx)(`button`,{onClick:()=>N(e),className:r(`px-2 py-1 rounded capitalize transition-colors`,S.includes(e)?F(e).split(` `)[1]+` `+F(e).split(` `)[0]:`text-muted-foreground hover:bg-muted`),children:e},e))}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer select-none`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`sr-only`,checked:E,onChange:()=>D(!E)}),(0,v.jsx)(`div`,{className:r(`w-8 h-4 rounded-full relative transition-colors`,E?`bg-primary`:`bg-muted border shadow-inner`),children:(0,v.jsx)(`div`,{className:r(`absolute top-0.5 w-3 h-3 rounded-full bg-white transition-all shadow-sm`,E?`left-[17px]`:`left-0.5`)})}),`Auto-scroll`]}),(0,v.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,v.jsx)(`div`,{className:r(`w-2 h-2 rounded-full`,A===`connected`?`bg-green-500 animate-pulse`:`bg-red-500`)}),A===`connected`?`STREAMING`:`OFFLINE`,(0,v.jsx)(`span`,{className:`mx-1 opacity-30`,children:`|`}),P.length,` de `,e.length,` entradas`]})]})}),(0,v.jsx)(g,{className:`flex-1 overflow-hidden border-2`,children:(0,v.jsx)(h,{className:`p-0 h-full bg-black/95`,children:(0,v.jsx)(l,{className:`h-full w-full`,ref:O,children:(0,v.jsxs)(`div`,{className:`p-4 font-mono text-[11px] leading-relaxed`,children:[P.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 text-muted-foreground opacity-50`,children:[(0,v.jsx)(i,{className:`h-10 w-10 mb-4 stroke-[1]`}),(0,v.jsx)(`p`,{children:n?`Analizando registros...`:`No se encontraron logs con los filtros activos.`})]}):(0,v.jsx)(`div`,{className:`space-y-0.5`,children:P.map(e=>(0,v.jsxs)(`div`,{className:`group flex items-start gap-3 py-0.5 hover:bg-white/5 rounded px-1 transition-colors`,children:[(0,v.jsx)(`span`,{className:`text-slate-600 shrink-0 select-none hidden md:inline`,children:e.timestamp.includes(`T`)?e.timestamp.split(`T`)[1].split(`.`)[0]:e.timestamp}),(0,v.jsx)(m,{variant:`outline`,className:r(`px-1 py-0 h-4 text-[9px] uppercase font-bold shrink-0 border`,F(e.level)),children:e.level}),(0,v.jsxs)(`div`,{className:`flex-1 break-all text-slate-300`,children:[(0,v.jsxs)(`span`,{className:`text-slate-500 mr-2`,children:[`[`,e.source,`]`]}),e.message,e.meta&&(0,v.jsx)(`span`,{className:`text-slate-500 ml-2 italic opacity-60`,children:JSON.stringify(e.meta)})]})]},`${e.timestamp}-${e.source}-${e.message.slice(0,30)}`))}),(0,v.jsx)(`div`,{className:`h-4`}),` `]})})})})]})}export{y as LogsPage};
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./utils-3pnRFmFe.js";import{t as i}from"./activity-c3pNngT_.js";import{t as a}from"./pause-BUqah9Bi.js";import{t as o}from"./play-NcZ4swwL.js";import{t as s}from"./refresh-cw-DaYdjQFk.js";import{n as c,t as l}from"./scroll-area-DkeyX32e.js";import{t as u}from"./trash-2-CNjMkoq6.js";import{M as d,j as f,x as p}from"./index-CQ7fn00w.js";import{t as m}from"./badge-DXUDdTed.js";import{n as h,t as g}from"./card-CNf6BS2e.js";var _=e(t(),1),v=n();function y(){let[e,t]=(0,_.useState)([]),[n,y]=(0,_.useState)(!1),[b,x]=(0,_.useState)(``),[S,C]=(0,_.useState)([`info`,`warn`,`error`]),[w,T]=(0,_.useState)(!1),[E,D]=(0,_.useState)(!0),O=(0,_.useRef)(null),{url:k,status:A,subscribe:j,send:M}=p();(0,_.useEffect)(()=>{if(A!==`connected`)return;M({type:`logs_subscribe`});let e=j(`log`,e=>{w||e.logEntry&&t(t=>[...t,e.logEntry].slice(-2e3))});return()=>{M({type:`logs_unsubscribe`}),e()}},[A,j,M,w]),(0,_.useEffect)(()=>{if(E&&O.current){let e=O.current.querySelector(`[data-radix-scroll-area-viewport]`);e&&(e.scrollTop=e.scrollHeight)}},[e,E]);let N=e=>{C(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},P=(0,_.useMemo)(()=>e.filter(e=>{let t=S.includes(e.level),n=e.message.toLowerCase().includes(b.toLowerCase())||e.meta&&JSON.stringify(e.meta).toLowerCase().includes(b.toLowerCase());return t&&n}),[e,S,b]),F=e=>{switch(e){case`error`:return`bg-red-500/10 text-red-500 border-red-500/20`;case`warn`:return`bg-yellow-500/10 text-yellow-500 border-yellow-500/20`;case`debug`:return`bg-slate-500/10 text-slate-500 border-slate-500/20`;default:return`bg-blue-500/10 text-blue-500 border-blue-500/20`}};return(0,v.jsxs)(`div`,{className:`flex flex-col h-[calc(100vh-8rem)] space-y-4 mt-10`,children:[(0,v.jsxs)(`div`,{className:`flex flex-col md:flex-row md:items-center justify-between gap-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Logs del Sistema`}),(0,v.jsx)(`p`,{className:`text-muted-foreground`,children:`Monitoreo en tiempo real de la actividad del enjambre.`})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>T(!w),className:w?`text-yellow-500 border-yellow-500/50 hover:bg-yellow-500/10`:``,children:[w?(0,v.jsx)(o,{className:`h-4 w-4 mr-2`}):(0,v.jsx)(a,{className:`h-4 w-4 mr-2`}),w?`Renaudar`:`Pausar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>t([]),children:[(0,v.jsx)(u,{className:`h-4 w-4 mr-2`}),`Limpiar`]}),(0,v.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>{},disabled:!0,className:`opacity-50`,children:[(0,v.jsx)(s,{className:`h-4 w-4 mr-2`}),`Sincronizado via WS`]})]})]}),(0,v.jsx)(g,{className:`bg-muted/30`,children:(0,v.jsxs)(h,{className:`p-3 flex flex-wrap items-center gap-4`,children:[(0,v.jsxs)(`div`,{className:`relative flex-1 min-w-[200px]`,children:[(0,v.jsx)(c,{className:`absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground`}),(0,v.jsx)(f,{placeholder:`Buscar en logs...`,className:`pl-9 h-9 bg-background`,value:b,onChange:e=>x(e.target.value)})]}),(0,v.jsx)(`div`,{className:`flex items-center gap-1.5 p-1 bg-background rounded-md border text-xs`,children:[`debug`,`info`,`warn`,`error`].map(e=>(0,v.jsx)(`button`,{onClick:()=>N(e),className:r(`px-2 py-1 rounded capitalize transition-colors`,S.includes(e)?F(e).split(` `)[1]+` `+F(e).split(` `)[0]:`text-muted-foreground hover:bg-muted`),children:e},e))}),(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs cursor-pointer select-none`,children:[(0,v.jsx)(`input`,{type:`checkbox`,className:`sr-only`,checked:E,onChange:()=>D(!E)}),(0,v.jsx)(`div`,{className:r(`w-8 h-4 rounded-full relative transition-colors`,E?`bg-primary`:`bg-muted border shadow-inner`),children:(0,v.jsx)(`div`,{className:r(`absolute top-0.5 w-3 h-3 rounded-full bg-white transition-all shadow-sm`,E?`left-[17px]`:`left-0.5`)})}),`Auto-scroll`]}),(0,v.jsxs)(`div`,{className:`ml-auto flex items-center gap-2 text-[10px] text-muted-foreground`,children:[(0,v.jsx)(`div`,{className:r(`w-2 h-2 rounded-full`,A===`connected`?`bg-green-500 animate-pulse`:`bg-red-500`)}),A===`connected`?`STREAMING`:`OFFLINE`,(0,v.jsx)(`span`,{className:`mx-1 opacity-30`,children:`|`}),P.length,` de `,e.length,` entradas`]})]})}),(0,v.jsx)(g,{className:`flex-1 overflow-hidden border-2`,children:(0,v.jsx)(h,{className:`p-0 h-full bg-black/95`,children:(0,v.jsx)(l,{className:`h-full w-full`,ref:O,children:(0,v.jsxs)(`div`,{className:`p-4 font-mono text-[11px] leading-relaxed`,children:[P.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-20 text-muted-foreground opacity-50`,children:[(0,v.jsx)(i,{className:`h-10 w-10 mb-4 stroke-[1]`}),(0,v.jsx)(`p`,{children:n?`Analizando registros...`:`No se encontraron logs con los filtros activos.`})]}):(0,v.jsx)(`div`,{className:`space-y-0.5`,children:P.map(e=>(0,v.jsxs)(`div`,{className:`group flex items-start gap-3 py-0.5 hover:bg-white/5 rounded px-1 transition-colors`,children:[(0,v.jsx)(`span`,{className:`text-slate-600 shrink-0 select-none hidden md:inline`,children:e.timestamp.includes(`T`)?e.timestamp.split(`T`)[1].split(`.`)[0]:e.timestamp}),(0,v.jsx)(m,{variant:`outline`,className:r(`px-1 py-0 h-4 text-[9px] uppercase font-bold shrink-0 border`,F(e.level)),children:e.level}),(0,v.jsxs)(`div`,{className:`flex-1 break-all text-slate-300`,children:[(0,v.jsxs)(`span`,{className:`text-slate-500 mr-2`,children:[`[`,e.source,`]`]}),e.message,e.meta&&(0,v.jsx)(`span`,{className:`text-slate-500 ml-2 italic opacity-60`,children:JSON.stringify(e.meta)})]})]},`${e.timestamp}-${e.source}-${e.message.slice(0,30)}`))}),(0,v.jsx)(`div`,{className:`h-4`}),` `]})})})})]})}export{y as LogsPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{n as i,t as a}from"./chevron-up-BYhk0K2J.js";import{t as ee}from"./file-text-BT_9S9SM.js";import{t as o}from"./history-BSG-Ypqf.js";import{n as s,t as c}from"./square-BD81nFtN.js";import{n as l,r as u,t as d}from"./gateway-url-COCbW0IR.js";import{M as f,j as p,q as m}from"./index-DMCjjdqf.js";import{t as h}from"./badge-ChpACfWO.js";var g=r(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),_=r(`MonitorSpeaker`,[[`path`,{d:`M5.5 20H8`,key:`1k40s5`}],[`path`,{d:`M17 9h.01`,key:`1j24nn`}],[`rect`,{width:`10`,height:`16`,x:`12`,y:`4`,rx:`2`,key:`ixliua`}],[`path`,{d:`M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4`,key:`1mp6e1`}],[`circle`,{cx:`17`,cy:`15`,r:`1`,key:`tqvash`}]]),v=r(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),y=e(t(),1),b=u((e,t)=>({sessions:[],activeSessionId:null,segments:[],isRecording:!1,isConnecting:!1,error:null,wsConnection:null,startSession:async(n,r=`whisper-large-v3-turbo`)=>{e({error:null,isConnecting:!0});try{let i=await(await fetch(`${d()}/api/meetings`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:n,stt_model:r})})).json();return!i.ok||!i.session?(e({error:i.error??`Error al crear sesión`,isConnecting:!1}),null):(e({activeSessionId:i.session.id,segments:[],sessions:[i.session,...t().sessions],isConnecting:!1}),i.session.id)}catch(t){return e({error:t.message,isConnecting:!1}),null}},stopSession:async()=>{let{activeSessionId:n,wsConnection:r}=t();if(n){if(r&&r.readyState===WebSocket.OPEN)r.send(JSON.stringify({type:`meeting_stop`}));else try{await fetch(`${d()}/api/meetings/${n}/stop`,{method:`POST`})}catch{}r?.close(),e({isRecording:!1,wsConnection:null})}},fetchSessions:async()=>{try{let t=await(await fetch(`${d()}/api/meetings`)).json();t.ok&&t.sessions&&e({sessions:t.sessions})}catch{}},fetchSession:async t=>{try{let n=await(await fetch(`${d()}/api/meetings/${t}`)).json();n.ok&&n.session&&e({activeSessionId:t,segments:n.segments??[]})}catch{}},addSegmentLocal:t=>e(e=>({segments:[...e.segments,t]})),setWsConnection:t=>e({wsConnection:t}),setRecording:t=>e({isRecording:t}),setConnecting:t=>e({isConnecting:t}),setError:t=>e({error:t}),clearActiveSession:()=>e({activeSessionId:null,segments:[],isRecording:!1,wsConnection:null})}));function x(e){return`${l()}/meeting-stream?meetingSessionId=${encodeURIComponent(e)}`}var S=n();function te(e){let t=Math.floor(Date.now()/1e3-e);return`${Math.floor(t/60).toString().padStart(2,`0`)}:${(t%60).toString().padStart(2,`0`)}`}async function ne(){if(!navigator.mediaDevices?.getDisplayMedia)return!1;try{let e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),t=e.getAudioTracks().length>0;return e.getTracks().forEach(e=>e.stop()),t}catch{return!1}}function re({segment:e}){return(0,S.jsxs)(`div`,{className:`flex gap-3 py-2 px-3 rounded-lg hover:bg-white/[0.03] transition-colors`,children:[e.speaker&&(0,S.jsxs)(`span`,{className:`shrink-0 text-xs font-semibold text-amber-400 mt-0.5 leading-5`,children:[`[`,e.speaker,`]`]}),(0,S.jsx)(`span`,{className:`text-sm text-zinc-300 leading-relaxed`,children:e.text})]})}function ie(){return(0,S.jsxs)(`span`,{className:`relative flex h-3 w-3`,children:[(0,S.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75`}),(0,S.jsx)(`span`,{className:`relative inline-flex rounded-full h-3 w-3 bg-red-500`})]})}function ae(){let{sessions:e,activeSessionId:t,segments:n,isRecording:r,isConnecting:l,error:u,wsConnection:ae,startSession:C,stopSession:w,fetchSessions:T,addSegmentLocal:E,setWsConnection:D,setRecording:O,setError:k,clearActiveSession:oe}=b(),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(`00:00`),[P,F]=(0,y.useState)(!0),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(`microphone`),[H,U]=(0,y.useState)(null),W=(0,y.useRef)(null),G=(0,y.useRef)([]),K=(0,y.useRef)(null),q=(0,y.useRef)(null),J=(0,y.useRef)(null),Y=(0,y.useRef)(null),X=(0,y.useRef)(null),Z=(0,y.useRef)(!1),Q=e.find(e=>e.id===t);(0,y.useEffect)(()=>{if(!r||!Q)return;let e=setInterval(()=>N(te(Q.started_at)),1e3);return()=>clearInterval(e)},[r,Q]),(0,y.useEffect)(()=>{X.current?.scrollIntoView({behavior:`smooth`})},[n]),(0,y.useEffect)(()=>{T()},[]),(0,y.useEffect)(()=>{ne().then(e=>{U(e)})},[]);let $=(0,y.useCallback)(async()=>{if(!A.trim()){k(`Ingresa el título de la reunión`);return}if(k(null),z(!1),!navigator.mediaDevices?.getUserMedia){k(`Tu navegador no puede acceder al micrófono. Asegúrate de usar HTTPS o localhost.`);return}let e=`audio/webm`,t,n=`microphone`;try{let e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});K.current=e;let r;if(H)try{r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),q.current=r,n=r.getAudioTracks().length>0?`system`:`microphone`}catch{n=`microphone`}if(n===`system`&&r){let n=new AudioContext;J.current=n;let i=n.createMediaStreamDestination();Y.current=i,n.createMediaStreamSource(e).connect(i),n.createMediaStreamSource(r).connect(i),t=new MediaStream([...i.stream.getAudioTracks()]),V(`dual`)}else t=e,V(`microphone`)}catch(e){let t=e.name;k(t===`NotAllowedError`||t===`PermissionDeniedError`?`Permiso de micrófono denegado. Ve a la configuración del navegador (🔒 en la barra de URL) y permite el micrófono.`:t===`NotFoundError`?`No se encontró ningún micrófono en este dispositivo.`:`No se pudo acceder al micrófono: ${e.message}`);return}K.current=t;let r=await C(A.trim());if(!r){t.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop());return}let i=new WebSocket(x(r));D(i);let a=()=>{if(!Z.current||i.readyState!==WebSocket.OPEN)return;G.current=[];let n=new MediaRecorder(t,{mimeType:e});W.current=n,n.ondataavailable=e=>{e.data.size>0&&G.current.push(e.data)},n.onstop=()=>{if(G.current.length===0){Z.current&&i.readyState===WebSocket.OPEN&&a();return}let t=new Blob(G.current,{type:e}),n=new FileReader;n.readAsDataURL(t),n.onloadend=()=>{let t=n.result.split(`,`)[1];i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`audio_chunk`,audio:t,mime_type:e})),Z.current&&i.readyState===WebSocket.OPEN&&a()}},n.start(),setTimeout(()=>{n.state===`recording`&&n.stop()},5e3)};i.onopen=()=>{Z.current=!0,O(!0),a()},i.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`transcript_segment`&&E({seq:t.seq,speaker:t.speaker||null,text:t.text}),t.type===`meeting_stopped`&&(Z.current=!1,O(!1)),t.type===`error`&&k(t.error)}catch{}},i.onerror=()=>k(`Error en la conexión WebSocket`),i.onclose=()=>{Z.current=!1,O(!1),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close()}},[A,C,D,O,k,E,H]),se=(0,y.useCallback)(async()=>{Z.current=!1,W.current?.stop(),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close(),await w(),N(`00:00`)},[w]),ce=(0,y.useCallback)(async()=>{if(t){L(!0),k(null);try{(await fetch(`${d()}/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Genera el reporte de la reunión ${t}`})})).ok?z(!0):k(`Error al enviar el mensaje al agente`)}catch(e){k(e.message)}finally{L(!1)}}},[t,k]),le=!r&&t,ue=!r&&!Q?.status.startsWith(`stop`)&&!t;return(0,S.jsxs)(`div`,{className:`flex h-full flex-col bg-[#111319] text-white`,children:[(0,S.jsx)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] bg-[#191b22]/80 backdrop-blur-sm`,children:(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,S.jsx)(v,{className:`h-4 w-4 text-amber-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-sm font-semibold text-white leading-tight`,children:`Transcripción de Reuniones`}),(0,S.jsx)(`p`,{className:`text-[11px] text-zinc-500 leading-tight`,children:`Captura · Transcribe · Informa en tiempo real`})]})]}),r&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-full bg-red-500/10 border border-red-500/20`,children:[(0,S.jsx)(ie,{}),(0,S.jsx)(`span`,{className:`text-xs font-semibold text-red-400 tabular-nums`,children:M})]})]})}),(0,S.jsxs)(`div`,{className:`flex flex-col lg:flex-row flex-1 overflow-hidden min-h-0`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] space-y-3`,children:[ue?(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,S.jsx)(p,{placeholder:`Nombre de la reunión...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>e.key===`Enter`&&$(),className:`flex-1 bg-white/[0.04] border-white/[0.08] text-white placeholder:text-zinc-600 focus-visible:ring-amber-500/40 focus-visible:border-amber-500/40 rounded-xl h-10`,disabled:l}),(0,S.jsxs)(f,{onClick:$,disabled:l||!A.trim(),className:`shrink-0 bg-amber-500 hover:bg-amber-400 active:bg-amber-600 text-black font-semibold rounded-xl h-10 px-5 shadow-lg shadow-amber-900/30 transition-all`,children:[(0,S.jsx)(s,{className:`h-4 w-4 mr-1.5`}),l?`Iniciando...`:`Iniciar`]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,S.jsx)(h,{variant:`outline`,className:r?`border-red-500/40 text-red-400 bg-red-500/10 rounded-full px-2.5`:`border-zinc-600/40 text-zinc-400 bg-white/[0.04] rounded-full px-2.5`,children:r?`● REC`:`Detenida`}),B!==`microphone`&&r&&(0,S.jsx)(h,{variant:`outline`,className:`border-blue-500/40 text-blue-400 bg-blue-500/10 rounded-full px-2.5`,children:B===`dual`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Mic+Altavozz`]}):B===`system`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Altavozz`]}):null}),(0,S.jsx)(`span`,{className:`text-sm font-medium text-zinc-200 truncate max-w-[180px]`,children:Q?.title}),r&&(0,S.jsxs)(`span`,{className:`hidden sm:flex items-center gap-1 text-xs text-zinc-500`,children:[(0,S.jsx)(m,{className:`h-3 w-3`}),M]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[r&&(0,S.jsxs)(f,{variant:`outline`,size:`sm`,onClick:se,className:`border-red-500/30 text-red-400 hover:bg-red-500/10 hover:border-red-500/50 rounded-xl h-8`,children:[(0,S.jsx)(c,{className:`h-3 w-3 mr-1.5 fill-current`}),`Detener`]}),le&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(f,{size:`sm`,onClick:ce,disabled:I||R,className:`bg-amber-500 hover:bg-amber-400 text-black font-semibold rounded-xl h-8 px-3 shadow-md shadow-amber-900/30 disabled:opacity-60`,children:[(0,S.jsx)(ee,{className:`h-3.5 w-3.5 mr-1.5`}),I?`Generando...`:R?`Enviado ✓`:`Generar Reporte`]}),(0,S.jsx)(f,{variant:`ghost`,size:`sm`,onClick:oe,className:`text-zinc-500 hover:text-zinc-300 hover:bg-white/[0.05] rounded-xl h-8`,children:`Nueva reunión`})]})]})]}),u&&(0,S.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3.5 py-2.5 rounded-xl bg-red-500/[0.08] border border-red-500/20 text-xs text-red-400`,children:[(0,S.jsx)(`span`,{className:`shrink-0 mt-px`,children:`⚠`}),(0,S.jsx)(`span`,{children:u})]}),R&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl bg-emerald-500/[0.08] border border-emerald-500/20 text-xs text-emerald-400`,children:[(0,S.jsx)(`span`,{children:`✓`}),(0,S.jsx)(`span`,{children:`El agente está generando el reporte. Verifica el chat para el informe completo.`})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 min-h-0`,children:n.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-zinc-600`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-2xl bg-white/[0.03] border border-white/[0.06]`,children:(0,S.jsx)(g,{className:`h-7 w-7`})}),(0,S.jsx)(`p`,{className:`text-sm text-center max-w-[220px] leading-relaxed`,children:r?`Escuchando… las transcripciones aparecerán aquí`:`Inicia una sesión para ver la transcripción en tiempo real`})]}):(0,S.jsxs)(`div`,{className:`space-y-0.5`,children:[n.map(e=>(0,S.jsx)(re,{segment:e},e.seq)),(0,S.jsx)(`div`,{ref:X})]})}),n.length>0&&(0,S.jsxs)(`div`,{className:`shrink-0 border-t border-white/[0.06] px-5 py-2 flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-[11px] text-zinc-600`,children:[n.length,` segmento`,n.length===1?``:`s`,` transcritos`]}),r&&(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-zinc-500`,children:[(0,S.jsx)(m,{className:`h-3 w-3`}),M]})]})]}),(0,S.jsxs)(`div`,{className:`shrink-0 flex flex-col lg:w-64 xl:w-72 border-t lg:border-t-0 lg:border-l border-white/[0.06] bg-[#191b22]/40 max-h-60 lg:max-h-none`,children:[(0,S.jsxs)(`button`,{onClick:()=>F(!P),className:`flex items-center justify-between px-4 py-3 text-[11px] font-semibold text-zinc-500 uppercase tracking-wider hover:text-zinc-300 border-b border-white/[0.06] transition-colors`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-3.5 w-3.5`}),`Historial (`,e.length,`)`]}),P?(0,S.jsx)(a,{className:`h-3 w-3`}):(0,S.jsx)(i,{className:`h-3 w-3`})]}),P&&(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 gap-2 text-zinc-600`,children:[(0,S.jsx)(o,{className:`h-6 w-6 opacity-40`}),(0,S.jsx)(`p`,{className:`text-xs`,children:`Sin reuniones aún`})]}):(0,S.jsx)(`div`,{className:`py-1`,children:e.map(e=>(0,S.jsxs)(`button`,{onClick:()=>b.getState().fetchSession(e.id),className:`w-full text-left px-4 py-3 hover:bg-white/[0.04] transition-colors border-b border-white/[0.04] ${e.id===t?`bg-amber-500/[0.06]`:``}`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-zinc-200 truncate leading-snug`,children:e.title}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,S.jsx)(h,{variant:`outline`,className:`text-[10px] px-1.5 py-0 rounded-full border-0 ${e.status===`active`?`bg-emerald-500/15 text-emerald-400`:e.status===`report_ready`?`bg-blue-500/15 text-blue-400`:`bg-white/[0.05] text-zinc-500`}`,children:e.status===`active`?`activa`:e.status===`report_ready`?`con reporte`:`detenida`}),e.segment_count!==void 0&&e.segment_count>0&&(0,S.jsxs)(`span`,{className:`text-[10px] text-zinc-600`,children:[e.segment_count,` seg`]})]})]},e.id))})})]})]})]})}function C(){return(0,S.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,S.jsx)(ae,{})})}export{C as MeetingPage};
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{n as i,t as a}from"./chevron-up-BYhk0K2J.js";import{t as ee}from"./file-text-BT_9S9SM.js";import{t as o}from"./history-BSG-Ypqf.js";import{n as s,t as c}from"./square-BD81nFtN.js";import{n as l,r as u,t as d}from"./gateway-url-COCbW0IR.js";import{M as f,j as p,q as m}from"./index-CQ7fn00w.js";import{t as h}from"./badge-DXUDdTed.js";var g=r(`MicOff`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M18.89 13.23A7.12 7.12 0 0 0 19 12v-2`,key:`80xlxr`}],[`path`,{d:`M5 10v2a7 7 0 0 0 12 5`,key:`p2k8kg`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}]]),_=r(`MonitorSpeaker`,[[`path`,{d:`M5.5 20H8`,key:`1k40s5`}],[`path`,{d:`M17 9h.01`,key:`1j24nn`}],[`rect`,{width:`10`,height:`16`,x:`12`,y:`4`,rx:`2`,key:`ixliua`}],[`path`,{d:`M8 6H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h4`,key:`1mp6e1`}],[`circle`,{cx:`17`,cy:`15`,r:`1`,key:`tqvash`}]]),v=r(`Radio`,[[`path`,{d:`M4.9 19.1C1 15.2 1 8.8 4.9 4.9`,key:`1vaf9d`}],[`path`,{d:`M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5`,key:`u1ii0m`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5`,key:`1j5fej`}],[`path`,{d:`M19.1 4.9C23 8.8 23 15.1 19.1 19`,key:`10b0cb`}]]),y=e(t(),1),b=u((e,t)=>({sessions:[],activeSessionId:null,segments:[],isRecording:!1,isConnecting:!1,error:null,wsConnection:null,startSession:async(n,r=`whisper-large-v3-turbo`)=>{e({error:null,isConnecting:!0});try{let i=await(await fetch(`${d()}/api/meetings`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:n,stt_model:r})})).json();return!i.ok||!i.session?(e({error:i.error??`Error al crear sesión`,isConnecting:!1}),null):(e({activeSessionId:i.session.id,segments:[],sessions:[i.session,...t().sessions],isConnecting:!1}),i.session.id)}catch(t){return e({error:t.message,isConnecting:!1}),null}},stopSession:async()=>{let{activeSessionId:n,wsConnection:r}=t();if(n){if(r&&r.readyState===WebSocket.OPEN)r.send(JSON.stringify({type:`meeting_stop`}));else try{await fetch(`${d()}/api/meetings/${n}/stop`,{method:`POST`})}catch{}r?.close(),e({isRecording:!1,wsConnection:null})}},fetchSessions:async()=>{try{let t=await(await fetch(`${d()}/api/meetings`)).json();t.ok&&t.sessions&&e({sessions:t.sessions})}catch{}},fetchSession:async t=>{try{let n=await(await fetch(`${d()}/api/meetings/${t}`)).json();n.ok&&n.session&&e({activeSessionId:t,segments:n.segments??[]})}catch{}},addSegmentLocal:t=>e(e=>({segments:[...e.segments,t]})),setWsConnection:t=>e({wsConnection:t}),setRecording:t=>e({isRecording:t}),setConnecting:t=>e({isConnecting:t}),setError:t=>e({error:t}),clearActiveSession:()=>e({activeSessionId:null,segments:[],isRecording:!1,wsConnection:null})}));function x(e){return`${l()}/meeting-stream?meetingSessionId=${encodeURIComponent(e)}`}var S=n();function te(e){let t=Math.floor(Date.now()/1e3-e);return`${Math.floor(t/60).toString().padStart(2,`0`)}:${(t%60).toString().padStart(2,`0`)}`}async function ne(){if(!navigator.mediaDevices?.getDisplayMedia)return!1;try{let e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),t=e.getAudioTracks().length>0;return e.getTracks().forEach(e=>e.stop()),t}catch{return!1}}function re({segment:e}){return(0,S.jsxs)(`div`,{className:`flex gap-3 py-2 px-3 rounded-lg hover:bg-white/[0.03] transition-colors`,children:[e.speaker&&(0,S.jsxs)(`span`,{className:`shrink-0 text-xs font-semibold text-amber-400 mt-0.5 leading-5`,children:[`[`,e.speaker,`]`]}),(0,S.jsx)(`span`,{className:`text-sm text-zinc-300 leading-relaxed`,children:e.text})]})}function ie(){return(0,S.jsxs)(`span`,{className:`relative flex h-3 w-3`,children:[(0,S.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-red-400 opacity-75`}),(0,S.jsx)(`span`,{className:`relative inline-flex rounded-full h-3 w-3 bg-red-500`})]})}function ae(){let{sessions:e,activeSessionId:t,segments:n,isRecording:r,isConnecting:l,error:u,wsConnection:ae,startSession:C,stopSession:w,fetchSessions:T,addSegmentLocal:E,setWsConnection:D,setRecording:O,setError:k,clearActiveSession:oe}=b(),[A,j]=(0,y.useState)(``),[M,N]=(0,y.useState)(`00:00`),[P,F]=(0,y.useState)(!0),[I,L]=(0,y.useState)(!1),[R,z]=(0,y.useState)(!1),[B,V]=(0,y.useState)(`microphone`),[H,U]=(0,y.useState)(null),W=(0,y.useRef)(null),G=(0,y.useRef)([]),K=(0,y.useRef)(null),q=(0,y.useRef)(null),J=(0,y.useRef)(null),Y=(0,y.useRef)(null),X=(0,y.useRef)(null),Z=(0,y.useRef)(!1),Q=e.find(e=>e.id===t);(0,y.useEffect)(()=>{if(!r||!Q)return;let e=setInterval(()=>N(te(Q.started_at)),1e3);return()=>clearInterval(e)},[r,Q]),(0,y.useEffect)(()=>{X.current?.scrollIntoView({behavior:`smooth`})},[n]),(0,y.useEffect)(()=>{T()},[]),(0,y.useEffect)(()=>{ne().then(e=>{U(e)})},[]);let $=(0,y.useCallback)(async()=>{if(!A.trim()){k(`Ingresa el título de la reunión`);return}if(k(null),z(!1),!navigator.mediaDevices?.getUserMedia){k(`Tu navegador no puede acceder al micrófono. Asegúrate de usar HTTPS o localhost.`);return}let e=`audio/webm`,t,n=`microphone`;try{let e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}});K.current=e;let r;if(H)try{r=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0,systemAudio:`include`}),q.current=r,n=r.getAudioTracks().length>0?`system`:`microphone`}catch{n=`microphone`}if(n===`system`&&r){let n=new AudioContext;J.current=n;let i=n.createMediaStreamDestination();Y.current=i,n.createMediaStreamSource(e).connect(i),n.createMediaStreamSource(r).connect(i),t=new MediaStream([...i.stream.getAudioTracks()]),V(`dual`)}else t=e,V(`microphone`)}catch(e){let t=e.name;k(t===`NotAllowedError`||t===`PermissionDeniedError`?`Permiso de micrófono denegado. Ve a la configuración del navegador (🔒 en la barra de URL) y permite el micrófono.`:t===`NotFoundError`?`No se encontró ningún micrófono en este dispositivo.`:`No se pudo acceder al micrófono: ${e.message}`);return}K.current=t;let r=await C(A.trim());if(!r){t.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop());return}let i=new WebSocket(x(r));D(i);let a=()=>{if(!Z.current||i.readyState!==WebSocket.OPEN)return;G.current=[];let n=new MediaRecorder(t,{mimeType:e});W.current=n,n.ondataavailable=e=>{e.data.size>0&&G.current.push(e.data)},n.onstop=()=>{if(G.current.length===0){Z.current&&i.readyState===WebSocket.OPEN&&a();return}let t=new Blob(G.current,{type:e}),n=new FileReader;n.readAsDataURL(t),n.onloadend=()=>{let t=n.result.split(`,`)[1];i.readyState===WebSocket.OPEN&&i.send(JSON.stringify({type:`audio_chunk`,audio:t,mime_type:e})),Z.current&&i.readyState===WebSocket.OPEN&&a()}},n.start(),setTimeout(()=>{n.state===`recording`&&n.stop()},5e3)};i.onopen=()=>{Z.current=!0,O(!0),a()},i.onmessage=e=>{try{let t=JSON.parse(e.data);t.type===`transcript_segment`&&E({seq:t.seq,speaker:t.speaker||null,text:t.text}),t.type===`meeting_stopped`&&(Z.current=!1,O(!1)),t.type===`error`&&k(t.error)}catch{}},i.onerror=()=>k(`Error en la conexión WebSocket`),i.onclose=()=>{Z.current=!1,O(!1),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close()}},[A,C,D,O,k,E,H]),se=(0,y.useCallback)(async()=>{Z.current=!1,W.current?.stop(),K.current?.getTracks().forEach(e=>e.stop()),q.current?.getTracks().forEach(e=>e.stop()),J.current?.close(),await w(),N(`00:00`)},[w]),ce=(0,y.useCallback)(async()=>{if(t){L(!0),k(null);try{(await fetch(`${d()}/api/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({message:`Genera el reporte de la reunión ${t}`})})).ok?z(!0):k(`Error al enviar el mensaje al agente`)}catch(e){k(e.message)}finally{L(!1)}}},[t,k]),le=!r&&t,ue=!r&&!Q?.status.startsWith(`stop`)&&!t;return(0,S.jsxs)(`div`,{className:`flex h-full flex-col bg-[#111319] text-white`,children:[(0,S.jsx)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] bg-[#191b22]/80 backdrop-blur-sm`,children:(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-9 h-9 rounded-xl bg-amber-500/10 border border-amber-500/20`,children:(0,S.jsx)(v,{className:`h-4 w-4 text-amber-400`})}),(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`h1`,{className:`text-sm font-semibold text-white leading-tight`,children:`Transcripción de Reuniones`}),(0,S.jsx)(`p`,{className:`text-[11px] text-zinc-500 leading-tight`,children:`Captura · Transcribe · Informa en tiempo real`})]})]}),r&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 rounded-full bg-red-500/10 border border-red-500/20`,children:[(0,S.jsx)(ie,{}),(0,S.jsx)(`span`,{className:`text-xs font-semibold text-red-400 tabular-nums`,children:M})]})]})}),(0,S.jsxs)(`div`,{className:`flex flex-col lg:flex-row flex-1 overflow-hidden min-h-0`,children:[(0,S.jsxs)(`div`,{className:`flex flex-col flex-1 min-h-0 overflow-hidden`,children:[(0,S.jsxs)(`div`,{className:`shrink-0 px-5 py-4 border-b border-white/[0.06] space-y-3`,children:[ue?(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-2`,children:[(0,S.jsx)(p,{placeholder:`Nombre de la reunión...`,value:A,onChange:e=>j(e.target.value),onKeyDown:e=>e.key===`Enter`&&$(),className:`flex-1 bg-white/[0.04] border-white/[0.08] text-white placeholder:text-zinc-600 focus-visible:ring-amber-500/40 focus-visible:border-amber-500/40 rounded-xl h-10`,disabled:l}),(0,S.jsxs)(f,{onClick:$,disabled:l||!A.trim(),className:`shrink-0 bg-amber-500 hover:bg-amber-400 active:bg-amber-600 text-black font-semibold rounded-xl h-10 px-5 shadow-lg shadow-amber-900/30 transition-all`,children:[(0,S.jsx)(s,{className:`h-4 w-4 mr-1.5`}),l?`Iniciando...`:`Iniciar`]})]}):(0,S.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 min-w-0`,children:[(0,S.jsx)(h,{variant:`outline`,className:r?`border-red-500/40 text-red-400 bg-red-500/10 rounded-full px-2.5`:`border-zinc-600/40 text-zinc-400 bg-white/[0.04] rounded-full px-2.5`,children:r?`● REC`:`Detenida`}),B!==`microphone`&&r&&(0,S.jsx)(h,{variant:`outline`,className:`border-blue-500/40 text-blue-400 bg-blue-500/10 rounded-full px-2.5`,children:B===`dual`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Mic+Altavozz`]}):B===`system`?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(_,{className:`h-3 w-3 mr-1`}),`Altavozz`]}):null}),(0,S.jsx)(`span`,{className:`text-sm font-medium text-zinc-200 truncate max-w-[180px]`,children:Q?.title}),r&&(0,S.jsxs)(`span`,{className:`hidden sm:flex items-center gap-1 text-xs text-zinc-500`,children:[(0,S.jsx)(m,{className:`h-3 w-3`}),M]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[r&&(0,S.jsxs)(f,{variant:`outline`,size:`sm`,onClick:se,className:`border-red-500/30 text-red-400 hover:bg-red-500/10 hover:border-red-500/50 rounded-xl h-8`,children:[(0,S.jsx)(c,{className:`h-3 w-3 mr-1.5 fill-current`}),`Detener`]}),le&&(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(f,{size:`sm`,onClick:ce,disabled:I||R,className:`bg-amber-500 hover:bg-amber-400 text-black font-semibold rounded-xl h-8 px-3 shadow-md shadow-amber-900/30 disabled:opacity-60`,children:[(0,S.jsx)(ee,{className:`h-3.5 w-3.5 mr-1.5`}),I?`Generando...`:R?`Enviado ✓`:`Generar Reporte`]}),(0,S.jsx)(f,{variant:`ghost`,size:`sm`,onClick:oe,className:`text-zinc-500 hover:text-zinc-300 hover:bg-white/[0.05] rounded-xl h-8`,children:`Nueva reunión`})]})]})]}),u&&(0,S.jsxs)(`div`,{className:`flex items-start gap-2.5 px-3.5 py-2.5 rounded-xl bg-red-500/[0.08] border border-red-500/20 text-xs text-red-400`,children:[(0,S.jsx)(`span`,{className:`shrink-0 mt-px`,children:`⚠`}),(0,S.jsx)(`span`,{children:u})]}),R&&(0,S.jsxs)(`div`,{className:`flex items-center gap-2.5 px-3.5 py-2.5 rounded-xl bg-emerald-500/[0.08] border border-emerald-500/20 text-xs text-emerald-400`,children:[(0,S.jsx)(`span`,{children:`✓`}),(0,S.jsx)(`span`,{children:`El agente está generando el reporte. Verifica el chat para el informe completo.`})]})]}),(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 py-4 min-h-0`,children:n.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full gap-4 text-zinc-600`,children:[(0,S.jsx)(`div`,{className:`flex items-center justify-center w-16 h-16 rounded-2xl bg-white/[0.03] border border-white/[0.06]`,children:(0,S.jsx)(g,{className:`h-7 w-7`})}),(0,S.jsx)(`p`,{className:`text-sm text-center max-w-[220px] leading-relaxed`,children:r?`Escuchando… las transcripciones aparecerán aquí`:`Inicia una sesión para ver la transcripción en tiempo real`})]}):(0,S.jsxs)(`div`,{className:`space-y-0.5`,children:[n.map(e=>(0,S.jsx)(re,{segment:e},e.seq)),(0,S.jsx)(`div`,{ref:X})]})}),n.length>0&&(0,S.jsxs)(`div`,{className:`shrink-0 border-t border-white/[0.06] px-5 py-2 flex items-center justify-between`,children:[(0,S.jsxs)(`span`,{className:`text-[11px] text-zinc-600`,children:[n.length,` segmento`,n.length===1?``:`s`,` transcritos`]}),r&&(0,S.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] text-zinc-500`,children:[(0,S.jsx)(m,{className:`h-3 w-3`}),M]})]})]}),(0,S.jsxs)(`div`,{className:`shrink-0 flex flex-col lg:w-64 xl:w-72 border-t lg:border-t-0 lg:border-l border-white/[0.06] bg-[#191b22]/40 max-h-60 lg:max-h-none`,children:[(0,S.jsxs)(`button`,{onClick:()=>F(!P),className:`flex items-center justify-between px-4 py-3 text-[11px] font-semibold text-zinc-500 uppercase tracking-wider hover:text-zinc-300 border-b border-white/[0.06] transition-colors`,children:[(0,S.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(o,{className:`h-3.5 w-3.5`}),`Historial (`,e.length,`)`]}),P?(0,S.jsx)(a,{className:`h-3 w-3`}):(0,S.jsx)(i,{className:`h-3 w-3`})]}),P&&(0,S.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:e.length===0?(0,S.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 gap-2 text-zinc-600`,children:[(0,S.jsx)(o,{className:`h-6 w-6 opacity-40`}),(0,S.jsx)(`p`,{className:`text-xs`,children:`Sin reuniones aún`})]}):(0,S.jsx)(`div`,{className:`py-1`,children:e.map(e=>(0,S.jsxs)(`button`,{onClick:()=>b.getState().fetchSession(e.id),className:`w-full text-left px-4 py-3 hover:bg-white/[0.04] transition-colors border-b border-white/[0.04] ${e.id===t?`bg-amber-500/[0.06]`:``}`,children:[(0,S.jsx)(`p`,{className:`text-xs font-medium text-zinc-200 truncate leading-snug`,children:e.title}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 mt-1`,children:[(0,S.jsx)(h,{variant:`outline`,className:`text-[10px] px-1.5 py-0 rounded-full border-0 ${e.status===`active`?`bg-emerald-500/15 text-emerald-400`:e.status===`report_ready`?`bg-blue-500/15 text-blue-400`:`bg-white/[0.05] text-zinc-500`}`,children:e.status===`active`?`activa`:e.status===`report_ready`?`con reporte`:`detenida`}),e.segment_count!==void 0&&e.segment_count>0&&(0,S.jsxs)(`span`,{className:`text-[10px] text-zinc-600`,children:[e.segment_count,` seg`]})]})]},e.id))})})]})]})]})}function C(){return(0,S.jsx)(`div`,{className:`h-full overflow-hidden`,children:(0,S.jsx)(ae,{})})}export{C as MeetingPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{a as i,c as a,l as o,n as s,r as c,s as l,t as u}from"./switch-BDwN8RYV.js";import{n as d}from"./chevron-up-BYhk0K2J.js";import{t as f}from"./chevron-right-CR4Skrf3.js";import{t as p}from"./circle-check-Bb54Ebmu.js";import{t as m}from"./cpu-Cdgc_B1K.js";import{t as h}from"./download-C3ifGMjJ.js";import{n as g,t as _}from"./eye-DqNTU_GD.js";import{t as v}from"./globe-DeCQTCDJ.js";import{t as y}from"./key-3EP0dhkT.js";import{t as b}from"./loader-circle-CZNax6kS.js";import{a as x,c as S,d as C,f as w,i as T,l as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as j}from"./table-CSc8ubon.js";import{t as ne}from"./lock-Ei1_J-Nq.js";import{n as M,t as N}from"./square-BD81nFtN.js";import{n as re,t as P}from"./terminal-DN38Q456.js";import{t as F}from"./play-NcZ4swwL.js";import{t as I}from"./plus-CX1xyhp5.js";import{t as L}from"./refresh-cw-DaYdjQFk.js";import{n as R,t as z}from"./scroll-area-DkeyX32e.js";import{t as ie}from"./settings-Ds4SqD8s.js";import{t as ae}from"./trash-2-CNjMkoq6.js";import{G as oe,M as B,R as se,W as ce,a as le,c as V,d as ue,h as H,i as de,j as U,p as fe,r as W,s as pe}from"./index-DMCjjdqf.js";import{t as G}from"./label-D2H1IR_J.js";import{c as me,i as he,o as ge,r as _e,s as ve,t as ye}from"./dialog-QnZ0ad8O.js";import{t as K}from"./badge-ChpACfWO.js";import{a as q,n as J,o as Y,r as X,t as Z}from"./card-CNf6BS2e.js";import"./useProviders-C6_QHsEi.js";var be=r(`Binary`,[[`rect`,{x:`14`,y:`14`,width:`4`,height:`6`,rx:`2`,key:`p02svl`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`6`,rx:`2`,key:`xm4xkj`}],[`path`,{d:`M6 20h4`,key:`1i6q5t`}],[`path`,{d:`M14 10h4`,key:`ru81e7`}],[`path`,{d:`M6 14h2v6`,key:`16z9wg`}],[`path`,{d:`M14 4h2v6`,key:`1idq9u`}]]),xe=r(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Se=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),$=n();function Ce({provider:e,onSave:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(e?.baseUrl||e?.base_url||``),[l,u]=(0,Q.useState)(e?.config?.headers?JSON.stringify(e.config.headers,null,2):``),[d,f]=(0,Q.useState)(e?.num_ctx?String(e.num_ctx):``),m=s||e?.baseUrl||e?.base_url||``,h=e?.id===`ollama`||m.includes(`localhost`)||m.includes(`127.0.0.1`),v=!!e?.has_api_key,y=!!e?.has_headers;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`API Key`}),v&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(p,{className:`h-3 w-3`}),`Configurada`]})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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,$.jsx)(B,{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,$.jsx)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{value:s,onChange:e=>c(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),h&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(U,{type:`number`,value:d,onChange:e=>f(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Custom Headers (JSON)`}),y&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(p,{className:`h-3 w-3`}),`Configurados`]})]}),(0,$.jsx)(`textarea`,{value:l,onChange:e=>u(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,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:n,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{let e;if(l.trim())try{e=JSON.parse(l.trim())}catch{H.fire(`Error`,`JSON de Headers inválido`,`error`);return}t&&t({apiKey:a,baseUrl:s||void 0,headers:e,numCtx:d.trim()?Number(d.trim()):null})},children:`Guardar`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var we=ie,Te=d,Ee=f,De=m,Oe=I,ke=xe,Ae=v,je=L,Me=re,Ne=ae,Pe=o,Fe=se;function Ie({provider:e,updateProvider:t,onManageModels:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(null),{models:S,toggleModel:C,createModel:w,syncModels:T,deleteModel:E,updateModel:D}=pe(),{toggleProvider:O}=V(),k=(0,Q.useMemo)(()=>{let t=S.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[S,e.id,e.models]),A=k.filter(e=>e.enabled||e.active),ee=n=>{t(e.id,n),i(!1)},te=async t=>{try{await O(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},j=async(e,t)=>{try{await C(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},ne=async()=>{p(!0);try{await T(e.id),o(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{p(!1)}},M=e=>{h(e.id),_(e.name),y(e.id)},N=()=>{h(null),_(``),y(``)},re=async e=>{let t=g.trim()||e.name,n=v.trim()||e.id;if(t===e.name&&n===e.id){N();return}try{await D(e.id,{name:t,id:n}),N()}catch(e){console.error(`Failed to update model:`,e)}},P=async e=>{x(e.id);try{await E(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{x(null)}},F=async()=>{let t=s.trim();if(t){d(!0);try{await w(e.id,t),c(``)}catch(e){console.error(`Failed to add model:`,e)}finally{d(!1)}}},I=!!e.active,L=e.base_url||e.baseUrl,R=e.id===`ollama`||L?.includes(`localhost`)||L?.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${I?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,$.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,$.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 ${I?`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,$.jsx)(De,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),I&&(0,$.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${I?`text-blue-400`:`text-white/30`}`,children:I?`ON`:`OFF`}),(0,$.jsx)(u,{checked:I,onCheckedChange:te,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,$.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(ke,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:R?`text-amber-400`:`text-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):R?(0,$.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,$.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),L&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:L})]}),R&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(De,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,$.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,$.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.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:()=>o(!a),children:[a?(0,$.jsx)(Te,{className:`h-3 w-3`}):(0,$.jsx)(Ee,{className:`h-3 w-3`}),`MODELOS`,(0,$.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[A.length,`/`,k.length]})]}),R&&(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(`button`,{type:`button`,onClick:ne,disabled:f,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,$.jsx)(je,{className:`h-3 w-3 ${f?`animate-spin`:``}`})})]})]}),!a&&k.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[k.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),k.length>3&&(0,$.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,k.length-3]})]}),a&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[k.length===0&&(0,$.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),k.map(e=>{let t=e.enabled||!!e.active,n=m===e.id;return(0,$.jsx)(`div`,{className:`rounded-lg transition-colors ${t&&!n||n?`bg-white/5`:`bg-transparent opacity-40`}`,children:n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5`,children:[(0,$.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Display name`,className:`w-full bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`API model ID`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>re(e),className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors`,children:(0,$.jsx)(Pe,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:N,className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-white/5 border border-white/10 text-white/40 hover:text-white hover:bg-white/10 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3 w-3`})})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-white truncate flex-1 mr-2`,children:e.name}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(e),title:`Editar modelo`,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,$.jsx)(Me,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(e),disabled:b===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,$.jsx)(Ne,{className:`h-3 w-3`})}),(0,$.jsx)(u,{checked:t,onCheckedChange:t=>j(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1.5 border-t border-white/5`,children:[(0,$.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&F(),placeholder:`nombre-del-modelo`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsxs)(`button`,{type:`button`,onClick:F,disabled:l||!s.trim(),className:`shrink-0 h-7 px-2.5 flex items-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 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:[(0,$.jsx)(Oe,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden xs:inline`,children:`ADD`})]})]})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:`99.9%`})]}),(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`hive-stat__value ${I?`text-emerald-400`:`text-white/30`}`,children:I?`Activo`:`Inactivo`})]})]}),(0,$.jsxs)(ye,{open:r,onOpenChange:i,children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.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,$.jsx)(we,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`CONFIG`})]})}),(0,$.jsxs)(_e,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,$.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,$.jsx)(ve,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,$.jsx)(he,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsx)(Ce,{provider:e,onSave:ee,onCancel:()=>i(!1)})})]})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${I?``:`opacity-20`}`})]})}function Le(){let{providers:e,updateProvider:t}=V(),n=e.filter(e=>e.active).length;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[n,` activos / `,e.length,` total`]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`,children:[e.map(e=>(0,$.jsx)(Ie,{provider:e,updateProvider:t},e.id)),e.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`})]})]})}function Re({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)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),v=o.toLowerCase()===`ollama`||u.includes(`localhost`)||u.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Nombre del Provider`}),(0,$.jsx)(U,{value:i,onChange:e=>a(e.target.value),placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Tipo de Provider`}),(0,$.jsx)(U,{value:o,onChange:e=>s(e.target.value),placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(G,{className:`hive-label`,children:`API Key`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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,$.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,$.jsx)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{value:u,onChange:e=>d(e.target.value),placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),v&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(U,{type:`number`,value:m,onChange:e=>h(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(G,{className:`hive-label`,children:`Custom Headers (JSON)`})}),(0,$.jsx)(`textarea`,{value:f,onChange:e=>p(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,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:t,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{if(!i.trim()){H.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){H.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){H.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{H.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:u.trim()||void 0,headers:t,numCtx:m.trim()?Number(m.trim()):null})},children:`Crear Provider`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var ze={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 Be({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,$.jsx)($.Fragment,{children:t.map(e=>(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:ze[e]??e},e))})}function Ve({model:e}){let{toggleModel:t}=pe();return(0,$.jsx)(Z,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,$.jsxs)(J,{className:`flex items-center gap-4 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold`,children:e.name}),(0,$.jsx)(K,{variant:`secondary`,className:`text-[10px]`,children:e.providerId||e.provider_id})]}),e.contextWindow&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(e.contextWindow/1e3).toFixed(0),`K tokens contexto`]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,$.jsx)(Be,{capabilities:e.capabilities})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,$.jsx)(u,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,$.jsx)(K,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function He(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ue(){let{availableModels:e,activeProviders:t}=V(),n=W(e=>e.fetchAll),[r,o]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[n]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=He(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()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),(0,$.jsx)(K,{variant:`secondary`,children:f.length})]}),(0,$.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,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-26rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,$.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]})]})})]})}function We({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:i,isDownloadingModel:a,downloadLogs:s,fetchDownloadLogs:c}=le(),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&d()},[e]);let d=async()=>{u(!0),await r(),u(!1)},f=async e=>{await i(e)},p=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,$.jsx)(ye,{open:e,onOpenChange:t,children:(0,$.jsxs)(_e,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,$.jsxs)(ge,{children:[(0,$.jsx)(ve,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,$.jsx)(he,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(K,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||a,className:`gap-2`,children:[(0,$.jsx)(L,{className:`h-4 w-4 ${l?`animate-spin`:``}`}),`Actualizar`]})]}),l&&!n.length?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,$.jsx)(b,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):n.length===0?(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,$.jsxs)(te,{children:[(0,$.jsx)(x,{children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{children:`Modelo`}),(0,$.jsx)(T,{children:`Idioma`}),(0,$.jsx)(T,{children:`Calidad`}),(0,$.jsx)(T,{children:`Tamaño`}),(0,$.jsx)(T,{children:`Estado`}),(0,$.jsx)(T,{className:`text-right`,children:`Acciones`})]})}),(0,$.jsx)(D,{children:n.map(e=>(0,$.jsxs)(O,{children:[(0,$.jsx)(A,{className:`font-medium`,children:e.name}),(0,$.jsx)(A,{children:e.language}),(0,$.jsx)(A,{children:(0,$.jsx)(K,{className:p(e.quality),children:e.quality})}),(0,$.jsx)(A,{className:`text-muted-foreground`,children:e.size}),(0,$.jsx)(A,{children:e.installed?(0,$.jsxs)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,$.jsx)(o,{className:`h-3 w-3`}),`Instalado`]}):a&&s.some(t=>t.includes(e.name))?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,$.jsx)(A,{className:`text-right`,children:e.installed?(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,$.jsx)(o,{className:`h-4 w-4`}),`Instalado`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>f(e.id),disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),s.length>0&&(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,$.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,$.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})})}function Ge(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=le(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(``),[p,m]=(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&&v()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,s,t]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[l]);let v=async()=>{try{let e=await fe(`/api/tts-local/logs`);u(e.logs),f(e.ttsRoot)}catch{}},y=async()=>{o(!0),c(!0);try{await n(),await v()}finally{o(!1)}},b=async()=>{o(!0);try{await r()}finally{o(!1)}},x=async()=>{o(!0);try{await i()}finally{o(!1)}},S=async()=>{c(e=>!e),s||await v()},{installed:T,running:E,piperExists:D,voiceExists:O,port:k}=e,A=e.installing;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${E?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Y,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,$.jsx)(X,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[A?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):T?(0,$.jsx)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),T&&(E?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(C,{className:`h-3 w-3`}),`Servidor :`,k]}):(0,$.jsxs)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,$.jsx)(w,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,$.jsxs)(J,{className:`space-y-4`,children:[!T&&!A&&(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${D?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:D?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:O?`✓`:`○`}),` Voz española (~60 MB)`]})]}),T&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:k}),` · Configurable con`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!T&&!A&&(0,$.jsxs)(B,{size:`sm`,onClick:y,disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),A&&(0,$.jsxs)(B,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),T&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:b,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),E&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:x,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),T&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>m(!0),disabled:a,className:`gap-2`,children:[(0,$.jsx)(Se,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,$.jsx)(K,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),A&&(0,$.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,$.jsxs)(`div`,{className:`space-y-1`,children:[d&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,d]}),(0,$.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:l.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):l.map((e,t)=>(0,$.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,$.jsx)(We,{open:p,onOpenChange:m})]})]})}var Ke={groq:{name:`Groq`,description:`STT (Speech-to-Text) - Transcripcion de audio ultra-rapida`,logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{name:`ElevenLabs`,description:`TTS (Text-to-Speech) - Voces neuronales de alta calidad`,logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{name:`OpenAI`,description:`STT/TTS - Whisper y TTS-1`,logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{name:`Google Gemini`,description:`TTS - Voces de Gemini`,logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{name:`Qwen (Alibaba)`,description:`TTS - Voces de Qwen`,logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{name:`Piper TTS (Local)`,description:`TTS offline — sin internet, sin API key.`,logo:`🖥️`,consoleUrl:`/settings/voz`,noApiKey:!0}};function qe(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Je(){let{availableModels:e,activeProviders:t}=V(),{voiceProviders:n,configuredVoiceProviders:r,fetchVoiceProviders:u,fetchConfiguredVoiceProviders:d,saveVoiceProviderKey:f}=ue(),p=W(e=>e.fetchAll),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{u(),d(),p(!0)},[u,d,p]);let D=async e=>{if(g.trim()){b(!0);try{await f(e,g.trim()),await d(),h(null),_(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{b(!1)}}},O=n.length>0?n:Object.keys(Ke),A=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=qe(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}),[e,C,T]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,$.jsx)(K,{variant:`secondary`,children:A.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,$.jsxs)(s,{value:T,onValueChange:E,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-60`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[A.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),A.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(M,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsx)(Ge,{}),O.map(e=>{let t=Ke[e]||{name:e,description:``,logo:`🔌`,consoleUrl:`#`},n=r[e]===!0,i=m===e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Y,{className:`text-lg`,children:t.name}),(0,$.jsx)(X,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,$.jsx)(K,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,$.jsxs)(K,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,$.jsx)(o,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,$.jsx)(J,{className:`space-y-4`,children:t.noApiKey?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):i?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(G,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,$.jsx)(U,{id:`api-key-${e}`,type:x?`text`:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,$.jsx)(B,{variant:`outline`,size:`icon`,onClick:()=>S(!x),title:x?`Ocultar`:`Mostrar`,children:x?(0,$.jsx)(ne,{className:`h-4 w-4`}):(0,$.jsx)(k,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(B,{size:`sm`,onClick:()=>D(e),disabled:v||!g.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(null),_(``)},children:`Cancelar`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(y,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,$.jsxs)(Z,{children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(Y,{className:`text-lg`,children:`Como funciona?`}),(0,$.jsx)(X,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,$.jsxs)(J,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,$.jsx)(`div`,{className:`pt-2 border-t`,children:(0,$.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}function Ye(){let{localLLM:e,localLLMLogs:t,fetchLocalLLMStatus:n,installLocalLLM:r,startLocalLLM:i,stopLocalLLM:a,downloadLLMModel:o,fetchLocalLLMLogs:s}=de(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n()},[n]),(0,Q.useEffect)(()=>(e.installing||e.downloadingModelId?g.current=setInterval(()=>{n()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,e.downloadingModelId,n]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[t]),(0,Q.useEffect)(()=>{if(!u)return;let e=new EventSource(`/api/llm-local/logs?mode=TEXT`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);t.llmRoot&&p(t.llmRoot),(t.logs||t.serverLogs)&&W.setState(e=>({localLLMLogs:[...t.logs||[],...t.serverLogs||[]]}))}catch(e){console.error(`Error parsing SSE log data`,e)}},()=>{e.close()}},[u]);let v=async()=>{l(!0),d(!0);try{await r()}finally{l(!1)}},y=async e=>{l(!0);try{await o(e)}finally{l(!1)}},b=async(e=`TEXT`)=>{l(!0);try{await i(e)}finally{l(!1)}},x=async e=>{l(!0);try{await a(e)}finally{l(!1)}},S=()=>{d(e=>!e)},{installed:C,binaryExists:w,anyModelExists:T,installing:E,downloadingModelId:D,gpu:O,models:k}=e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${C?`border-amber-500/30 bg-amber-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🤖`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Y,{className:`text-lg flex items-center gap-2`,children:[`Local LLM (llama-server)`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Private`})]}),(0,$.jsxs)(X,{className:`text-xs`,children:[`Inferencia local sin internet usando llama-server. Soporta aceleración por GPU (`,O.backend,`).`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e.activeServers.map(e=>(0,$.jsxs)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75`}),(0,$.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-green-500`})]}),e.mode,` (`,e.port,`)`]},e.mode)),!e.running&&w&&(0,$.jsx)(K,{variant:`outline`,className:`border-zinc-700 text-zinc-500`,children:`Apagado`}),E?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Configurando…`]}):w?(0,$.jsx)(K,{className:`bg-amber-500/10 text-amber-500 border-amber-500/30`,children:`Binario Listo`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No configurado`}),O&&(0,$.jsxs)(K,{variant:`outline`,className:`gap-1 border-zinc-700 text-zinc-400`,children:[(0,$.jsx)(m,{className:`h-3 w-3`}),O.deviceName||O.backend]})]})]})}),(0,$.jsxs)(J,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(be,{className:`h-4 w-4 text-amber-400`}),`Infraestructura`]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsx)(`span`,{className:`text-zinc-400`,children:`Motor llama-server`}),w?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Instalado`}):(0,$.jsx)(B,{variant:`link`,size:`sm`,onClick:v,disabled:c||E,className:`h-auto p-0 text-amber-400`,children:`Instalar ahora`})]}),e.activeServers.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 uppercase font-bold tracking-wider`,children:`Servidores Activos`}),e.activeServers.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] bg-zinc-800/30 p-1.5 rounded border border-zinc-700/50`,children:[(0,$.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:e.mode}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-zinc-500`,children:[`Puerto `,e.port]}),(0,$.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-5 w-5 text-red-400 hover:text-red-300 hover:bg-red-400/10`,onClick:()=>x(e.mode),disabled:c,children:(0,$.jsx)(N,{className:`h-3 w-3 fill-current`})})]})]},e.mode))]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`h-4 w-4 text-amber-400`}),`Modelos Disponibles`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:k.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-zinc-200`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:e.size})]}),e.downloaded?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Descargado`}):D===e.id?(0,$.jsxs)(`span`,{className:`text-yellow-400 flex items-center gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Descargando…`]}):(0,$.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>y(e.id),disabled:c||!!D,className:`h-7 text-[10px] px-2 border-zinc-700`,children:`Descargar`})]},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-2 border-t border-zinc-800`,children:[!w&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:v,disabled:c,className:`gap-2 bg-amber-600 hover:bg-amber-500`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Configurar Local LLM`]}),w&&!E&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 w-full`,children:[(0,$.jsx)(`div`,{className:`flex gap-1 bg-zinc-900/80 p-1 rounded-lg border border-zinc-800`,children:[`TEXT`,`IMAGE`,`AUDIO`].map(t=>{let n=e.activeServers.some(e=>e.mode===t);return(0,$.jsxs)(B,{size:`sm`,variant:n?`default`:`ghost`,onClick:()=>n?x(t):b(t),disabled:c||!n&&!T,className:`gap-1.5 text-[10px] h-7 px-2.5 ${n?`bg-green-600 hover:bg-green-500 text-white`:`text-zinc-400 hover:text-zinc-200`}`,children:[n?(0,$.jsx)(N,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(F,{className:`h-3 w-3 fill-current`}),t]},t)})}),e.running&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>x(),disabled:c,className:`gap-2 border-red-500/30 text-red-400 hover:bg-red-500/10 h-9`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 fill-current`}),`Apagar Todo`]})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>n(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs ml-auto`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),u?`Ocultar log`:`Ver log`]})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[f&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono text-right`,children:[`ruta: `,f]}),(0,$.jsx)(`div`,{ref:_,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-48 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:t.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la configuración para ver el progreso.`}):t.map((e,t)=>(0,$.jsx)(`div`,{className:e.includes(`[error]`)?`text-red-400`:e.includes(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})}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}=V(),n=W(e=>e.fetchAll),[r,o]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=Xe(e.capabilities),n=(t.includes(`chat`)||!t.includes(`vision`))&&e.model_type!==`stt`&&e.model_type!==`tts`,i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(Ye,{}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Texto`}),(0,$.jsx)(K,{variant:`secondary`,children:f.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-22rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state`,children:`No hay modelos de texto disponibles.`})]})})]})]})}var Qe=I,$e=oe,et=_,tt=M,nt=ce;function rt(){let{providers:e,createProvider:t}=V(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(`text`);return(0,$.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),(0,$.jsxs)(ye,{open:n,onOpenChange:e=>{r(e)},children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,$.jsx)(Qe,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,$.jsxs)(_e,{className:`max-w-md`,children:[(0,$.jsxs)(ge,{className:`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,$.jsx)(ve,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,$.jsx)(he,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),(0,$.jsx)(`div`,{className:`p-6`,children:(0,$.jsx)(Re,{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}),r(!1)}catch(e){console.error(`Error creating provider:`,e)}},onCancel:()=>r(!1)})})]})]})]}),(0,$.jsxs)(ee,{value:i,onValueChange:a,className:`w-full`,children:[(0,$.jsxs)(E,{className:`w-full grid grid-cols-4 h-10`,children:[(0,$.jsxs)(j,{value:`text`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)($e,{className:`h-3.5 w-3.5`}),`Texto`]}),(0,$.jsxs)(j,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(et,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,$.jsxs)(j,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5`}),`Voz`]}),(0,$.jsxs)(j,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),`Providers`]})]}),(0,$.jsx)(S,{value:`text`,className:`mt-4`,children:(0,$.jsx)(Ze,{})}),(0,$.jsx)(S,{value:`vision`,className:`mt-4`,children:(0,$.jsx)(Ue,{})}),(0,$.jsx)(S,{value:`voice`,className:`mt-4`,children:(0,$.jsx)(Je,{})}),(0,$.jsx)(S,{value:`providers`,className:`mt-4`,children:(0,$.jsx)(Le,{})})]})]})}export{rt as ProvidersPage};
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{r}from"./utils-3pnRFmFe.js";import{a as i,c as a,l as o,n as s,r as c,s as l,t as u}from"./switch-BDwN8RYV.js";import{n as d}from"./chevron-up-BYhk0K2J.js";import{t as f}from"./chevron-right-CR4Skrf3.js";import{t as p}from"./circle-check-Bb54Ebmu.js";import{t as m}from"./cpu-Cdgc_B1K.js";import{t as h}from"./download-C3ifGMjJ.js";import{n as g,t as _}from"./eye-DqNTU_GD.js";import{t as v}from"./globe-DeCQTCDJ.js";import{t as y}from"./key-3EP0dhkT.js";import{t as b}from"./loader-circle-CZNax6kS.js";import{a as x,c as S,d as C,f as w,i as T,l as E,n as D,o as O,p as k,r as A,s as ee,t as te,u as j}from"./table-CSc8ubon.js";import{t as ne}from"./lock-Ei1_J-Nq.js";import{n as M,t as N}from"./square-BD81nFtN.js";import{n as re,t as P}from"./terminal-DN38Q456.js";import{t as F}from"./play-NcZ4swwL.js";import{t as I}from"./plus-CX1xyhp5.js";import{t as L}from"./refresh-cw-DaYdjQFk.js";import{n as R,t as z}from"./scroll-area-DkeyX32e.js";import{t as ie}from"./settings-Ds4SqD8s.js";import{t as ae}from"./trash-2-CNjMkoq6.js";import{G as oe,M as B,R as se,W as ce,a as le,c as V,d as ue,h as H,i as de,j as U,p as fe,r as W,s as pe}from"./index-CQ7fn00w.js";import{t as G}from"./label-CrH0Jj3v.js";import{c as me,i as he,o as ge,r as _e,s as ve,t as ye}from"./dialog-bI9jImCS.js";import{t as K}from"./badge-DXUDdTed.js";import{a as q,n as J,o as Y,r as X,t as Z}from"./card-CNf6BS2e.js";import"./useProviders-CnlC_qCS.js";var be=r(`Binary`,[[`rect`,{x:`14`,y:`14`,width:`4`,height:`6`,rx:`2`,key:`p02svl`}],[`rect`,{x:`6`,y:`4`,width:`4`,height:`6`,rx:`2`,key:`xm4xkj`}],[`path`,{d:`M6 20h4`,key:`1i6q5t`}],[`path`,{d:`M14 10h4`,key:`ru81e7`}],[`path`,{d:`M6 14h2v6`,key:`16z9wg`}],[`path`,{d:`M14 4h2v6`,key:`1idq9u`}]]),xe=r(`KeyRound`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Se=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),$=n();function Ce({provider:e,onSave:t,onCancel:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(e?.baseUrl||e?.base_url||``),[l,u]=(0,Q.useState)(e?.config?.headers?JSON.stringify(e.config.headers,null,2):``),[d,f]=(0,Q.useState)(e?.num_ctx?String(e.num_ctx):``),m=s||e?.baseUrl||e?.base_url||``,h=e?.id===`ollama`||m.includes(`localhost`)||m.includes(`127.0.0.1`),v=!!e?.has_api_key,y=!!e?.has_headers;return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`API Key`}),v&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(p,{className:`h-3 w-3`}),`Configurada`]})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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,$.jsx)(B,{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,$.jsx)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{value:s,onChange:e=>c(e.target.value),placeholder:`https://api.example.com`,className:`hive-input !h-8 text-xs`})]}),h&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(U,{type:`number`,value:d,onChange:e=>f(e.target.value),placeholder:`8192`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto. Tu modelo soporta hasta 262 144 tokens.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Custom Headers (JSON)`}),y&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[10px] font-bold text-emerald-400`,children:[(0,$.jsx)(p,{className:`h-3 w-3`}),`Configurados`]})]}),(0,$.jsx)(`textarea`,{value:l,onChange:e=>u(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,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:n,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{let e;if(l.trim())try{e=JSON.parse(l.trim())}catch{H.fire(`Error`,`JSON de Headers inválido`,`error`);return}t&&t({apiKey:a,baseUrl:s||void 0,headers:e,numCtx:d.trim()?Number(d.trim()):null})},children:`Guardar`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var we=ie,Te=d,Ee=f,De=m,Oe=I,ke=xe,Ae=v,je=L,Me=re,Ne=ae,Pe=o,Fe=se;function Ie({provider:e,updateProvider:t,onManageModels:n}){let[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(null),{models:S,toggleModel:C,createModel:w,syncModels:T,deleteModel:E,updateModel:D}=pe(),{toggleProvider:O}=V(),k=(0,Q.useMemo)(()=>{let t=S.filter(t=>(t.providerId||t.provider_id)===e.id);return t.length>0?t:e.models||[]},[S,e.id,e.models]),A=k.filter(e=>e.enabled||e.active),ee=n=>{t(e.id,n),i(!1)},te=async t=>{try{await O(e.id,t)}catch(e){console.error(`Failed to toggle provider:`,e)}},j=async(e,t)=>{try{await C(e.id,t)}catch(e){console.error(`Failed to toggle model:`,e)}},ne=async()=>{p(!0);try{await T(e.id),o(!0)}catch(e){console.error(`Failed to sync models:`,e)}finally{p(!1)}},M=e=>{h(e.id),_(e.name),y(e.id)},N=()=>{h(null),_(``),y(``)},re=async e=>{let t=g.trim()||e.name,n=v.trim()||e.id;if(t===e.name&&n===e.id){N();return}try{await D(e.id,{name:t,id:n}),N()}catch(e){console.error(`Failed to update model:`,e)}},P=async e=>{x(e.id);try{await E(e.id)}catch(e){console.error(`Failed to delete model:`,e)}finally{x(null)}},F=async()=>{let t=s.trim();if(t){d(!0);try{await w(e.id,t),c(``)}catch(e){console.error(`Failed to add model:`,e)}finally{d(!1)}}},I=!!e.active,L=e.base_url||e.baseUrl,R=e.id===`ollama`||L?.includes(`localhost`)||L?.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`hive-card group overflow-hidden flex flex-col gap-0 transition-all duration-500 ${I?`hive-card--active`:`opacity-70 grayscale-[0.5] hover:grayscale-0 hover:opacity-100`}`,children:[(0,$.jsx)(`div`,{className:`hive-card-body pb-3`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,$.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 ${I?`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,$.jsx)(De,{className:`h-5 w-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`h3`,{className:`font-black text-white tracking-tight text-base sm:text-lg uppercase leading-none truncate`,children:e.name}),I&&(0,$.jsx)(`div`,{className:`hive-status-dot--active h-1.5 w-1.5 shrink-0`})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-white/35 font-medium leading-none truncate`,children:e.id})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,$.jsx)(`span`,{className:`hidden sm:block text-[10px] font-black tracking-widest ${I?`text-blue-400`:`text-white/30`}`,children:I?`ON`:`OFF`}),(0,$.jsx)(u,{checked:I,onCheckedChange:te,className:`data-[state=checked]:bg-blue-500`})]})]})}),(0,$.jsxs)(`div`,{className:`px-5 pb-3 space-y-2 border-b border-white/5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(ke,{className:`h-3.5 w-3.5 shrink-0 ${e.has_api_key?`text-emerald-400`:R?`text-amber-400`:`text-white/20`}`}),(0,$.jsx)(`span`,{className:`text-[11px] font-mono truncate`,children:e.masked_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:e.masked_api_key}):e.has_api_key?(0,$.jsx)(`span`,{className:`text-white/50`,children:`••••••••••••••••`}):R?(0,$.jsx)(`span`,{className:`text-amber-400/70`,children:`Local — sin API key`}):(0,$.jsx)(`span`,{className:`text-white/25`,children:`Sin API key`})})]}),L&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(Ae,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsx)(`span`,{className:`text-[11px] text-white/40 truncate font-mono`,children:L})]}),R&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(De,{className:`h-3.5 w-3.5 shrink-0 text-white/20`}),(0,$.jsxs)(`span`,{className:`text-[11px] text-white/40 font-mono`,children:[`ctx: `,(0,$.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,$.jsxs)(`div`,{className:`px-5 py-3 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.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:()=>o(!a),children:[a?(0,$.jsx)(Te,{className:`h-3 w-3`}):(0,$.jsx)(Ee,{className:`h-3 w-3`}),`MODELOS`,(0,$.jsxs)(`span`,{className:`hive-tag scale-90 origin-left`,children:[A.length,`/`,k.length]})]}),R&&(0,$.jsxs)($.Fragment,{children:[(0,$.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,$.jsx)(`button`,{type:`button`,onClick:ne,disabled:f,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,$.jsx)(je,{className:`h-3 w-3 ${f?`animate-spin`:``}`})})]})]}),!a&&k.length>0&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:[k.slice(0,3).map(e=>(0,$.jsx)(`span`,{className:`hive-tag text-[10px] ${e.enabled||e.active?``:`opacity-40`}`,children:e.name.split(`/`).pop()||e.name},e.id)),k.length>3&&(0,$.jsxs)(`span`,{className:`hive-tag text-[10px] text-white/30`,children:[`+`,k.length-3]})]}),a&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`hive-scroll max-h-44 overflow-y-auto flex flex-col gap-0.5 pr-1`,children:[k.length===0&&(0,$.jsx)(`p`,{className:`text-[11px] text-white/25 py-2 text-center`,children:`Sin modelos configurados`}),k.map(e=>{let t=e.enabled||!!e.active,n=m===e.id;return(0,$.jsx)(`div`,{className:`rounded-lg transition-colors ${t&&!n||n?`bg-white/5`:`bg-transparent opacity-40`}`,children:n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 px-2.5 py-1.5`,children:[(0,$.jsx)(`input`,{type:`text`,value:g,onChange:e=>_(e.target.value),placeholder:`Display name`,className:`w-full bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`API model ID`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>re(e),className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20 transition-colors`,children:(0,$.jsx)(Pe,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:N,className:`shrink-0 h-7 w-7 flex items-center justify-center rounded-md bg-white/5 border border-white/10 text-white/40 hover:text-white hover:bg-white/10 transition-colors`,children:(0,$.jsx)(Fe,{className:`h-3 w-3`})})]})]}):(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-2.5 py-1.5`,children:[(0,$.jsx)(`span`,{className:`text-[11px] font-medium text-white truncate flex-1 mr-2`,children:e.name}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>M(e),title:`Editar modelo`,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,$.jsx)(Me,{className:`h-3 w-3`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>P(e),disabled:b===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,$.jsx)(Ne,{className:`h-3 w-3`})}),(0,$.jsx)(u,{checked:t,onCheckedChange:t=>j(e,t),className:`scale-[0.7] origin-right data-[state=checked]:bg-blue-400 ml-0.5`})]})]})},e.id)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 pt-1.5 border-t border-white/5`,children:[(0,$.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.key===`Enter`&&F(),placeholder:`nombre-del-modelo`,className:`flex-1 min-w-0 bg-white/5 border border-white/10 rounded-md px-2 h-7 text-[11px] text-white/70 placeholder-white/20 focus:outline-none focus:border-blue-500/50 transition-all font-mono`}),(0,$.jsxs)(`button`,{type:`button`,onClick:F,disabled:l||!s.trim(),className:`shrink-0 h-7 px-2.5 flex items-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 disabled:opacity-40 disabled:cursor-not-allowed transition-colors`,children:[(0,$.jsx)(Oe,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{className:`hidden xs:inline`,children:`ADD`})]})]})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3 border-t border-white/5 flex items-center justify-between gap-2 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 overflow-hidden`,children:[(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Uptime`}),(0,$.jsx)(`span`,{className:`hive-stat__value`,children:`99.9%`})]}),(0,$.jsxs)(`div`,{className:`hive-stat shrink-0`,children:[(0,$.jsx)(`span`,{className:`hive-stat__label`,children:`Estado`}),(0,$.jsx)(`span`,{className:`hive-stat__value ${I?`text-emerald-400`:`text-white/30`}`,children:I?`Activo`:`Inactivo`})]})]}),(0,$.jsxs)(ye,{open:r,onOpenChange:i,children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.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,$.jsx)(we,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:`CONFIG`})]})}),(0,$.jsxs)(_e,{className:`rounded-xl border border-white/10 p-0 overflow-hidden w-[calc(100vw-2rem)] max-w-md bg-[#09090b]`,children:[(0,$.jsxs)(`div`,{className:`p-5 border-b border-white/5 bg-white/5 relative overflow-hidden`,children:[(0,$.jsx)(`div`,{className:`absolute -top-10 -right-10 h-32 w-32 bg-blue-600/10 rounded-full blur-[80px] pointer-events-none`}),(0,$.jsx)(ve,{className:`text-lg font-black text-white uppercase tracking-tighter`,children:e.name}),(0,$.jsx)(he,{className:`text-xs text-white/40 font-medium mt-0.5`,children:`Autenticación y punto de enlace.`})]}),(0,$.jsx)(`div`,{className:`p-5`,children:(0,$.jsx)(Ce,{provider:e,onSave:ee,onCancel:()=>i(!1)})})]})]})]}),(0,$.jsx)(`div`,{className:`hive-strip--bottom ${I?``:`opacity-20`}`})]})}function Le(){let{providers:e,updateProvider:t}=V(),n=e.filter(e=>e.active).length;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`hive-title-section`,children:`Providers de IA`}),(0,$.jsxs)(`span`,{className:`hive-tag hive-tag--provider`,children:[n,` activos / `,e.length,` total`]})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-3 gap-4 sm:gap-5`,children:[e.map(e=>(0,$.jsx)(Ie,{provider:e,updateProvider:t},e.id)),e.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state col-span-full`,children:`No hay providers disponibles.`})]})]})}function Re({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)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),v=o.toLowerCase()===`ollama`||u.includes(`localhost`)||u.includes(`127.0.0.1`);return(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Nombre del Provider`}),(0,$.jsx)(U,{value:i,onChange:e=>a(e.target.value),placeholder:`Mi Provider Personalizado`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Se usará como identificador interno`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Tipo de Provider`}),(0,$.jsx)(U,{value:o,onChange:e=>s(e.target.value),placeholder:`openai, anthropic, ollama...`,className:`hive-input !h-8 text-xs`}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/30`,children:`Ej: openai, anthropic, ollama, custom...`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(G,{className:`hive-label`,children:`API Key`})}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(U,{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,$.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,$.jsx)(g,{className:`h-3 w-3`}):(0,$.jsx)(_,{className:`h-3 w-3`})})]})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Base URL (opcional)`}),(0,$.jsx)(U,{value:u,onChange:e=>d(e.target.value),placeholder:`https://api.example.com o http://localhost:11434`,className:`hive-input !h-8 text-xs`})]}),v&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(G,{className:`hive-label`,children:`Context Window (num_ctx)`}),(0,$.jsx)(`span`,{className:`text-[10px] text-white/30`,children:`tokens — por defecto 32 768`})]}),(0,$.jsx)(U,{type:`number`,value:m,onChange:e=>h(e.target.value),placeholder:`32768`,min:512,step:512,className:`hive-input !h-8 text-xs font-mono`}),(0,$.jsx)(`p`,{className:`text-[10px] text-amber-400/60`,children:`Aumenta si ves errores de contexto.`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,$.jsx)(G,{className:`hive-label`,children:`Custom Headers (JSON)`})}),(0,$.jsx)(`textarea`,{value:f,onChange:e=>p(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,$.jsxs)(`div`,{className:`flex gap-2 pt-2`,children:[(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-cancel flex-1`,onClick:t,children:`Cancelar`}),(0,$.jsx)(`button`,{className:`hive-btn hive-btn--form-submit flex-1`,onClick:()=>{if(!i.trim()){H.fire(`Error`,`El nombre del provider es requerido`,`error`);return}if(!o){H.fire(`Error`,`Selecciona un tipo de provider`,`error`);return}if(!c.trim()&&!v){H.fire(`Error`,`La API Key es requerida para este provider`,`error`);return}let t;if(f.trim())try{t=JSON.parse(f.trim())}catch{H.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:u.trim()||void 0,headers:t,numCtx:m.trim()?Number(m.trim()):null})},children:`Crear Provider`})]}),(0,$.jsx)(`p`,{className:`text-[10px] text-white/20 pt-2`,children:`La API key se guarda cifrada en la base de datos.`})]})}var ze={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 Be({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,$.jsx)($.Fragment,{children:t.map(e=>(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] py-0 h-4`,children:ze[e]??e},e))})}function Ve({model:e}){let{toggleModel:t}=pe();return(0,$.jsx)(Z,{className:e.active?``:`opacity-70 bg-muted/30`,children:(0,$.jsxs)(J,{className:`flex items-center gap-4 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold`,children:e.name}),(0,$.jsx)(K,{variant:`secondary`,className:`text-[10px]`,children:e.providerId||e.provider_id})]}),e.contextWindow&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(e.contextWindow/1e3).toFixed(0),`K tokens contexto`]}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,children:(0,$.jsx)(Be,{capabilities:e.capabilities})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-end gap-2`,children:[(0,$.jsx)(u,{checked:!!e.active,onCheckedChange:n=>t(e.id,n)}),(0,$.jsx)(K,{variant:e.active?`default`:`secondary`,className:`text-[10px]`,children:e.active?`Activo`:`Inactivo`})]})]})})}function He(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Ue(){let{availableModels:e,activeProviders:t}=V(),n=W(e=>e.fetchAll),[r,o]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[n]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=He(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()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Imagen / Vision`})}),(0,$.jsx)(K,{variant:`secondary`,children:f.length})]}),(0,$.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,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-26rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(_,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos con capacidad de vision.`}),(0,$.jsx)(`p`,{className:`text-xs mt-1`,children:`Habilita modelos con capability "vision" en la tab Providers.`})]})]})})]})}function We({open:e,onOpenChange:t}){let{availableTTSModels:n,fetchAvailableTTSModels:r,downloadTTSModel:i,isDownloadingModel:a,downloadLogs:s,fetchDownloadLogs:c}=le(),[l,u]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&d()},[e]);let d=async()=>{u(!0),await r(),u(!1)},f=async e=>{await i(e)},p=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,$.jsx)(ye,{open:e,onOpenChange:t,children:(0,$.jsxs)(_e,{className:`max-w-3xl max-h-[80vh] overflow-hidden flex flex-col`,children:[(0,$.jsxs)(ge,{children:[(0,$.jsx)(ve,{className:`flex items-center gap-2`,children:`📦 Gestionar Modelos TTS`}),(0,$.jsx)(he,{children:`Descarga modelos de voz adicionales para Piper TTS. Cada modelo incluye el archivo de voz (.onnx) y su configuración (.json).`})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-auto mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(K,{variant:`outline`,children:[n.filter(e=>e.installed).length,` / `,n.length,` instalados`]})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:d,disabled:l||a,className:`gap-2`,children:[(0,$.jsx)(L,{className:`h-4 w-4 ${l?`animate-spin`:``}`}),`Actualizar`]})]}),l&&!n.length?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,$.jsx)(b,{className:`h-6 w-6 animate-spin text-muted-foreground`})}):n.length===0?(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground`,children:`No hay modelos disponibles`}):(0,$.jsxs)(te,{children:[(0,$.jsx)(x,{children:(0,$.jsxs)(O,{children:[(0,$.jsx)(T,{children:`Modelo`}),(0,$.jsx)(T,{children:`Idioma`}),(0,$.jsx)(T,{children:`Calidad`}),(0,$.jsx)(T,{children:`Tamaño`}),(0,$.jsx)(T,{children:`Estado`}),(0,$.jsx)(T,{className:`text-right`,children:`Acciones`})]})}),(0,$.jsx)(D,{children:n.map(e=>(0,$.jsxs)(O,{children:[(0,$.jsx)(A,{className:`font-medium`,children:e.name}),(0,$.jsx)(A,{children:e.language}),(0,$.jsx)(A,{children:(0,$.jsx)(K,{className:p(e.quality),children:e.quality})}),(0,$.jsx)(A,{className:`text-muted-foreground`,children:e.size}),(0,$.jsx)(A,{children:e.installed?(0,$.jsxs)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1`,children:[(0,$.jsx)(o,{className:`h-3 w-3`}),`Instalado`]}):a&&s.some(t=>t.includes(e.name))?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(b,{className:`h-3 w-3 animate-spin`}),`Descargando`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`})}),(0,$.jsx)(A,{className:`text-right`,children:e.installed?(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,disabled:!0,className:`gap-2 opacity-50`,children:[(0,$.jsx)(o,{className:`h-4 w-4`}),`Instalado`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>f(e.id),disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{className:`h-4 w-4`}),`Descargar`]})})]},e.id))})]}),s.length>0&&(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium mb-2`,children:`Progreso de descarga:`}),(0,$.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,$.jsx)(`div`,{className:e.startsWith(`[error]`)?`text-red-400`:e.startsWith(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})})}function Ge(){let{localTTS:e,fetchLocalTTSStatus:t,installLocalTTS:n,startLocalTTS:r,stopLocalTTS:i}=le(),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)([]),[d,f]=(0,Q.useState)(``),[p,m]=(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&&v()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,s,t]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[l]);let v=async()=>{try{let e=await fe(`/api/tts-local/logs`);u(e.logs),f(e.ttsRoot)}catch{}},y=async()=>{o(!0),c(!0);try{await n(),await v()}finally{o(!1)}},b=async()=>{o(!0);try{await r()}finally{o(!1)}},x=async()=>{o(!0);try{await i()}finally{o(!1)}},S=async()=>{c(e=>!e),s||await v()},{installed:T,running:E,piperExists:D,voiceExists:O,port:k}=e,A=e.installing;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${E?`border-blue-500/30 bg-blue-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🎙️`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Y,{className:`text-lg flex items-center gap-2`,children:[`Piper TTS`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Offline`})]}),(0,$.jsx)(X,{className:`text-xs`,children:`TTS sin internet — binario nativo, sin Python, sin Docker. Fallback cuando no hay providers online.`})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[A?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Instalando…`]}):T?(0,$.jsx)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30`,children:`Instalado`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No instalado`}),T&&(E?(0,$.jsxs)(K,{className:`bg-blue-500/20 text-blue-400 border-blue-500/30 gap-1`,children:[(0,$.jsx)(C,{className:`h-3 w-3`}),`Servidor :`,k]}):(0,$.jsxs)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400 gap-1`,children:[(0,$.jsx)(w,{className:`h-3 w-3`}),`Detenido`]}))]})]})}),(0,$.jsxs)(J,{className:`space-y-4`,children:[!T&&!A&&(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 text-xs text-muted-foreground`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${D?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:D?`✓`:`○`}),` Binario Piper (~8 MB)`]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 ${O?`text-green-400`:``}`,children:[(0,$.jsx)(`span`,{children:O?`✓`:`○`}),` Voz española (~60 MB)`]})]}),T&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Voz: `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:e.voices?.[0]||`N/A`}),` · Puerto:`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:k}),` · Configurable con`,` `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_PORT`}),` / `,(0,$.jsx)(`code`,{className:`text-zinc-300`,children:`TTS_VOICE`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[!T&&!A&&(0,$.jsxs)(B,{size:`sm`,onClick:y,disabled:a,className:`gap-2`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Instalar Piper (~68 MB)`]}),A&&(0,$.jsxs)(B,{size:`sm`,disabled:!0,className:`gap-2 opacity-70`,children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 animate-spin`}),`Descargando…`]}),T&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:b,disabled:a,className:`gap-2 bg-blue-600 hover:bg-blue-500 text-white`,children:[(0,$.jsx)(F,{className:`h-3.5 w-3.5`}),`Iniciar servidor`]}),E&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:x,disabled:a,className:`gap-2 border-red-500/40 text-red-400 hover:bg-red-500/10`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5`}),`Detener servidor`]}),T&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>m(!0),disabled:a,className:`gap-2`,children:[(0,$.jsx)(Se,{className:`h-3.5 w-3.5`}),`Gestionar modelos`,e.voices&&e.voices.length>0&&(0,$.jsx)(K,{variant:`secondary`,className:`ml-1 text-[10px] px-1`,children:e.voices.length})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>t(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),s?`Ocultar log`:`Ver log`]})]}),A&&(0,$.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,$.jsxs)(`div`,{className:`space-y-1`,children:[d&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono`,children:[`ruta: `,d]}),(0,$.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:l.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la instalación para ver el progreso.`}):l.map((e,t)=>(0,$.jsx)(`div`,{className:e.startsWith(`[stderr]`)||e.startsWith(`[error]`)?`text-red-400`:``,children:e},t))})]}),(0,$.jsx)(We,{open:p,onOpenChange:m})]})]})}var Ke={groq:{name:`Groq`,description:`STT (Speech-to-Text) - Transcripcion de audio ultra-rapida`,logo:`🔴`,consoleUrl:`https://console.groq.com/keys`},elevenlabs:{name:`ElevenLabs`,description:`TTS (Text-to-Speech) - Voces neuronales de alta calidad`,logo:`🎙️`,consoleUrl:`https://elevenlabs.io/app/settings/api-keys`},openai:{name:`OpenAI`,description:`STT/TTS - Whisper y TTS-1`,logo:`🟢`,consoleUrl:`https://platform.openai.com/api-keys`},gemini:{name:`Google Gemini`,description:`TTS - Voces de Gemini`,logo:`🔵`,consoleUrl:`https://aistudio.google.com/app/apikey`},qwen:{name:`Qwen (Alibaba)`,description:`TTS - Voces de Qwen`,logo:`🟣`,consoleUrl:`https://dashscope.console.aliyun.com/apiKey`},piper:{name:`Piper TTS (Local)`,description:`TTS offline — sin internet, sin API key.`,logo:`🖥️`,consoleUrl:`/settings/voz`,noApiKey:!0}};function qe(e){if(!e)return[];if(typeof e==`string`)try{return JSON.parse(e)}catch{return[]}return Array.isArray(e)?e:[]}function Je(){let{availableModels:e,activeProviders:t}=V(),{voiceProviders:n,configuredVoiceProviders:r,fetchVoiceProviders:u,fetchConfiguredVoiceProviders:d,saveVoiceProviderKey:f}=ue(),p=W(e=>e.fetchAll),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(``),[v,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{u(),d(),p(!0)},[u,d,p]);let D=async e=>{if(g.trim()){b(!0);try{await f(e,g.trim()),await d(),h(null),_(``)}catch(e){console.error(`Failed to save API key:`,e)}finally{b(!1)}}},O=n.length>0?n:Object.keys(Ke),A=(0,Q.useMemo)(()=>e.filter(e=>{let t=e.model_type===`stt`||e.model_type===`tts`,n=qe(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}),[e,C,T]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Voz (STT / TTS)`}),(0,$.jsx)(K,{variant:`secondary`,children:A.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:C,onChange:e=>w(e.target.value)})]}),(0,$.jsxs)(s,{value:T,onValueChange:E,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-60`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[A.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),A.length===0&&(0,$.jsxs)(`div`,{className:`hive-empty-state`,children:[(0,$.jsx)(M,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground`}),(0,$.jsx)(`p`,{children:`No hay modelos de voz disponibles.`})]})]})})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`API Keys de Voz`}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsx)(Ge,{}),O.map(e=>{let t=Ke[e]||{name:e,description:``,logo:`🔌`,consoleUrl:`#`},n=r[e]===!0,i=m===e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden ${n?`border-green-500/30 bg-green-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:t.logo}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(Y,{className:`text-lg`,children:t.name}),(0,$.jsx)(X,{className:`text-xs`,children:t.description})]})]}),t.noApiKey?(0,$.jsx)(K,{variant:`outline`,className:`bg-zinc-700/40 text-zinc-300 border-zinc-600`,children:`Sin API key`}):n?(0,$.jsxs)(K,{variant:`default`,className:`bg-green-500/20 text-green-400 border-green-500/30`,children:[(0,$.jsx)(o,{className:`h-3 w-3 mr-1`}),`Configurado`]}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30`,children:`Sin configurar`})]})}),(0,$.jsx)(J,{className:`space-y-4`,children:t.noApiKey?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.description}):i?(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(G,{htmlFor:`api-key-${e}`,children:`API Key`}),(0,$.jsxs)(`div`,{className:`flex gap-2 mt-1`,children:[(0,$.jsx)(U,{id:`api-key-${e}`,type:x?`text`:`password`,placeholder:`sk-...`,value:g,onChange:e=>_(e.target.value),className:`flex-1 font-mono text-sm`,autoFocus:!0}),(0,$.jsx)(B,{variant:`outline`,size:`icon`,onClick:()=>S(!x),title:x?`Ocultar`:`Mostrar`,children:x?(0,$.jsx)(ne,{className:`h-4 w-4`}):(0,$.jsx)(k,{className:`h-4 w-4`})})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(B,{size:`sm`,onClick:()=>D(e),disabled:v||!g.trim(),className:`flex-1`,children:v?`Guardando...`:`Guardar`}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(null),_(``)},children:`Cancelar`})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[n?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,$.jsx)(y,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:`API key guardada de forma segura (encriptada)`})]}):(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Necesitas una API key de `,t.name,` para usar esta funcionalidad.`]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n?(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Actualizar API Key`]}):(0,$.jsxs)(B,{size:`sm`,onClick:()=>{h(e),_(``)},className:`flex-1`,children:[(0,$.jsx)(y,{className:`h-3 w-3 mr-2`}),`Configurar API Key`]}),(0,$.jsx)(B,{size:`sm`,variant:`outline`,onClick:()=>window.open(t.consoleUrl,`_blank`),children:`Obtener Key`})]})]})})]},e)})]})]}),(0,$.jsxs)(Z,{children:[(0,$.jsxs)(q,{children:[(0,$.jsx)(Y,{className:`text-lg`,children:`Como funciona?`}),(0,$.jsx)(X,{children:`Configura las API keys de los providers de voz para habilitar STT y TTS en tus canales.`})]}),(0,$.jsxs)(J,{className:`space-y-4 text-sm text-muted-foreground`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`STT (Speech-to-Text):`}),` Convierte el audio entrante en texto. Groq Whisper es recomendado por su velocidad.`]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`strong`,{className:`text-foreground`,children:`TTS (Text-to-Speech):`}),` Convierte las respuestas de texto en audio. ElevenLabs ofrece las voces mas naturales.`]}),(0,$.jsx)(`div`,{className:`pt-2 border-t`,children:(0,$.jsx)(`p`,{className:`text-xs`,children:`Las API keys se guardan encriptadas en la base de datos local de Hive.`})})]})]})]})}function Ye(){let{localLLM:e,localLLMLogs:t,fetchLocalLLMStatus:n,installLocalLLM:r,startLocalLLM:i,stopLocalLLM:a,downloadLLMModel:o,fetchLocalLLMLogs:s}=de(),[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),g=(0,Q.useRef)(null),_=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{n()},[n]),(0,Q.useEffect)(()=>(e.installing||e.downloadingModelId?g.current=setInterval(()=>{n()},3e3):g.current&&clearInterval(g.current),()=>{g.current&&clearInterval(g.current)}),[e.installing,e.downloadingModelId,n]),(0,Q.useEffect)(()=>{_.current&&(_.current.scrollTop=_.current.scrollHeight)},[t]),(0,Q.useEffect)(()=>{if(!u)return;let e=new EventSource(`/api/llm-local/logs?mode=TEXT`);return e.onmessage=e=>{try{let t=JSON.parse(e.data);t.llmRoot&&p(t.llmRoot),(t.logs||t.serverLogs)&&W.setState(e=>({localLLMLogs:[...t.logs||[],...t.serverLogs||[]]}))}catch(e){console.error(`Error parsing SSE log data`,e)}},()=>{e.close()}},[u]);let v=async()=>{l(!0),d(!0);try{await r()}finally{l(!1)}},y=async e=>{l(!0);try{await o(e)}finally{l(!1)}},b=async(e=`TEXT`)=>{l(!0);try{await i(e)}finally{l(!1)}},x=async e=>{l(!0);try{await a(e)}finally{l(!1)}},S=()=>{d(e=>!e)},{installed:C,binaryExists:w,anyModelExists:T,installing:E,downloadingModelId:D,gpu:O,models:k}=e;return(0,$.jsxs)(Z,{className:`relative overflow-hidden col-span-full ${C?`border-amber-500/30 bg-amber-500/[0.02]`:``}`,children:[(0,$.jsx)(q,{children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between flex-wrap gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-3xl`,children:`🤖`}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(Y,{className:`text-lg flex items-center gap-2`,children:[`Local LLM (llama-server)`,(0,$.jsx)(K,{variant:`outline`,className:`text-[10px] px-1.5 py-0 font-normal border-zinc-600 text-zinc-400`,children:`Local · Private`})]}),(0,$.jsxs)(X,{className:`text-xs`,children:[`Inferencia local sin internet usando llama-server. Soporta aceleración por GPU (`,O.backend,`).`]})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e.activeServers.map(e=>(0,$.jsxs)(K,{className:`bg-green-500/20 text-green-400 border-green-500/30 gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`relative flex h-2 w-2`,children:[(0,$.jsx)(`span`,{className:`animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75`}),(0,$.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-green-500`})]}),e.mode,` (`,e.port,`)`]},e.mode)),!e.running&&w&&(0,$.jsx)(K,{variant:`outline`,className:`border-zinc-700 text-zinc-500`,children:`Apagado`}),E?(0,$.jsxs)(K,{className:`bg-yellow-500/20 text-yellow-400 border-yellow-500/30 gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Configurando…`]}):w?(0,$.jsx)(K,{className:`bg-amber-500/10 text-amber-500 border-amber-500/30`,children:`Binario Listo`}):(0,$.jsx)(K,{variant:`secondary`,className:`bg-zinc-700/50 text-zinc-400`,children:`No configurado`}),O&&(0,$.jsxs)(K,{variant:`outline`,className:`gap-1 border-zinc-700 text-zinc-400`,children:[(0,$.jsx)(m,{className:`h-3 w-3`}),O.deviceName||O.backend]})]})]})}),(0,$.jsxs)(J,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(be,{className:`h-4 w-4 text-amber-400`}),`Infraestructura`]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsx)(`span`,{className:`text-zinc-400`,children:`Motor llama-server`}),w?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Instalado`}):(0,$.jsx)(B,{variant:`link`,size:`sm`,onClick:v,disabled:c||E,className:`h-auto p-0 text-amber-400`,children:`Instalar ahora`})]}),e.activeServers.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1.5 mt-2`,children:[(0,$.jsx)(`p`,{className:`text-[10px] text-zinc-500 uppercase font-bold tracking-wider`,children:`Servidores Activos`}),e.activeServers.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-[11px] bg-zinc-800/30 p-1.5 rounded border border-zinc-700/50`,children:[(0,$.jsx)(`span`,{className:`text-zinc-300 font-medium`,children:e.mode}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-zinc-500`,children:[`Puerto `,e.port]}),(0,$.jsx)(B,{variant:`ghost`,size:`icon`,className:`h-5 w-5 text-red-400 hover:text-red-300 hover:bg-red-400/10`,onClick:()=>x(e.mode),disabled:c,children:(0,$.jsx)(N,{className:`h-3 w-3 fill-current`})})]})]},e.mode))]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`h4`,{className:`text-sm font-medium flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`h-4 w-4 text-amber-400`}),`Modelos Disponibles`]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:k.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs border border-zinc-800 p-2 rounded bg-zinc-900/50`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-zinc-200`,children:e.name}),(0,$.jsx)(`span`,{className:`text-[10px] text-zinc-500`,children:e.size})]}),e.downloaded?(0,$.jsx)(`span`,{className:`text-green-400 font-medium`,children:`✓ Descargado`}):D===e.id?(0,$.jsxs)(`span`,{className:`text-yellow-400 flex items-center gap-1`,children:[(0,$.jsx)(L,{className:`h-3 w-3 animate-spin`}),`Descargando…`]}):(0,$.jsx)(B,{variant:`outline`,size:`sm`,onClick:()=>y(e.id),disabled:c||!!D,className:`h-7 text-[10px] px-2 border-zinc-700`,children:`Descargar`})]},e.id))})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 pt-2 border-t border-zinc-800`,children:[!w&&!E&&(0,$.jsxs)(B,{size:`sm`,onClick:v,disabled:c,className:`gap-2 bg-amber-600 hover:bg-amber-500`,children:[(0,$.jsx)(h,{className:`h-3.5 w-3.5`}),`Configurar Local LLM`]}),w&&!E&&(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 w-full`,children:[(0,$.jsx)(`div`,{className:`flex gap-1 bg-zinc-900/80 p-1 rounded-lg border border-zinc-800`,children:[`TEXT`,`IMAGE`,`AUDIO`].map(t=>{let n=e.activeServers.some(e=>e.mode===t);return(0,$.jsxs)(B,{size:`sm`,variant:n?`default`:`ghost`,onClick:()=>n?x(t):b(t),disabled:c||!n&&!T,className:`gap-1.5 text-[10px] h-7 px-2.5 ${n?`bg-green-600 hover:bg-green-500 text-white`:`text-zinc-400 hover:text-zinc-200`}`,children:[n?(0,$.jsx)(N,{className:`h-3 w-3 fill-current`}):(0,$.jsx)(F,{className:`h-3 w-3 fill-current`}),t]},t)})}),e.running&&(0,$.jsxs)(B,{size:`sm`,variant:`outline`,onClick:()=>x(),disabled:c,className:`gap-2 border-red-500/30 text-red-400 hover:bg-red-500/10 h-9`,children:[(0,$.jsx)(N,{className:`h-3.5 w-3.5 fill-current`}),`Apagar Todo`]})]}),(0,$.jsx)(B,{size:`sm`,variant:`ghost`,onClick:()=>n(),title:`Actualizar estado`,className:`text-zinc-400`,children:(0,$.jsx)(L,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(B,{size:`sm`,variant:`ghost`,onClick:S,className:`gap-1.5 text-zinc-400 text-xs ml-auto`,children:[(0,$.jsx)(P,{className:`h-3.5 w-3.5`}),u?`Ocultar log`:`Ver log`]})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[f&&(0,$.jsxs)(`p`,{className:`text-[10px] text-zinc-500 font-mono text-right`,children:[`ruta: `,f]}),(0,$.jsx)(`div`,{ref:_,className:`bg-black/40 rounded-md border border-zinc-700/50 p-3 h-48 overflow-y-auto font-mono text-[11px] text-zinc-300 leading-relaxed`,children:t.length===0?(0,$.jsx)(`span`,{className:`text-zinc-600`,children:`Sin registros aún. Inicia la configuración para ver el progreso.`}):t.map((e,t)=>(0,$.jsx)(`div`,{className:e.includes(`[error]`)?`text-red-400`:e.includes(`✓`)?`text-green-400`:``,children:e},t))})]})]})]})}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}=V(),n=W(e=>e.fetchAll),[r,o]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(`all`);(0,Q.useEffect)(()=>{n(!0)},[]);let f=(0,Q.useMemo)(()=>e.filter(e=>{let t=Xe(e.capabilities),n=(t.includes(`chat`)||!t.includes(`vision`))&&e.model_type!==`stt`&&e.model_type!==`tts`,i=e.name.toLowerCase().includes(r.toLowerCase())||e.id.toLowerCase().includes(r.toLowerCase()),a=u===`all`||e.providerId===u||e.provider_id===u;return n&&i&&a}),[e,r,u]);return(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(Ye,{}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Modelos de Texto`}),(0,$.jsx)(K,{variant:`secondary`,children:f.length})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(R,{className:`absolute left-2 top-2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(U,{placeholder:`Buscar modelo...`,className:`h-8 pl-8 text-sm`,value:r,onChange:e=>o(e.target.value)})]}),(0,$.jsxs)(s,{value:u,onValueChange:d,children:[(0,$.jsx)(l,{className:`h-8 w-40 text-sm`,children:(0,$.jsx)(a,{placeholder:`Provider`})}),(0,$.jsxs)(c,{children:[(0,$.jsx)(i,{value:`all`,children:`Todos`}),t.map(e=>(0,$.jsx)(i,{value:e.id,children:e.name},e.id))]})]})]}),(0,$.jsx)(z,{className:`h-[calc(100vh-22rem)]`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[f.map(e=>(0,$.jsx)(Ve,{model:e},e.id)),f.length===0&&(0,$.jsx)(`div`,{className:`hive-empty-state`,children:`No hay modelos de texto disponibles.`})]})})]})]})}var Qe=I,$e=oe,et=_,tt=M,nt=ce;function rt(){let{providers:e,createProvider:t}=V(),[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(`text`);return(0,$.jsxs)(`div`,{className:`space-y-4 mt-6 sm:mt-10`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,$.jsx)(`div`,{className:`hive-page-header__dot`}),(0,$.jsx)(`span`,{className:`hive-page-header__label`,children:`INFRAESTRUCTURA`})]}),(0,$.jsxs)(`h2`,{className:`hive-title-page`,children:[`Providers de IA`,(0,$.jsx)(`span`,{className:`hive-title-page__accent`,children:`.`})]})]}),(0,$.jsxs)(ye,{open:n,onOpenChange:e=>{r(e)},children:[(0,$.jsx)(me,{asChild:!0,children:(0,$.jsxs)(`button`,{className:`hive-btn hive-btn--primary`,children:[(0,$.jsx)(Qe,{className:`mr-1 h-4 w-4`}),`Añadir Provider`]})}),(0,$.jsxs)(_e,{className:`max-w-md`,children:[(0,$.jsxs)(ge,{className:`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,$.jsx)(ve,{className:`text-xl font-black text-white uppercase tracking-tighter`,children:`Añadir Provider`}),(0,$.jsx)(he,{className:`text-xs text-white/40 font-medium mt-1`,children:`Crea un nuevo provider de IA para tu infraestructura.`})]}),(0,$.jsx)(`div`,{className:`p-6`,children:(0,$.jsx)(Re,{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}),r(!1)}catch(e){console.error(`Error creating provider:`,e)}},onCancel:()=>r(!1)})})]})]})]}),(0,$.jsxs)(ee,{value:i,onValueChange:a,className:`w-full`,children:[(0,$.jsxs)(E,{className:`w-full grid grid-cols-4 h-10`,children:[(0,$.jsxs)(j,{value:`text`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)($e,{className:`h-3.5 w-3.5`}),`Texto`]}),(0,$.jsxs)(j,{value:`vision`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(et,{className:`h-3.5 w-3.5`}),`Imagen`]}),(0,$.jsxs)(j,{value:`voice`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5`}),`Voz`]}),(0,$.jsxs)(j,{value:`providers`,className:`gap-1.5 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),`Providers`]})]}),(0,$.jsx)(S,{value:`text`,className:`mt-4`,children:(0,$.jsx)(Ze,{})}),(0,$.jsx)(S,{value:`vision`,className:`mt-4`,children:(0,$.jsx)(Ue,{})}),(0,$.jsx)(S,{value:`voice`,className:`mt-4`,children:(0,$.jsx)(Je,{})}),(0,$.jsx)(S,{value:`providers`,className:`mt-4`,children:(0,$.jsx)(Le,{})})]})]})}export{rt as ProvidersPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./arrow-left-CBcbX5EZ.js";import{n as i,t as a}from"./eye-DqNTU_GD.js";import{t as o}from"./loader-circle-CZNax6kS.js";import{c as s}from"./vendor-router-C9pIYwbJ.js";import{M as c,j as l}from"./index-DMCjjdqf.js";import{t as u}from"./label-D2H1IR_J.js";var d=e(t(),1),f=n();function p(){let e=s(),[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)(c,{type:`submit`,className:`w-full`,disabled:y,children:[y&&(0,f.jsx)(o,{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
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as t}from"./vendor-charts-Bu2lyBKP.js";import{o as n}from"./vendor-query-DsWPbQdG.js";import{t as r}from"./arrow-left-CBcbX5EZ.js";import{n as i,t as a}from"./eye-DqNTU_GD.js";import{t as o}from"./loader-circle-CZNax6kS.js";import{c as s}from"./vendor-router-C9pIYwbJ.js";import{M as c,j as l}from"./index-CQ7fn00w.js";import{t as u}from"./label-CrH0Jj3v.js";var d=e(t(),1),f=n();function p(){let e=s(),[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)(c,{type:`submit`,className:`w-full`,disabled:y,children:[y&&(0,f.jsx)(o,{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};