apteva 0.4.20 → 0.4.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActivityPage.41nbye4r.js +3 -0
- package/dist/{ApiDocsPage.kf6bbwkk.js → ApiDocsPage.4smnt8m3.js} +2 -2
- package/dist/{App.jfx3der4.js → App.0sbax9et.js} +3 -3
- package/dist/App.0ws427h8.js +4 -0
- package/dist/App.4ehxpt48.js +4 -0
- package/dist/App.6q6bar8b.js +4 -0
- package/dist/App.ca1rz1ph.js +4 -0
- package/dist/{App.7v1w3ys9.js → App.ensa6z0r.js} +3 -3
- package/dist/{App.n4jb3c22.js → App.f8g7tych.js} +3 -3
- package/dist/App.kh7d2xj3.js +267 -0
- package/dist/App.mvtqv6qc.js +20 -0
- package/dist/{App.c90t3dxg.js → App.ncgc9cxy.js} +3 -3
- package/dist/{App.039re6cf.js → App.p0fb1pds.js} +3 -3
- package/dist/App.pmaq48sj.js +4 -0
- package/dist/{App.2yy66bnp.js → App.yv87t9m5.js} +3 -3
- package/dist/App.zjmfm8p6.js +4 -0
- package/dist/ConnectionsPage.anb3rv9a.js +3 -0
- package/dist/McpPage.y396h6fy.js +3 -0
- package/dist/SettingsPage.5k6vp396.js +3 -0
- package/dist/SkillsPage.yj3xdsay.js +3 -0
- package/dist/TasksPage.sjv0khtv.js +3 -0
- package/dist/TelemetryPage.2qm4w16r.js +3 -0
- package/dist/TestsPage.zzs4qfj8.js +3 -0
- package/dist/index.html +1 -1
- package/dist/styles.css +1 -1
- package/package.json +2 -2
- package/src/channels/telegram.ts +5 -0
- package/src/crypto.ts +13 -4
- package/src/db.ts +25 -2
- package/src/integrations/agentdojo.ts +1 -1
- package/src/providers.ts +46 -0
- package/src/routes/api/agent-utils.ts +64 -9
- package/src/routes/api/agents.ts +41 -13
- package/src/routes/api/integrations.ts +16 -6
- package/src/routes/api/mcp.ts +7 -0
- package/src/routes/api/triggers.ts +45 -5
- package/src/web/App.tsx +1 -0
- package/src/web/components/activity/ActivityPage.tsx +349 -214
- package/src/web/components/agents/AgentCard.tsx +37 -8
- package/src/web/components/agents/AgentPanel.tsx +268 -23
- package/src/web/components/connections/IntegrationsTab.tsx +57 -31
- package/src/web/components/connections/TriggersTab.tsx +336 -159
- package/src/web/components/dashboard/Dashboard.tsx +39 -7
- package/src/web/components/layout/Header.tsx +0 -34
- package/src/web/components/layout/Sidebar.tsx +43 -3
- package/src/web/components/mcp/McpPage.tsx +16 -5
- package/src/web/components/settings/SettingsPage.tsx +279 -30
- package/src/web/components/tasks/TasksPage.tsx +32 -6
- package/src/web/context/ProjectContext.tsx +5 -0
- package/src/web/context/TelemetryContext.tsx +14 -0
- package/src/web/types.ts +20 -2
- package/dist/ActivityPage.h769ek3a.js +0 -3
- package/dist/App.2jmkqm8c.js +0 -4
- package/dist/App.3515wsb4.js +0 -4
- package/dist/App.edwahsvz.js +0 -4
- package/dist/App.q3bpx15d.js +0 -20
- package/dist/App.r0a2nmqs.js +0 -267
- package/dist/App.s2yrcz15.js +0 -4
- package/dist/App.s5j82a5j.js +0 -4
- package/dist/App.tg1b94tx.js +0 -4
- package/dist/ConnectionsPage.a67fjgbf.js +0 -3
- package/dist/McpPage.d4p3xvtk.js +0 -3
- package/dist/SettingsPage.46sqpe39.js +0 -3
- package/dist/SkillsPage.j9hkqm99.js +0 -3
- package/dist/TasksPage.6pvkb7s7.js +0 -3
- package/dist/TelemetryPage.5zq9msb5.js +0 -3
- package/dist/TestsPage.24432yqt.js +0 -3
package/dist/App.2jmkqm8c.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as r}from"./App.7v1w3ys9.js";import{s as Oz}from"./App.c90t3dxg.js";import{M as Jz,N as o}from"./App.2yy66bnp.js";import{P as t}from"./App.039re6cf.js";import{Q as a,T as Qz,U as zz,aa as c,da as Gz}from"./App.q3bpx15d.js";var J=a(Qz(),1);var z=a(zz(),1);function Mz(){let{authFetch:G}=c(),{projects:_,currentProjectId:H}=Gz(),[L,w]=J.useState([]),[W,B]=J.useState(!0),[q,F]=J.useState(!1),[U,T]=J.useState(null),[M,K]=J.useState(null),[Q,k]=J.useState("servers"),{confirm:y,ConfirmDialog:I}=Jz(),X=_.length>0,b=async()=>{try{let A=await(await G("/api/mcp/servers")).json();w(A.servers||[])}catch($){console.error("Failed to fetch MCP servers:",$)}B(!1)};J.useEffect(()=>{b()},[G]);let Z=L.filter(($)=>{if(!H)return!0;if(H==="unassigned")return $.project_id===null;return $.project_id===null||$.project_id===H}),S=async($)=>{try{await G(`/api/mcp/servers/${$}/start`,{method:"POST"}),b()}catch(A){console.error("Failed to start server:",A)}},C=async($)=>{try{await G(`/api/mcp/servers/${$}/stop`,{method:"POST"}),b()}catch(A){console.error("Failed to stop server:",A)}},m=async($)=>{if(!await y("Delete this MCP server?",{confirmText:"Delete",title:"Delete Server"}))return;try{if(await G(`/api/mcp/servers/${$}`,{method:"DELETE"}),M?.id===$)K(null);b()}catch(f){console.error("Failed to delete server:",f)}},g=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}),b()}catch(f){console.error("Failed to rename server:",f)}},V=async($,A)=>{try{await G(`/api/mcp/servers/${$}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)}),b()}catch(f){throw console.error("Failed to update server:",f),f}};return z.jsxDEV(z.Fragment,{children:[I,z.jsxDEV("div",{className:"flex-1 overflow-auto p-6",children:[z.jsxDEV("div",{className:"max-w-6xl",children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[z.jsxDEV("div",{children:[z.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666]",children:"Manage Model Context Protocol servers for tool integrations."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"+ Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-1 w-fit",children:[z.jsxDEV("button",{onClick:()=>k("servers"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="servers"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"My Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("hosted"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="hosted"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Hosted Services"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:`px-4 py-2 rounded text-sm font-medium transition ${Q==="registry"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Q==="servers"&&z.jsxDEV(z.Fragment,{children:[W&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this),!W&&Z.length===0&&L.length===0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV(Oz,{className:"w-12 h-12 text-[#333] mx-auto mb-4"},void 0,!1,void 0,this),z.jsxDEV("h3",{className:"text-lg font-medium mb-2",children:"No MCP servers configured"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-[#666] mb-6 max-w-md mx-auto",children:"MCP servers extend your agents with tools like file access, web browsing, database connections, and more."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-3 justify-center",children:[z.jsxDEV("button",{onClick:()=>F(!0),className:"bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition",children:"Add Manually"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>k("registry"),className:"border border-[#333] hover:border-[#666] px-4 py-2 rounded font-medium transition",children:"Browse Registry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!W&&Z.length===0&&L.length>0&&z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-6 text-center",children:z.jsxDEV("p",{className:"text-[#666]",children:"No servers match this filter."},void 0,!1,void 0,this)},void 0,!1,void 0,this),!W&&Z.length>0&&z.jsxDEV("div",{className:"flex gap-6",children:[z.jsxDEV("div",{className:`space-y-3 ${M?"w-1/2":"w-full"}`,children:Z.map(($)=>{let f=$.type==="http"&&$.url||$.status==="running",p=X&&$.project_id?_.find((j)=>j.id===$.project_id):null;return z.jsxDEV(Wz,{server:$,project:p,selected:M?.id===$.id,onSelect:()=>K(f?$:null),onStart:()=>S($.id),onStop:()=>C($.id),onDelete:()=>m($.id),onEdit:()=>T($)},$.id,!1,void 0,this)})},void 0,!1,void 0,this),M&&z.jsxDEV("div",{className:"w-1/2",children:z.jsxDEV(Xz,{server:M,onClose:()=>K(null)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q==="hosted"&&z.jsxDEV(_z,{onServerAdded:b,projectId:H},void 0,!1,void 0,this),Q==="registry"&&z.jsxDEV(Zz,{onInstall:($)=>{b(),k("servers")}},void 0,!1,void 0,this),Q==="servers"&&z.jsxDEV("div",{className:"mt-8 p-4 bg-[#111] border border-[#1a1a1a] rounded-lg",children:[z.jsxDEV("h3",{className:"font-medium mb-2",children:"Quick Start"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-3",children:"Add an MCP server by providing its npm package name. For example:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch"},{name:"memory",pkg:"@modelcontextprotocol/server-memory"}].map(($)=>z.jsxDEV("code",{className:"text-xs bg-[#0a0a0a] px-2 py-1 rounded",children:$.pkg},$.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&z.jsxDEV(Bz,{onClose:()=>F(!1),onAdded:()=>{F(!1),b()},projects:X?_:void 0,defaultProjectId:H&&H!=="unassigned"?H:null},void 0,!1,void 0,this),U&&z.jsxDEV(Uz,{server:U,projects:X?_:void 0,onClose:()=>T(null),onSaved:()=>{T(null),b()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Wz({server:G,project:_,selected:H,onSelect:L,onStart:w,onStop:W,onDelete:B,onEdit:q}){let F=G.type==="http"&&G.url,U=F||G.status==="running",T=()=>{if(F)return`${G.source||"remote"} • http`;return`${G.type} • ${G.package||G.command||"custom"}${G.status==="running"&&G.port?` • :${G.port}`:""}`},M=()=>{if(_)return z.jsxDEV("span",{className:"text-xs px-1.5 py-0.5 rounded",style:{backgroundColor:`${_.color}20`,color:_.color},children:_.name},void 0,!1,void 0,this);if(G.project_id===null)return z.jsxDEV("span",{className:"text-xs text-[#666] bg-[#1a1a1a] px-1.5 py-0.5 rounded",children:"Global"},void 0,!1,void 0,this);return null};return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,onClick:U?L:void 0,children:z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("div",{className:`w-2 h-2 rounded-full ${U?"bg-green-400":"bg-[#444]"}`},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("h3",{className:"font-medium",children:G.name},void 0,!1,void 0,this),M()]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666]",children:T()},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),q()},className:"text-sm text-[#666] hover:text-[#888] px-3 py-1 transition",title:"Edit server settings",children:"Edit"},void 0,!1,void 0,this),F?z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Remove"},void 0,!1,void 0,this):G.status==="running"?z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),L()},className:"text-sm text-[#f97316] hover:text-[#fb923c] px-3 py-1 transition",children:"Tools"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),W()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Stop"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV(z.Fragment,{children:[z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),w()},className:"text-sm text-[#666] hover:text-green-400 px-3 py-1 transition",children:"Start"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:(K)=>{K.stopPropagation(),B()},className:"text-sm text-[#666] hover:text-red-400 px-3 py-1 transition",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Xz({server:G,onClose:_}){let{authFetch:H}=c(),[L,w]=J.useState([]),[W,B]=J.useState(null),[q,F]=J.useState(!0),[U,T]=J.useState(null),[M,K]=J.useState(null);return J.useEffect(()=>{(async()=>{F(!0),T(null);try{let k=await H(`/api/mcp/servers/${G.id}/tools`),y=await k.json();if(!k.ok){T(y.error||"Failed to fetch tools");return}w(y.tools||[]),B(y.serverInfo||null)}catch(k){T(`Failed to fetch tools: ${k}`)}finally{F(!1)}})()},[G.id,H]),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg overflow-hidden",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between",children:[z.jsxDEV("div",{children:[z.jsxDEV("h3",{className:"font-medium",children:[G.name," Tools"]},void 0,!0,void 0,this),W&&z.jsxDEV("p",{className:"text-xs text-[#666]",children:[W.name," v",W.version]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:_,className:"text-[#666] hover:text-[#888] text-xl leading-none",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 max-h-[500px] overflow-auto",children:[q&&z.jsxDEV("p",{className:"text-[#666]",children:"Loading tools..."},void 0,!1,void 0,this),U&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:U},void 0,!1,void 0,this),!q&&!U&&L.length===0&&z.jsxDEV("p",{className:"text-[#666]",children:"No tools available from this server."},void 0,!1,void 0,this),!q&&!U&&L.length>0&&!M&&z.jsxDEV("div",{className:"space-y-2",children:L.map((Q)=>z.jsxDEV("button",{onClick:()=>K(Q),className:"w-full text-left p-3 bg-[#0a0a0a] hover:bg-[#1a1a1a] border border-[#222] hover:border-[#333] rounded transition",children:[z.jsxDEV("div",{className:"font-medium text-sm",children:Q.name},void 0,!1,void 0,this),Q.description&&z.jsxDEV("div",{className:"text-xs text-[#666] mt-1",children:Q.description},void 0,!1,void 0,this)]},Q.name,!0,void 0,this))},void 0,!1,void 0,this),M&&z.jsxDEV(Yz,{serverId:G.id,tool:M,onBack:()=>K(null)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yz({serverId:G,tool:_,onBack:H}){let{authFetch:L}=c(),[w,W]=J.useState("{}"),[B,q]=J.useState(null),[F,U]=J.useState(null),[T,M]=J.useState(!1);J.useEffect(()=>{let Q=_.inputSchema;if(Q&&typeof Q==="object"&&"properties"in Q){let k=Q.properties,y={};for(let[I,X]of Object.entries(k))if(X.default!==void 0)y[I]=X.default;else if(X.type==="string")y[I]="";else if(X.type==="number"||X.type==="integer")y[I]=0;else if(X.type==="boolean")y[I]=!1;else if(X.type==="array")y[I]=[];else if(X.type==="object")y[I]={};W(JSON.stringify(y,null,2))}},[_]);let K=async()=>{M(!0),U(null),q(null);try{let Q=JSON.parse(w),k=await L(`/api/mcp/servers/${G}/tools/${encodeURIComponent(_.name)}/call`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({arguments:Q})}),y=await k.json();if(!k.ok){U(y.error||"Failed to call tool");return}q(y.result)}catch(Q){U(`Error: ${Q}`)}finally{M(!1)}};return z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888] text-sm",children:"← Back"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-[#444]",children:"/"},void 0,!1,void 0,this),z.jsxDEV("span",{className:"font-medium",children:_.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_.description&&z.jsxDEV("p",{className:"text-sm text-[#666]",children:_.description},void 0,!1,void 0,this),_.inputSchema&&z.jsxDEV("div",{className:"text-xs",children:z.jsxDEV("details",{className:"cursor-pointer",children:[z.jsxDEV("summary",{className:"text-[#666] hover:text-[#888]",children:"Input Schema"},void 0,!1,void 0,this),z.jsxDEV("pre",{className:"mt-2 p-2 bg-[#0a0a0a] rounded text-[#888] overflow-auto max-h-32",children:JSON.stringify(_.inputSchema,null,2)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments (JSON)"},void 0,!1,void 0,this),z.jsxDEV("textarea",{value:w,onChange:(Q)=>W(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 h-32 font-mono text-sm focus:outline-none focus:border-[#f97316] resize-none",placeholder:"{}"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("button",{onClick:K,disabled:T,className:"w-full bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:T?"Calling...":"Call Tool"},void 0,!1,void 0,this),F&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 rounded",children:F},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"space-y-2",children:[z.jsxDEV("div",{className:"text-sm text-[#666]",children:["Result ",B.isError&&z.jsxDEV("span",{className:"text-red-400",children:"(error)"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:`p-3 rounded text-sm ${B.isError?"bg-red-500/10":"bg-green-500/10"}`,children:B.content.map((Q,k)=>z.jsxDEV("div",{className:"mb-2 last:mb-0",children:[Q.type==="text"&&z.jsxDEV("pre",{className:"whitespace-pre-wrap font-mono text-xs",children:Q.text},void 0,!1,void 0,this),Q.type==="image"&&Q.data&&z.jsxDEV("img",{src:`data:${Q.mimeType||"image/png"};base64,${Q.data}`,alt:"Tool result",className:"max-w-full rounded"},void 0,!1,void 0,this)]},k,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zz({onInstall:G}){let{authFetch:_}=c(),[H,L]=J.useState(""),[w,W]=J.useState([]),[B,q]=J.useState(!1),[F,U]=J.useState(!1),[T,M]=J.useState(null),[K,Q]=J.useState(null),k=async(X)=>{q(!0),Q(null);try{let b=await _(`/api/mcp/registry?search=${encodeURIComponent(X)}&limit=20`),Z=await b.json();if(!b.ok)Q(Z.error||"Failed to search registry"),W([]);else W(Z.servers||[])}catch(b){Q(`Failed to search: ${b}`),W([])}finally{q(!1),U(!0)}},y=(X)=>{if(X.preventDefault(),H.trim())k(H.trim())};J.useEffect(()=>{k("")},[]);let I=async(X)=>{if(!X.npmPackage){Q("This server does not have an npm package");return}M(X.id),Q(null);try{let b=await _("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:X.name,type:"npm",package:X.npmPackage})});if(!b.ok){let Z=await b.json();Q(Z.error||"Failed to add server");return}G(X)}catch(b){Q(`Failed to add server: ${b}`)}finally{M(null)}};return z.jsxDEV("div",{className:"space-y-6",children:[z.jsxDEV("form",{onSubmit:y,className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:H,onChange:(X)=>L(X.target.value),placeholder:"Search MCP servers (e.g., filesystem, github, slack...)",className:"flex-1 bg-[#111] border border-[#333] rounded-lg px-4 py-3 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{type:"submit",disabled:B,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-6 py-3 rounded-lg font-medium transition",children:B?"...":"Search"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),K&&z.jsxDEV("div",{className:"text-red-400 text-sm p-3 bg-red-500/10 border border-red-500/20 rounded-lg",children:K},void 0,!1,void 0,this),!B&&F&&w.length===0&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"No servers found. Try a different search term."},void 0,!1,void 0,this),w.length>0&&z.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2",children:w.map((X)=>z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 hover:border-[#333] transition",children:z.jsxDEV("div",{className:"flex items-start justify-between gap-3",children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("h3",{className:"font-medium truncate",children:X.name},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mt-1 line-clamp-2",children:X.description||"No description"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 mt-2 text-xs text-[#555]",children:[X.version&&z.jsxDEV("span",{children:["v",X.version]},void 0,!0,void 0,this),z.jsxDEV("span",{className:`px-1.5 py-0.5 rounded ${X.npmPackage?"bg-green-500/10 text-green-400":"bg-blue-500/10 text-blue-400"}`,children:X.npmPackage?"npm":"remote"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("code",{className:"text-xs text-[#555] bg-[#0a0a0a] px-2 py-0.5 rounded mt-2 inline-block truncate max-w-full",children:X.npmPackage||X.fullName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex-shrink-0",children:X.npmPackage?z.jsxDEV("button",{onClick:()=>I(X),disabled:T===X.id,className:"text-sm bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-3 py-1.5 rounded transition disabled:opacity-50",children:T===X.id?"Adding...":"Add"},void 0,!1,void 0,this):X.repository?z.jsxDEV("a",{href:X.repository,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#666] hover:text-[#f97316] transition",children:"View →"},void 0,!1,void 0,this):null},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},X.id,!1,void 0,this))},void 0,!1,void 0,this),B&&z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Searching registry..."},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-4 bg-[#111] border border-[#1a1a1a] rounded-lg text-sm text-[#666]",children:z.jsxDEV("p",{children:["Servers are sourced from the"," ",z.jsxDEV("a",{href:"https://github.com/modelcontextprotocol/servers",target:"_blank",rel:"noopener noreferrer",className:"text-[#f97316] hover:underline",children:"official MCP registry"},void 0,!1,void 0,this),". Not all servers have npm packages - some require manual setup."]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function _z({onServerAdded:G,projectId:_}){let{authFetch:H}=c(),[L,w]=J.useState("composio"),[W,B]=J.useState("configs"),[q,F]=J.useState(!1),[U,T]=J.useState(!1),[M,K]=J.useState(!1),[Q,k]=J.useState([]),[y,I]=J.useState(new Set),[X,b]=J.useState(!0),[Z,S]=J.useState(!1),[C,m]=J.useState(null),{alert:g,AlertDialog:V}=o(),$=async()=>{try{let P=_&&_!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(_)}`:"/api/mcp/servers",[i,Y]=await Promise.all([H("/api/providers"),H(P)]),R=await i.json(),u=await Y.json(),D=R.providers||[],O=u.servers||[],N=new Set(O.filter((E)=>E.source==="composio"&&E.url).map((E)=>{let e=E.url.match(/\/v3\/mcp\/([^/]+)/);return e?e[1]:null}).filter(Boolean));I(N);let h=D.find((E)=>E.id==="composio"),l=D.find((E)=>E.id==="smithery"),n=D.find((E)=>E.id==="agentdojo"),d=h?.hasKey||!1,v=l?.hasKey||!1,s=n?.hasKey||!1;if(F(d),T(v),K(s),d)w("composio"),A();else if(v)w("smithery");else if(s)w("agentdojo")}catch(P){console.error("Failed to fetch providers:",P)}b(!1)},A=async()=>{S(!0);try{let P=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await(await H(`/api/integrations/composio/configs${P}`)).json();k(Y.configs||[])}catch(P){console.error("Failed to fetch Composio configs:",P)}S(!1)},f=async(P)=>{m(P);try{let i=_&&_!=="unassigned"?`?project_id=${_}`:"",Y=await H(`/api/integrations/composio/configs/${P}/add${i}`,{method:"POST"});if(Y.ok)I((R)=>new Set([...R,P])),G?.();else{let R=await Y.json();await g(R.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(i){console.error("Failed to add config:",i)}m(null)},p=(P)=>{return y.has(P)};if(J.useEffect(()=>{$()},[H,_]),X)return z.jsxDEV("div",{className:"text-center py-8 text-[#666]",children:"Loading..."},void 0,!1,void 0,this);let j=q||U||M,x=[q,U,M].filter(Boolean).length;if(!j)return z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-8 text-center",children:[z.jsxDEV("p",{className:"text-[#888] mb-2",children:"No hosted MCP services connected"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect Composio, Smithery, or AgentDojo in Settings to access cloud-based MCP servers."},void 0,!1,void 0,this),z.jsxDEV("a",{href:"/settings",className:"inline-block bg-[#1a1a1a] hover:bg-[#222] border border-[#333] hover:border-[#f97316] px-4 py-2 rounded text-sm font-medium transition",children:"Go to Settings →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return z.jsxDEV(z.Fragment,{children:[V,z.jsxDEV("div",{className:"space-y-6",children:[x>1&&z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1 w-fit",children:[q&&z.jsxDEV("button",{onClick:()=>{w("composio"),B("configs")},className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="composio"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio"]},void 0,!0,void 0,this),U&&z.jsxDEV("button",{onClick:()=>w("smithery"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="smithery"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery"]},void 0,!0,void 0,this),M&&z.jsxDEV("button",{onClick:()=>w("agentdojo"),className:`px-4 py-2 rounded text-sm font-medium transition flex items-center gap-2 ${L==="agentdojo"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q&&(x===1||L==="composio")&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{className:"flex items-center justify-between",children:[z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>B("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Configs"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("connect"),className:`px-4 py-2 rounded text-sm font-medium transition ${W==="connect"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Connect Apps"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666]",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-purple-500"},void 0,!1,void 0,this),"Composio",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="connect"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Connect your accounts to enable tools in MCP configs"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"composio",projectId:_,onConnectionComplete:()=>{A()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP configs from Composio"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-3",children:[z.jsxDEV("button",{onClick:A,disabled:Z,className:"text-xs text-[#666] hover:text-[#888] transition",children:Z?"Loading...":"Refresh"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Create Config →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Z?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading configs..."},void 0,!1,void 0,this):Q.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP configs found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:["First ",z.jsxDEV("button",{onClick:()=>B("connect"),className:"text-[#f97316] hover:text-[#fb923c]",children:"connect some apps"},void 0,!1,void 0,this),", then create a config."]},void 0,!0,void 0,this),z.jsxDEV("a",{href:"https://app.composio.dev/mcp_configs",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#f97316] hover:text-[#fb923c] mt-2 inline-block",children:"Create in Composio →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:Q.map((P)=>{let i=p(P.id),Y=C===P.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${i?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:P.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[P.toolsCount," tools"]},void 0,!0,void 0,this),i&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P.toolkits.length>0&&z.jsxDEV("div",{className:"flex flex-wrap gap-1 mt-1",children:[P.toolkits.slice(0,4).map((R)=>z.jsxDEV("span",{className:"text-xs bg-[#1a1a1a] text-[#666] px-1.5 py-0.5 rounded",children:R},R,!1,void 0,this)),P.toolkits.length>4&&z.jsxDEV("span",{className:"text-xs text-[#555]",children:["+",P.toolkits.length-4]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:[i?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>f(P.id),disabled:Y,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:Y?"Adding...":"Add"},void 0,!1,void 0,this),z.jsxDEV("a",{href:`https://app.composio.dev/mcp_configs/${P.id}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#888] transition",children:"Edit"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},P.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),U&&(x===1||L==="smithery")&&z.jsxDEV("div",{children:[x===1&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-blue-500"},void 0,!1,void 0,this),"Smithery",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Add MCP servers from the Smithery registry"},void 0,!1,void 0,this),z.jsxDEV("a",{href:"https://smithery.ai/servers",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#666] hover:text-[#f97316] transition",children:"Browse Smithery →"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:["Smithery servers can be added from the ",z.jsxDEV("strong",{children:"Browse Registry"},void 0,!1,void 0,this)," tab."]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:"Your API key will be used automatically when adding Smithery servers."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&(x===1||L==="agentdojo")&&z.jsxDEV($z,{projectId:_,onServerAdded:G,showProviderBadge:x===1},void 0,!1,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded text-xs text-[#666]",children:[z.jsxDEV("strong",{className:"text-[#888]",children:"Tip:"},void 0,!1,void 0,this)," Connect apps first, then add MCP configs to make tools available to your agents."," · ",z.jsxDEV("a",{href:"/settings",className:"text-[#f97316] hover:text-[#fb923c]",children:"Add more providers in Settings"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $z({projectId:G,onServerAdded:_,showProviderBadge:H}){let{authFetch:L}=c(),[w,W]=J.useState("configs"),[B,q]=J.useState([]),[F,U]=J.useState(new Set),[T,M]=J.useState(!1),[K,Q]=J.useState(null),{alert:k,AlertDialog:y}=o(),I=async()=>{M(!0);try{let Z=G&&G!=="unassigned"?`?project_id=${G}`:"",S=G&&G!=="unassigned"?`/api/mcp/servers?project=${encodeURIComponent(G)}`:"/api/mcp/servers",[C,m]=await Promise.all([L(`/api/integrations/agentdojo/configs${Z}`),L(S)]),g=await C.json(),V=await m.json();q(g.configs||[]);let $=new Set((V.servers||[]).filter((A)=>A.source==="agentdojo").map((A)=>{let f=A.url?.match(/\/mcp\/([^/?]+)/);return f?f[1]:A.name}));U($)}catch(Z){console.error("Failed to fetch AgentDojo configs:",Z)}M(!1)},X=async(Z)=>{Q(Z);try{let S=G&&G!=="unassigned"?`?project_id=${G}`:"",C=await L(`/api/integrations/agentdojo/configs/${Z}/add${S}`,{method:"POST"});if(C.ok){let m=B.find((g)=>g.id===Z);U((g)=>new Set([...g,m?.slug||Z])),_?.()}else{let m=await C.json();await k(m.error||"Failed to add config",{title:"Error",variant:"error"})}}catch(S){console.error("Failed to add config:",S)}Q(null)},b=(Z)=>{return F.has(Z.slug)||F.has(Z.id)||F.has(Z.name)};return J.useEffect(()=>{I()},[L,G]),z.jsxDEV(z.Fragment,{children:[y,z.jsxDEV("div",{children:[H&&z.jsxDEV("div",{className:"flex items-center gap-2 text-xs text-[#666] mb-4",children:[z.jsxDEV("span",{className:"w-2 h-2 rounded-full bg-green-500"},void 0,!1,void 0,this),"AgentDojo",z.jsxDEV("span",{className:"text-green-400",children:"Connected"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded-lg p-1",children:[z.jsxDEV("button",{onClick:()=>W("configs"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="configs"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"MCP Servers"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>W("toolkits"),className:`px-4 py-2 rounded text-sm font-medium transition ${w==="toolkits"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Browse Toolkits"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),w==="configs"&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-3",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"Your MCP servers from AgentDojo"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:I,disabled:T,className:"text-xs text-[#666] hover:text-[#888] transition",children:T?"Loading...":"Refresh"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T?z.jsxDEV("div",{className:"text-center py-6 text-[#666]",children:"Loading servers..."},void 0,!1,void 0,this):B.length===0?z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 text-center",children:[z.jsxDEV("p",{className:"text-sm text-[#666]",children:"No MCP servers found"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:[z.jsxDEV("button",{onClick:()=>W("toolkits"),className:"text-[#f97316] hover:text-[#fb923c]",children:"Browse toolkits"},void 0,!1,void 0,this)," ","to create a new MCP server."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.jsxDEV("div",{className:"space-y-2",children:B.map((Z)=>{let S=b(Z),C=K===Z.id;return z.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-3 transition flex items-center justify-between ${S?"border-green-500/30":"border-[#1a1a1a] hover:border-[#333]"}`,children:[z.jsxDEV("div",{className:"flex-1 min-w-0",children:[z.jsxDEV("div",{className:"flex items-center gap-2",children:[z.jsxDEV("span",{className:"font-medium text-sm",children:Z.name},void 0,!1,void 0,this),z.jsxDEV("span",{className:"text-xs text-[#555]",children:[Z.toolsCount," tools"]},void 0,!0,void 0,this),S&&z.jsxDEV("span",{className:"text-xs text-green-400",children:"Added"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.mcpUrl&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.mcpUrl},void 0,!1,void 0,this),!Z.mcpUrl&&Z.slug&&z.jsxDEV("code",{className:"text-xs text-[#555] mt-1 block truncate",children:Z.slug},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex items-center gap-2 ml-3",children:S?z.jsxDEV("span",{className:"text-xs text-[#555] px-2 py-1",children:"In Servers"},void 0,!1,void 0,this):z.jsxDEV("button",{onClick:()=>X(Z.id),disabled:C,className:"text-xs bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1 rounded font-medium transition disabled:opacity-50",children:C?"Adding...":"Add"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},Z.id,!0,void 0,this)})},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w==="toolkits"&&z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"Browse available toolkits and create MCP servers"},void 0,!1,void 0,this),z.jsxDEV(r,{providerId:"agentdojo",projectId:G,onConnectionComplete:()=>{I()}},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qz(G){let _=[],H=G,L=null,w=G.match(/(?:npx\s+-y\s+)?(@?[\w-]+\/)?(@?[\w-]+)(?:@[\w.-]+)?/);if(w){let q=w[2]||w[1];if(q)L=q.replace(/^@/,"").replace(/-mcp$/,"").replace(/-server$/,"").replace(/^server-/,"").replace(/^mcp-/,"")}let W=/--(\w+[-\w]*)\s+(YOUR_\w+|<[\w_]+>|\{[\w_]+\}|\$[\w_]+|[\w_]*(?:TOKEN|KEY|SECRET|PASSWORD|USER|ID|APIKEY)[\w_]*)/gi,B;while((B=W.exec(G))!==null){let q=B[1],F=B[2],U=q.toUpperCase().replace(/-/g,"_"),T=L?`${L.toUpperCase().replace(/-/g,"_")}_${U}`:U;_.push({key:T,flag:q}),H=H.replace(new RegExp(`(--${q}\\s+)${F.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}`,"i"),`--${q} $${T}`)}return{cleanCommand:H,credentials:_,serverName:L}}function Bz({onClose:G,onAdded:_,projects:H,defaultProjectId:L}){let{authFetch:w}=c(),[W,B]=J.useState("npm"),[q,F]=J.useState(""),[U,T]=J.useState(""),[M,K]=J.useState(""),[Q,k]=J.useState(""),[y,I]=J.useState(""),[X,b]=J.useState(""),[Z,S]=J.useState(""),[C,m]=J.useState([]),[g,V]=J.useState(L||null),[$,A]=J.useState(!1),[f,p]=J.useState(null),j=H&&H.length>0,x=()=>{m([...C,{key:"",value:""}])},P=(O,N,h)=>{let l=[...C];l[O][N]=h,m(l)},i=(O)=>{m(C.filter((N,h)=>h!==O))},Y=(O)=>{if(k(O),O.includes("YOUR_")||O.includes("<")||O.includes("{")||/TOKEN|KEY|SECRET|PASSWORD/i.test(O)){let{cleanCommand:N,credentials:h,serverName:l}=qz(O);if(!q&&l)F(l);if(h.length>0){let n=new Set(C.map((v)=>v.key)),d=h.filter((v)=>!n.has(v.key)).map((v)=>({key:v.key,value:""}));if(d.length>0)m([...C,...d]),k(N)}}},R=(O)=>{if(O.startsWith("npx ")||O.includes(" --")||O.includes("YOUR_")||O.includes("<")||/\s+(TOKEN|KEY|SECRET|PASSWORD)/i.test(O))B("command"),Y(O);else if(T(O),!q&&O){let h=O.replace(/^@[\w-]+\//,"").replace(/@[\w.-]+$/,"").replace(/^server-/,"").replace(/-server$/,"").replace(/^mcp-/,"").replace(/-mcp$/,"");if(h&&h!==O)F(h)}},u=async()=>{if(!q){p("Name is required");return}if(W==="npm"&&!U){p("npm package is required");return}if(W==="pip"&&!U){p("pip package is required");return}if(W==="command"&&!Q){p("Command is required");return}if(W==="http"&&!y){p("URL is required");return}A(!0),p(null);let O={};for(let{key:N,value:h}of C)if(N.trim())O[N.trim()]=h;try{let N={name:q};if(W==="npm")N.type="npm",N.package=U;else if(W==="pip"){if(N.type="pip",N.package=U,M)N.pip_module=M}else if(W==="http"){N.type="http",N.url=y;let l={"Content-Type":"application/json"};if(X&&Z){let n=btoa(`${X}:${Z}`);l.Authorization=`Basic ${n}`}N.headers=l}else{let l=Q.trim().split(/\s+/);N.type="custom",N.command=l[0],N.args=l.slice(1).join(" ")}if(Object.keys(O).length>0)N.env=O;if(g)N.project_id=g;let h=await w("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!h.ok){let l=await h.json();p(l.error||"Failed to add server"),A(!1);return}_()}catch(N){p("Failed to add server"),A(!1)}},D=(O,N)=>{B("npm"),F(O),T(N)};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Add MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:G,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("p",{className:"text-sm text-[#666] mb-2",children:"Quick add:"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex flex-wrap gap-2",children:[{name:"filesystem",pkg:"@modelcontextprotocol/server-filesystem",type:"npm"},{name:"fetch",pkg:"@modelcontextprotocol/server-fetch",type:"npm"},{name:"memory",pkg:"@modelcontextprotocol/server-memory",type:"npm"},{name:"github",pkg:"@modelcontextprotocol/server-github",type:"npm"},{name:"time",pkg:"mcp-server-time",module:"mcp_server_time",type:"pip"}].map((O)=>z.jsxDEV("button",{onClick:()=>{if(B(O.type),F(O.name),T(O.pkg),O.type==="pip"&&"module"in O)K(O.module||"");else K("")},className:"text-sm bg-[#1a1a1a] hover:bg-[#222] px-3 py-1 rounded transition",children:O.name},O.name,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"flex gap-1 bg-[#0a0a0a] border border-[#222] rounded p-1",children:[z.jsxDEV("button",{onClick:()=>B("npm"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="npm"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"npm"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("pip"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="pip"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"pip"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("command"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="command"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"Command"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>B("http"),className:`flex-1 px-2 py-1.5 rounded text-sm transition ${W==="http"?"bg-[#1a1a1a] text-white":"text-[#666] hover:text-[#888]"}`,children:"HTTP"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(O)=>F(O.target.value),placeholder:"e.g., pushover",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:g||"",onChange:(O)=>V(O||null),options:[{value:"",label:"Global (all projects)"},...H.map((O)=>({value:O.id,label:O.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Global servers are available to all agents. Project-scoped servers are only available to agents in that project."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>R(O.target.value),placeholder:"e.g., @modelcontextprotocol/server-filesystem or paste full command",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Package name or paste a full npx command with credentials"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="pip"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(O)=>{if(T(O.target.value),!M&&O.target.value){let N=O.target.value.split("[")[0].replace(/-/g,".");K(N)}},placeholder:"e.g., late-sdk[mcp]",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python package with extras, e.g., late-sdk[mcp] or mcp-server-time"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Module (optional)"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(O)=>K(O.target.value),placeholder:"e.g., late.mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Python module to run with -m. Auto-detected from package name if not specified."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W==="command"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(O)=>Y(O.target.value),placeholder:"e.g., npx -y pushover-mcp@latest start --token YOUR_TOKEN",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Paste the full command - credentials like YOUR_TOKEN will be auto-extracted"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W==="http"&&z.jsxDEV("div",{className:"space-y-4",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:y,onChange:(O)=>I(O.target.value),placeholder:"e.g., https://example.com/wp-json/mcp/v1/messages",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-3 bg-[#0a0a0a] border border-[#222] rounded",children:[z.jsxDEV("p",{className:"text-xs text-[#666] mb-3",children:"Optional: Basic Auth credentials (will be encoded and stored securely)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"grid grid-cols-2 gap-3",children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Username"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:X,onChange:(O)=>b(O.target.value),placeholder:"username",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-xs text-[#555] mb-1",children:"Password"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Z,onChange:(O)=>S(O.target.value),placeholder:"password or app key",className:"w-full bg-[#111] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:x,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"Add environment variables for API tokens and credentials. These are stored encrypted and passed to the server at startup."},void 0,!1,void 0,this),C.length>0&&z.jsxDEV("div",{className:"space-y-2",children:C.map((O,N)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:O.key,onChange:(h)=>P(N,"key",h.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:O.value,onChange:(h)=>P(N,"value",h.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>i(N),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},N,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:f},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:G,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:u,disabled:$||!q||(W==="npm"?!U:W==="pip"?!U:W==="http"?!y:!Q),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:$?"Adding...":"Add Server"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Uz({server:G,projects:_,onClose:H,onSaved:L}){let{authFetch:w}=c(),[W,B]=J.useState(G.name),[q,F]=J.useState(G.package||""),[U,T]=J.useState(G.command||""),[M,K]=J.useState(G.args||""),[Q,k]=J.useState(G.url||""),[y,I]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":")[0]||""}catch{return""}return""}),[X,b]=J.useState(()=>{let Y=G.headers?.Authorization||"";if(Y.startsWith("Basic "))try{return atob(Y.slice(6)).split(":").slice(1).join(":")||""}catch{return""}return""}),[Z,S]=J.useState(()=>{return Object.entries(G.env||{}).map(([Y,R])=>({key:Y,value:R}))}),[C,m]=J.useState(G.project_id),[g,V]=J.useState(!1),[$,A]=J.useState(null),f=_&&_.length>0,p=G.type==="http",j=()=>{S([...Z,{key:"",value:""}])},x=(Y,R,u)=>{let D=[...Z];D[Y][R]=u,S(D)},P=(Y)=>{S(Z.filter((R,u)=>u!==Y))},i=async()=>{if(!W.trim()){A("Name is required");return}V(!0),A(null);let Y={};for(let{key:R,value:u}of Z)if(R.trim())Y[R.trim()]=u;try{let R={name:W.trim(),env:Y};if(p){if(Q.trim())R.url=Q.trim();let D={"Content-Type":"application/json"};if(y&&X){let O=btoa(`${y}:${X}`);D.Authorization=`Basic ${O}`}R.headers=D}else{if(G.type==="npm"&&q.trim())R.package=q.trim();if(G.type==="pip"&&q.trim())R.package=q.trim();if(G.type==="custom"){if(U.trim())R.command=U.trim();if(M.trim())R.args=M.trim()}}R.project_id=C;let u=await w(`/api/mcp/servers/${G.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!u.ok){let D=await u.json();A(D.error||"Failed to save changes"),V(!1);return}if(G.status==="running"&&!p)try{await w(`/api/mcp/servers/${G.id}/stop`,{method:"POST"}),await w(`/api/mcp/servers/${G.id}/start`,{method:"POST"})}catch(D){console.error("Failed to restart server:",D)}L()}catch(R){A("Failed to save changes"),V(!1)}};return z.jsxDEV("div",{className:"fixed inset-0 bg-black/50 backdrop-blur-[2px] z-50 flex items-center justify-center p-4",children:z.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg w-full max-w-lg max-h-[90vh] overflow-y-auto",children:[z.jsxDEV("div",{className:"p-4 border-b border-[#1a1a1a] flex items-center justify-between sticky top-0 bg-[#111]",children:[z.jsxDEV("h2",{className:"text-lg font-semibold",children:"Edit MCP Server"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:H,className:"text-[#666] hover:text-[#888]",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 space-y-4",children:[z.jsxDEV("div",{className:"text-sm text-[#666] bg-[#0a0a0a] border border-[#222] rounded p-3",children:["Type: ",z.jsxDEV("span",{className:"text-[#888]",children:G.type},void 0,!1,void 0,this),G.package&&z.jsxDEV(z.Fragment,{children:[" • Package: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.package},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.command&&z.jsxDEV(z.Fragment,{children:[" • Command: ",z.jsxDEV("span",{className:"text-[#888] font-mono",children:G.command},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:W,onChange:(Y)=>B(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Scope"},void 0,!1,void 0,this),z.jsxDEV(t,{value:C||"",onChange:(Y)=>m(Y||null),options:[{value:"",label:"Global (all projects)"},..._.map((Y)=>({value:Y.id,label:Y.name}))],placeholder:"Select scope..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="npm"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"npm Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),G.type==="pip"&&z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"pip Package"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:q,onChange:(Y)=>F(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),p&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Server URL"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:Q,onChange:(Y)=>k(Y.target.value),placeholder:"https://example.com/mcp",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Authentication (Basic Auth)"},void 0,!1,void 0,this),z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:y,onChange:(Y)=>I(Y.target.value),placeholder:"Username",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:X,onChange:(Y)=>b(Y.target.value),placeholder:"Password / App Password",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:"Leave empty if no authentication required"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G.type==="custom"&&z.jsxDEV(z.Fragment,{children:[z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Command"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:U,onChange:(Y)=>T(Y.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{children:[z.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Arguments"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"text",value:M,onChange:(Y)=>K(Y.target.value),placeholder:"e.g., --token $TOKEN --verbose",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 font-mono text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!p&&z.jsxDEV("div",{children:[z.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[z.jsxDEV("label",{className:"text-sm text-[#666]",children:"Environment Variables / Credentials"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:j,className:"text-xs text-[#f97316] hover:text-[#fb923c] transition",children:"+ Add Variable"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z.length===0&&z.jsxDEV("p",{className:"text-xs text-[#555] bg-[#0a0a0a] border border-[#222] rounded p-3",children:"No environment variables configured."},void 0,!1,void 0,this),Z.length>0&&z.jsxDEV("div",{className:"space-y-2",children:Z.map((Y,R)=>z.jsxDEV("div",{className:"flex gap-2",children:[z.jsxDEV("input",{type:"text",value:Y.key,onChange:(u)=>x(R,"key",u.target.value),placeholder:"KEY",className:"w-1/3 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("input",{type:"password",value:Y.value,onChange:(u)=>x(R,"value",u.target.value),placeholder:"value",className:"flex-1 bg-[#0a0a0a] border border-[#333] rounded px-2 py-1.5 text-sm font-mono focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:()=>P(R),className:"text-[#666] hover:text-red-400 px-2 transition",children:"✕"},void 0,!1,void 0,this)]},R,!0,void 0,this))},void 0,!1,void 0,this),z.jsxDEV("p",{className:"text-xs text-[#555] mt-2",children:G.status==="running"?"Server will be automatically restarted to apply changes.":"Changes will take effect when the server is started."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&z.jsxDEV("p",{className:"text-red-400 text-sm",children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.jsxDEV("div",{className:"p-4 border-t border-[#1a1a1a] flex justify-end gap-2 sticky bottom-0 bg-[#111]",children:[z.jsxDEV("button",{onClick:H,className:"px-4 py-2 border border-[#333] hover:border-[#666] rounded transition",children:"Cancel"},void 0,!1,void 0,this),z.jsxDEV("button",{onClick:i,disabled:g||!W.trim(),className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] text-black rounded font-medium transition disabled:opacity-50",children:g?"Saving...":"Save Changes"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}
|
|
2
|
-
export{Mz as h};
|
|
3
|
-
|
|
4
|
-
//# debugId=5835E74D4CBA249B64756E2164756E21
|
package/dist/App.3515wsb4.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{F as S,G as f,H as h,k as g,p as T}from"./App.c90t3dxg.js";import{Q as M,T as u,U as I,X as C,aa as b,da as v}from"./App.q3bpx15d.js";var Y=M(u(),1);var q=M(I(),1);function j({onSelectAgent:z}){let{authFetch:Q}=b(),{currentProjectId:Z}=v(),[X,$]=Y.useState([]),[P,J]=Y.useState(!0),[U,G]=Y.useState("all"),[H,K]=Y.useState(null),[_,F]=Y.useState(!1),W=Y.useRef(null),{events:w}=C({category:"TASK"}),A=Y.useCallback(async()=>{try{let B=`/api/tasks?status=${U}`;if(Z!==null)B+=`&project_id=${encodeURIComponent(Z)}`;let R=await(await Q(B)).json();$(R.tasks||[])}catch(B){console.error("Failed to fetch tasks:",B)}finally{J(!1)}},[Q,U,Z]);Y.useEffect(()=>{A()},[A]),Y.useEffect(()=>{if(!w.length)return;let B=w[0];if(!B||B.id===W.current)return;let N=B.type;if(N==="task_created"||N==="task_updated"||N==="task_deleted")W.current=B.id,console.log("[TasksPage] Telemetry event:",N),A()},[w,A]);let p=Y.useCallback(async(B)=>{K(B),F(!0);try{let N=await Q(`/api/tasks/${B.agentId}/${B.id}`);if(console.log("[TasksPage] Fetch task response status:",N.status),N.ok){let R=await N.json();if(console.log("[TasksPage] Task data:",R),console.log("[TasksPage] Has trajectory:",!!R.task?.trajectory,"Length:",R.task?.trajectory?.length),R.task)K({...R.task,agentId:B.agentId,agentName:B.agentName})}else console.error("[TasksPage] Failed to fetch task:",N.status,await N.text())}catch(N){console.error("Failed to fetch task details:",N)}finally{F(!1)}},[Q]),O={pending:"bg-yellow-500/20 text-yellow-400",running:"bg-blue-500/20 text-blue-400",completed:"bg-green-500/20 text-green-400",failed:"bg-red-500/20 text-red-400",cancelled:"bg-gray-500/20 text-gray-400"};return q.jsxDEV("div",{className:"flex-1 flex overflow-hidden",children:[q.jsxDEV("div",{className:`flex-1 p-4 md:p-6 overflow-auto ${H?"hidden md:block md:w-1/2 lg:w-2/3":""}`,children:q.jsxDEV("div",{className:"max-w-4xl",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("div",{className:"mb-4",children:[q.jsxDEV("h1",{className:"text-xl md:text-2xl font-semibold mb-1",children:"Tasks"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"View tasks from all running agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 overflow-x-auto scrollbar-hide pb-1",children:[{value:"all",label:"All"},{value:"pending",label:"Pending"},{value:"running",label:"Running"},{value:"completed",label:"Completed"},{value:"failed",label:"Failed"}].map((B)=>q.jsxDEV("button",{onClick:()=>G(B.value),className:`px-3 py-1.5 rounded text-sm transition whitespace-nowrap ${U===B.value?"bg-[#f97316] text-black":"bg-[#1a1a1a] hover:bg-[#222]"}`,children:B.label},B.value,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),P?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:"Loading tasks..."},void 0,!1,void 0,this):X.length===0?q.jsxDEV("div",{className:"text-center py-12",children:[q.jsxDEV(T,{className:"w-12 h-12 mx-auto mb-4 text-[#333]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"No tasks found"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#444] mt-1",children:"Tasks will appear here when agents create them"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:X.map((B)=>q.jsxDEV("div",{onClick:()=>p(B),className:`bg-[#111] border rounded-lg p-4 cursor-pointer transition ${H?.id===B.id&&H?.agentId===B.agentId?"border-[#f97316]":"border-[#1a1a1a] hover:border-[#333]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between mb-2",children:[q.jsxDEV("div",{className:"flex-1",children:[q.jsxDEV("h3",{className:"font-medium",children:B.title},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:B.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium ${O[B.status]||O.pending}`,children:B.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),B.description&&q.jsxDEV("p",{className:"text-sm text-[#888] mb-2 line-clamp-2",children:B.description},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-[#555]",children:[q.jsxDEV("span",{className:"flex items-center gap-1",children:[B.type==="recurring"?q.jsxDEV(S,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):B.execute_at?q.jsxDEV(f,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this):q.jsxDEV(h,{className:"w-3.5 h-3.5"},void 0,!1,void 0,this),B.type==="recurring"&&B.recurrence?m(B.recurrence):B.type]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Priority: ",B.priority]},void 0,!0,void 0,this),B.next_run&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.next_run)},void 0,!1,void 0,this),!B.next_run&&B.execute_at&&q.jsxDEV("span",{className:"text-[#f97316]",children:L(B.execute_at)},void 0,!1,void 0,this),q.jsxDEV("span",{children:["Created: ",new Date(B.created_at).toLocaleDateString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},`${B.agentId}-${B.id}`,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),H&&q.jsxDEV(l,{task:H,statusColors:O,onClose:()=>K(null),onSelectAgent:z,loading:_},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function l({task:z,statusColors:Q,onClose:Z,onSelectAgent:X,loading:$}){return q.jsxDEV("div",{className:"w-full md:w-1/2 lg:w-1/3 border-l border-[#1a1a1a] bg-[#0a0a0a] flex flex-col overflow-hidden",children:[q.jsxDEV("div",{className:"flex items-center justify-between p-4 border-b border-[#1a1a1a]",children:[q.jsxDEV("h2",{className:"font-medium truncate pr-2",children:"Task Details"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:Z,className:"text-[#666] hover:text-[#e0e0e0] transition",children:q.jsxDEV(g,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("h3",{className:"text-lg font-medium",children:z.title},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-1 rounded text-xs font-medium flex-shrink-0 ${Q[z.status]}`,children:z.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>X?.(z.agentId),className:"text-sm text-[#f97316] hover:underline",children:z.agentName},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.description&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-1",children:"Description"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] whitespace-pre-wrap",children:z.description},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Type"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.type},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Priority"},void 0,!1,void 0,this),q.jsxDEV("p",{children:z.priority},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Source"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"capitalize",children:z.source},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.recurrence&&q.jsxDEV("div",{children:[q.jsxDEV("span",{className:"text-[#666]",children:"Recurrence"},void 0,!1,void 0,this),q.jsxDEV("p",{children:m(z.recurrence)},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#444] mt-0.5 font-mono",children:z.recurrence},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Created"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.created_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.execute_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Scheduled"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.execute_at)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.executed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Started"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.executed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.completed_at&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Completed"},void 0,!1,void 0,this),q.jsxDEV("span",{children:new Date(z.completed_at).toLocaleString()},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.next_run&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Next Run"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#f97316]",children:L(z.next_run)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.status==="failed"&&z.error&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-red-400 uppercase tracking-wider mb-1",children:"Error"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-red-400 whitespace-pre-wrap break-words",children:z.error},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.status==="completed"&&z.result&&q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h4",{className:"text-xs text-green-400 uppercase tracking-wider mb-1",children:"Result"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/20 rounded p-3 overflow-x-auto",children:q.jsxDEV("pre",{className:"text-sm text-green-400 whitespace-pre-wrap break-words",children:typeof z.result==="string"?z.result:JSON.stringify(z.result,null,2)},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$&&!z.trajectory&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:"Trajectory"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"text-sm text-[#555]",children:"Loading trajectory..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.trajectory&&z.trajectory.length>0&&q.jsxDEV("div",{children:[q.jsxDEV("h4",{className:"text-xs text-[#666] uppercase tracking-wider mb-2",children:["Trajectory (",z.trajectory.length," steps)"]},void 0,!0,void 0,this),q.jsxDEV(c,{trajectory:z.trajectory},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function c({trajectory:z}){let[Q,Z]=Y.useState(new Set),X=(J)=>{Z((U)=>{let G=new Set(U);if(G.has(J))G.delete(J);else G.add(J);return G})},$={user:{bg:"bg-blue-500/10",text:"text-blue-400",icon:"\uD83D\uDC64",label:"User"},assistant:{bg:"bg-purple-500/10",text:"text-purple-400",icon:"\uD83E\uDD16",label:"Assistant"}},P=(J)=>{let U=J.content;if(typeof U==="string"){let G=U.length>200,H=Q.has(J.id);return q.jsxDEV("div",{children:[q.jsxDEV("p",{className:`text-sm text-[#ccc] whitespace-pre-wrap break-words ${!H&&G?"line-clamp-4":""}`,children:U},void 0,!1,void 0,this),G&&q.jsxDEV("button",{onClick:()=>X(J.id),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:H?"Show less":"Show more..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}return q.jsxDEV("div",{className:"space-y-2",children:U.map((G,H)=>{if(G.type==="tool_use"){let K=JSON.stringify(G.input,null,2),_=K.length>150,F=`${J.id}-${H}`,W=Q.has(F);return q.jsxDEV("div",{className:"bg-orange-500/10 border border-orange-500/20 rounded p-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{className:"text-orange-400",children:"\uD83D\uDD27"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs font-medium text-orange-400",children:"Tool Call"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#888]",children:G.name},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto ${!W&&_?"line-clamp-3":""}`,children:K},void 0,!1,void 0,this),_&&q.jsxDEV("button",{onClick:()=>X(F),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:W?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}if(G.type==="tool_result"){let K=G.is_error,_=`${J.id}-${H}`,F=Q.has(_),W=G.content.length>150;return q.jsxDEV("div",{className:`${K?"bg-red-500/10 border-red-500/20":"bg-teal-500/10 border-teal-500/20"} border rounded p-2`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("span",{children:K?"❌":"\uD83D\uDCCB"},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${K?"text-red-400":"text-teal-400"}`,children:"Tool Result"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("pre",{className:`text-xs text-[#888] overflow-x-auto whitespace-pre-wrap break-words ${!F&&W?"line-clamp-3":""}`,children:G.content},void 0,!1,void 0,this),W&&q.jsxDEV("button",{onClick:()=>X(_),className:"text-xs text-[#666] hover:text-[#888] mt-1",children:F?"Show less":"Show more..."},void 0,!1,void 0,this)]},H,!0,void 0,this)}return null})},void 0,!1,void 0,this)};return q.jsxDEV("div",{className:"space-y-2",children:z.map((J)=>{let U=$[J.role]||$.assistant;return q.jsxDEV("div",{className:`${U.bg} border border-[#1a1a1a] rounded overflow-hidden p-3`,children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-2",children:[q.jsxDEV("span",{children:U.icon},void 0,!1,void 0,this),q.jsxDEV("span",{className:`text-xs font-medium ${U.text}`,children:U.label},void 0,!1,void 0,this),J.model&&q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",J.model]},void 0,!0,void 0,this),q.jsxDEV("span",{className:"text-xs text-[#555]",children:["· ",new Date(J.created_at).toLocaleTimeString()]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),P(J)]},J.id,!0,void 0,this)})},void 0,!1,void 0,this)}var y=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function m(z){try{let Q=z.trim().split(/\s+/);if(Q.length!==5)return z;let[Z,X,$,P,J]=Q;if(Z.startsWith("*/")&&X==="*"&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(Z.slice(2));if(G===1)return"Every minute";return`Every ${G} minutes`}if(Z!=="*"&&!Z.includes("/")&&X==="*"&&$==="*"&&P==="*"&&J==="*")return"Every hour";if(X.startsWith("*/")&&$==="*"&&P==="*"&&J==="*"){let G=parseInt(X.slice(2));if(G===1)return"Every hour";return`Every ${G} hours`}let U=(G,H)=>{let K=parseInt(G),_=parseInt(H);if(isNaN(K))return"";let F=K>=12?"PM":"AM";return`${K===0?12:K>12?K-12:K}:${_.toString().padStart(2,"0")} ${F}`};if(X!=="*"&&!X.includes("/")&&$==="*"&&P==="*"){let G=U(X,Z);if(J==="*")return`Daily at ${G}`;let H=J.split(",").map((K)=>{let _=parseInt(K.trim());return y[_]||K});if(H.length===7)return`Daily at ${G}`;if(H.length===5&&!H.includes("Sat")&&!H.includes("Sun"))return`Weekdays at ${G}`;if(H.length===1)return`Weekly on ${H[0]} at ${G}`;return`${H.join(" & ")} at ${G}`}return z}catch{return z}}function L(z){let Q=new Date(z),Z=new Date,X=Q.getTime()-Z.getTime(),$=Math.abs(X),P=X>0,J=Math.floor($/60000),U=Math.floor($/3600000),G=Math.floor($/86400000),H=Q.toLocaleTimeString([],{hour:"numeric",minute:"2-digit"}),K=Q.toDateString()===Z.toDateString(),_=new Date(Z);_.setDate(_.getDate()+1);let F=Q.toDateString()===_.toDateString(),W=new Date(Z);W.setDate(W.getDate()-1);let w=Q.toDateString()===W.toDateString();if(K){if(J<1)return P?"now":"just now";if(J<60)return P?`in ${J} min (${H})`:`${J} min ago`;return P?`in ${U}h (${H})`:`${U}h ago`}if(F)return`Tomorrow at ${H}`;if(w)return`Yesterday at ${H}`;if(G<7)return`${y[Q.getDay()]} at ${H}`;return Q.toLocaleDateString([],{month:"short",day:"numeric"})+` at ${H}`}
|
|
2
|
-
export{j as e,m as f,L as g};
|
|
3
|
-
|
|
4
|
-
//# debugId=70495ECA00A83B0164756E2164756E21
|
package/dist/App.edwahsvz.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{E as x,j as C,k as j}from"./App.c90t3dxg.js";import{L as o,M as v}from"./App.2yy66bnp.js";import{P as n}from"./App.039re6cf.js";import{Q as D,T as t,U as E,aa as y,da as c}from"./App.q3bpx15d.js";var B=D(t(),1);var q=D(E(),1);function Nq(){let{projectsEnabled:z}=c(),[H,L]=B.useState("general"),T=[{key:"general",label:"General"},{key:"providers",label:"Providers"},...z?[{key:"projects",label:"Projects"}]:[],{key:"channels",label:"Channels"},{key:"api-keys",label:"API Keys"},{key:"account",label:"Account"},{key:"updates",label:"Updates"},{key:"data",label:"Data"}];return q.jsxDEV("div",{className:"flex-1 flex flex-col md:flex-row overflow-hidden",children:[q.jsxDEV("div",{className:"md:hidden border-b border-[#1a1a1a] bg-[#0a0a0a]",children:q.jsxDEV("div",{className:"flex overflow-x-auto",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:T.map((J)=>q.jsxDEV("button",{onClick:()=>L(J.key),className:`flex-shrink-0 px-4 py-3 text-sm font-medium border-b-2 transition ${H===J.key?"border-[#f97316] text-[#f97316]":"border-transparent text-[#666] hover:text-[#888]"}`,children:J.label},J.key,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("div",{className:"hidden md:block w-48 border-r border-[#1a1a1a] p-4 flex-shrink-0",children:[q.jsxDEV("h2",{className:"text-sm font-medium text-[#666] uppercase tracking-wider mb-3",children:"Settings"},void 0,!1,void 0,this),q.jsxDEV("nav",{className:"space-y-1",children:T.map((J)=>q.jsxDEV(s,{label:J.label,active:H===J.key,onClick:()=>L(J.key)},J.key,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex-1 overflow-auto p-4 md:p-6",children:[H==="general"&&q.jsxDEV(e,{},void 0,!1,void 0,this),H==="providers"&&q.jsxDEV(qq,{},void 0,!1,void 0,this),H==="projects"&&z&&q.jsxDEV(zq,{},void 0,!1,void 0,this),H==="channels"&&q.jsxDEV(Gq,{},void 0,!1,void 0,this),H==="api-keys"&&q.jsxDEV(Yq,{},void 0,!1,void 0,this),H==="account"&&q.jsxDEV(Zq,{},void 0,!1,void 0,this),H==="updates"&&q.jsxDEV(Hq,{},void 0,!1,void 0,this),H==="data"&&q.jsxDEV($q,{},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function s({label:z,active:H,onClick:L}){return q.jsxDEV("button",{onClick:L,className:`w-full text-left px-3 py-2 rounded text-sm transition ${H?"bg-[#1a1a1a] text-[#e0e0e0]":"text-[#666] hover:bg-[#111] hover:text-[#888]"}`,children:z},void 0,!1,void 0,this)}function e(){let{authFetch:z}=y(),[H,L]=B.useState(""),[T,J]=B.useState(!0),[G,N]=B.useState(!1),[_,U]=B.useState(null);B.useEffect(()=>{(async()=>{try{let Y=await(await z("/api/settings/instance-url")).json();L(Y.instance_url||"")}catch{}J(!1)})()},[]);let R=async()=>{N(!0),U(null);try{let O=await z("/api/settings/instance-url",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({instance_url:H})}),M=await O.json();if(O.ok)L(M.instance_url||""),U({type:"success",text:"Instance URL saved"});else U({type:"error",text:M.error||"Failed to save"})}catch{U({type:"error",text:"Failed to save"})}N(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"General"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Instance configuration."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Instance URL"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:"The public HTTPS URL for this instance. Used for webhook callbacks from external services like Composio."},void 0,!1,void 0,this),T?q.jsxDEV("div",{className:"text-[#666] text-sm",children:"Loading..."},void 0,!1,void 0,this):q.jsxDEV("div",{className:"space-y-3 max-w-lg",children:[q.jsxDEV("input",{type:"text",value:H,onChange:(O)=>L(O.target.value),placeholder:"https://your-domain.com",className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316] font-mono text-sm"},void 0,!1,void 0,this),_&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${_.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:_.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:R,disabled:G,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black rounded text-sm font-medium transition",children:G?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function qq(){let{authFetch:z}=y(),{projects:H,projectsEnabled:L}=c(),[T,J]=B.useState([]),[G,N]=B.useState(null),[_,U]=B.useState(""),[R,O]=B.useState(!1),[M,Y]=B.useState(!1),[W,Q]=B.useState(null),[b,F]=B.useState(null),{confirm:I,ConfirmDialog:K}=v(),w=async()=>{let m=await(await z("/api/providers")).json();J(m.providers||[])};B.useEffect(()=>{w()},[]);let f=async()=>{if(!G||!_)return;O(!0),Q(null),F(null);try{Y(!0);let m=await(await z(`/api/keys/${G}/test`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})})).json();if(Y(!1),!m.valid){Q(m.error||"API key is invalid"),O(!1);return}let l=await z(`/api/keys/${G}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:_})}),h=await l.json();if(!l.ok)Q(h.error||"Failed to save key");else{let p="API key saved!";if(h.restartedAgents&&h.restartedAgents.length>0){let u=h.restartedAgents.filter((V)=>V.success).length;if(h.restartedAgents.length-u===0)p+=` Restarted ${u} agent${u>1?"s":""} with new key.`;else p+=` Restarted ${u}/${h.restartedAgents.length} agents.`}F(p),U(""),N(null),w()}}catch($){Q("Failed to save key")}O(!1)},g=async($)=>{if(!await I("Are you sure you want to remove this API key?",{confirmText:"Remove",title:"Remove API Key"}))return;await z(`/api/keys/${$}`,{method:"DELETE"}),w()},k=T.filter(($)=>$.type==="llm"),P=T.filter(($)=>$.type==="integration"),Z=k.filter(($)=>$.hasKey).length,X=P.filter(($)=>$.hasKey).length;return B.useEffect(()=>{if(b&&!G){let $=setTimeout(()=>F(null),5000);return()=>clearTimeout($)}},[b,G]),q.jsxDEV(q.Fragment,{children:[K,q.jsxDEV("div",{className:"space-y-10",children:[b&&!G&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center justify-between",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{children:b},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>F(null),className:"text-green-400 hover:text-green-300",children:q.jsxDEV(j,{className:"w-4 h-4"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"AI Providers"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Manage your API keys for AI providers. ",Z," of ",k.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:k.map(($)=>q.jsxDEV(Qq,{provider:$,isEditing:G===$.id,apiKey:_,saving:R,testing:M,error:G===$.id?W:null,success:G===$.id?b:null,onStartEdit:()=>{N($.id),Q(null),F(null)},onCancelEdit:()=>{N(null),U(""),Q(null)},onApiKeyChange:U,onSave:f,onDelete:()=>g($.id)},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"MCP Integrations"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Connect to MCP gateways for tool integrations. ",X," of ",P.length," configured."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-3",children:P.map(($)=>q.jsxDEV(Xq,{provider:$,isEditing:G===$.id,apiKey:_,saving:R,testing:M,error:G===$.id?W:null,success:G===$.id?b:null,onStartEdit:()=>{N($.id),Q(null),F(null)},onCancelEdit:()=>{N(null),U(""),Q(null)},onApiKeyChange:U,onSave:f,onDelete:()=>g($.id),projectsEnabled:L,projects:H,onRefresh:w},$.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}var i=["#f97316","#6366f1","#22c55e","#ef4444","#3b82f6","#a855f7","#14b8a6","#f59e0b"];function zq(){let{projects:z,createProject:H,updateProject:L,deleteProject:T}=c(),[J,G]=B.useState(!1),[N,_]=B.useState(null),{confirm:U,ConfirmDialog:R}=v(),O=async(Q)=>{if(!await U("Are you sure you want to delete this project? Agents in this project will become unassigned.",{confirmText:"Delete",title:"Delete Project"}))return;await T(Q)},M=()=>{_(null),G(!0)},Y=(Q)=>{_(Q),G(!0)},W=()=>{G(!1),_(null)};return q.jsxDEV(q.Fragment,{children:[R,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Projects"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Organize agents into projects for better management."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:M,className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(x,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Project"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),z.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No projects yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create a project to organize your agents."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:z.map((Q)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 flex items-center gap-4",children:[q.jsxDEV("div",{className:"w-4 h-4 rounded-full flex-shrink-0",style:{backgroundColor:Q.color}},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:Q.name},void 0,!1,void 0,this),Q.description&&q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:Q.description},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#666] mt-1",children:[Q.agentCount," agent",Q.agentCount!==1?"s":""]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("button",{onClick:()=>Y(Q),className:"text-sm text-[#888] hover:text-[#e0e0e0] px-2 py-1",children:"Edit"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>O(Q.id),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1",children:"Delete"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},Q.id,!0,void 0,this))},void 0,!1,void 0,this),J&&q.jsxDEV(Bq,{project:N,onSave:async(Q)=>{if(N){let b=await L(N.id,Q);if(b)W();return!!b}else{let b=await H(Q);if(b)W();return!!b}},onClose:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Bq({project:z,onSave:H,onClose:L}){let[T,J]=B.useState(z?.name||""),[G,N]=B.useState(z?.description||""),[_,U]=B.useState(z?.color||i[Math.floor(Math.random()*i.length)]),[R,O]=B.useState(!1),[M,Y]=B.useState(null),W=async()=>{if(!T.trim()){Y("Name is required");return}O(!0),Y(null);let Q=await H({name:T,description:G||void 0,color:_});if(O(!1),!Q)Y(z?"Failed to update project":"Failed to create project")};return q.jsxDEV(o,{onClose:L,children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-6",children:z?"Edit Project":"Create New Project"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:T,onChange:(Q)=>J(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"My Project",autoFocus:!0},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Description (optional)"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:G,onChange:(Q)=>N(Q.target.value),className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",placeholder:"A short description"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Color"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-3 flex-wrap",children:i.map((Q)=>q.jsxDEV("button",{type:"button",onClick:()=>U(Q),className:`w-10 h-10 rounded-full transition ${_===Q?"ring-2 ring-white ring-offset-2 ring-offset-[#111]":"hover:scale-110"}`,style:{backgroundColor:Q}},Q,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-3 mt-6",children:[q.jsxDEV("button",{onClick:L,className:"flex-1 border border-[#333] hover:border-[#f97316] hover:text-[#f97316] px-4 py-2 rounded font-medium transition",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:W,disabled:R||!T.trim(),className:"flex-1 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-2 rounded font-medium transition",children:R?"Saving...":z?"Update":"Create"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Hq(){let{authFetch:z}=y(),[H,L]=B.useState(null),[T,J]=B.useState(!1),[G,N]=B.useState(!1),[_,U]=B.useState(null),[R,O]=B.useState(null),[M,Y]=B.useState(null),W=async()=>{J(!0),U(null);try{let I=await z("/api/version");if(!I.ok)throw Error("Failed to check for updates");let K=await I.json();L(K)}catch(I){U("Failed to check for updates")}J(!1)},Q=async()=>{N(!0),U(null),O(null);try{let K=await(await z("/api/version/update",{method:"POST"})).json();if(!K.success)U(K.error||"Update failed");else{let w=K.restarted?.length||0,f=w>0?` ${w} running agent${w>1?"s":""} restarted.`:"";O(`Agent binary updated to v${K.version}.${f}`),await W()}}catch(I){U("Failed to update agent")}N(!1)};B.useEffect(()=>{W()},[]);let b=(I,K)=>{navigator.clipboard.writeText(I),Y(K),setTimeout(()=>Y(null),2000)},F=H?.apteva.updateAvailable||H?.agent.updateAvailable;return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Updates"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Check for new versions of apteva and the agent binary."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T&&!H?q.jsxDEV("div",{className:"text-[#666]",children:"Checking version info..."},void 0,!1,void 0,this):_&&!H?q.jsxDEV("div",{className:"text-red-400",children:_},void 0,!1,void 0,this):H?.isDocker?q.jsxDEV("div",{className:"space-y-6",children:[q.jsxDEV("div",{className:"bg-blue-500/10 border border-blue-500/30 rounded-lg p-4",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-blue-400 mb-2",children:[q.jsxDEV("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 24 24",children:q.jsxDEV("path",{d:"M13.983 11.078h2.119a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.119a.185.185 0 00-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 00.186-.186V3.574a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 00.186-.186V6.29a.186.186 0 00-.186-.185h-2.118a.185.185 0 00-.185.185v1.887c0 .102.082.186.185.186m-2.93 0h2.12a.186.186 0 00.184-.186V6.29a.185.185 0 00-.185-.185H8.1a.185.185 0 00-.185.185v1.887c0 .102.083.186.185.186m-2.964 0h2.119a.186.186 0 00.185-.186V6.29a.186.186 0 00-.185-.185H5.136a.186.186 0 00-.186.185v1.887c0 .102.084.186.186.186m5.893 2.715h2.118a.186.186 0 00.186-.185V9.006a.186.186 0 00-.186-.186h-2.118a.185.185 0 00-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.185.185 0 00-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 00.185-.185V9.006a.185.185 0 00-.185-.186H5.136a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 00.184-.185V9.006a.185.185 0 00-.184-.186h-2.12a.186.186 0 00-.186.186v1.887c0 .102.084.185.186.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 00-.75.748 11.376 11.376 0 00.692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 003.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"},void 0,!1,void 0,this)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"Docker Environment"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888]",children:"Updates are automatic when you pull a new image version."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Current Version"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"apteva + agent binary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.apteva.installed||"?"]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:["A newer version (v",H.apteva.latest,") is available. To update:"]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"space-y-2",children:[q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker pull apteva/apteva:latest"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"docker compose up -d"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{navigator.clipboard.writeText("docker pull apteva/apteva:latest && docker compose up -d"),Y("docker"),setTimeout(()=>Y(null),2000)},className:"mt-3 px-3 py-1.5 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="docker"?"Copied!":"Copy commands"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555]",children:"Your data is stored in a Docker volume and persists across updates."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):H?q.jsxDEV("div",{className:"space-y-6",children:[R&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 text-green-400",children:R},void 0,!1,void 0,this),_&&q.jsxDEV("div",{className:"bg-red-500/10 border border-red-500/30 rounded-lg p-4 text-red-400",children:_},void 0,!1,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"apteva"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The app you're running"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.apteva.installed||"?"]},void 0,!0,void 0,this),H.apteva.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",H.apteva.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.apteva.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Update by running:"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#888]",children:"npx apteva@latest"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>b("npx apteva@latest","apteva"),className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm",children:M==="apteva"?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-5",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium text-lg",children:"Agent Binary"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"The Go binary that runs agents"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"text-right",children:[q.jsxDEV("div",{className:"text-xl font-mono",children:["v",H.agent.installed||"?"]},void 0,!0,void 0,this),H.agent.updateAvailable&&q.jsxDEV("div",{className:"text-sm text-[#f97316]",children:["→ v",H.agent.latest]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.agent.updateAvailable?q.jsxDEV("div",{className:"bg-[#f97316]/10 border border-[#f97316]/30 rounded-lg p-4",children:[q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"A new version is available. Stop all agents before updating."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:q.jsxDEV("button",{onClick:Q,disabled:G,className:"px-4 py-2 bg-[#f97316] text-black rounded font-medium text-sm disabled:opacity-50",children:G?"Updating...":"Update Agent"},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 text-sm",children:[q.jsxDEV(C,{className:"w-4 h-4"},void 0,!1,void 0,this),"Up to date"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!F&&!R&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 flex items-center gap-2 text-green-400",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),"Everything is up to date!"]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:W,disabled:T,className:"text-sm text-[#666] hover:text-[#888] disabled:opacity-50",children:T?"Checking...":"Check for updates"},void 0,!1,void 0,this)]},void 0,!0,void 0,this):null]},void 0,!0,void 0,this)}function Qq({provider:z,isEditing:H,apiKey:L,saving:T,testing:J,error:G,success:N,onStartEdit:_,onCancelEdit:U,onApiKeyChange:R,onSave:O,onDelete:M}){let Y=z.id==="ollama",[W,Q]=B.default.useState(null);return B.default.useEffect(()=>{if(Y&&z.hasKey)fetch("/api/providers/ollama/status").then((b)=>b.json()).then((b)=>Q({connected:b.connected,modelCount:b.modelCount})).catch(()=>Q({connected:!1}))},[Y,z.hasKey]),q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-green-500/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-start justify-between gap-2 mb-2",children:[q.jsxDEV("div",{className:"min-w-0",children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] truncate",children:z.type==="integration"?z.description||"MCP integration":Y?"Run models locally":`${z.models.length} models`},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:`text-xs flex items-center gap-1 px-2 py-1 rounded whitespace-nowrap flex-shrink-0 ${Y&&W?W.connected?"text-green-400 bg-green-500/10":"text-yellow-400 bg-yellow-500/10":"text-green-400 bg-green-500/10"}`,children:Y&&W?W.connected?q.jsxDEV(q.Fragment,{children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),W.modelCount," models"]},void 0,!0,void 0,this):q.jsxDEV(q.Fragment,{children:"Not running"},void 0,!1,void 0,this):q.jsxDEV(q.Fragment,{children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this)},void 0,!1,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded whitespace-nowrap flex-shrink-0",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:Y?"text":"password",value:L,onChange:(b)=>R(b.target.value),placeholder:Y?"http://localhost:11434":z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),Y&&q.jsxDEV("p",{className:"text-xs text-[#666]",children:"Enter your Ollama server URL. Default is http://localhost:11434"},void 0,!1,void 0,this),G&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:G},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:U,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!L||T,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:J?"Validating...":T?"Saving...":Y?"Connect":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Download Ollama":"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:_,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:Y?"Change URL":"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:Y?"Download Ollama":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:Y?"Configure":"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Xq({provider:z,isEditing:H,apiKey:L,saving:T,testing:J,error:G,success:N,onStartEdit:_,onCancelEdit:U,onApiKeyChange:R,onSave:O,onDelete:M,projectsEnabled:Y,projects:W,onRefresh:Q}){let{authFetch:b}=y(),[F,I]=B.useState([]),[K,w]=B.useState(""),[f,g]=B.useState(!1),[k,P]=B.useState(null),[Z,X]=B.useState(!1),{confirm:$,ConfirmDialog:m}=v(),l=async()=>{try{let S=await(await b(`/api/keys/${z.id}`)).json();I(S.keys||[])}catch(A){console.error("Failed to fetch keys:",A)}};B.useEffect(()=>{if(Y)l()},[z.id,Y]),B.useEffect(()=>{if(H)P(null)},[H]);let h=async()=>{if(!L)return;X(!0),P(null);try{let A=await b(`/api/keys/${z.id}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key:L,project_id:K||null})}),S=await A.json();if(A.ok)R(""),w(""),U(),l(),Q();else P(S.error||"Failed to save key")}catch(A){console.error("Failed to save key:",A),P("Failed to save key")}X(!1)},p=async(A,S)=>{if(!await $(`Are you sure you want to remove this API key${S?` (${S})`:""}?`,{confirmText:"Remove",title:"Remove API Key"}))return;try{await b(`/api/keys/by-id/${A}`,{method:"DELETE"}),l(),Q()}catch(r){console.error("Failed to delete key:",r)}},u=F.find((A)=>!A.project_id),d=F.filter((A)=>A.project_id),V=(A)=>W.find((S)=>S.id===A)?.name||"Unknown",a=(A)=>W.find((S)=>S.id===A)?.color||"#666";if(!Y)return q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${z.hasKey?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),z.hasKey?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),z.keyHint]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:L,onChange:(A)=>R(A.target.value),placeholder:z.hasKey?"Enter new API key...":"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),G&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:G},void 0,!1,void 0,this),N&&q.jsxDEV("p",{className:"text-green-400 text-sm",children:N},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:U,className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:!L||T,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:J?"Validating...":T?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):z.hasKey?q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"View docs"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3",children:[q.jsxDEV("button",{onClick:_,className:"text-sm text-[#888] hover:text-[#e0e0e0]",children:"Update key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:M,className:"text-red-400 hover:text-red-300 text-sm",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this);return q.jsxDEV(q.Fragment,{children:[m,q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 ${F.length>0?"border-[#f97316]/20":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-2",children:[q.jsxDEV("div",{children:[q.jsxDEV("h3",{className:"font-medium",children:z.name},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:z.description||"MCP integration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.length>0?q.jsxDEV("span",{className:"text-[#f97316] text-xs flex items-center gap-1 bg-[#f97316]/10 px-2 py-1 rounded",children:[q.jsxDEV(C,{className:"w-3 h-3"},void 0,!1,void 0,this),F.length," key",F.length!==1?"s":""]},void 0,!0,void 0,this):q.jsxDEV("span",{className:"text-[#666] text-xs bg-[#1a1a1a] px-2 py-1 rounded",children:"Not configured"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F.length>0&&q.jsxDEV("div",{className:"mt-3 space-y-2",children:[u&&q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("span",{className:"text-[#888]",children:"Global"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:u.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(u.id,"Global"),className:"text-red-400 hover:text-red-300 text-xs",children:"Remove"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d.slice(0,f?void 0:2).map((A)=>q.jsxDEV("div",{className:"flex items-center justify-between text-sm bg-[#0a0a0a] rounded px-3 py-2",children:[q.jsxDEV("div",{className:"flex items-center gap-2 min-w-0",children:[q.jsxDEV("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:a(A.project_id)}},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#888] truncate",children:A.name||V(A.project_id)},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#555]",children:"·"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"text-[#666] font-mono text-xs",children:A.key_hint},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>p(A.id,A.name||V(A.project_id)),className:"text-red-400 hover:text-red-300 text-xs flex-shrink-0 ml-2",children:"Remove"},void 0,!1,void 0,this)]},A.id,!0,void 0,this)),d.length>2&&!f&&q.jsxDEV("button",{onClick:()=>g(!0),className:"text-xs text-[#666] hover:text-[#888] w-full text-center py-1",children:["Show ",d.length-2," more..."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"mt-3 pt-3 border-t border-[#1a1a1a]",children:H?q.jsxDEV("div",{className:"space-y-3",children:[q.jsxDEV("input",{type:"password",value:L,onChange:(A)=>R(A.target.value),placeholder:"Enter API key...",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),q.jsxDEV(n,{value:K,onChange:w,placeholder:"Global (all projects)",options:[{value:"",label:"Global (all projects)"},...W.map((A)=>({value:A.id,label:A.name}))]},void 0,!1,void 0,this),k&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:k},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{U(),w(""),P(null)},className:"flex-1 px-3 py-1.5 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:h,disabled:!L||Z,className:"flex-1 px-3 py-1.5 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:Z?"Saving...":"Save"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"flex items-center justify-between",children:[q.jsxDEV("a",{href:z.docsUrl,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#3b82f6] hover:underline",children:F.length>0?"View docs":"Get API key"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:_,className:"text-sm text-[#f97316] hover:text-[#fb923c]",children:"+ Add key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Yq(){let{authFetch:z}=y(),[H,L]=B.useState([]),[T,J]=B.useState(!1),[G,N]=B.useState(""),[_,U]=B.useState("90"),[R,O]=B.useState(!1),[M,Y]=B.useState(null),[W,Q]=B.useState(null),[b,F]=B.useState(!1),{confirm:I,ConfirmDialog:K}=v(),w=async()=>{try{let $=await(await z("/api/keys/personal")).json();L($.keys||[])}catch{}};B.useEffect(()=>{w()},[]);let f=async()=>{if(!G.trim()){Y("Name is required");return}O(!0),Y(null);try{let X=await z("/api/keys/personal",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:G.trim(),expires_in_days:_?parseInt(_):null})}),$=await X.json();if(!X.ok)Y($.error||"Failed to create key");else Q($.key),N(""),U("90"),w()}catch{Y("Failed to create key")}O(!1)},g=async(X,$)=>{if(!await I(`Delete API key "${$}"? This cannot be undone.`,{confirmText:"Delete",title:"Delete API Key"}))return;try{await z(`/api/keys/personal/${X}`,{method:"DELETE"}),w()}catch{}},k=()=>{if(W)navigator.clipboard.writeText(W),F(!0),setTimeout(()=>F(!1),2000)},P=(X)=>{if(!X)return"Never";return new Date(X).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})},Z=(X)=>{if(!X)return!1;return new Date(X)<new Date};return q.jsxDEV(q.Fragment,{children:[K,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6 flex items-center justify-between gap-4",children:[q.jsxDEV("div",{children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"API Keys"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:["Create personal API keys for programmatic access. Use them with the ",q.jsxDEV("code",{className:"text-[#888] bg-[#1a1a1a] px-1 rounded text-xs",children:"X-API-Key"},void 0,!1,void 0,this)," header."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),!T&&!W&&q.jsxDEV("button",{onClick:()=>{J(!0),Y(null)},className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-4 py-2 rounded font-medium transition flex-shrink-0",children:[q.jsxDEV(x,{className:"w-4 h-4"},void 0,!1,void 0,this),"New Key"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W&&q.jsxDEV("div",{className:"bg-green-500/10 border border-green-500/30 rounded-lg p-4 mb-6",children:[q.jsxDEV("div",{className:"flex items-center gap-2 text-green-400 mb-2",children:[q.jsxDEV(C,{className:"w-5 h-5"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"font-medium",children:"API key created"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#888] mb-3",children:"Copy this key now. You won't be able to see it again."},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2",children:[q.jsxDEV("code",{className:"flex-1 bg-[#0a0a0a] px-3 py-2 rounded font-mono text-sm text-[#e0e0e0] break-all select-all",children:W},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:k,className:"px-3 py-2 bg-[#1a1a1a] hover:bg-[#222] rounded text-sm flex-shrink-0",children:b?"Copied!":"Copy"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>{Q(null),J(!1)},className:"mt-3 text-sm text-[#666] hover:text-[#888]",children:"Done"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T&&!W&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Create new API key"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:G,onChange:(X)=>N(X.target.value),placeholder:"e.g. CI Pipeline, My Script",autoFocus:!0,className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Expiration"},void 0,!1,void 0,this),q.jsxDEV("select",{value:_,onChange:(X)=>U(X.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]",children:[q.jsxDEV("option",{value:"30",children:"30 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"90",children:"90 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"180",children:"180 days"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"365",children:"1 year"},void 0,!1,void 0,this),q.jsxDEV("option",{value:"",children:"No expiration"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),M&&q.jsxDEV("p",{className:"text-red-400 text-sm",children:M},void 0,!1,void 0,this),q.jsxDEV("div",{className:"flex gap-2",children:[q.jsxDEV("button",{onClick:()=>{J(!1),Y(null),N("")},className:"flex-1 px-3 py-2 border border-[#333] rounded text-sm hover:border-[#666]",children:"Cancel"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:f,disabled:R||!G.trim(),className:"flex-1 px-3 py-2 bg-[#f97316] text-black rounded text-sm font-medium disabled:opacity-50",children:R?"Creating...":"Create Key"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),H.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No API keys yet"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Create an API key to access apteva programmatically."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:H.map((X)=>q.jsxDEV("div",{className:`bg-[#111] border rounded-lg p-4 flex items-center gap-4 ${!X.is_active||Z(X.expires_at)?"border-[#1a1a1a] opacity-60":"border-[#1a1a1a]"}`,children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:X.name},void 0,!1,void 0,this),!X.is_active&&q.jsxDEV("span",{className:"text-xs text-red-400 bg-red-500/10 px-2 py-0.5 rounded",children:"Revoked"},void 0,!1,void 0,this),X.is_active&&Z(X.expires_at)&&q.jsxDEV("span",{className:"text-xs text-yellow-400 bg-yellow-500/10 px-2 py-0.5 rounded",children:"Expired"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-3 text-sm text-[#666]",children:[q.jsxDEV("code",{className:"font-mono text-xs bg-[#0a0a0a] px-2 py-0.5 rounded",children:[X.prefix,"..."]},void 0,!0,void 0,this),q.jsxDEV("span",{children:["Created ",P(X.created_at)]},void 0,!0,void 0,this),X.expires_at&&q.jsxDEV("span",{children:["Expires ",P(X.expires_at)]},void 0,!0,void 0,this),X.last_used_at&&q.jsxDEV("span",{children:["Last used ",P(X.last_used_at)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),X.is_active&&q.jsxDEV("button",{onClick:()=>g(X.id,X.name),className:"text-sm text-red-400 hover:text-red-300 px-2 py-1 flex-shrink-0",children:"Delete"},void 0,!1,void 0,this)]},X.id,!0,void 0,this))},void 0,!1,void 0,this),H.length>0&&q.jsxDEV("div",{className:"mt-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2 text-sm",children:"Usage"},void 0,!1,void 0,this),q.jsxDEV("code",{className:"block bg-[#0a0a0a] px-3 py-2 rounded font-mono text-xs text-[#888]",children:'curl -H "X-API-Key: apt_..." http://localhost:4280/api/agents'},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Zq(){let{authFetch:z,user:H}=y(),[L,T]=B.useState(""),[J,G]=B.useState(""),[N,_]=B.useState(""),[U,R]=B.useState(!1),[O,M]=B.useState(null),Y=async()=>{if(!L||!J||!N){M({type:"error",text:"All fields are required"});return}if(J!==N){M({type:"error",text:"New passwords do not match"});return}if(J.length<8){M({type:"error",text:"Password must be at least 8 characters"});return}R(!0),M(null);try{let W=await z("/api/auth/password",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:L,newPassword:J})}),Q=await W.json();if(W.ok)M({type:"success",text:"Password updated successfully"}),T(""),G(""),_("");else M({type:"error",text:Q.error||"Failed to update password"})}catch{M({type:"error",text:"Failed to update password"})}R(!1)};return q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Account Settings"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage your account and security."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H&&q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4 mb-6",children:[q.jsxDEV("h3",{className:"font-medium mb-3",children:"Profile"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-2 text-sm",children:[q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Username"},void 0,!1,void 0,this),q.jsxDEV("span",{children:H.username},void 0,!1,void 0,this)]},void 0,!0,void 0,this),H.email&&q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Email"},void 0,!1,void 0,this),q.jsxDEV("span",{children:H.email},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex justify-between",children:[q.jsxDEV("span",{className:"text-[#666]",children:"Role"},void 0,!1,void 0,this),q.jsxDEV("span",{className:"capitalize",children:H.role},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-4",children:"Change Password"},void 0,!1,void 0,this),q.jsxDEV("div",{className:"space-y-4 max-w-md",children:[q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Current Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:L,onChange:(W)=>T(W.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:J,onChange:(W)=>G(W.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-sm text-[#666] mb-1",children:"Confirm New Password"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:N,onChange:(W)=>_(W.target.value),className:"w-full bg-[#0a0a0a] border border-[#333] rounded px-3 py-2 focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),O&&q.jsxDEV("div",{className:`p-3 rounded text-sm ${O.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:O.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:Y,disabled:U||!L||!J||!N,className:"px-4 py-2 bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 disabled:cursor-not-allowed text-black rounded text-sm font-medium transition",children:U?"Updating...":"Update Password"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function $q(){let{authFetch:z}=y(),[H,L]=B.useState(!1),[T,J]=B.useState(null),[G,N]=B.useState(null),{confirm:_,ConfirmDialog:U}=v(),R=async()=>{try{let Y=await(await z("/api/telemetry/stats")).json();N(Y.stats?.total_events||0)}catch{N(null)}};B.useEffect(()=>{R()},[]);let O=async()=>{if(!await _("Are you sure you want to delete all telemetry data? This cannot be undone.",{confirmText:"Clear All",title:"Clear Telemetry Data"}))return;L(!0),J(null);try{let Y=await z("/api/telemetry/clear",{method:"POST"}),W=await Y.json();if(Y.ok)J({type:"success",text:`Cleared ${W.deleted||0} telemetry events.`}),N(0);else J({type:"error",text:W.error||"Failed to clear telemetry"})}catch{J({type:"error",text:"Failed to clear telemetry"})}L(!1)};return q.jsxDEV(q.Fragment,{children:[U,q.jsxDEV("div",{className:"max-w-4xl w-full",children:[q.jsxDEV("div",{className:"mb-6",children:[q.jsxDEV("h1",{className:"text-2xl font-semibold mb-1",children:"Data Management"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-[#666]",children:"Manage stored data and telemetry."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:[q.jsxDEV("h3",{className:"font-medium mb-2",children:"Telemetry Data"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666] mb-4",children:G!==null?`${G.toLocaleString()} events stored`:"Loading..."},void 0,!1,void 0,this),T&&q.jsxDEV("div",{className:`mb-4 p-3 rounded text-sm ${T.type==="success"?"bg-green-500/10 text-green-400 border border-green-500/30":"bg-red-500/10 text-red-400 border border-red-500/30"}`,children:T.text},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:O,disabled:H||G===0,className:"px-4 py-2 bg-red-500/20 text-red-400 hover:bg-red-500/30 disabled:opacity-50 disabled:cursor-not-allowed rounded text-sm font-medium transition",children:H?"Clearing...":"Clear All Telemetry"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function Gq(){let{authFetch:z}=y(),[H,L]=B.useState([]),[T,J]=B.useState([]),[G,N]=B.useState(!0),[_,U]=B.useState(!1),[R,O]=B.useState({name:"",agent_id:"",botToken:""}),[M,Y]=B.useState(!1),[W,Q]=B.useState(null),{confirm:b,ConfirmDialog:F}=v(),I=async()=>{try{let X=await(await z("/api/channels")).json();L(X.channels||[])}catch{}finally{N(!1)}},K=async()=>{try{let X=await(await z("/api/agents")).json();J((X.agents||[]).map(($)=>({id:$.id,name:$.name,status:$.status})))}catch{}};B.useEffect(()=>{I(),K()},[]);let w=async()=>{if(!R.name||!R.agent_id||!R.botToken)return;Y(!0),Q(null);try{let Z=await z("/api/channels",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"telegram",name:R.name,agent_id:R.agent_id,config:{botToken:R.botToken}})});if(!Z.ok){let X=await Z.json();Q(X.error||"Failed to create channel")}else O({name:"",agent_id:"",botToken:""}),U(!1),await I()}catch(Z){Q(Z.message)}finally{Y(!1)}},f=async(Z)=>{let X=Z.status==="running"?"stop":"start";try{let $=await z(`/api/channels/${Z.id}/${X}`,{method:"POST"});if(!$.ok){let m=await $.json();Q(m.error||`Failed to ${X} channel`)}await I()}catch{Q(`Failed to ${X} channel`)}},g=async(Z)=>{if(!await b(`Delete channel "${Z.name}"?`,{confirmText:"Delete",title:"Delete Channel"}))return;try{await z(`/api/channels/${Z.id}`,{method:"DELETE"}),await I()}catch{}},k={running:"bg-green-500/20 text-green-400",stopped:"bg-[#333] text-[#666]",error:"bg-red-500/20 text-red-400"},P=(Z)=>{return T.find((X)=>X.id===Z)?.name||Z};return q.jsxDEV(q.Fragment,{children:[F,q.jsxDEV("div",{className:"max-w-2xl",children:[q.jsxDEV("div",{className:"flex items-center justify-between mb-6",children:[q.jsxDEV("div",{children:[q.jsxDEV("h2",{className:"text-xl font-semibold mb-1",children:"Channels"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:"Connect agents to external messaging platforms"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("button",{onClick:()=>U(!_),className:"flex items-center gap-2 bg-[#f97316] hover:bg-[#fb923c] text-black px-3 py-1.5 rounded text-sm font-medium transition",children:[q.jsxDEV(x,{},void 0,!1,void 0,this)," Add Channel"]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),W&&q.jsxDEV("div",{className:"mb-4 bg-red-500/10 text-red-400 border border-red-500/30 px-3 py-2 rounded text-sm flex items-center justify-between",children:[q.jsxDEV("span",{children:W},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>Q(null),className:"text-red-400 hover:text-red-300 ml-2",children:q.jsxDEV(j,{},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),_&&q.jsxDEV("div",{className:"mb-6 bg-[#111] border border-[#1a1a1a] rounded-lg p-4 space-y-3",children:[q.jsxDEV("h3",{className:"text-sm font-medium text-[#888] mb-2",children:"New Telegram Channel"},void 0,!1,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Channel Name"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"text",value:R.name,onChange:(Z)=>O((X)=>({...X,name:Z.target.value})),placeholder:"e.g. My Telegram Bot",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Agent"},void 0,!1,void 0,this),q.jsxDEV(n,{value:R.agent_id,options:T.map((Z)=>({value:Z.id,label:Z.name})),onChange:(Z)=>O((X)=>({...X,agent_id:Z})),placeholder:"Select an agent..."},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{children:[q.jsxDEV("label",{className:"block text-xs text-[#666] mb-1",children:"Bot Token"},void 0,!1,void 0,this),q.jsxDEV("input",{type:"password",value:R.botToken,onChange:(Z)=>O((X)=>({...X,botToken:Z.target.value})),placeholder:"From @BotFather on Telegram",className:"w-full bg-[#0a0a0a] border border-[#222] rounded px-3 py-2 text-sm focus:outline-none focus:border-[#f97316]"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-xs text-[#555] mt-1",children:["Create a bot via ",q.jsxDEV("a",{href:"https://t.me/BotFather",target:"_blank",className:"text-[#f97316] hover:underline",children:"@BotFather"},void 0,!1,void 0,this)," on Telegram to get a token."]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex gap-2 pt-1",children:[q.jsxDEV("button",{onClick:w,disabled:M||!R.name||!R.agent_id||!R.botToken,className:"bg-[#f97316] hover:bg-[#fb923c] disabled:opacity-50 text-black px-4 py-1.5 rounded text-sm font-medium transition",children:M?"Creating...":"Create"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>{U(!1),O({name:"",agent_id:"",botToken:""})},className:"border border-[#333] hover:border-[#444] px-4 py-1.5 rounded text-sm transition",children:"Cancel"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),G?q.jsxDEV("p",{className:"text-[#666] text-sm",children:"Loading channels..."},void 0,!1,void 0,this):H.length===0?q.jsxDEV("div",{className:"text-center py-12 text-[#666]",children:[q.jsxDEV("p",{className:"text-lg mb-2",children:"No channels configured"},void 0,!1,void 0,this),q.jsxDEV("p",{className:"text-sm",children:"Add a Telegram channel to let users message your agents directly."},void 0,!1,void 0,this)]},void 0,!0,void 0,this):q.jsxDEV("div",{className:"space-y-3",children:H.map((Z)=>q.jsxDEV("div",{className:"bg-[#111] border border-[#1a1a1a] rounded-lg p-4",children:q.jsxDEV("div",{className:"flex items-start justify-between",children:[q.jsxDEV("div",{className:"flex-1 min-w-0",children:[q.jsxDEV("div",{className:"flex items-center gap-2 mb-1",children:[q.jsxDEV("h3",{className:"font-medium",children:Z.name},void 0,!1,void 0,this),q.jsxDEV("span",{className:`px-2 py-0.5 rounded text-xs font-medium ${k[Z.status]||k.stopped}`,children:Z.status},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("p",{className:"text-sm text-[#666]",children:[Z.type==="telegram"?"Telegram":Z.type," → ",P(Z.agent_id)]},void 0,!0,void 0,this),Z.status==="error"&&Z.error&&q.jsxDEV("p",{className:"text-xs text-red-400 mt-1",children:Z.error},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q.jsxDEV("div",{className:"flex items-center gap-2 ml-4",children:[q.jsxDEV("button",{onClick:()=>f(Z),className:`px-3 py-1 rounded text-xs font-medium transition ${Z.status==="running"?"bg-[#f97316]/20 text-[#f97316] hover:bg-[#f97316]/30":"bg-[#3b82f6]/20 text-[#3b82f6] hover:bg-[#3b82f6]/30"}`,children:Z.status==="running"?"Stop":"Start"},void 0,!1,void 0,this),q.jsxDEV("button",{onClick:()=>g(Z),className:"text-[#666] hover:text-red-400 transition text-sm",children:"×"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},Z.id,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}
|
|
2
|
-
export{Nq as c};
|
|
3
|
-
|
|
4
|
-
//# debugId=94748AB622E888B364756E2164756E21
|
package/dist/App.q3bpx15d.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
var rW=Object.create;var{getPrototypeOf:aW,defineProperty:mW,getOwnPropertyNames:tW}=Object;var eW=Object.prototype.hasOwnProperty;var n=(H,R,w)=>{w=H!=null?rW(aW(H)):{};let F=R||!H||!H.__esModule?mW(w,"default",{value:H,enumerable:!0}):w;for(let k of tW(H))if(!eW.call(F,k))mW(F,k,{get:()=>H[k],enumerable:!0});return F};var fW=(H,R)=>()=>(R||H((R={exports:{}}).exports,R),R.exports);var DZ=((H)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(H,{get:(R,w)=>(typeof require<"u"?require:R)[w]}):H)(function(H){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+H+'" is not supported')});var UW=fW((WZ,RW)=>{(function(){function H(W,Z){Object.defineProperty(F.prototype,W,{get:function(){console.warn("%s(...) is deprecated in plain JavaScript React classes. %s",Z[0],Z[1])}})}function R(W){if(W===null||typeof W!=="object")return null;return W=NW&&W[NW]||W["@@iterator"],typeof W==="function"?W:null}function w(W,Z){W=(W=W.constructor)&&(W.displayName||W.name)||"ReactClass";var X=W+"."+Z;PW[X]||(console.error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",Z,W),PW[X]=!0)}function F(W,Z,X){this.props=W,this.context=Z,this.refs=FW,this.updater=X||xW}function k(){}function C(W,Z,X){this.props=W,this.context=Z,this.refs=FW,this.updater=X||xW}function _(){}function A(W){return""+W}function S(W){try{A(W);var Z=!1}catch(Y){Z=!0}if(Z){Z=console;var X=Z.error,B=typeof Symbol==="function"&&Symbol.toStringTag&&W[Symbol.toStringTag]||W.constructor.name||"Object";return X.call(Z,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",B),A(W)}}function y(W){if(W==null)return null;if(typeof W==="function")return W.$$typeof===iW?null:W.displayName||W.name||null;if(typeof W==="string")return W;switch(W){case GW:return"Fragment";case U:return"Profiler";case M:return"StrictMode";case HW:return"Suspense";case x:return"SuspenseList";case DW:return"Activity"}if(typeof W==="object")switch(typeof W.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),W.$$typeof){case OW:return"Portal";case b:return W.displayName||"Context";case N:return(W._context.displayName||"Context")+".Consumer";case o:var Z=W.render;return W=W.displayName,W||(W=Z.displayName||Z.name||"",W=W!==""?"ForwardRef("+W+")":"ForwardRef"),W;case l:return Z=W.displayName||null,Z!==null?Z:y(W.type)||"Memo";case r:Z=W._payload,W=W._init;try{return y(W(Z))}catch(X){}}return null}function c(W){if(W===GW)return"<>";if(typeof W==="object"&&W!==null&&W.$$typeof===r)return"<...>";try{var Z=y(W);return Z?"<"+Z+">":"<...>"}catch(X){return"<...>"}}function p(){var W=O.A;return W===null?null:W.getOwner()}function s(){return Error("react-stack-top-frame")}function u(W){if(LW.call(W,"key")){var Z=Object.getOwnPropertyDescriptor(W,"key").get;if(Z&&Z.isReactWarning)return!1}return W.key!==void 0}function f(W,Z){function X(){jW||(jW=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",Z))}X.isReactWarning=!0,Object.defineProperty(W,"key",{get:X,configurable:!0})}function g(){var W=y(this.type);return vW[W]||(vW[W]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),W=this.props.ref,W!==void 0?W:null}function K(W,Z,X,B,Y,D){var $=X.ref;return W={$$typeof:QW,type:W,key:Z,props:X,_owner:B},($!==void 0?$:null)!==null?Object.defineProperty(W,"ref",{enumerable:!1,get:g}):Object.defineProperty(W,"ref",{enumerable:!1,value:null}),W._store={},Object.defineProperty(W._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(W,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(W,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.defineProperty(W,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:D}),Object.freeze&&(Object.freeze(W.props),Object.freeze(W)),W}function m(W,Z){return Z=K(W.type,Z,W.props,W._owner,W._debugStack,W._debugTask),W._store&&(Z._store.validated=W._store.validated),Z}function I(W){j(W)?W._store&&(W._store.validated=1):typeof W==="object"&&W!==null&&W.$$typeof===r&&(W._payload.status==="fulfilled"?j(W._payload.value)&&W._payload.value._store&&(W._payload.value._store.validated=1):W._store&&(W._store.validated=1))}function j(W){return typeof W==="object"&&W!==null&&W.$$typeof===QW}function d(W){var Z={"=":"=0",":":"=2"};return"$"+W.replace(/[=:]/g,function(X){return Z[X]})}function T(W,Z){return typeof W==="object"&&W!==null&&W.key!=null?(S(W.key),d(""+W.key)):Z.toString(36)}function J(W){switch(W.status){case"fulfilled":return W.value;case"rejected":throw W.reason;default:switch(typeof W.status==="string"?W.then(_,_):(W.status="pending",W.then(function(Z){W.status==="pending"&&(W.status="fulfilled",W.value=Z)},function(Z){W.status==="pending"&&(W.status="rejected",W.reason=Z)})),W.status){case"fulfilled":return W.value;case"rejected":throw W.reason}}throw W}function Q(W,Z,X,B,Y){var D=typeof W;if(D==="undefined"||D==="boolean")W=null;var $=!1;if(W===null)$=!0;else switch(D){case"bigint":case"string":case"number":$=!0;break;case"object":switch(W.$$typeof){case QW:case OW:$=!0;break;case r:return $=W._init,Q($(W._payload),Z,X,B,Y)}}if($){$=W,Y=Y($);var V=B===""?"."+T($,0):B;return AW(Y)?(X="",V!=null&&(X=V.replace(SW,"$&/")+"/"),Q(Y,Z,X,"",function(a){return a})):Y!=null&&(j(Y)&&(Y.key!=null&&($&&$.key===Y.key||S(Y.key)),X=m(Y,X+(Y.key==null||$&&$.key===Y.key?"":(""+Y.key).replace(SW,"$&/")+"/")+V),B!==""&&$!=null&&j($)&&$.key==null&&$._store&&!$._store.validated&&(X._store.validated=2),Y=X),Z.push(Y)),1}if($=0,V=B===""?".":B+":",AW(W))for(var L=0;L<W.length;L++)B=W[L],D=V+T(B,L),$+=Q(B,Z,X,D,Y);else if(L=R(W),typeof L==="function")for(L===W.entries&&(CW||console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."),CW=!0),W=L.call(W),L=0;!(B=W.next()).done;)B=B.value,D=V+T(B,L++),$+=Q(B,Z,X,D,Y);else if(D==="object"){if(typeof W.then==="function")return Q(J(W),Z,X,B,Y);throw Z=String(W),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(W).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return $}function G(W,Z,X){if(W==null)return W;var B=[],Y=0;return Q(W,B,"","",function(D){return Z.call(X,D,Y++)}),B}function q(W){if(W._status===-1){var Z=W._ioInfo;Z!=null&&(Z.start=Z.end=performance.now()),Z=W._result;var X=Z();if(X.then(function(Y){if(W._status===0||W._status===-1){W._status=1,W._result=Y;var D=W._ioInfo;D!=null&&(D.end=performance.now()),X.status===void 0&&(X.status="fulfilled",X.value=Y)}},function(Y){if(W._status===0||W._status===-1){W._status=2,W._result=Y;var D=W._ioInfo;D!=null&&(D.end=performance.now()),X.status===void 0&&(X.status="rejected",X.reason=Y)}}),Z=W._ioInfo,Z!=null){Z.value=X;var B=X.displayName;typeof B==="string"&&(Z.name=B)}W._status===-1&&(W._status=0,W._result=X)}if(W._status===1)return Z=W._result,Z===void 0&&console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
2
|
-
|
|
3
|
-
Your code should look like:
|
|
4
|
-
const MyComponent = lazy(() => import('./MyComponent'))
|
|
5
|
-
|
|
6
|
-
Did you accidentally put curly braces around the import?`,Z),"default"in Z||console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
|
|
7
|
-
|
|
8
|
-
Your code should look like:
|
|
9
|
-
const MyComponent = lazy(() => import('./MyComponent'))`,Z),Z.default;throw W._result}function z(){var W=O.H;return W===null&&console.error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
|
|
10
|
-
1. You might have mismatching versions of React and the renderer (such as React DOM)
|
|
11
|
-
2. You might be breaking the Rules of Hooks
|
|
12
|
-
3. You might have more than one copy of React in the same app
|
|
13
|
-
See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`),W}function h(){O.asyncTransitions--}function t(W){if(JW===null)try{var Z=("require"+Math.random()).slice(0,7);JW=(RW&&RW[Z]).call(RW,"timers").setImmediate}catch(X){JW=function(B){kW===!1&&(kW=!0,typeof MessageChannel>"u"&&console.error("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."));var Y=new MessageChannel;Y.port1.onmessage=B,Y.port2.postMessage(void 0)}}return JW(W)}function e(W){return 1<W.length&&typeof AggregateError==="function"?AggregateError(W):W[0]}function WW(W,Z){Z!==qW-1&&console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "),qW=Z}function XW(W,Z,X){var B=O.actQueue;if(B!==null)if(B.length!==0)try{BW(B),t(function(){return XW(W,Z,X)});return}catch(Y){O.thrownErrors.push(Y)}else O.actQueue=null;0<O.thrownErrors.length?(B=e(O.thrownErrors),O.thrownErrors.length=0,X(B)):Z(W)}function BW(W){if(!VW){VW=!0;var Z=0;try{for(;Z<W.length;Z++){var X=W[Z];do{O.didUsePromise=!1;var B=X(!1);if(B!==null){if(O.didUsePromise){W[Z]=X,W.splice(0,Z);return}X=B}else break}while(1)}W.length=0}catch(Y){W.splice(0,Z+1),O.thrownErrors.push(Y)}finally{VW=!1}}}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var QW=Symbol.for("react.transitional.element"),OW=Symbol.for("react.portal"),GW=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),U=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),b=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),HW=Symbol.for("react.suspense"),x=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),r=Symbol.for("react.lazy"),DW=Symbol.for("react.activity"),NW=Symbol.iterator,PW={},xW={isMounted:function(){return!1},enqueueForceUpdate:function(W){w(W,"forceUpdate")},enqueueReplaceState:function(W){w(W,"replaceState")},enqueueSetState:function(W){w(W,"setState")}},_W=Object.assign,FW={};Object.freeze(FW),F.prototype.isReactComponent={},F.prototype.setState=function(W,Z){if(typeof W!=="object"&&typeof W!=="function"&&W!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,W,Z,"setState")},F.prototype.forceUpdate=function(W){this.updater.enqueueForceUpdate(this,W,"forceUpdate")};var i={isMounted:["isMounted","Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],replaceState:["replaceState","Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]};for($W in i)i.hasOwnProperty($W)&&H($W,i[$W]);k.prototype=F.prototype,i=C.prototype=new k,i.constructor=C,_W(i,F.prototype),i.isPureReactComponent=!0;var AW=Array.isArray,iW=Symbol.for("react.client.reference"),O={H:null,A:null,T:null,S:null,actQueue:null,asyncTransitions:0,isBatchingLegacy:!1,didScheduleLegacyUpdate:!1,didUsePromise:!1,thrownErrors:[],getCurrentStack:null,recentlyCreatedOwnerStacks:0},LW=Object.prototype.hasOwnProperty,IW=console.createTask?console.createTask:function(){return null};i={react_stack_bottom_frame:function(W){return W()}};var jW,TW,vW={},cW=i.react_stack_bottom_frame.bind(i,s)(),oW=IW(c(s)),CW=!1,SW=/\/+/g,gW=typeof reportError==="function"?reportError:function(W){if(typeof window==="object"&&typeof window.ErrorEvent==="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof W==="object"&&W!==null&&typeof W.message==="string"?String(W.message):String(W),error:W});if(!window.dispatchEvent(Z))return}else if(typeof process==="object"&&typeof process.emit==="function"){process.emit("uncaughtException",W);return}console.error(W)},kW=!1,JW=null,qW=0,wW=!1,VW=!1,bW=typeof queueMicrotask==="function"?function(W){queueMicrotask(function(){return queueMicrotask(W)})}:t;i=Object.freeze({__proto__:null,c:function(W){return z().useMemoCache(W)}});var $W={map:G,forEach:function(W,Z,X){G(W,function(){Z.apply(this,arguments)},X)},count:function(W){var Z=0;return G(W,function(){Z++}),Z},toArray:function(W){return G(W,function(Z){return Z})||[]},only:function(W){if(!j(W))throw Error("React.Children.only expected to receive a single React element child.");return W}};WZ.Activity=DW,WZ.Children=$W,WZ.Component=F,WZ.Fragment=GW,WZ.Profiler=U,WZ.PureComponent=C,WZ.StrictMode=M,WZ.Suspense=HW,WZ.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=O,WZ.__COMPILER_RUNTIME=i,WZ.act=function(W){var Z=O.actQueue,X=qW;qW++;var B=O.actQueue=Z!==null?Z:[],Y=!1;try{var D=W()}catch(L){O.thrownErrors.push(L)}if(0<O.thrownErrors.length)throw WW(Z,X),W=e(O.thrownErrors),O.thrownErrors.length=0,W;if(D!==null&&typeof D==="object"&&typeof D.then==="function"){var $=D;return bW(function(){Y||wW||(wW=!0,console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"))}),{then:function(L,a){Y=!0,$.then(function(YW){if(WW(Z,X),X===0){try{BW(B),t(function(){return XW(YW,L,a)})}catch(nW){O.thrownErrors.push(nW)}if(0<O.thrownErrors.length){var lW=e(O.thrownErrors);O.thrownErrors.length=0,a(lW)}}else L(YW)},function(YW){WW(Z,X),0<O.thrownErrors.length?(YW=e(O.thrownErrors),O.thrownErrors.length=0,a(YW)):a(YW)})}}}var V=D;if(WW(Z,X),X===0&&(BW(B),B.length!==0&&bW(function(){Y||wW||(wW=!0,console.error("A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"))}),O.actQueue=null),0<O.thrownErrors.length)throw W=e(O.thrownErrors),O.thrownErrors.length=0,W;return{then:function(L,a){Y=!0,X===0?(O.actQueue=B,t(function(){return XW(V,L,a)})):L(V)}}},WZ.cache=function(W){return function(){return W.apply(null,arguments)}},WZ.cacheSignal=function(){return null},WZ.captureOwnerStack=function(){var W=O.getCurrentStack;return W===null?null:W()},WZ.cloneElement=function(W,Z,X){if(W===null||W===void 0)throw Error("The argument must be a React element, but you passed "+W+".");var B=_W({},W.props),Y=W.key,D=W._owner;if(Z!=null){var $;W:{if(LW.call(Z,"ref")&&($=Object.getOwnPropertyDescriptor(Z,"ref").get)&&$.isReactWarning){$=!1;break W}$=Z.ref!==void 0}$&&(D=p()),u(Z)&&(S(Z.key),Y=""+Z.key);for(V in Z)!LW.call(Z,V)||V==="key"||V==="__self"||V==="__source"||V==="ref"&&Z.ref===void 0||(B[V]=Z[V])}var V=arguments.length-2;if(V===1)B.children=X;else if(1<V){$=Array(V);for(var L=0;L<V;L++)$[L]=arguments[L+2];B.children=$}B=K(W.type,Y,B,D,W._debugStack,W._debugTask);for(Y=2;Y<arguments.length;Y++)I(arguments[Y]);return B},WZ.createContext=function(W){return W={$$typeof:b,_currentValue:W,_currentValue2:W,_threadCount:0,Provider:null,Consumer:null},W.Provider=W,W.Consumer={$$typeof:N,_context:W},W._currentRenderer=null,W._currentRenderer2=null,W},WZ.createElement=function(W,Z,X){for(var B=2;B<arguments.length;B++)I(arguments[B]);B={};var Y=null;if(Z!=null)for(L in TW||!("__self"in Z)||"key"in Z||(TW=!0,console.warn("Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform")),u(Z)&&(S(Z.key),Y=""+Z.key),Z)LW.call(Z,L)&&L!=="key"&&L!=="__self"&&L!=="__source"&&(B[L]=Z[L]);var D=arguments.length-2;if(D===1)B.children=X;else if(1<D){for(var $=Array(D),V=0;V<D;V++)$[V]=arguments[V+2];Object.freeze&&Object.freeze($),B.children=$}if(W&&W.defaultProps)for(L in D=W.defaultProps,D)B[L]===void 0&&(B[L]=D[L]);Y&&f(B,typeof W==="function"?W.displayName||W.name||"Unknown":W);var L=1e4>O.recentlyCreatedOwnerStacks++;return K(W,Y,B,p(),L?Error("react-stack-top-frame"):cW,L?IW(c(W)):oW)},WZ.createRef=function(){var W={current:null};return Object.seal(W),W},WZ.forwardRef=function(W){W!=null&&W.$$typeof===l?console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."):typeof W!=="function"?console.error("forwardRef requires a render function but was given %s.",W===null?"null":typeof W):W.length!==0&&W.length!==2&&console.error("forwardRef render functions accept exactly two parameters: props and ref. %s",W.length===1?"Did you forget to use the ref parameter?":"Any additional parameter will be undefined."),W!=null&&W.defaultProps!=null&&console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");var Z={$$typeof:o,render:W},X;return Object.defineProperty(Z,"displayName",{enumerable:!1,configurable:!0,get:function(){return X},set:function(B){X=B,W.name||W.displayName||(Object.defineProperty(W,"name",{value:B}),W.displayName=B)}}),Z},WZ.isValidElement=j,WZ.lazy=function(W){W={_status:-1,_result:W};var Z={$$typeof:r,_payload:W,_init:q},X={name:"lazy",start:-1,end:-1,value:null,owner:null,debugStack:Error("react-stack-top-frame"),debugTask:console.createTask?console.createTask("lazy()"):null};return W._ioInfo=X,Z._debugInfo=[{awaited:X}],Z},WZ.memo=function(W,Z){W==null&&console.error("memo: The first argument must be a component. Instead received: %s",W===null?"null":typeof W),Z={$$typeof:l,type:W,compare:Z===void 0?null:Z};var X;return Object.defineProperty(Z,"displayName",{enumerable:!1,configurable:!0,get:function(){return X},set:function(B){X=B,W.name||W.displayName||(Object.defineProperty(W,"name",{value:B}),W.displayName=B)}}),Z},WZ.startTransition=function(W){var Z=O.T,X={};X._updatedFibers=new Set,O.T=X;try{var B=W(),Y=O.S;Y!==null&&Y(X,B),typeof B==="object"&&B!==null&&typeof B.then==="function"&&(O.asyncTransitions++,B.then(h,h),B.then(_,gW))}catch(D){gW(D)}finally{Z===null&&X._updatedFibers&&(W=X._updatedFibers.size,X._updatedFibers.clear(),10<W&&console.warn("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.")),Z!==null&&X.types!==null&&(Z.types!==null&&Z.types!==X.types&&console.error("We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."),Z.types=X.types),O.T=Z}},WZ.unstable_useCacheRefresh=function(){return z().useCacheRefresh()},WZ.use=function(W){return z().use(W)},WZ.useActionState=function(W,Z,X){return z().useActionState(W,Z,X)},WZ.useCallback=function(W,Z){return z().useCallback(W,Z)},WZ.useContext=function(W){var Z=z();return W.$$typeof===N&&console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"),Z.useContext(W)},WZ.useDebugValue=function(W,Z){return z().useDebugValue(W,Z)},WZ.useDeferredValue=function(W,Z){return z().useDeferredValue(W,Z)},WZ.useEffect=function(W,Z){return W==null&&console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"),z().useEffect(W,Z)},WZ.useEffectEvent=function(W){return z().useEffectEvent(W)},WZ.useId=function(){return z().useId()},WZ.useImperativeHandle=function(W,Z,X){return z().useImperativeHandle(W,Z,X)},WZ.useInsertionEffect=function(W,Z){return W==null&&console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"),z().useInsertionEffect(W,Z)},WZ.useLayoutEffect=function(W,Z){return W==null&&console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"),z().useLayoutEffect(W,Z)},WZ.useMemo=function(W,Z){return z().useMemo(W,Z)},WZ.useOptimistic=function(W,Z){return z().useOptimistic(W,Z)},WZ.useReducer=function(W,Z,X){return z().useReducer(W,Z,X)},WZ.useRef=function(W){return z().useRef(W)},WZ.useState=function(W){return z().useState(W)},WZ.useSyncExternalStore=function(W,Z,X){return z().useSyncExternalStore(W,Z,X)},WZ.useTransition=function(){return z().useTransition()},WZ.version="19.2.4",typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop==="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()});var MW=fW((ZZ)=>{var ZW=n(UW());(function(){function H(M){if(M==null)return null;if(typeof M==="function")return M.$$typeof===z?null:M.displayName||M.name||null;if(typeof M==="string")return M;switch(M){case g:return"Fragment";case m:return"Profiler";case K:return"StrictMode";case T:return"Suspense";case J:return"SuspenseList";case q:return"Activity"}if(typeof M==="object")switch(typeof M.tag==="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),M.$$typeof){case f:return"Portal";case j:return M.displayName||"Context";case I:return(M._context.displayName||"Context")+".Consumer";case d:var U=M.render;return M=M.displayName,M||(M=U.displayName||U.name||"",M=M!==""?"ForwardRef("+M+")":"ForwardRef"),M;case Q:return U=M.displayName||null,U!==null?U:H(M.type)||"Memo";case G:U=M._payload,M=M._init;try{return H(M(U))}catch(N){}}return null}function R(M){return""+M}function w(M){try{R(M);var U=!1}catch(o){U=!0}if(U){U=console;var N=U.error,b=typeof Symbol==="function"&&Symbol.toStringTag&&M[Symbol.toStringTag]||M.constructor.name||"Object";return N.call(U,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),R(M)}}function F(M){if(M===g)return"<>";if(typeof M==="object"&&M!==null&&M.$$typeof===G)return"<...>";try{var U=H(M);return U?"<"+U+">":"<...>"}catch(N){return"<...>"}}function k(){var M=h.A;return M===null?null:M.getOwner()}function C(){return Error("react-stack-top-frame")}function _(M){if(t.call(M,"key")){var U=Object.getOwnPropertyDescriptor(M,"key").get;if(U&&U.isReactWarning)return!1}return M.key!==void 0}function A(M,U){function N(){XW||(XW=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",U))}N.isReactWarning=!0,Object.defineProperty(M,"key",{get:N,configurable:!0})}function S(){var M=H(this.type);return BW[M]||(BW[M]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),M=this.props.ref,M!==void 0?M:null}function y(M,U,N,b,o,HW){var x=N.ref;return M={$$typeof:u,type:M,key:U,props:N,_owner:b},(x!==void 0?x:null)!==null?Object.defineProperty(M,"ref",{enumerable:!1,get:S}):Object.defineProperty(M,"ref",{enumerable:!1,value:null}),M._store={},Object.defineProperty(M._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(M,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(M,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:o}),Object.defineProperty(M,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:HW}),Object.freeze&&(Object.freeze(M.props),Object.freeze(M)),M}function c(M,U,N,b,o,HW){var x=U.children;if(x!==void 0)if(b)if(e(x)){for(b=0;b<x.length;b++)p(x[b]);Object.freeze&&Object.freeze(x)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else p(x);if(t.call(U,"key")){x=H(M);var l=Object.keys(U).filter(function(DW){return DW!=="key"});b=0<l.length?"{key: someKey, "+l.join(": ..., ")+": ...}":"{key: someKey}",GW[x+b]||(l=0<l.length?"{"+l.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
14
|
-
let props = %s;
|
|
15
|
-
<%s {...props} />
|
|
16
|
-
React keys must be passed directly to JSX without using spread:
|
|
17
|
-
let props = %s;
|
|
18
|
-
<%s key={someKey} {...props} />`,b,x,l,x),GW[x+b]=!0)}if(x=null,N!==void 0&&(w(N),x=""+N),_(U)&&(w(U.key),x=""+U.key),"key"in U){N={};for(var r in U)r!=="key"&&(N[r]=U[r])}else N=U;return x&&A(N,typeof M==="function"?M.displayName||M.name||"Unknown":M),y(M,x,N,k(),o,HW)}function p(M){s(M)?M._store&&(M._store.validated=1):typeof M==="object"&&M!==null&&M.$$typeof===G&&(M._payload.status==="fulfilled"?s(M._payload.value)&&M._payload.value._store&&(M._payload.value._store.validated=1):M._store&&(M._store.validated=1))}function s(M){return typeof M==="object"&&M!==null&&M.$$typeof===u}var u=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),K=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),j=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),J=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),G=Symbol.for("react.lazy"),q=Symbol.for("react.activity"),z=Symbol.for("react.client.reference"),h=ZW.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,t=Object.prototype.hasOwnProperty,e=Array.isArray,WW=console.createTask?console.createTask:function(){return null};ZW={react_stack_bottom_frame:function(M){return M()}};var XW,BW={},QW=ZW.react_stack_bottom_frame.bind(ZW,C)(),OW=WW(F(C)),GW={};ZZ.Fragment=g,ZZ.jsxDEV=function(M,U,N,b){var o=1e4>h.recentlyCreatedOwnerStacks++;return c(M,U,N,b,o?Error("react-stack-top-frame"):QW,o?WW(F(M)):OW)}})()});var P=n(UW(),1),yW=n(MW(),1),hW=P.createContext(null),MZ=200;function XZ({children:H}){let[R,w]=P.useState(!1),[F,k]=P.useState([]),[C,_]=P.useState({}),[A,S]=P.useState({}),[y,c]=P.useState(0),[p,s]=P.useState(0),[u,f]=P.useState(0),g=P.useRef(null),K=P.useRef(null);P.useEffect(()=>{let j=setInterval(()=>{let d=Date.now();S((T)=>{let J={};for(let[Q,G]of Object.entries(T))if(G.expiresAt>d)J[Q]=G;return J})},500);return()=>clearInterval(j)},[]);let m=P.useCallback(()=>{if(g.current)g.current.close(),g.current=null;try{let j=new EventSource("/api/telemetry/stream");g.current=j,j.onopen=()=>{w(!0)},j.onmessage=(d)=>{if(!d.data||d.data.trim()==="")return;try{let T=JSON.parse(d.data);if(T.connected){w(!0);return}if(Array.isArray(T)){if(k((J)=>{return[...T,...J].slice(0,MZ)}),_((J)=>{let Q={...J};for(let G of T){let q=Q[G.agent_id];if(!q||new Date(G.timestamp)>new Date(q.timestamp))Q[G.agent_id]={timestamp:G.timestamp,category:G.category,type:G.type}}return Q}),S((J)=>{let Q={...J},G=Date.now()+3000;for(let q of T)Q[q.agent_id]={type:q.type,expiresAt:G};return Q}),T.some((J)=>J.category==="system"&&(J.type==="agent_started"||J.type==="agent_stopped")))c((J)=>J+1);if(T.some((J)=>J.category==="TASK"&&(J.type==="task_created"||J.type==="task_updated"||J.type==="task_deleted")))s((J)=>J+1);if(T.some((J)=>J.level==="error"||J.category==="ERROR"||J.category==="system"&&J.type==="agent_stopped"))f((J)=>J+1)}}catch{}},j.onerror=()=>{if(w(!1),j.close(),g.current=null,K.current)clearTimeout(K.current);K.current=setTimeout(m,2000)}}catch{if(w(!1),K.current)clearTimeout(K.current);K.current=setTimeout(m,2000)}},[]);P.useEffect(()=>{return m(),()=>{if(g.current)g.current.close();if(K.current)clearTimeout(K.current)}},[m]);let I=P.useCallback(()=>{k([])},[]);return yW.jsxDEV(hW.Provider,{value:{connected:R,events:F,lastActivityByAgent:C,activeAgents:A,statusChangeCounter:y,taskChangeCounter:p,notificationCounter:u,clearEvents:I},children:H},void 0,!1,void 0,this)}function zW(){let H=P.useContext(hW);if(!H)throw Error("useTelemetryContext must be used within TelemetryProvider");return H}function BZ(H){let{connected:R,events:w,lastActivityByAgent:F}=zW(),k=P.default.useMemo(()=>{let A=w;if(H?.agent_id)A=A.filter((S)=>S.agent_id===H.agent_id);if(H?.category)A=A.filter((S)=>S.category===H.category);if(H?.limit)A=A.slice(0,H.limit);return A},[w,H?.agent_id,H?.category,H?.limit]),C=H?.agent_id?F[H.agent_id]:void 0,_=P.default.useMemo(()=>{if(!C)return!1;let A=new Date(C.timestamp).getTime();return Date.now()-A<1e4},[C]);return{connected:R,events:k,lastActivity:C,isActive:_}}function GZ(H){let{activeAgents:R}=zW(),w=R[H];return{isActive:!!w,type:w?.type}}function HZ(){let{statusChangeCounter:H}=zW();return H}function YZ(){let{taskChangeCounter:H}=zW();return H}function zZ(){let{notificationCounter:H}=zW();return H}var E=n(UW(),1),sW=n(MW(),1),uW=E.createContext(null);function KW(){let H=E.useContext(uW);if(!H)throw Error("useAuth must be used within an AuthProvider");return H}function QZ({children:H}){let[R,w]=E.useState(null),[F,k]=E.useState(null),[C,_]=E.useState(!0),[A,S]=E.useState(null),[y,c]=E.useState(!1),[p,s]=E.useState(null),u=E.useRef(null),f=E.useRef(!1),g=E.useRef(!1),K=E.useCallback((G)=>{u.current=G,k(G)},[]),m=E.useCallback(async()=>{if(f.current)return!1;f.current=!0;try{let G=await fetch("/api/auth/refresh",{method:"POST",credentials:"include"});if(!G.ok)return!1;let q=await G.json();if(K(q.accessToken),q.user)w(q.user);if(q.onboarding)s(q.onboarding.completed||q.onboarding.has_any_keys);return!!q.user}catch(G){return console.error("Token refresh failed:",G),!1}finally{f.current=!1}},[K]),I=E.useCallback(async()=>{try{let G=u.current,z=await(await fetch("/api/auth/check",{headers:G?{Authorization:`Bearer ${G}`}:{}})).json();if(S(z.hasUsers),c(z.isDev??!1),z.onboarding)s(z.onboarding.completed||z.onboarding.has_any_keys);if(z.authenticated&&z.user)w(z.user);else if(w(null),z.hasUsers){if(!await m())K(null)}}catch(G){console.error("Auth check failed:",G),w(null),K(null)}finally{_(!1)}},[m,K]),j=E.useCallback(async(G,q)=>{try{let z=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({username:G,password:q})}),h=await z.json();if(!z.ok)return{success:!1,error:h.error||"Login failed"};return K(h.accessToken),w(h.user),S(!0),{success:!0}}catch(z){return console.error("Login failed:",z),{success:!1,error:"Login failed"}}},[K]),d=E.useCallback(async()=>{try{let G=u.current;await fetch("/api/auth/logout",{method:"POST",credentials:"include",headers:G?{Authorization:`Bearer ${G}`}:{}})}catch(G){console.error("Logout failed:",G)}finally{w(null),K(null)}},[K]),T=E.useCallback(async(G,q={})=>{let z=new Headers(q.headers),h=u.current;if(h)z.set("Authorization",`Bearer ${h}`);return fetch(G,{...q,headers:z})},[]),J=E.useCallback(async()=>{return m()},[m]);E.useEffect(()=>{if(g.current)return;g.current=!0,I()},[I]),E.useEffect(()=>{if(!F)return;let G=setInterval(()=>{m()},840000);return()=>clearInterval(G)},[F,m]);let Q={user:R,isAuthenticated:!!R,isLoading:C,hasUsers:A,isDev:y,accessToken:F,onboardingComplete:p,setOnboardingComplete:s,login:j,logout:d,refreshToken:J,checkAuth:I,authFetch:T};return sW.jsxDEV(uW.Provider,{value:Q,children:H},void 0,!1,void 0,this)}function $Z(){let{accessToken:H}=KW();return H?{Authorization:`Bearer ${H}`}:{}}var v=n(UW(),1);var pW=n(MW(),1),dW=v.createContext(null);function UZ(){let H=v.useContext(dW);if(!H)throw Error("useProjects must be used within a ProjectProvider");return H}var EW="apteva_current_project";function OZ({children:H}){let{authFetch:R,isAuthenticated:w,isLoading:F}=KW(),[k,C]=v.useState([]),[_,A]=v.useState(()=>{if(typeof window<"u")return localStorage.getItem(EW);return null}),[S,y]=v.useState(!0),[c,p]=v.useState(null),[s,u]=v.useState(0),[f,g]=v.useState(!1);v.useEffect(()=>{fetch("/api/features").then((Q)=>Q.json()).then((Q)=>{g(Q.projects===!0)}).catch(()=>{g(!1)})},[]);let K=v.useCallback((Q)=>{if(A(Q),typeof window<"u")if(Q===null)localStorage.removeItem(EW);else localStorage.setItem(EW,Q)},[]),m=k.find((Q)=>Q.id===_)||null,I=v.useCallback(async()=>{if(!f){C([]),y(!1);return}if(!w&&!F){C([]),y(!1);return}try{p(null);let Q=await R("/api/projects");if(!Q.ok)throw Error("Failed to fetch projects");let G=await Q.json();if(C(G.projects||[]),u(G.unassignedCount||0),_&&_!=="unassigned"&&!G.projects.find((q)=>q.id===_))K(null)}catch(Q){console.error("Failed to fetch projects:",Q),p("Failed to load projects")}finally{y(!1)}},[R,w,F,_,K,f]),j=v.useCallback(async(Q)=>{try{let G=await R("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)});if(!G.ok){let z=await G.json();throw Error(z.error||"Failed to create project")}let q=await G.json();return await I(),q.project}catch(G){return console.error("Failed to create project:",G),null}},[R,I]),d=v.useCallback(async(Q,G)=>{try{let q=await R(`/api/projects/${Q}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!q.ok){let h=await q.json();throw Error(h.error||"Failed to update project")}let z=await q.json();return await I(),z.project}catch(q){return console.error("Failed to update project:",q),null}},[R,I]),T=v.useCallback(async(Q)=>{try{let G=await R(`/api/projects/${Q}`,{method:"DELETE"});if(!G.ok){let q=await G.json();throw Error(q.error||"Failed to delete project")}if(_===Q)K(null);return await I(),!0}catch(G){return console.error("Failed to delete project:",G),!1}},[R,_,K,I]);v.useEffect(()=>{if(!F&&f)I()},[F,f,I]);let J={projects:k,currentProjectId:_,currentProject:m,isLoading:S,error:c,unassignedCount:s,projectsEnabled:f,setCurrentProjectId:K,createProject:j,updateProject:d,deleteProject:T,refreshProjects:I};return pW.jsxDEV(dW.Provider,{value:J,children:H},void 0,!1,void 0,this)}export{n as Q,fW as R,DZ as S,UW as T,MW as U,XZ as V,zW as W,BZ as X,GZ as Y,HZ as Z,YZ as _,zZ as $,KW as aa,QZ as ba,$Z as ca,UZ as da,OZ as ea};
|
|
19
|
-
|
|
20
|
-
//# debugId=7C0ACD18FC193FD464756E2164756E21
|