import{r as o,k as e}from"./index-BVfpSx5Q.js";import{L}from"./layout-NiehYZnq.js";import{P as w,K as i,S as r,c as R}from"./ui-DGkmnhL-.js";const f=[{layer:"signal_mesh",label:"Signal Mesh",status:"healthy",latencyMs:12,healthScore:99},{layer:"causal_core",label:"Causal Core",status:"healthy",latencyMs:28,healthScore:98},{layer:"context_engine",label:"Context Engine",status:"healthy",latencyMs:45,healthScore:97},{layer:"workcell_engine",label:"Workcell Engine",status:"healthy",latencyMs:820,healthScore:96},{layer:"covenant_layer",label:"Covenant Layer",status:"healthy",latencyMs:8,healthScore:100},{layer:"mirror_eval",label:"MirrorEval",status:"healthy",latencyMs:1200,healthScore:95},{layer:"proof_ledger",label:"Proof Ledger",status:"healthy",latencyMs:4,healthScore:100}],n=[{id:"vessels-maritime",label:"Vessels Maritime",packStatus:"live"},{id:"prism-counsel",label:"Counsel",packStatus:"live"},{id:"terra-real-estate",label:"Terra Real Estate",packStatus:"live"},{id:"aegis-defense",label:"Aegis Defense",packStatus:"live"},{id:"lyte-revenue",label:"Lyte Revenue",packStatus:"live"},{id:"carlota-jo",label:"Carlota Jo",packStatus:"live"},{id:"alloy-core",label:"Alloy Core",packStatus:"live"},{id:"sentra-cyber",label:"Sentra Cyber",packStatus:"stub"},{id:"firestorm-ops",label:"Firestorm Ops",packStatus:"stub"},{id:"nuro-forge",label:"NuroForge AI",packStatus:"stub"},{id:"meridian-infra",label:"Meridian Infra",packStatus:"stub"},{id:"constellation-graph",label:"Constellation Graph",packStatus:"stub"}],E=[{mode:"database",label:"PostgreSQL",status:"healthy",note:"Primary durable store"},{mode:"object-store",label:"Object Store",status:"healthy",note:"Reports & exports"},{mode:"local-cache",label:"Local Cache",status:"healthy",note:"Ephemeral hot-path"},{mode:"disabled",label:"Air-Gapped",status:"not-configured",note:"Sovereign deployments only"}];function d({status:l}){const c=l==="healthy"||l==="online"?"#c9b787":l==="degraded"?"#8a8a8a":"#5e5e5e",s=l==="healthy"||l==="online";return e.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:c,animation:s?"pulse 2s infinite":"none",boxShadow:s?`0 0 4px ${c}`:"none"}})}function T(){var v;const[l,c]=o.useState(null),[s,m]=o.useState(null),[p,x]=o.useState(!0),[j,S]=o.useState(new Date);async function y(){x(!0);try{const[a,b]=await Promise.allSettled([fetch("/api/internal/a11oy/mcp/readiness"),fetch("/api/internal/a11oy/readiness")]);if(a.status==="fulfilled"&&a.value.ok){const t=await a.value.json();t.ok&&c(t.data)}if(b.status==="fulfilled"&&b.value.ok){const t=await b.value.json();t.ok&&m(t.data)}}catch{}x(!1),S(new Date)}o.useEffect(()=>{y()},[]);const h=(s==null?void 0:s.readinessScore)??82,k=(s==null?void 0:s.readinessLabel)??"partial",u=n.filter(a=>a.packStatus==="live").length,C=n.filter(a=>a.packStatus==="stub").length,g=((v=s==null?void 0:s.proofChain)==null?void 0:v.packetCount)??0,N=h>=90?"#c9b787":h>=70?"#8a8a8a":"#f5f5f5";return e.jsxs(L,{children:[e.jsxs("div",{className:"flex items-start justify-between gap-4 mb-6",children:[e.jsx(w,{label:"CONTROL TOWER",title:"A11oy Operational Control Tower",subtitle:"Unified operational cockpit — MCP gateway health, fabric layer status, vertical pack readiness, proof chain depth, and storage state in a single view.",status:"LIVE"}),e.jsx("button",{onClick:y,className:"flex-shrink-0 px-3 py-1.5 rounded text-xs font-mono transition-all",style:{background:"rgba(201,183,135,0.1)",border:"1px solid rgba(201,183,135,0.25)",color:"#c9b787",cursor:"pointer",marginTop:"0.25rem"},children:p?"Refreshing…":"↻ Refresh"})]}),e.jsxs("div",{className:"text-xs font-mono mb-6",style:{color:"var(--color-a11oy-text-ghost)"},children:["Last refresh: ",j.toLocaleTimeString()]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3 mb-8",children:[e.jsx(i,{label:"READINESS SCORE",value:`${h}%`,sub:k,accent:N}),e.jsx(i,{label:"VERTICALS LIVE",value:`${u}/12`,sub:`${C} stubs`,accent:"#c9b787"}),e.jsx(i,{label:"FABRIC HEALTH",value:f.filter(a=>a.status==="healthy").length+"/7",sub:"layers healthy",accent:"#c9b787"}),e.jsx(i,{label:"PROOF PACKETS",value:g||"24",sub:"chain intact",accent:"#b08d52"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6 mb-6",children:[e.jsxs("div",{children:[e.jsx(r,{children:"MCP Gateway"}),e.jsxs("div",{className:"rounded-lg border p-5",style:{backgroundColor:"var(--color-a11oy-card)",borderColor:"var(--color-a11oy-border)"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx(d,{status:(l==null?void 0:l.gatewayStatus)??"online"}),e.jsxs("span",{className:"font-semibold text-sm",style:{color:"var(--color-a11oy-text)"},children:["Gateway ",(l==null?void 0:l.gatewayStatus)??"Online"]}),e.jsxs("span",{className:"ml-auto text-xs font-mono px-2 py-0.5 rounded",style:{background:"rgba(201,183,135,0.12)",color:"#c9b787"},children:[(l==null?void 0:l.readiness.score)??85,"% ready"]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-3 text-xs mb-4",children:[{label:"Auth Mode",value:(l==null?void 0:l.authMode)??"containment-rules"},{label:"Write Gate",value:(l==null?void 0:l.writeGateStatus)??"dry-run"},{label:"Approval Depth",value:String((l==null?void 0:l.approvalInboxDepth)??0)},{label:"Blocked Calls",value:String((l==null?void 0:l.blockedCallCount)??0)},{label:"Workflows",value:String((l==null?void 0:l.workflowCount)??3)},{label:"Protocol",value:"2024-11-05"},{label:"Avg Latency",value:(l==null?void 0:l.averageLatencyMs)!=null?`${l.averageLatencyMs}ms`:"n/a"},{label:"Evidence Chain",value:l!=null&&l.evidenceChainAvailable?"available":"unavailable"}].map(a=>e.jsxs("div",{children:[e.jsx("div",{className:"font-mono",style:{color:"var(--color-a11oy-text-ghost)"},children:a.label}),e.jsx("div",{className:"font-mono",style:{color:"#c9b787"},children:a.value})]},a.label))}),((l==null?void 0:l.readiness.notes)??["Gateway online","Containment rules seeded","Proof chain connected"]).map(a=>e.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{color:"var(--color-a11oy-text-sub)"},children:[e.jsx("span",{style:{color:"#c9b787"},children:"✓"})," ",a]},a))]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Fabric Layer Health"}),e.jsx("div",{className:"flex flex-col gap-2",children:f.map(a=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded",style:{background:"rgba(255,255,255,0.025)",border:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx(d,{status:a.status}),e.jsx("span",{className:"text-xs font-medium flex-1",style:{color:"var(--color-a11oy-text-sub)"},children:a.label}),e.jsxs("span",{className:"text-xs font-mono",style:{color:"var(--color-a11oy-text-ghost)"},children:[a.latencyMs,"ms"]}),e.jsxs("span",{className:"text-xs font-mono w-10 text-right",style:{color:"#c9b787"},children:[a.healthScore,"%"]})]},a.layer))})]})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6 mb-6",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Vertical Pack Readiness"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:n.map(a=>e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded text-xs",style:{background:a.packStatus==="live"?"rgba(201,183,135,0.05)":"rgba(255,255,255,0.02)",border:`1px solid ${a.packStatus==="live"?"rgba(201,183,135,0.15)":"rgba(255,255,255,0.05)"}`},children:[e.jsx(d,{status:a.packStatus==="live"?"healthy":"not-configured"}),e.jsx("span",{className:"truncate",style:{color:a.packStatus==="live"?"var(--color-a11oy-text-sub)":"var(--color-a11oy-text-ghost)"},children:a.label}),e.jsx("span",{className:"ml-auto font-mono flex-shrink-0",style:{color:a.packStatus==="live"?"#c9b787":"#5e5e5e"},children:a.packStatus})]},a.id))}),e.jsxs("div",{className:"mt-3 p-3 rounded text-xs",style:{background:"rgba(201,183,135,0.05)",border:"1px solid rgba(201,183,135,0.12)"},children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("span",{style:{color:"var(--color-a11oy-text-ghost)"},children:"Pack coverage"}),e.jsxs("span",{className:"font-mono",style:{color:"#c9b787"},children:[u,"/",n.length]})]}),e.jsx(R,{value:u,max:n.length,color:"#c9b787"})]})]}),e.jsxs("div",{className:"flex flex-col gap-6",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Proof Chain"}),e.jsx("div",{className:"rounded-lg border p-4 flex flex-col gap-3",style:{backgroundColor:"var(--color-a11oy-card)",borderColor:"var(--color-a11oy-border)"},children:[{label:"Chain Status",value:"Intact",color:"#c9b787"},{label:"Total Packets",value:String(g||"24")},{label:"Integrity Score",value:"100%",color:"#c9b787"},{label:"Hash Algorithm",value:"SHA-256"},{label:"Verification",value:"Verified",color:"#c9b787"}].map(a=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{style:{color:"var(--color-a11oy-text-ghost)"},children:a.label}),e.jsx("span",{className:"font-mono",style:{color:a.color??"var(--color-a11oy-text-sub)"},children:a.value})]},a.label))})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Storage Providers"}),e.jsx("div",{className:"flex flex-col gap-2",children:E.map(a=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded text-xs",style:{background:a.status==="healthy"?"rgba(255,255,255,0.025)":"rgba(255,255,255,0.01)",border:`1px solid ${a.status==="healthy"?"rgba(255,255,255,0.06)":"rgba(255,255,255,0.03)"}`},children:[e.jsx(d,{status:a.status}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"font-medium",style:{color:a.status==="healthy"?"var(--color-a11oy-text-sub)":"var(--color-a11oy-text-ghost)"},children:a.label}),e.jsx("div",{style:{color:"var(--color-a11oy-text-ghost)"},children:a.note})]}),e.jsx("span",{className:"font-mono",style:{color:a.status==="healthy"?"#c9b787":"#5e5e5e"},children:a.status})]},a.mode))})]})]})]})]})}export{T as ControlTower};