diff --git a/apps/console-proxy/public/assets/AcceptInvitePage-C_meFJ5R.js b/apps/console-proxy/public/assets/AcceptInvitePage-C_meFJ5R.js new file mode 100644 index 00000000..7b4e5d22 --- /dev/null +++ b/apps/console-proxy/public/assets/AcceptInvitePage-C_meFJ5R.js @@ -0,0 +1,2 @@ +import{z,u as B,r as n,j as e}from"./index-C0nK3ekl.js";function C(){const[f]=z(),y=B(),o=f.get("token")||"",[p,b]=n.useState(""),[i,v]=n.useState(""),[x,j]=n.useState(""),[r,g]=n.useState(!1),[u,s]=n.useState(null),[S,k]=n.useState(!1);n.useEffect(()=>{o||s("Invalid invitation link — no token provided.")},[o]);const w=async t=>{if(t.preventDefault(),!!o){if(i&&i!==x){s("Passwords do not match");return}g(!0),s(null);try{const h=await fetch("/api/v1/team/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:o,name:p.trim()||void 0,password:i||void 0})}),m=await h.json();if(!h.ok||!m.success){s(m.error||"Failed to accept invitation");return}k(!0),setTimeout(()=>y("/login"),2500)}catch{s("Network error — please try again")}finally{g(!1)}}},a={minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#0d0d14",padding:"24px"},l={background:"#12131a",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"8px",padding:"40px",width:"100%",maxWidth:"420px"},d={width:"100%",padding:"10px 12px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:"4px",color:"#e2e8f0",fontSize:"14px",fontFamily:"inherit",boxSizing:"border-box",outline:"none"},c={display:"block",marginBottom:"6px",fontSize:"12px",fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:"0.05em"};return o?S?e.jsx("div",{style:a,children:e.jsx("div",{style:l,children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"✅"}),e.jsx("h2",{style:{color:"#e2e8f0",marginBottom:"8px"},children:"Invitation Accepted!"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"Your account has been set up. Redirecting to login..."})]})})}):e.jsx("div",{style:a,children:e.jsxs("div",{style:l,children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:"32px"},children:[e.jsx("div",{style:{fontSize:"36px",marginBottom:"12px"},children:"🏛️"}),e.jsx("h1",{style:{color:"#e2e8f0",fontSize:"22px",fontWeight:700,marginBottom:"8px"},children:"Join Vienna OS Workspace"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"You've been invited to collaborate on AI governance."})]}),e.jsxs("form",{onSubmit:w,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:c,children:["Your Name ",e.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"(optional)"})]}),e.jsx("input",{type:"text",placeholder:"Jane Smith",value:p,onChange:t=>b(t.target.value),style:d})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:c,children:["Password ",e.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"(optional — skip if using SSO)"})]}),e.jsx("input",{type:"password",placeholder:"Choose a password",value:i,onChange:t=>v(t.target.value),style:d})]}),i&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:c,children:"Confirm Password"}),e.jsx("input",{type:"password",placeholder:"Confirm password",value:x,onChange:t=>j(t.target.value),style:d})]}),u&&e.jsx("div",{style:{marginBottom:"16px",padding:"10px 14px",background:"rgba(248,113,113,0.08)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"4px",color:"#ef4444",fontSize:"13px"},children:u}),e.jsx("button",{type:"submit",disabled:r,style:{width:"100%",padding:"12px",background:r?"rgba(99,102,241,0.5)":"#6366f1",color:"#fff",border:"none",borderRadius:"4px",fontSize:"14px",fontWeight:600,cursor:r?"not-allowed":"pointer",fontFamily:"inherit",transition:"background 0.15s"},children:r?"Setting up account...":"Accept Invitation"})]}),e.jsx("p",{style:{marginTop:"20px",textAlign:"center",fontSize:"12px",color:"rgba(255,255,255,0.3)"},children:"By accepting, you agree to Vienna OS terms of service"})]})}):e.jsx("div",{style:a,children:e.jsx("div",{style:l,children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"❌"}),e.jsx("h2",{style:{color:"#e2e8f0",marginBottom:"8px"},children:"Invalid Link"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"This invitation link is missing a token. Please use the link from your email."})]})})})}export{C as default}; +//# sourceMappingURL=AcceptInvitePage-C_meFJ5R.js.map diff --git a/apps/console-proxy/public/assets/AcceptInvitePage-DbpinmWd.js b/apps/console-proxy/public/assets/AcceptInvitePage-DbpinmWd.js deleted file mode 100644 index 271c1432..00000000 --- a/apps/console-proxy/public/assets/AcceptInvitePage-DbpinmWd.js +++ /dev/null @@ -1,2 +0,0 @@ -import{G as z,u as B,r as n,j as e}from"./index-D_7YXFSJ.js";function C(){const[f]=z(),y=B(),o=f.get("token")||"",[p,b]=n.useState(""),[i,v]=n.useState(""),[x,j]=n.useState(""),[r,g]=n.useState(!1),[u,s]=n.useState(null),[S,k]=n.useState(!1);n.useEffect(()=>{o||s("Invalid invitation link — no token provided.")},[o]);const w=async t=>{if(t.preventDefault(),!!o){if(i&&i!==x){s("Passwords do not match");return}g(!0),s(null);try{const h=await fetch("/api/v1/team/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:o,name:p.trim()||void 0,password:i||void 0})}),m=await h.json();if(!h.ok||!m.success){s(m.error||"Failed to accept invitation");return}k(!0),setTimeout(()=>y("/login"),2500)}catch{s("Network error — please try again")}finally{g(!1)}}},a={minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",background:"#0d0d14",padding:"24px"},l={background:"#12131a",border:"1px solid rgba(255,255,255,0.08)",borderRadius:"8px",padding:"40px",width:"100%",maxWidth:"420px"},d={width:"100%",padding:"10px 12px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:"4px",color:"#e2e8f0",fontSize:"14px",fontFamily:"inherit",boxSizing:"border-box",outline:"none"},c={display:"block",marginBottom:"6px",fontSize:"12px",fontWeight:600,color:"rgba(255,255,255,0.6)",textTransform:"uppercase",letterSpacing:"0.05em"};return o?S?e.jsx("div",{style:a,children:e.jsx("div",{style:l,children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"✅"}),e.jsx("h2",{style:{color:"#e2e8f0",marginBottom:"8px"},children:"Invitation Accepted!"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"Your account has been set up. Redirecting to login..."})]})})}):e.jsx("div",{style:a,children:e.jsxs("div",{style:l,children:[e.jsxs("div",{style:{textAlign:"center",marginBottom:"32px"},children:[e.jsx("div",{style:{fontSize:"36px",marginBottom:"12px"},children:"🏛️"}),e.jsx("h1",{style:{color:"#e2e8f0",fontSize:"22px",fontWeight:700,marginBottom:"8px"},children:"Join Vienna OS Workspace"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"You've been invited to collaborate on AI governance."})]}),e.jsxs("form",{onSubmit:w,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:c,children:["Your Name ",e.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"(optional)"})]}),e.jsx("input",{type:"text",placeholder:"Jane Smith",value:p,onChange:t=>b(t.target.value),style:d})]}),e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsxs("label",{style:c,children:["Password ",e.jsx("span",{style:{color:"rgba(255,255,255,0.3)"},children:"(optional — skip if using SSO)"})]}),e.jsx("input",{type:"password",placeholder:"Choose a password",value:i,onChange:t=>v(t.target.value),style:d})]}),i&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:c,children:"Confirm Password"}),e.jsx("input",{type:"password",placeholder:"Confirm password",value:x,onChange:t=>j(t.target.value),style:d})]}),u&&e.jsx("div",{style:{marginBottom:"16px",padding:"10px 14px",background:"rgba(248,113,113,0.08)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"4px",color:"#ef4444",fontSize:"13px"},children:u}),e.jsx("button",{type:"submit",disabled:r,style:{width:"100%",padding:"12px",background:r?"rgba(99,102,241,0.5)":"#6366f1",color:"#fff",border:"none",borderRadius:"4px",fontSize:"14px",fontWeight:600,cursor:r?"not-allowed":"pointer",fontFamily:"inherit",transition:"background 0.15s"},children:r?"Setting up account...":"Accept Invitation"})]}),e.jsx("p",{style:{marginTop:"20px",textAlign:"center",fontSize:"12px",color:"rgba(255,255,255,0.3)"},children:"By accepting, you agree to Vienna OS terms of service"})]})}):e.jsx("div",{style:a,children:e.jsx("div",{style:l,children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:"❌"}),e.jsx("h2",{style:{color:"#e2e8f0",marginBottom:"8px"},children:"Invalid Link"}),e.jsx("p",{style:{color:"rgba(255,255,255,0.5)",fontSize:"14px"},children:"This invitation link is missing a token. Please use the link from your email."})]})})})}export{C as default}; -//# sourceMappingURL=AcceptInvitePage-DbpinmWd.js.map diff --git a/apps/console-proxy/public/assets/ActionTypesPage-mg5oQEeP.js b/apps/console-proxy/public/assets/ActionTypesPage-mg5oQEeP.js deleted file mode 100644 index 7b7da04a..00000000 --- a/apps/console-proxy/public/assets/ActionTypesPage-mg5oQEeP.js +++ /dev/null @@ -1,8 +0,0 @@ -import{a as v,r as l,e as M,j as e}from"./index-D_7YXFSJ.js";const j={list:t=>v.get("/action-types",t),get:t=>v.get(`/action-types/${t}`),create:t=>v.post("/action-types",t),update:(t,s)=>v.put(`/action-types/${t}`,s),delete:t=>v.delete(`/action-types/${t}`),usage:(t,s)=>v.get(`/action-types/${t}/usage`,s),validate:(t,s)=>v.post("/action-types/validate",{action_type:t,payload:s}),categories:()=>v.get("/action-types/categories")},N=[{value:"T0",label:"T0 — Auto-approve",color:"#10b981",description:"Low risk. Executes automatically without human approval."},{value:"T1",label:"T1 — Review Required",color:"#f59e0b",description:"Medium risk. Requires operator review before execution."},{value:"T2",label:"T2 — Multi-Party",color:"#ef4444",description:"High risk. Requires multiple approvals before execution."}],F=["activity","alert-triangle","archive","arrow-right","bell","book","briefcase","calendar","check-circle","cloud","code","cpu","credit-card","database","dollar-sign","download","edit","external-link","eye","file","file-text","flag","folder","git-branch","globe","hard-drive","heart","home","image","inbox","key","layers","layout","link","lock","mail","map-pin","message-circle","monitor","package","percent","phone","play","plus-circle","power","printer","refresh-cw","rocket","save","search","send","server","settings","shield","shopping-cart","shuffle","star","terminal","thumbs-up","tool","trash","trending-up","truck","umbrella","unlock","upload","upload-cloud","user","users","wifi","zap"],$=["#3b82f6","#8b5cf6","#06b6d4","#10b981","#f59e0b","#ef4444","#ec4899","#6366f1","#f97316","#64748b","#eab308","#14b8a6","#a855f7","#f43f5e","#0ea5e9"],G=["all","infrastructure","financial","healthcare","communication","integration","data","custom"],q={activity:"📊","alert-triangle":"⚠️",archive:"📦","arrow-right":"➡️",bell:"🔔",book:"📖",briefcase:"💼",calendar:"📅","check-circle":"✅",cloud:"☁️",code:"💻",cpu:"🖥️","credit-card":"💳",database:"🗄️","dollar-sign":"💰",download:"⬇️",edit:"✏️","external-link":"🔗",eye:"👁️",file:"📄","file-text":"📝",flag:"🚩",folder:"📁","git-branch":"🔀",globe:"🌐","hard-drive":"💾",heart:"❤️",home:"🏠",image:"🖼️",inbox:"📥",key:"🔑",layers:"📚",layout:"📐",link:"🔗",lock:"🔒",mail:"✉️","map-pin":"📍","message-circle":"💬",monitor:"🖥️",package:"📦",percent:"💹",phone:"📞",play:"▶️","plus-circle":"➕",power:"⚡",printer:"🖨️","refresh-cw":"🔄",rocket:"🚀",save:"💾",search:"🔍",send:"📤",server:"🖧",settings:"⚙️",shield:"🛡️","shopping-cart":"🛒",shuffle:"🔀",star:"⭐",terminal:"🖥️","thumbs-up":"👍",tool:"🔧",trash:"🗑️","trending-up":"📈",truck:"🚚",umbrella:"☂️",unlock:"🔓",upload:"⬆️","upload-cloud":"☁️",user:"👤",users:"👥",wifi:"📶",zap:"⚡"};function O(t){return q[t]||"📊"}const r={page:{maxWidth:"1200px",margin:"0 auto"},header:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},title:{fontSize:"24px",fontWeight:700,color:"var(--text-primary)",margin:0},subtitle:{fontSize:"14px",color:"var(--text-secondary)",marginTop:"4px"},registerBtn:{padding:"10px 20px",background:"linear-gradient(135deg, #f59e0b, #6366f1)",color:"#fff",border:"none",borderRadius:"8px",fontSize:"14px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},filterBar:{display:"flex",gap:"8px",marginBottom:"20px",flexWrap:"wrap"},filterBtn:t=>({padding:"6px 14px",background:t?"rgba(124, 58, 237, 0.2)":"rgba(255, 255, 255, 0.04)",color:t?"#f59e0b":"#9ca3af",border:t?"1px solid rgba(124, 58, 237, 0.4)":"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"6px",fontSize:"13px",fontWeight:t?600:400,cursor:"pointer",textTransform:"capitalize"}),grid:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"16px"},card:{background:"#12131a",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"8px",padding:"20px",cursor:"pointer",transition:"all 150ms ease",position:"relative"},cardHover:{borderColor:"rgba(124, 58, 237, 0.3)",background:"#1a1b26"},cardHeader:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"12px"},cardIcon:t=>({width:"40px",height:"40px",borderRadius:"8px",background:`${t}20`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"20px",flexShrink:0}),cardTitle:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",margin:0},cardSlug:{fontSize:"12px",color:"var(--text-muted)",fontFamily:"monospace"},cardDescription:{fontSize:"13px",color:"var(--text-secondary)",marginBottom:"14px",lineHeight:"1.4",minHeight:"36px"},cardFooter:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},badge:(t,s)=>({padding:"2px 8px",background:t,color:s,borderRadius:"4px",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px"}),lockIcon:{position:"absolute",top:"12px",right:"12px",fontSize:"14px",color:"var(--text-muted)",title:"Built-in (cannot be deleted)"},usageCount:{fontSize:"12px",color:"var(--text-muted)"},overlay:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"20px"},modal:{background:"#0a0a0f",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",width:"100%",maxWidth:"640px",maxHeight:"90vh",overflow:"auto",padding:"28px"},modalTitle:{fontSize:"20px",fontWeight:700,color:"var(--text-primary)",marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center"},formGroup:{marginBottom:"18px"},label:{display:"block",fontSize:"13px",fontWeight:600,color:"#d1d5db",marginBottom:"6px"},input:{width:"100%",padding:"10px 12px",background:"#12131a",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"14px",outline:"none",boxSizing:"border-box"},textarea:{width:"100%",padding:"10px 12px",background:"#12131a",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"14px",outline:"none",resize:"vertical",minHeight:"80px",fontFamily:"monospace",boxSizing:"border-box"},select:{width:"100%",padding:"10px 12px",background:"#12131a",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"14px",outline:"none",boxSizing:"border-box"},row:{display:"flex",gap:"12px"},halfCol:{flex:1},riskSelector:{display:"flex",gap:"8px"},riskOption:(t,s)=>({flex:1,padding:"10px",background:t?`${s}15`:"#1f2937",border:t?`2px solid ${s}`:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"8px",cursor:"pointer",textAlign:"center"}),riskLabel:t=>({fontSize:"14px",fontWeight:700,color:t}),riskDesc:{fontSize:"11px",color:"var(--text-secondary)",marginTop:"4px"},iconGrid:{display:"flex",flexWrap:"wrap",gap:"4px",maxHeight:"120px",overflow:"auto",padding:"8px",background:"#12131a",borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.1)"},iconBtn:t=>({width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"4px",border:t?"2px solid #f59e0b":"1px solid transparent",background:t?"rgba(124, 58, 237, 0.2)":"transparent",cursor:"pointer",fontSize:"16px"}),colorGrid:{display:"flex",gap:"6px",flexWrap:"wrap"},colorBtn:(t,s)=>({width:"28px",height:"28px",borderRadius:"6px",background:t,border:s?"2px solid #fff":"2px solid transparent",cursor:"pointer",outline:s?`2px solid ${t}`:"none",outlineOffset:"2px"}),actions:{display:"flex",justifyContent:"flex-end",gap:"10px",marginTop:"24px",paddingTop:"18px",borderTop:"1px solid rgba(255, 255, 255, 0.06)"},cancelBtn:{padding:"10px 20px",background:"transparent",color:"var(--text-secondary)",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"6px",fontSize:"14px",cursor:"pointer"},submitBtn:{padding:"10px 24px",background:"linear-gradient(135deg, #f59e0b, #6366f1)",color:"#fff",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:600,cursor:"pointer"},deleteBtn:{padding:"10px 20px",background:"rgba(239, 68, 68, 0.1)",color:"#ef4444",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"6px",fontSize:"14px",cursor:"pointer",marginRight:"auto"},toggleSwitch:t=>({width:"40px",height:"22px",borderRadius:"11px",background:t?"#f59e0b":"#4b5563",position:"relative",cursor:"pointer",border:"none",transition:"background 150ms",flexShrink:0}),toggleKnob:t=>({width:"18px",height:"18px",borderRadius:"50%",background:"#fff",position:"absolute",top:"2px",left:t?"20px":"2px",transition:"left 150ms"}),error:{padding:"12px 16px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"6px",color:"#fca5a5",fontSize:"13px",marginBottom:"16px"},emptyState:{textAlign:"center",padding:"60px 20px",color:"var(--text-muted)"},detailPanel:{background:"#0a0a0f",border:"1px solid rgba(255, 255, 255, 0.1)",borderRadius:"12px",padding:"24px",marginBottom:"20px"},detailHeader:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"20px"},detailSection:{marginBottom:"16px"},sectionLabel:{fontSize:"11px",fontWeight:600,color:"var(--text-muted)",textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:"8px"},schemaBlock:{background:"#12131a",border:"1px solid rgba(255, 255, 255, 0.06)",borderRadius:"6px",padding:"12px",fontFamily:"monospace",fontSize:"12px",color:"#d1d5db",whiteSpace:"pre-wrap",overflow:"auto",maxHeight:"200px"},usageBar:{display:"flex",gap:"4px",alignItems:"flex-end",height:"40px"},usageBarItem:(t,s)=>({width:"24px",height:`${Math.max(t,2)}px`,background:s,borderRadius:"2px 2px 0 0",opacity:t>0?1:.2})};function Y(){const[t,s]=l.useState([]),[_,R]=l.useState([]),[i,p]=l.useState(!0),[w,d]=l.useState(null),[h,S]=l.useState("all"),[b,m]=l.useState(null),{isMobile:A}=M(),[B,C]=l.useState(!1),[I,z]=l.useState(null),[n,f]=l.useState(null),[k,E]=l.useState(!1),u=l.useCallback(async()=>{try{p(!0);const[a,x]=await Promise.all([j.list({category:h==="all"?void 0:h}),j.categories()]);s(a||[]),R(x||[]),d(null)}catch(a){d(a instanceof Error?a.message:"Failed to load action types")}finally{p(!1)}},[h]);l.useEffect(()=>{u()},[u]);const P=async a=>{if((n==null?void 0:n.id)===a.id){f(null);return}try{E(!0);const x=await j.get(a.id);f(x)}catch{f({...a,usage_count:a.usage_count||0,usage_last_7_days:[]})}finally{E(!1)}},D=async(a,x)=>{x.stopPropagation();try{if(await j.update(a.id,{enabled:!a.enabled}),await u(),(n==null?void 0:n.id)===a.id){const g=await j.get(a.id);f(g)}}catch(g){d(g instanceof Error?g.message:"Failed to toggle")}},W=async a=>{if(confirm("Delete this action type? This cannot be undone."))try{await j.delete(a),f(null),await u()}catch(x){d(x instanceof Error?x.message:"Failed to delete")}},L=a=>{switch(a){case"T0":return"#10b981";case"T1":return"#f59e0b";case"T2":return"#ef4444";default:return"#6b7280"}},y=a=>{switch(a){case"T0":return"rgba(16, 185, 129, 0.15)";case"T1":return"rgba(245, 158, 11, 0.15)";case"T2":return"rgba(239, 68, 68, 0.15)";default:return"rgba(107, 114, 128, 0.15)"}};return e.jsxs("div",{style:r.page,children:[e.jsxs("div",{style:r.header,children:[e.jsxs("div",{children:[e.jsx("h1",{style:r.title,children:"⚡ Action Type Registry"}),e.jsxs("p",{style:r.subtitle,children:[t.length," action type",t.length!==1?"s":""," registered",_.length>0&&` across ${_.length} categories`]})]}),e.jsx("button",{style:r.registerBtn,onClick:()=>{z(null),C(!0)},onMouseEnter:a=>{a.currentTarget.style.opacity="0.9"},onMouseLeave:a=>{a.currentTarget.style.opacity="1"},children:"➕ Register New Action Type"})]}),w&&e.jsxs("div",{style:r.error,children:[w,e.jsx("button",{onClick:()=>d(null),style:{background:"none",border:"none",color:"#fca5a5",marginLeft:"12px",cursor:"pointer",textDecoration:"underline"},children:"dismiss"})]}),e.jsx("div",{style:r.filterBar,children:G.map(a=>e.jsx("button",{style:r.filterBtn(h===a),onClick:()=>S(a),children:a},a))}),n&&e.jsx(J,{type:n,loading:k,onEdit:()=>{z(n),C(!0)},onDelete:()=>W(n.id),onClose:()=>f(null),riskColor:L,riskBg:y}),i?e.jsx("div",{style:r.emptyState,children:e.jsx("p",{style:{fontSize:"16px"},children:"Loading action types..."})}):t.length===0?e.jsxs("div",{style:r.emptyState,children:[e.jsx("p",{style:{fontSize:"40px",marginBottom:"12px"},children:"⚡"}),e.jsx("p",{style:{fontSize:"16px",color:"var(--text-secondary)"},children:"No action types found"}),e.jsx("p",{style:{fontSize:"13px",marginTop:"4px"},children:"Register your first custom action type to get started"})]}):e.jsx("div",{style:r.grid,children:t.map(a=>{const x=b===a.id,g=(n==null?void 0:n.id)===a.id;return e.jsxs("div",{style:{...r.card,...x||g?r.cardHover:{},...g?{borderColor:"rgba(124, 58, 237, 0.5)"}:{},opacity:a.enabled?1:.5},onMouseEnter:()=>m(a.id),onMouseLeave:()=>m(null),onClick:()=>P(a),children:[a.is_builtin&&e.jsx("span",{style:r.lockIcon,title:"Built-in (protected)",children:"🔒"}),e.jsxs("div",{style:r.cardHeader,children:[e.jsx("div",{style:r.cardIcon(a.color),children:O(a.icon)}),e.jsxs("div",{children:[e.jsx("h3",{style:r.cardTitle,children:a.display_name}),e.jsx("span",{style:r.cardSlug,children:a.action_type})]})]}),e.jsx("p",{style:r.cardDescription,children:a.description||"No description"}),e.jsxs("div",{style:r.cardFooter,children:[e.jsxs("div",{style:{display:"flex",gap:"6px",alignItems:"center"},children:[e.jsx("span",{style:r.badge(`${a.color}20`,a.color),children:a.category}),e.jsx("span",{style:r.badge(y(a.default_risk_tier),L(a.default_risk_tier)),children:a.default_risk_tier})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("span",{style:r.usageCount,children:[a.usage_count||0," uses"]}),e.jsx("button",{style:r.toggleSwitch(a.enabled),onClick:o=>D(a,o),title:a.enabled?"Disable":"Enable",children:e.jsx("div",{style:r.toggleKnob(a.enabled)})})]})]})]},a.id)})}),B&&e.jsx(K,{editingType:I,onClose:()=>{C(!1),z(null)},onSaved:()=>{C(!1),z(null),u(),f(null)},onError:d})]})}function J({type:t,loading:s,onEdit:_,onDelete:R,onClose:i,riskColor:p,riskBg:w}){var S;const{isMobile:d}=M();if(s)return e.jsx("div",{style:r.detailPanel,children:e.jsx("p",{style:{color:"var(--text-secondary)"},children:"Loading details..."})});const h=Math.max(...((S=t.usage_last_7_days)==null?void 0:S.map(b=>b.count))||[0],1);return e.jsxs("div",{style:r.detailPanel,children:[e.jsxs("div",{style:r.detailHeader,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"14px"},children:[e.jsx("div",{style:r.cardIcon(t.color),children:e.jsx("span",{style:{fontSize:"24px"},children:O(t.icon)})}),e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,color:"var(--text-primary)",fontSize:"18px"},children:t.display_name}),e.jsx("span",{style:{fontFamily:"monospace",fontSize:"13px",color:"var(--text-muted)"},children:t.action_type})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{style:{...r.cancelBtn,fontSize:"12px",padding:"6px 12px"},onClick:_,children:"✏️ Edit"}),!t.is_builtin&&e.jsx("button",{style:{...r.deleteBtn,fontSize:"12px",padding:"6px 12px",marginRight:0},onClick:R,children:"🗑️ Delete"}),e.jsx("button",{style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"18px"},onClick:i,children:"✕"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:d?"1fr":"1fr 1fr",gap:"20px"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:r.detailSection,children:[e.jsx("div",{style:r.sectionLabel,children:"Description"}),e.jsx("p",{style:{margin:0,color:"#d1d5db",fontSize:"13px"},children:t.description||"No description"})]}),e.jsxs("div",{style:r.detailSection,children:[e.jsx("div",{style:r.sectionLabel,children:"Properties"}),e.jsxs("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[e.jsx("span",{style:r.badge(`${t.color}20`,t.color),children:t.category}),e.jsx("span",{style:r.badge(w(t.default_risk_tier),p(t.default_risk_tier)),children:t.default_risk_tier}),t.is_builtin&&e.jsx("span",{style:r.badge("rgba(107,114,128,0.15)","#9ca3af"),children:"🔒 built-in"}),e.jsx("span",{style:r.badge(t.enabled?"rgba(16,185,129,0.15)":"rgba(239,68,68,0.15)",t.enabled?"#10b981":"#ef4444"),children:t.enabled?"enabled":"disabled"})]})]}),e.jsxs("div",{style:r.detailSection,children:[e.jsx("div",{style:r.sectionLabel,children:"Payload Schema"}),e.jsx("div",{style:r.schemaBlock,children:Object.keys(t.payload_schema||{}).length>0?JSON.stringify(t.payload_schema,null,2):"(no schema defined — accepts any payload)"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:r.detailSection,children:[e.jsxs("div",{style:r.sectionLabel,children:["Usage — Last 7 Days (",t.usage_count," total)"]}),t.usage_last_7_days&&t.usage_last_7_days.length>0?e.jsx("div",{style:r.usageBar,children:t.usage_last_7_days.map((b,m)=>e.jsx("div",{style:r.usageBarItem(b.count/h*40,t.color),title:`${b.day}: ${b.count} uses`},m))}):e.jsx("p",{style:{color:"var(--text-muted)",fontSize:"12px",margin:0},children:"No usage recorded"})]}),e.jsxs("div",{style:r.detailSection,children:[e.jsx("div",{style:r.sectionLabel,children:"Metadata"}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-muted)",lineHeight:"1.8"},children:[e.jsxs("div",{children:["Created by: ",e.jsx("span",{style:{color:"var(--text-secondary)"},children:t.created_by})]}),e.jsxs("div",{children:["Created: ",e.jsx("span",{style:{color:"var(--text-secondary)"},children:new Date(t.created_at).toLocaleString()})]}),e.jsxs("div",{children:["Updated: ",e.jsx("span",{style:{color:"var(--text-secondary)"},children:new Date(t.updated_at).toLocaleString()})]})]})]})]})]})]})}function K({editingType:t,onClose:s,onSaved:_,onError:R}){const i=!!t,[p,w]=l.useState((t==null?void 0:t.display_name)||""),[d,h]=l.useState((t==null?void 0:t.action_type)||""),[S,b]=l.useState(i),[m,A]=l.useState((t==null?void 0:t.description)||""),[B,C]=l.useState((t==null?void 0:t.category)||"custom"),[I,z]=l.useState((t==null?void 0:t.default_risk_tier)||"T1"),[n,f]=l.useState(t!=null&&t.payload_schema&&Object.keys(t.payload_schema).length>0?JSON.stringify(t.payload_schema,null,2):""),[k,E]=l.useState((t==null?void 0:t.icon)||"activity"),[u,P]=l.useState((t==null?void 0:t.color)||"#3b82f6"),[D,W]=l.useState(!1),[L,y]=l.useState(null),[a,x]=l.useState(!1);l.useEffect(()=>{if(!S&&!i){const o=p.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");h(o)}},[p,S,i]);const g=async()=>{if(y(null),!p.trim()){y("Display name is required");return}if(!d.trim()){y("Action type identifier is required");return}let o={};if(n.trim())try{o=JSON.parse(n)}catch{y("Invalid JSON in payload schema");return}W(!0);try{if(i&&t){const c={};t.is_builtin||(c.display_name=p,c.description=m,c.category=B,c.payload_schema=o,c.default_risk_tier=I,c.icon=k,c.color=u),await j.update(t.id,c)}else{const c={action_type:d,display_name:p,description:m||void 0,category:B,payload_schema:o,default_risk_tier:I,icon:k,color:u};await j.create(c)}_()}catch(c){const H=(c==null?void 0:c.message)||"Failed to save";y(H),R(H)}finally{W(!1)}};return e.jsx("div",{style:r.overlay,onClick:s,children:e.jsxs("div",{style:r.modal,onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{style:r.modalTitle,children:[e.jsx("span",{children:i?"✏️ Edit Action Type":"➕ Register New Action Type"}),e.jsx("button",{style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:"20px"},onClick:s,children:"✕"})]}),L&&e.jsx("div",{style:r.error,children:L}),i&&(t==null?void 0:t.is_builtin)&&e.jsx("div",{style:{...r.error,background:"rgba(245, 158, 11, 0.1)",borderColor:"rgba(245, 158, 11, 0.2)",color:"#fcd34d"},children:"🔒 This is a built-in action type. Only the enabled toggle can be changed."}),e.jsxs("div",{style:r.formGroup,children:[e.jsx("label",{style:r.label,children:"Display Name"}),e.jsx("input",{style:r.input,value:p,onChange:o=>w(o.target.value),placeholder:"e.g., Wire Transfer",disabled:i&&(t==null?void 0:t.is_builtin)})]}),e.jsxs("div",{style:r.formGroup,children:[e.jsxs("label",{style:r.label,children:["Action Type Identifier",e.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",marginLeft:"8px"},children:"(auto-generated, editable)"})]}),e.jsx("input",{style:{...r.input,fontFamily:"monospace"},value:d,onChange:o=>{h(o.target.value),b(!0)},placeholder:"e.g., wire_transfer",disabled:i})]}),e.jsxs("div",{style:r.formGroup,children:[e.jsx("label",{style:r.label,children:"Description"}),e.jsx("textarea",{style:{...r.textarea,fontFamily:"inherit"},value:m,onChange:o=>A(o.target.value),placeholder:"What does this action do?",disabled:i&&(t==null?void 0:t.is_builtin)})]}),e.jsxs("div",{style:r.row,children:[e.jsx("div",{style:r.halfCol,children:e.jsxs("div",{style:r.formGroup,children:[e.jsx("label",{style:r.label,children:"Category"}),e.jsxs("select",{style:r.select,value:B,onChange:o=>C(o.target.value),disabled:i&&(t==null?void 0:t.is_builtin),children:[e.jsx("option",{value:"infrastructure",children:"Infrastructure"}),e.jsx("option",{value:"financial",children:"Financial"}),e.jsx("option",{value:"healthcare",children:"Healthcare"}),e.jsx("option",{value:"communication",children:"Communication"}),e.jsx("option",{value:"integration",children:"Integration"}),e.jsx("option",{value:"data",children:"Data"}),e.jsx("option",{value:"custom",children:"Custom"})]})]})}),e.jsx("div",{style:r.halfCol,children:e.jsxs("div",{style:r.formGroup,children:[e.jsx("label",{style:r.label,children:"Default Risk Tier"}),e.jsx("div",{style:r.riskSelector,children:N.map(o=>e.jsxs("div",{style:r.riskOption(I===o.value,o.color),onClick:()=>{i&&(t!=null&&t.is_builtin)||z(o.value)},children:[e.jsx("div",{style:r.riskLabel(o.color),children:o.value}),e.jsx("div",{style:r.riskDesc,children:o.value==="T0"?"Auto":o.value==="T1"?"Review":"Multi"})]},o.value))})]})})]}),e.jsxs("div",{style:r.formGroup,children:[e.jsxs("label",{style:r.label,children:["Payload Schema (JSON)",e.jsx("span",{style:{fontWeight:400,color:"var(--text-muted)",marginLeft:"8px"},children:"optional — validates incoming payloads"})]}),e.jsx("textarea",{style:r.textarea,value:n,onChange:o=>f(o.target.value),placeholder:`{ - "type": "object", - "required": ["target"], - "properties": { - "target": { "type": "string" } - } -}`,rows:6,disabled:i&&(t==null?void 0:t.is_builtin)})]}),e.jsxs("div",{style:r.row,children:[e.jsx("div",{style:r.halfCol,children:e.jsxs("div",{style:r.formGroup,children:[e.jsxs("label",{style:r.label,children:["Icon",e.jsx("button",{style:{background:"none",border:"none",color:"#f59e0b",cursor:"pointer",marginLeft:"8px",fontSize:"12px"},onClick:()=>x(!a),children:a?"hide picker":"show picker"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{...r.cardIcon(u),width:"36px",height:"36px"},children:O(k)}),e.jsx("input",{style:{...r.input,flex:1},value:k,onChange:o=>E(o.target.value),disabled:i&&(t==null?void 0:t.is_builtin)})]}),a&&e.jsx("div",{style:{...r.iconGrid,marginTop:"8px"},children:F.map(o=>e.jsx("button",{style:r.iconBtn(k===o),onClick:()=>{i&&(t!=null&&t.is_builtin)||E(o)},title:o,children:O(o)},o))})]})}),e.jsx("div",{style:r.halfCol,children:e.jsxs("div",{style:r.formGroup,children:[e.jsx("label",{style:r.label,children:"Color"}),e.jsx("div",{style:r.colorGrid,children:$.map(o=>e.jsx("button",{style:r.colorBtn(o,u===o),onClick:()=>{i&&(t!=null&&t.is_builtin)||P(o)}},o))}),e.jsx("input",{style:{...r.input,marginTop:"8px",width:"120px"},value:u,onChange:o=>P(o.target.value),placeholder:"#3b82f6",disabled:i&&(t==null?void 0:t.is_builtin)})]})})]}),e.jsxs("div",{style:r.actions,children:[e.jsx("button",{style:r.cancelBtn,onClick:s,children:"Cancel"}),e.jsx("button",{style:{...r.submitBtn,opacity:D?.6:1},onClick:g,disabled:D,children:D?"Saving...":i?"Save Changes":"Register Action Type"})]})]})})}export{Y as ActionTypesPage}; -//# sourceMappingURL=ActionTypesPage-mg5oQEeP.js.map diff --git a/apps/console-proxy/public/assets/ActivityFeedPage-Cm83sZAp.js b/apps/console-proxy/public/assets/ActivityFeedPage-Vk-UPy1N.js similarity index 99% rename from apps/console-proxy/public/assets/ActivityFeedPage-Cm83sZAp.js rename to apps/console-proxy/public/assets/ActivityFeedPage-Vk-UPy1N.js index d5095e46..a36f5318 100644 --- a/apps/console-proxy/public/assets/ActivityFeedPage-Cm83sZAp.js +++ b/apps/console-proxy/public/assets/ActivityFeedPage-Vk-UPy1N.js @@ -1,2 +1,2 @@ -import{r as y,j as e}from"./index-D_7YXFSJ.js";const F={completed:"#10b981",failed:"#ef4444",pending:"#f59e0b",pending_approval:"#f59e0b"},D={completed:"rgba(16, 185, 129, 0.12)",failed:"rgba(239, 68, 68, 0.12)",pending:"rgba(245, 158, 11, 0.12)",pending_approval:"rgba(245, 158, 11, 0.12)"},v=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6","#f97316","#a855f7"];function W(l){const p=new Date(l),a=(new Date().getTime()-p.getTime())/1e3;return a<60?"Just now":a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:p.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"numeric"})+", "+p.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function B({completed:l,failed:p,pending:r}){const a=l+p+r||1,d=70,s=90,o=90,g=14,f=2*Math.PI*d,h=l/a,k=p/a,S=r/a,c=h*f,x=k*f,m=S*f,b=0,j=-c,w=-(c+x);return e.jsxs("svg",{width:"180",height:"180",viewBox:"0 0 180 180",children:[e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:g}),l>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#10b981",strokeWidth:g,strokeDasharray:`${c} ${f-c}`,strokeDashoffset:b,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),p>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#ef4444",strokeWidth:g,strokeDasharray:`${x} ${f-x}`,strokeDashoffset:j,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),r>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#f59e0b",strokeWidth:g,strokeDasharray:`${m} ${f-m}`,strokeDashoffset:w,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),e.jsx("text",{x:s,y:o-6,textAnchor:"middle",fill:"#10b981",fontSize:"28",fontWeight:"700",fontFamily:"var(--font-mono, monospace)",children:l}),e.jsx("text",{x:s,y:o+14,textAnchor:"middle",fill:"rgba(255,255,255,0.5)",fontSize:"11",fontFamily:"var(--font-mono, monospace)",style:{textTransform:"uppercase",letterSpacing:"0.05em"},children:"Completed"})]})}function U(){var T,z,A,C;const[l,p]=y.useState([]),[r,a]=y.useState(null),[d,s]=y.useState("24h"),[o,g]=y.useState(!0),[f,h]=y.useState(null),[k,S]=y.useState(new Date),c=y.useCallback(async()=>{try{const[n,i]=await Promise.all([fetch("/api/v1/activity/feed?limit=50",{credentials:"include"}).then(u=>u.json()),fetch(`/api/v1/activity/summary?period=${d}`,{credentials:"include"}).then(u=>u.json())]);n.success?(p(n.data||[]),h(null)):h(n.error||"Failed to load activity feed"),i.success&&a(i.data),S(new Date)}catch(n){console.error("[ActivityFeed] Fetch error:",n),h(n instanceof Error?n.message:"Network error loading activity feed")}finally{g(!1)}},[d]);y.useEffect(()=>{g(!0),c();const n=setInterval(c,8e3);return()=>clearInterval(n)},[c]);const x=((T=r==null?void 0:r.actions_by_status)==null?void 0:T.completed)||0,m=((z=r==null?void 0:r.actions_by_status)==null?void 0:z.failed)||0,b=(((A=r==null?void 0:r.actions_by_status)==null?void 0:A.pending)||0)+(((C=r==null?void 0:r.actions_by_status)==null?void 0:C.pending_approval)||0),j=(r==null?void 0:r.total_actions)||0,w=j>0?Math.round(x/j*100):0,t={page:{padding:"0 24px 40px",maxWidth:1200,margin:"0 auto"},header:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",padding:"24px 0 20px"},title:{fontSize:22,fontWeight:600,color:"var(--text-primary, #e2e8f0)",margin:0,lineHeight:1.3},subtitle:{fontSize:13,color:"var(--text-tertiary, rgba(255,255,255,0.45))",marginTop:4},headerRight:{display:"flex",alignItems:"center",gap:12},timestamp:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)"},refreshBtn:{fontSize:12,padding:"6px 14px",borderRadius:6,background:"rgba(255,255,255,0.06)",color:"var(--text-secondary, rgba(255,255,255,0.7))",border:"1px solid rgba(255,255,255,0.08)",cursor:"pointer",display:"flex",alignItems:"center",gap:6},kpiRow:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},kpiCard:n=>({background:"var(--surface-secondary, #12131a)",borderRadius:8,padding:"16px 18px",borderLeft:`3px solid ${n}`}),kpiLabel:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.45))",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:6,fontFamily:"var(--font-mono, monospace)"},kpiValue:n=>({fontSize:26,fontWeight:700,color:n,lineHeight:1,fontFamily:"var(--font-mono, monospace)"}),kpiSub:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",marginTop:4},filterRow:{display:"flex",alignItems:"center",gap:8,marginBottom:20},filterLabel:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",textTransform:"uppercase",letterSpacing:"0.04em",marginRight:4},filterBtn:n=>({fontSize:12,padding:"5px 14px",borderRadius:5,cursor:"pointer",fontFamily:"var(--font-mono, monospace)",fontWeight:n?600:400,background:n?"rgba(255,255,255,0.12)":"rgba(255,255,255,0.04)",color:n?"var(--text-primary, #e2e8f0)":"var(--text-tertiary, rgba(255,255,255,0.5))",border:n?"1px solid rgba(255,255,255,0.15)":"1px solid rgba(255,255,255,0.06)",transition:"all 0.15s ease"}),columns:{display:"grid",gridTemplateColumns:"1fr 340px",gap:16,alignItems:"start"},panel:{background:"var(--surface-secondary, #12131a)",borderRadius:10,overflow:"hidden"},panelHeader:{padding:"14px 18px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid rgba(255,255,255,0.06)"},panelTitle:{fontSize:14,fontWeight:600,color:"var(--text-primary, #e2e8f0)"},panelAction:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",cursor:"pointer",fontFamily:"var(--font-mono, monospace)"},eventRow:{padding:"12px 18px",display:"flex",alignItems:"flex-start",gap:12,borderBottom:"1px solid rgba(255,255,255,0.04)",transition:"background 0.1s ease",cursor:"default"},eventAvatar:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,flexShrink:0,background:"rgba(255,255,255,0.06)"},eventBody:{flex:1,minWidth:0},eventTopLine:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},eventActor:{fontSize:13,fontWeight:600,color:"var(--text-primary, #e2e8f0)"},badge:n=>({fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:4,color:F[n]||"#94a3b8",background:D[n]||"rgba(255,255,255,0.06)",textTransform:"uppercase",letterSpacing:"0.03em",fontFamily:"var(--font-mono, monospace)"}),eventTime:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontFamily:"var(--font-mono, monospace)"},eventAction:{fontSize:12,color:"var(--text-secondary, rgba(255,255,255,0.6))",marginTop:2},viewLink:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer",flexShrink:0,alignSelf:"center",textDecoration:"none"},agentRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",borderBottom:"1px solid rgba(255,255,255,0.04)"},agentLeft:{display:"flex",alignItems:"center",gap:10},agentRank:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontFamily:"var(--font-mono, monospace)",width:20,textAlign:"right"},agentIcon:{width:26,height:26,borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,background:"rgba(255,255,255,0.06)"},agentName:{fontSize:13,fontWeight:500,color:"var(--text-primary, #e2e8f0)"},agentActions:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer"},donutCenter:{display:"flex",justifyContent:"center",padding:"20px 0 10px"},legendRow:{display:"flex",justifyContent:"center",gap:16,padding:"0 18px 14px",flexWrap:"wrap"},legendItem:n=>({display:"flex",alignItems:"center",gap:5,fontSize:11,color:"var(--text-secondary, rgba(255,255,255,0.6))",fontFamily:"var(--font-mono, monospace)"}),legendDot:n=>({width:7,height:7,borderRadius:"50%",background:n,flexShrink:0}),compactAgentRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid rgba(255,255,255,0.04)"},spinner:{display:"flex",justifyContent:"center",alignItems:"center",padding:"60px 0",color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontSize:13},empty:{padding:"40px 18px",textAlign:"center",color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontSize:13}};return e.jsxs("div",{style:t.page,children:[f&&e.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",padding:"12px 16px",borderRadius:"8px",marginBottom:"16px",display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{fontSize:"14px",color:"#ef4444"},children:"⚠️"}),e.jsx("span",{style:{fontSize:"13px",color:"#fca5a5",flex:1},children:f}),e.jsx("button",{onClick:()=>{g(!0),h(null),c()},style:{background:"rgba(239, 68, 68, 0.2)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#fca5a5",padding:"6px 12px",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:600},children:"Retry"})]}),e.jsxs("div",{style:t.header,children:[e.jsxs("div",{children:[e.jsx("h1",{style:t.title,children:"Activity Feed"}),e.jsx("div",{style:t.subtitle,children:"Real-time view of all agent activity in your organization"})]}),e.jsxs("div",{style:t.headerRight,children:[e.jsxs("span",{style:t.timestamp,children:["Updated ",k.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})]}),e.jsx("button",{style:t.refreshBtn,onClick:()=>{g(!0),c()},children:"↻ Refresh"})]})]}),e.jsxs("div",{style:t.kpiRow,children:[e.jsxs("div",{style:t.kpiCard("#6366f1"),children:[e.jsx("div",{style:t.kpiLabel,children:"Total Actions"}),e.jsx("div",{style:t.kpiValue("#818cf8"),children:j}),e.jsxs("div",{style:t.kpiSub,children:["Last ",d]})]}),e.jsxs("div",{style:t.kpiCard("#10b981"),children:[e.jsx("div",{style:t.kpiLabel,children:"Completed"}),e.jsx("div",{style:t.kpiValue("#10b981"),children:x}),e.jsxs("div",{style:t.kpiSub,children:[w,"% success rate"]})]}),e.jsxs("div",{style:t.kpiCard("#ef4444"),children:[e.jsx("div",{style:t.kpiLabel,children:"Failed"}),e.jsx("div",{style:t.kpiValue("#ef4444"),children:m})]}),e.jsxs("div",{style:t.kpiCard("#f59e0b"),children:[e.jsx("div",{style:t.kpiLabel,children:"Pending"}),e.jsx("div",{style:t.kpiValue("#f59e0b"),children:b})]})]}),e.jsxs("div",{style:t.filterRow,children:[e.jsx("span",{style:t.filterLabel,children:"Time period:"}),["1h","24h","7d","30d"].map(n=>e.jsx("button",{style:t.filterBtn(d===n),onClick:()=>s(n),children:n},n))]}),e.jsxs("div",{style:t.columns,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.panelHeader,children:[e.jsx("span",{style:t.panelTitle,children:"Recent Activity"}),e.jsxs("span",{style:t.panelAction,children:[l.length," events"]})]}),o?e.jsx("div",{style:t.spinner,children:"Loading activity…"}):l.length===0?e.jsx("div",{style:t.empty,children:"No recent activity"}):l.slice(0,12).map(n=>{var i,u,L,I,_;return e.jsxs("div",{style:t.eventRow,onMouseEnter:R=>R.currentTarget.style.background="rgba(255,255,255,0.03)",onMouseLeave:R=>R.currentTarget.style.background="transparent",children:[e.jsx("div",{style:t.eventAvatar,children:(((i=n.agent)==null?void 0:i.display_name)||"?")[0].toUpperCase()}),e.jsxs("div",{style:t.eventBody,children:[e.jsxs("div",{style:t.eventTopLine,children:[e.jsx("span",{style:t.eventActor,children:((u=n.agent)==null?void 0:u.display_name)||"Unknown Agent"}),e.jsx("span",{style:t.badge(((L=n.execution)==null?void 0:L.status)||"completed"),children:((I=n.execution)==null?void 0:I.status)||"completed"}),e.jsx("span",{style:t.eventTime,children:W(n.timestamp)})]}),e.jsx("div",{style:t.eventAction,children:n.type||((_=n.execution)==null?void 0:_.objective)||"—"})]}),e.jsx("span",{style:t.viewLink,children:"View →"})]},n.id)})]}),r&&r.top_agents.length>0&&e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.panelHeader,children:[e.jsx("span",{style:t.panelTitle,children:"Top Agents"}),e.jsx("span",{style:t.panelAction,children:"Actions →"})]}),r.top_agents.slice(0,5).map((n,i)=>e.jsxs("div",{style:t.agentRow,children:[e.jsxs("div",{style:t.agentLeft,children:[e.jsxs("span",{style:t.agentRank,children:["#",i+1]}),e.jsx("span",{style:t.agentName,children:n.agent_id})]}),e.jsxs("span",{style:t.agentActions,children:[n.count," actions →"]})]},n.agent_id))]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:t.panel,children:[e.jsx("div",{style:t.panelHeader,children:e.jsxs("span",{style:{...t.panelTitle,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"#10b981"}}),"Event Breakdown"]})}),e.jsx("div",{style:t.donutCenter,children:e.jsx(B,{completed:x,failed:m,pending:b})}),e.jsxs("div",{style:t.legendRow,children:[e.jsxs("div",{style:t.legendItem("#10b981"),children:[e.jsx("span",{style:t.legendDot("#10b981")})," ",x," Completed"]}),e.jsxs("div",{style:t.legendItem("#ef4444"),children:[e.jsx("span",{style:t.legendDot("#ef4444")})," ",m," Failed"]}),e.jsxs("div",{style:t.legendItem("#f59e0b"),children:[e.jsx("span",{style:t.legendDot("#f59e0b")})," ",b," Pending"]})]}),e.jsx("div",{style:{padding:"0 16px 14px"},children:e.jsx("div",{style:{padding:"8px 0",borderTop:"1px solid rgba(255,255,255,0.06)",textAlign:"center",fontSize:12,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer"},children:"Top Agents →"})})]}),r&&r.top_agents.length>0&&e.jsxs("div",{style:t.panel,children:[e.jsx("div",{style:t.panelHeader,children:e.jsx("span",{style:t.panelTitle,children:"Top Agents"})}),r.top_agents.slice(0,5).map((n,i)=>e.jsxs("div",{style:t.compactAgentRow,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:t.agentRank,children:["#",i+1]}),e.jsx("div",{style:{width:22,height:22,borderRadius:5,display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,background:v[i%v.length]+"20",border:`1px solid ${v[i%v.length]}40`,color:v[i%v.length]},children:n.agent_id.slice(0,2).toUpperCase()}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--text-primary, #e2e8f0)"},children:n.agent_id})]}),e.jsx("span",{style:{fontSize:10,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)"},children:"actions ›"})]},n.agent_id))]})]})]})]})}export{U as default}; -//# sourceMappingURL=ActivityFeedPage-Cm83sZAp.js.map +import{r as y,j as e}from"./index-C0nK3ekl.js";const F={completed:"#10b981",failed:"#ef4444",pending:"#f59e0b",pending_approval:"#f59e0b"},D={completed:"rgba(16, 185, 129, 0.12)",failed:"rgba(239, 68, 68, 0.12)",pending:"rgba(245, 158, 11, 0.12)",pending_approval:"rgba(245, 158, 11, 0.12)"},v=["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4","#ec4899","#14b8a6","#f97316","#a855f7"];function W(l){const p=new Date(l),a=(new Date().getTime()-p.getTime())/1e3;return a<60?"Just now":a<3600?`${Math.floor(a/60)}m ago`:a<86400?`${Math.floor(a/3600)}h ago`:p.toLocaleDateString("en-US",{month:"numeric",day:"numeric",year:"numeric"})+", "+p.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function B({completed:l,failed:p,pending:r}){const a=l+p+r||1,d=70,s=90,o=90,g=14,f=2*Math.PI*d,h=l/a,k=p/a,S=r/a,c=h*f,x=k*f,m=S*f,b=0,j=-c,w=-(c+x);return e.jsxs("svg",{width:"180",height:"180",viewBox:"0 0 180 180",children:[e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"rgba(255,255,255,0.06)",strokeWidth:g}),l>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#10b981",strokeWidth:g,strokeDasharray:`${c} ${f-c}`,strokeDashoffset:b,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),p>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#ef4444",strokeWidth:g,strokeDasharray:`${x} ${f-x}`,strokeDashoffset:j,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),r>0&&e.jsx("circle",{cx:s,cy:o,r:d,fill:"none",stroke:"#f59e0b",strokeWidth:g,strokeDasharray:`${m} ${f-m}`,strokeDashoffset:w,strokeLinecap:"round",transform:`rotate(-90 ${s} ${o})`,style:{transition:"stroke-dasharray 0.6s ease"}}),e.jsx("text",{x:s,y:o-6,textAnchor:"middle",fill:"#10b981",fontSize:"28",fontWeight:"700",fontFamily:"var(--font-mono, monospace)",children:l}),e.jsx("text",{x:s,y:o+14,textAnchor:"middle",fill:"rgba(255,255,255,0.5)",fontSize:"11",fontFamily:"var(--font-mono, monospace)",style:{textTransform:"uppercase",letterSpacing:"0.05em"},children:"Completed"})]})}function U(){var T,z,A,C;const[l,p]=y.useState([]),[r,a]=y.useState(null),[d,s]=y.useState("24h"),[o,g]=y.useState(!0),[f,h]=y.useState(null),[k,S]=y.useState(new Date),c=y.useCallback(async()=>{try{const[n,i]=await Promise.all([fetch("/api/v1/activity/feed?limit=50",{credentials:"include"}).then(u=>u.json()),fetch(`/api/v1/activity/summary?period=${d}`,{credentials:"include"}).then(u=>u.json())]);n.success?(p(n.data||[]),h(null)):h(n.error||"Failed to load activity feed"),i.success&&a(i.data),S(new Date)}catch(n){console.error("[ActivityFeed] Fetch error:",n),h(n instanceof Error?n.message:"Network error loading activity feed")}finally{g(!1)}},[d]);y.useEffect(()=>{g(!0),c();const n=setInterval(c,8e3);return()=>clearInterval(n)},[c]);const x=((T=r==null?void 0:r.actions_by_status)==null?void 0:T.completed)||0,m=((z=r==null?void 0:r.actions_by_status)==null?void 0:z.failed)||0,b=(((A=r==null?void 0:r.actions_by_status)==null?void 0:A.pending)||0)+(((C=r==null?void 0:r.actions_by_status)==null?void 0:C.pending_approval)||0),j=(r==null?void 0:r.total_actions)||0,w=j>0?Math.round(x/j*100):0,t={page:{padding:"0 24px 40px",maxWidth:1200,margin:"0 auto"},header:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",padding:"24px 0 20px"},title:{fontSize:22,fontWeight:600,color:"var(--text-primary, #e2e8f0)",margin:0,lineHeight:1.3},subtitle:{fontSize:13,color:"var(--text-tertiary, rgba(255,255,255,0.45))",marginTop:4},headerRight:{display:"flex",alignItems:"center",gap:12},timestamp:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)"},refreshBtn:{fontSize:12,padding:"6px 14px",borderRadius:6,background:"rgba(255,255,255,0.06)",color:"var(--text-secondary, rgba(255,255,255,0.7))",border:"1px solid rgba(255,255,255,0.08)",cursor:"pointer",display:"flex",alignItems:"center",gap:6},kpiRow:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:16},kpiCard:n=>({background:"var(--surface-secondary, #12131a)",borderRadius:8,padding:"16px 18px",borderLeft:`3px solid ${n}`}),kpiLabel:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.45))",textTransform:"uppercase",letterSpacing:"0.04em",marginBottom:6,fontFamily:"var(--font-mono, monospace)"},kpiValue:n=>({fontSize:26,fontWeight:700,color:n,lineHeight:1,fontFamily:"var(--font-mono, monospace)"}),kpiSub:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",marginTop:4},filterRow:{display:"flex",alignItems:"center",gap:8,marginBottom:20},filterLabel:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",textTransform:"uppercase",letterSpacing:"0.04em",marginRight:4},filterBtn:n=>({fontSize:12,padding:"5px 14px",borderRadius:5,cursor:"pointer",fontFamily:"var(--font-mono, monospace)",fontWeight:n?600:400,background:n?"rgba(255,255,255,0.12)":"rgba(255,255,255,0.04)",color:n?"var(--text-primary, #e2e8f0)":"var(--text-tertiary, rgba(255,255,255,0.5))",border:n?"1px solid rgba(255,255,255,0.15)":"1px solid rgba(255,255,255,0.06)",transition:"all 0.15s ease"}),columns:{display:"grid",gridTemplateColumns:"1fr 340px",gap:16,alignItems:"start"},panel:{background:"var(--surface-secondary, #12131a)",borderRadius:10,overflow:"hidden"},panelHeader:{padding:"14px 18px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid rgba(255,255,255,0.06)"},panelTitle:{fontSize:14,fontWeight:600,color:"var(--text-primary, #e2e8f0)"},panelAction:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",cursor:"pointer",fontFamily:"var(--font-mono, monospace)"},eventRow:{padding:"12px 18px",display:"flex",alignItems:"flex-start",gap:12,borderBottom:"1px solid rgba(255,255,255,0.04)",transition:"background 0.1s ease",cursor:"default"},eventAvatar:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,flexShrink:0,background:"rgba(255,255,255,0.06)"},eventBody:{flex:1,minWidth:0},eventTopLine:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},eventActor:{fontSize:13,fontWeight:600,color:"var(--text-primary, #e2e8f0)"},badge:n=>({fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:4,color:F[n]||"#94a3b8",background:D[n]||"rgba(255,255,255,0.06)",textTransform:"uppercase",letterSpacing:"0.03em",fontFamily:"var(--font-mono, monospace)"}),eventTime:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontFamily:"var(--font-mono, monospace)"},eventAction:{fontSize:12,color:"var(--text-secondary, rgba(255,255,255,0.6))",marginTop:2},viewLink:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer",flexShrink:0,alignSelf:"center",textDecoration:"none"},agentRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 18px",borderBottom:"1px solid rgba(255,255,255,0.04)"},agentLeft:{display:"flex",alignItems:"center",gap:10},agentRank:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontFamily:"var(--font-mono, monospace)",width:20,textAlign:"right"},agentIcon:{width:26,height:26,borderRadius:6,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,background:"rgba(255,255,255,0.06)"},agentName:{fontSize:13,fontWeight:500,color:"var(--text-primary, #e2e8f0)"},agentActions:{fontSize:11,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer"},donutCenter:{display:"flex",justifyContent:"center",padding:"20px 0 10px"},legendRow:{display:"flex",justifyContent:"center",gap:16,padding:"0 18px 14px",flexWrap:"wrap"},legendItem:n=>({display:"flex",alignItems:"center",gap:5,fontSize:11,color:"var(--text-secondary, rgba(255,255,255,0.6))",fontFamily:"var(--font-mono, monospace)"}),legendDot:n=>({width:7,height:7,borderRadius:"50%",background:n,flexShrink:0}),compactAgentRow:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",borderBottom:"1px solid rgba(255,255,255,0.04)"},spinner:{display:"flex",justifyContent:"center",alignItems:"center",padding:"60px 0",color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontSize:13},empty:{padding:"40px 18px",textAlign:"center",color:"var(--text-tertiary, rgba(255,255,255,0.35))",fontSize:13}};return e.jsxs("div",{style:t.page,children:[f&&e.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",padding:"12px 16px",borderRadius:"8px",marginBottom:"16px",display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{fontSize:"14px",color:"#ef4444"},children:"⚠️"}),e.jsx("span",{style:{fontSize:"13px",color:"#fca5a5",flex:1},children:f}),e.jsx("button",{onClick:()=>{g(!0),h(null),c()},style:{background:"rgba(239, 68, 68, 0.2)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#fca5a5",padding:"6px 12px",borderRadius:"6px",cursor:"pointer",fontSize:"12px",fontWeight:600},children:"Retry"})]}),e.jsxs("div",{style:t.header,children:[e.jsxs("div",{children:[e.jsx("h1",{style:t.title,children:"Activity Feed"}),e.jsx("div",{style:t.subtitle,children:"Real-time view of all agent activity in your organization"})]}),e.jsxs("div",{style:t.headerRight,children:[e.jsxs("span",{style:t.timestamp,children:["Updated ",k.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",second:"2-digit",hour12:!0})]}),e.jsx("button",{style:t.refreshBtn,onClick:()=>{g(!0),c()},children:"↻ Refresh"})]})]}),e.jsxs("div",{style:t.kpiRow,children:[e.jsxs("div",{style:t.kpiCard("#6366f1"),children:[e.jsx("div",{style:t.kpiLabel,children:"Total Actions"}),e.jsx("div",{style:t.kpiValue("#818cf8"),children:j}),e.jsxs("div",{style:t.kpiSub,children:["Last ",d]})]}),e.jsxs("div",{style:t.kpiCard("#10b981"),children:[e.jsx("div",{style:t.kpiLabel,children:"Completed"}),e.jsx("div",{style:t.kpiValue("#10b981"),children:x}),e.jsxs("div",{style:t.kpiSub,children:[w,"% success rate"]})]}),e.jsxs("div",{style:t.kpiCard("#ef4444"),children:[e.jsx("div",{style:t.kpiLabel,children:"Failed"}),e.jsx("div",{style:t.kpiValue("#ef4444"),children:m})]}),e.jsxs("div",{style:t.kpiCard("#f59e0b"),children:[e.jsx("div",{style:t.kpiLabel,children:"Pending"}),e.jsx("div",{style:t.kpiValue("#f59e0b"),children:b})]})]}),e.jsxs("div",{style:t.filterRow,children:[e.jsx("span",{style:t.filterLabel,children:"Time period:"}),["1h","24h","7d","30d"].map(n=>e.jsx("button",{style:t.filterBtn(d===n),onClick:()=>s(n),children:n},n))]}),e.jsxs("div",{style:t.columns,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.panelHeader,children:[e.jsx("span",{style:t.panelTitle,children:"Recent Activity"}),e.jsxs("span",{style:t.panelAction,children:[l.length," events"]})]}),o?e.jsx("div",{style:t.spinner,children:"Loading activity…"}):l.length===0?e.jsx("div",{style:t.empty,children:"No recent activity"}):l.slice(0,12).map(n=>{var i,u,L,I,_;return e.jsxs("div",{style:t.eventRow,onMouseEnter:R=>R.currentTarget.style.background="rgba(255,255,255,0.03)",onMouseLeave:R=>R.currentTarget.style.background="transparent",children:[e.jsx("div",{style:t.eventAvatar,children:(((i=n.agent)==null?void 0:i.display_name)||"?")[0].toUpperCase()}),e.jsxs("div",{style:t.eventBody,children:[e.jsxs("div",{style:t.eventTopLine,children:[e.jsx("span",{style:t.eventActor,children:((u=n.agent)==null?void 0:u.display_name)||"Unknown Agent"}),e.jsx("span",{style:t.badge(((L=n.execution)==null?void 0:L.status)||"completed"),children:((I=n.execution)==null?void 0:I.status)||"completed"}),e.jsx("span",{style:t.eventTime,children:W(n.timestamp)})]}),e.jsx("div",{style:t.eventAction,children:n.type||((_=n.execution)==null?void 0:_.objective)||"—"})]}),e.jsx("span",{style:t.viewLink,children:"View →"})]},n.id)})]}),r&&r.top_agents.length>0&&e.jsxs("div",{style:t.panel,children:[e.jsxs("div",{style:t.panelHeader,children:[e.jsx("span",{style:t.panelTitle,children:"Top Agents"}),e.jsx("span",{style:t.panelAction,children:"Actions →"})]}),r.top_agents.slice(0,5).map((n,i)=>e.jsxs("div",{style:t.agentRow,children:[e.jsxs("div",{style:t.agentLeft,children:[e.jsxs("span",{style:t.agentRank,children:["#",i+1]}),e.jsx("span",{style:t.agentName,children:n.agent_id})]}),e.jsxs("span",{style:t.agentActions,children:[n.count," actions →"]})]},n.agent_id))]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:t.panel,children:[e.jsx("div",{style:t.panelHeader,children:e.jsxs("span",{style:{...t.panelTitle,display:"flex",alignItems:"center",gap:6},children:[e.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"#10b981"}}),"Event Breakdown"]})}),e.jsx("div",{style:t.donutCenter,children:e.jsx(B,{completed:x,failed:m,pending:b})}),e.jsxs("div",{style:t.legendRow,children:[e.jsxs("div",{style:t.legendItem("#10b981"),children:[e.jsx("span",{style:t.legendDot("#10b981")})," ",x," Completed"]}),e.jsxs("div",{style:t.legendItem("#ef4444"),children:[e.jsx("span",{style:t.legendDot("#ef4444")})," ",m," Failed"]}),e.jsxs("div",{style:t.legendItem("#f59e0b"),children:[e.jsx("span",{style:t.legendDot("#f59e0b")})," ",b," Pending"]})]}),e.jsx("div",{style:{padding:"0 16px 14px"},children:e.jsx("div",{style:{padding:"8px 0",borderTop:"1px solid rgba(255,255,255,0.06)",textAlign:"center",fontSize:12,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)",cursor:"pointer"},children:"Top Agents →"})})]}),r&&r.top_agents.length>0&&e.jsxs("div",{style:t.panel,children:[e.jsx("div",{style:t.panelHeader,children:e.jsx("span",{style:t.panelTitle,children:"Top Agents"})}),r.top_agents.slice(0,5).map((n,i)=>e.jsxs("div",{style:t.compactAgentRow,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:t.agentRank,children:["#",i+1]}),e.jsx("div",{style:{width:22,height:22,borderRadius:5,display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,background:v[i%v.length]+"20",border:`1px solid ${v[i%v.length]}40`,color:v[i%v.length]},children:n.agent_id.slice(0,2).toUpperCase()}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--text-primary, #e2e8f0)"},children:n.agent_id})]}),e.jsx("span",{style:{fontSize:10,color:"var(--text-tertiary, rgba(255,255,255,0.4))",fontFamily:"var(--font-mono, monospace)"},children:"actions ›"})]},n.agent_id))]})]})]})]})}export{U as default}; +//# sourceMappingURL=ActivityFeedPage-Vk-UPy1N.js.map diff --git a/apps/console-proxy/public/assets/AgentDetailPage-DOTxeMwT.js b/apps/console-proxy/public/assets/AgentDetailPage-Cjo-fR2O.js similarity index 93% rename from apps/console-proxy/public/assets/AgentDetailPage-DOTxeMwT.js rename to apps/console-proxy/public/assets/AgentDetailPage-Cjo-fR2O.js index 8096bf0c..5de4c990 100644 --- a/apps/console-proxy/public/assets/AgentDetailPage-DOTxeMwT.js +++ b/apps/console-proxy/public/assets/AgentDetailPage-Cjo-fR2O.js @@ -1,7 +1,7 @@ -import{c as A,B as C,u as _,r as o,j as e,w as T,P as z,z as L,T as g,C as S}from"./index-D_7YXFSJ.js";import{f as i}from"./fleet-Bmy_93a8.js";import{C as R}from"./circle-x-DJXSWLrE.js";import{A as $}from"./activity-C-iTiNlh.js";/** +import{c as A,a as C,u as _,r as o,j as e,b as T,P as L,d as S,T as g,C as z}from"./index-C0nK3ekl.js";import{f as i}from"./fleet-ClHE8wrR.js";import{C as R}from"./circle-x-DX5Kt33e.js";import{A as $}from"./activity-DFouDeMs.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const B=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],D=A("arrow-left",B);function M(){const{agentId:a}=C(),c=_(),[m,f]=o.useState(null),[h,j]=o.useState(!0),[p,u]=o.useState(!1),[b,d]=o.useState(null),r=o.useCallback(async(s=!1)=>{if(a){s&&u(!0);try{const l=await i.getAgent(a);f(l)}catch(l){console.error("Agent load failed:",l)}finally{j(!1),u(!1)}}},[a]);o.useEffect(()=>{r()},[r]),o.useEffect(()=>{const s=setInterval(()=>r(),15e3);return()=>clearInterval(s)},[r]);const N=async()=>{if(a){d("suspend");try{await i.suspend(a),await r()}catch(s){console.error("Suspend failed:",s)}finally{d(null)}}},k=async()=>{if(a){d("activate");try{await i.activate(a),await r()}catch(s){console.error("Activate failed:",s)}finally{d(null)}}};if(h)return e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-subtle)",borderTopColor:"var(--accent-primary)"}})});if(!m)return e.jsxs("div",{className:"max-w-4xl mx-auto py-12 text-center",children:[e.jsx("h2",{className:"text-xl font-bold mb-2",style:{color:"var(--text-primary)"},children:"Agent Not Found"}),e.jsxs("p",{className:"mb-6",style:{color:"var(--text-tertiary)"},children:["Agent ID: ",a]}),e.jsx("button",{onClick:()=>c("/fleet"),className:"px-4 py-2 rounded-lg font-medium",style:{background:"var(--accent-primary)",color:"#000"},children:"Back to Fleet"})]});const{agent:t,recentActivity:y,alerts:v,metrics:n}=m,w=t.status==="active"?"text-emerald-500":t.status==="suspended"?"text-red-500":"text-amber-500";return e.jsxs("div",{className:"space-y-6 max-w-[1200px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>c("/fleet"),className:"p-2 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(D,{size:18,style:{color:"var(--text-tertiary)"}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight",style:{color:"var(--text-primary)"},children:t.display_name}),e.jsx("p",{className:"text-xs font-mono mt-0.5",style:{color:"var(--text-muted)"},children:t.agent_id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>r(!0),disabled:p,className:"p-2 rounded-lg transition-colors hover:opacity-80",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(T,{size:16,className:p?"animate-spin":"",style:{color:"var(--text-tertiary)"}})}),t.status==="active"?e.jsxs("button",{onClick:N,disabled:b==="suspend",className:"px-3 py-1.5 text-xs font-semibold rounded-md transition-colors flex items-center gap-1.5",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:[e.jsx(z,{size:14}),"Suspend"]}):e.jsxs("button",{onClick:k,disabled:b==="activate",className:"px-3 py-1.5 text-xs font-semibold rounded-md transition-colors flex items-center gap-1.5",style:{background:"var(--accent-primary)",color:"#000"},children:[e.jsx(L,{size:14}),"Activate"]})]})]}),e.jsxs("div",{className:"rounded-lg p-4 flex items-center justify-between",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${t.status==="active"?"bg-emerald-500 animate-pulse":t.status==="suspended"?"bg-red-500":"bg-amber-500"}`}),e.jsx("span",{className:`text-sm font-mono font-semibold uppercase ${w}`,children:t.status})]}),e.jsx("div",{className:"h-4 w-px",style:{background:"var(--border-subtle)"}}),e.jsxs("div",{className:"text-xs",style:{color:"var(--text-tertiary)"},children:["Type: ",e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:t.agent_type})]}),e.jsx("div",{className:"h-4 w-px",style:{background:"var(--border-subtle)"}}),e.jsxs("div",{className:"text-xs",style:{color:"var(--text-tertiary)"},children:["Trust: ",e.jsxs("span",{className:`font-mono font-semibold ${t.trust_score>=95?"text-emerald-500":t.trust_score>=85?"text-amber-500":"text-red-500"}`,children:[t.trust_score.toFixed(1),"%"]})]})]}),t.unresolved_alerts>0&&e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-app)",border:"1px solid rgba(245, 158, 11, 0.3)"},children:[e.jsx(g,{size:14,className:"text-amber-500"}),e.jsxs("span",{className:"text-xs font-mono text-amber-500",children:[t.unresolved_alerts," alerts"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(x,{label:"Actions Today",value:n.actionsToday.toLocaleString()}),e.jsx(x,{label:"Actions This Week",value:n.actionsThisWeek.toLocaleString()}),e.jsx(x,{label:"Avg Latency",value:`${n.avgLatencyMs.toFixed(1)}ms`}),e.jsx(x,{label:"Error Rate",value:`${(n.errorRate*100).toFixed(1)}%`})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Actions by Type"}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.actionsByType).slice(0,5).map(([s,l])=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:s}),e.jsx("span",{className:"font-mono font-semibold",style:{color:"var(--text-primary)"},children:l})]},s))})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Actions by Result"}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.actionsByResult).map(([s,l])=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s==="approved"&&e.jsx(S,{size:12,className:"text-emerald-500"}),s==="denied"&&e.jsx(R,{size:12,className:"text-red-500"}),s==="pending"&&e.jsx($,{size:12,className:"text-amber-500"}),e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:s})]}),e.jsx("span",{className:"font-mono font-semibold",style:{color:"var(--text-primary)"},children:l})]},s))})]})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Recent Activity"}),y.length===0?e.jsx("p",{className:"text-xs text-center py-6",style:{color:"var(--text-tertiary)"},children:"No recent activity"}):e.jsx("div",{className:"space-y-2",children:y.slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-2 rounded hover:opacity-90 transition-opacity",style:{background:"var(--bg-app)"},children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono shrink-0",style:{color:"var(--text-muted)"},children:new Date(s.created_at).toLocaleTimeString()}),e.jsx("span",{className:"font-mono truncate",style:{color:"var(--text-secondary)"},children:s.action_type}),e.jsx("span",{className:`text-[10px] font-mono font-semibold uppercase px-1.5 py-0.5 rounded ${s.result==="approved"?"bg-emerald-500/20 text-emerald-500":s.result==="denied"?"bg-red-500/20 text-red-500":"bg-amber-500/20 text-amber-500"}`,children:s.result})]}),e.jsxs("span",{className:"font-mono text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:[s.latency_ms,"ms"]})]},s.id))})]}),v.length>0&&e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid rgba(245, 158, 11, 0.3)"},children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3 flex items-center gap-2",style:{color:"var(--text-muted)"},children:[e.jsx(g,{size:14,className:"text-amber-500"}),"Active Alerts"]}),e.jsx("div",{className:"space-y-2",children:v.filter(s=>!s.resolved).map(s=>e.jsxs("div",{className:"p-3 rounded",style:{background:"var(--bg-app)",border:"1px solid rgba(245, 158, 11, 0.2)"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--text-primary)"},children:s.alert_type}),e.jsx("span",{className:`text-[10px] font-mono font-semibold uppercase px-1.5 py-0.5 rounded ${s.severity==="critical"?"bg-red-500/20 text-red-500":s.severity==="warning"?"bg-amber-500/20 text-amber-500":"bg-blue-500/20 text-blue-500"}`,children:s.severity})]}),e.jsx("p",{className:"text-xs mb-2",style:{color:"var(--text-secondary)"},children:s.message}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-muted)"},children:new Date(s.created_at).toLocaleString()}),e.jsx("button",{onClick:async()=>{await i.resolveAlert(s.id),await r()},className:"text-[10px] font-semibold uppercase px-2 py-1 rounded transition-colors",style:{background:"var(--accent-primary)",color:"#000"},children:"Resolve"})]})]},s.id))})]})]})}function x({label:a,value:c}){return e.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:a}),e.jsx("div",{className:"text-xl font-bold font-mono",style:{color:"var(--text-primary)"},children:c})]})}export{M as default}; -//# sourceMappingURL=AgentDetailPage-DOTxeMwT.js.map + */const D=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],E=A("arrow-left",D);function M(){const{agentId:a}=C(),c=_(),[m,f]=o.useState(null),[h,j]=o.useState(!0),[p,u]=o.useState(!1),[b,d]=o.useState(null),r=o.useCallback(async(s=!1)=>{if(a){s&&u(!0);try{const l=await i.getAgent(a);f(l)}catch(l){console.error("Agent load failed:",l)}finally{j(!1),u(!1)}}},[a]);o.useEffect(()=>{r()},[r]),o.useEffect(()=>{const s=setInterval(()=>r(),15e3);return()=>clearInterval(s)},[r]);const N=async()=>{if(a){d("suspend");try{await i.suspend(a),await r()}catch(s){console.error("Suspend failed:",s)}finally{d(null)}}},k=async()=>{if(a){d("activate");try{await i.activate(a),await r()}catch(s){console.error("Activate failed:",s)}finally{d(null)}}};if(h)return e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-subtle)",borderTopColor:"var(--accent-primary)"}})});if(!m)return e.jsxs("div",{className:"max-w-4xl mx-auto py-12 text-center",children:[e.jsx("h2",{className:"text-xl font-bold mb-2",style:{color:"var(--text-primary)"},children:"Agent Not Found"}),e.jsxs("p",{className:"mb-6",style:{color:"var(--text-tertiary)"},children:["Agent ID: ",a]}),e.jsx("button",{onClick:()=>c("/fleet"),className:"px-4 py-2 rounded-lg font-medium",style:{background:"var(--accent-primary)",color:"#000"},children:"Back to Fleet"})]});const{agent:t,recentActivity:y,alerts:v,metrics:n}=m,w=t.status==="active"?"text-emerald-500":t.status==="suspended"?"text-red-500":"text-amber-500";return e.jsxs("div",{className:"space-y-6 max-w-[1200px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>c("/fleet"),className:"p-2 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(E,{size:18,style:{color:"var(--text-tertiary)"}})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight",style:{color:"var(--text-primary)"},children:t.display_name}),e.jsx("p",{className:"text-xs font-mono mt-0.5",style:{color:"var(--text-muted)"},children:t.agent_id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>r(!0),disabled:p,className:"p-2 rounded-lg transition-colors hover:opacity-80",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(T,{size:16,className:p?"animate-spin":"",style:{color:"var(--text-tertiary)"}})}),t.status==="active"?e.jsxs("button",{onClick:N,disabled:b==="suspend",className:"px-3 py-1.5 text-xs font-semibold rounded-md transition-colors flex items-center gap-1.5",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",color:"var(--text-secondary)"},children:[e.jsx(L,{size:14}),"Suspend"]}):e.jsxs("button",{onClick:k,disabled:b==="activate",className:"px-3 py-1.5 text-xs font-semibold rounded-md transition-colors flex items-center gap-1.5",style:{background:"var(--accent-primary)",color:"#000"},children:[e.jsx(S,{size:14}),"Activate"]})]})]}),e.jsxs("div",{className:"rounded-lg p-4 flex items-center justify-between",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${t.status==="active"?"bg-emerald-500 animate-pulse":t.status==="suspended"?"bg-red-500":"bg-amber-500"}`}),e.jsx("span",{className:`text-sm font-mono font-semibold uppercase ${w}`,children:t.status})]}),e.jsx("div",{className:"h-4 w-px",style:{background:"var(--border-subtle)"}}),e.jsxs("div",{className:"text-xs",style:{color:"var(--text-tertiary)"},children:["Type: ",e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:t.agent_type})]}),e.jsx("div",{className:"h-4 w-px",style:{background:"var(--border-subtle)"}}),e.jsxs("div",{className:"text-xs",style:{color:"var(--text-tertiary)"},children:["Trust: ",e.jsxs("span",{className:`font-mono font-semibold ${t.trust_score>=95?"text-emerald-500":t.trust_score>=85?"text-amber-500":"text-red-500"}`,children:[t.trust_score.toFixed(1),"%"]})]})]}),t.unresolved_alerts>0&&e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded",style:{background:"var(--bg-app)",border:"1px solid rgba(245, 158, 11, 0.3)"},children:[e.jsx(g,{size:14,className:"text-amber-500"}),e.jsxs("span",{className:"text-xs font-mono text-amber-500",children:[t.unresolved_alerts," alerts"]})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[e.jsx(x,{label:"Actions Today",value:n.actionsToday.toLocaleString()}),e.jsx(x,{label:"Actions This Week",value:n.actionsThisWeek.toLocaleString()}),e.jsx(x,{label:"Avg Latency",value:`${n.avgLatencyMs.toFixed(1)}ms`}),e.jsx(x,{label:"Error Rate",value:`${(n.errorRate*100).toFixed(1)}%`})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Actions by Type"}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.actionsByType).slice(0,5).map(([s,l])=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:s}),e.jsx("span",{className:"font-mono font-semibold",style:{color:"var(--text-primary)"},children:l})]},s))})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Actions by Result"}),e.jsx("div",{className:"space-y-2",children:Object.entries(n.actionsByResult).map(([s,l])=>e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[s==="approved"&&e.jsx(z,{size:12,className:"text-emerald-500"}),s==="denied"&&e.jsx(R,{size:12,className:"text-red-500"}),s==="pending"&&e.jsx($,{size:12,className:"text-amber-500"}),e.jsx("span",{className:"font-mono",style:{color:"var(--text-secondary)"},children:s})]}),e.jsx("span",{className:"font-mono font-semibold",style:{color:"var(--text-primary)"},children:l})]},s))})]})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3",style:{color:"var(--text-muted)"},children:"Recent Activity"}),y.length===0?e.jsx("p",{className:"text-xs text-center py-6",style:{color:"var(--text-tertiary)"},children:"No recent activity"}):e.jsx("div",{className:"space-y-2",children:y.slice(0,10).map(s=>e.jsxs("div",{className:"flex items-center justify-between text-xs p-2 rounded hover:opacity-90 transition-opacity",style:{background:"var(--bg-app)"},children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("span",{className:"font-mono shrink-0",style:{color:"var(--text-muted)"},children:new Date(s.created_at).toLocaleTimeString()}),e.jsx("span",{className:"font-mono truncate",style:{color:"var(--text-secondary)"},children:s.action_type}),e.jsx("span",{className:`text-[10px] font-mono font-semibold uppercase px-1.5 py-0.5 rounded ${s.result==="approved"?"bg-emerald-500/20 text-emerald-500":s.result==="denied"?"bg-red-500/20 text-red-500":"bg-amber-500/20 text-amber-500"}`,children:s.result})]}),e.jsxs("span",{className:"font-mono text-[10px] shrink-0",style:{color:"var(--text-muted)"},children:[s.latency_ms,"ms"]})]},s.id))})]}),v.length>0&&e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid rgba(245, 158, 11, 0.3)"},children:[e.jsxs("h3",{className:"text-xs font-bold uppercase tracking-wider mb-3 flex items-center gap-2",style:{color:"var(--text-muted)"},children:[e.jsx(g,{size:14,className:"text-amber-500"}),"Active Alerts"]}),e.jsx("div",{className:"space-y-2",children:v.filter(s=>!s.resolved).map(s=>e.jsxs("div",{className:"p-3 rounded",style:{background:"var(--bg-app)",border:"1px solid rgba(245, 158, 11, 0.2)"},children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("span",{className:"text-xs font-semibold",style:{color:"var(--text-primary)"},children:s.alert_type}),e.jsx("span",{className:`text-[10px] font-mono font-semibold uppercase px-1.5 py-0.5 rounded ${s.severity==="critical"?"bg-red-500/20 text-red-500":s.severity==="warning"?"bg-amber-500/20 text-amber-500":"bg-blue-500/20 text-blue-500"}`,children:s.severity})]}),e.jsx("p",{className:"text-xs mb-2",style:{color:"var(--text-secondary)"},children:s.message}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[10px] font-mono",style:{color:"var(--text-muted)"},children:new Date(s.created_at).toLocaleString()}),e.jsx("button",{onClick:async()=>{await i.resolveAlert(s.id),await r()},className:"text-[10px] font-semibold uppercase px-2 py-1 rounded transition-colors",style:{background:"var(--accent-primary)",color:"#000"},children:"Resolve"})]})]},s.id))})]})]})}function x({label:a,value:c}){return e.jsxs("div",{className:"rounded-lg p-3",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:a}),e.jsx("div",{className:"text-xl font-bold font-mono",style:{color:"var(--text-primary)"},children:c})]})}export{M as default}; +//# sourceMappingURL=AgentDetailPage-Cjo-fR2O.js.map diff --git a/apps/console-proxy/public/assets/AgentTemplatesPage-Bb9BCTy1.js b/apps/console-proxy/public/assets/AgentTemplatesPage-Bb9BCTy1.js deleted file mode 100644 index 83217e2c..00000000 --- a/apps/console-proxy/public/assets/AgentTemplatesPage-Bb9BCTy1.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r,j as e}from"./index-D_7YXFSJ.js";function p(){const[d,x]=r.useState([]),[m,i]=r.useState(!0),[t,a]=r.useState(null),[c,n]=r.useState(!1);r.useEffect(()=>{b()},[]);const b=async()=>{try{i(!0);const l=await(await fetch("/api/v1/agent-templates")).json();l.success&&x(l.data)}catch{}finally{i(!1)}},o=async s=>{try{await fetch(`/api/v1/agent-templates/${s.id}/use`,{method:"POST"}),a(s),n(!0)}catch{}},h=s=>{navigator.clipboard.writeText(s)};return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-[#e2e8f0] mb-2",children:"Agent Templates"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)]",children:"Framework-specific governance templates with ready-to-use integration code"})]}),m?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("p",{className:"mt-4 text-[rgba(255,255,255,0.6)]",children:"Loading templates..."})]}):e.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:d.map(s=>e.jsxs("div",{className:"border border-[rgba(255,255,255,0.08)] rounded-lg p-6 hover:bg-[rgba(255,255,255,0.04)] transition-all",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("div",{className:"text-5xl",children:s.icon}),e.jsx("span",{className:"px-3 py-1 bg-amber-50 text-amber-600 text-sm rounded font-medium",children:s.framework})]}),e.jsx("h3",{className:"text-xl font-semibold text-[#e2e8f0] mb-3",children:s.name}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)] mb-4",children:s.description}),e.jsx("div",{className:"flex flex-wrap gap-2 mb-4",children:s.tags.map(l=>e.jsx("span",{className:"px-2 py-1 bg-[rgba(255,255,255,0.08)] text-[rgba(255,255,255,0.6)] text-xs rounded",children:l},l))}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:()=>a(s),className:"flex-1 bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 transition-colors",children:"View Details"}),e.jsx("button",{onClick:()=>o(s),className:"flex-1 border border-blue-500 text-blue-500 py-2 px-4 rounded hover:bg-[rgba(59,130,246,0.1)] transition-colors",children:"Get Started"})]}),e.jsxs("p",{className:"mt-3 text-xs text-[rgba(255,255,255,0.4)] text-center",children:["Used by ",s.use_count," teams"]})]},s.id))}),t&&!c&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",onClick:()=>a(null),children:e.jsxs("div",{className:"bg-[#12131a] rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto p-6 border border-[rgba(255,255,255,0.08)]",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center space-x-4",children:[e.jsx("div",{className:"text-6xl",children:t.icon}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-[#e2e8f0] mb-1",children:t.name}),e.jsx("span",{className:"px-3 py-1 bg-amber-50 text-amber-600 text-sm rounded",children:t.framework})]})]}),e.jsx("button",{onClick:()=>a(null),className:"text-[rgba(255,255,255,0.4)] hover:text-[rgba(255,255,255,0.6)]",children:"✕"})]}),e.jsx("div",{className:"prose max-w-none mb-6",children:e.jsx("div",{className:"whitespace-pre-wrap text-[rgba(255,255,255,0.6)]",dangerouslySetInnerHTML:{__html:t.quick_start_guide.replace(/\n/g,"
")}})}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:()=>{o(t)},className:"flex-1 bg-blue-500 text-white py-3 px-6 rounded-lg hover:bg-blue-600 transition-colors font-medium",children:"Get Integration Code"}),e.jsx("button",{onClick:()=>a(null),className:"px-6 py-3 border border-[rgba(255,255,255,0.08)] rounded-lg hover:bg-[rgba(255,255,255,0.04)] transition-colors text-[rgba(255,255,255,0.6)]",children:"Close"})]})]})}),c&&t&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",onClick:()=>{n(!1),a(null)},children:e.jsxs("div",{className:"bg-[#12131a] rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto p-6 border border-[rgba(255,255,255,0.08)]",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("h2",{className:"text-2xl font-bold text-[#e2e8f0]",children:[t.name," - Integration Code"]}),e.jsx("button",{onClick:()=>{n(!1),a(null)},className:"text-[rgba(255,255,255,0.4)] hover:text-[rgba(255,255,255,0.6)]",children:"✕"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0]",children:"Sample Code"}),e.jsx("button",{onClick:()=>h(t.integration_code),className:"px-3 py-1 bg-[rgba(255,255,255,0.08)] text-[rgba(255,255,255,0.6)] text-sm rounded hover:bg-[rgba(255,255,255,0.12)] transition-colors",children:"Copy Code"})]}),e.jsx("div",{className:"bg-gray-900 rounded-lg p-4 overflow-x-auto",children:e.jsx("pre",{className:"text-sm text-green-400 font-mono",children:t.integration_code})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0] mb-2",children:"Recommended Policies"}),e.jsx("div",{className:"bg-[rgba(255,255,255,0.03)] rounded p-4",children:e.jsx("pre",{className:"text-sm text-[rgba(255,255,255,0.6)] whitespace-pre-wrap",children:JSON.stringify(t.policies,null,2)})})]}),e.jsx("button",{onClick:()=>{n(!1),a(null)},className:"w-full bg-blue-500 text-white py-3 px-6 rounded-lg hover:bg-blue-600 transition-colors font-medium",children:"Done"})]})})]})}export{p as default}; -//# sourceMappingURL=AgentTemplatesPage-Bb9BCTy1.js.map diff --git a/apps/console-proxy/public/assets/AnalyticsPage-Dsi6O5ZQ.js b/apps/console-proxy/public/assets/AnalyticsPage-DG4geVN6.js similarity index 98% rename from apps/console-proxy/public/assets/AnalyticsPage-Dsi6O5ZQ.js rename to apps/console-proxy/public/assets/AnalyticsPage-DG4geVN6.js index 4644617d..c6bb3b5f 100644 --- a/apps/console-proxy/public/assets/AnalyticsPage-Dsi6O5ZQ.js +++ b/apps/console-proxy/public/assets/AnalyticsPage-DG4geVN6.js @@ -1,3 +1,3 @@ -import{a as h,r as x,b as j,j as e}from"./index-D_7YXFSJ.js";async function A(n="30d"){return h.get("/analytics",{range:n})}async function C(n="30d"){return h.get("/analytics/trends",{range:n})}function $(n,a){if(a===0)return{text:"New",color:"#06b6d4",arrow:"→"};const d=((n-a)/a*100).toFixed(1),c=parseFloat(d);return c>0?{text:`+${d}%`,color:"#10b981",arrow:"↑"}:c<0?{text:`${d}%`,color:"#ef4444",arrow:"↓"}:{text:"0%",color:"var(--text-tertiary)",arrow:"→"}}function F(n){const a=["Vienna OS Analytics Report",`Generated: ${new Date().toISOString()}`,`Time Range: ${n.timeRange}`,""];a.push("--- Metrics ---"),a.push("Metric,Current,Previous,Delta"),n.metrics.forEach(r=>{const t=r.previous>0?((r.current-r.previous)/r.previous*100).toFixed(1)+"%":"N/A";a.push(`${r.label},${r.current},${r.previous},${t}`)}),a.push("","--- Agent Leaderboard ---"),a.push("Agent,Total Actions,Successful,Failed,Avg Latency (ms)"),n.leaderboard.forEach(r=>{a.push(`${r.agent_name},${r.total_actions},${r.successful},${r.failed},${r.avg_latency_ms}`)}),a.push("","--- Cost Breakdown ---"),a.push("Category,Count,Estimated Cost"),n.costs.forEach(r=>{a.push(`${r.category},${r.count},$${r.estimated_cost.toFixed(2)}`)});const d=a.join(` +import{e as h,r as x,g as j,j as e}from"./index-C0nK3ekl.js";async function A(n="30d"){return h.get("/analytics",{range:n})}async function C(n="30d"){return h.get("/analytics/trends",{range:n})}function $(n,a){if(a===0)return{text:"New",color:"#06b6d4",arrow:"→"};const d=((n-a)/a*100).toFixed(1),c=parseFloat(d);return c>0?{text:`+${d}%`,color:"#10b981",arrow:"↑"}:c<0?{text:`${d}%`,color:"#ef4444",arrow:"↓"}:{text:"0%",color:"var(--text-tertiary)",arrow:"→"}}function F(n){const a=["Vienna OS Analytics Report",`Generated: ${new Date().toISOString()}`,`Time Range: ${n.timeRange}`,""];a.push("--- Metrics ---"),a.push("Metric,Current,Previous,Delta"),n.metrics.forEach(r=>{const t=r.previous>0?((r.current-r.previous)/r.previous*100).toFixed(1)+"%":"N/A";a.push(`${r.label},${r.current},${r.previous},${t}`)}),a.push("","--- Agent Leaderboard ---"),a.push("Agent,Total Actions,Successful,Failed,Avg Latency (ms)"),n.leaderboard.forEach(r=>{a.push(`${r.agent_name},${r.total_actions},${r.successful},${r.failed},${r.avg_latency_ms}`)}),a.push("","--- Cost Breakdown ---"),a.push("Category,Count,Estimated Cost"),n.costs.forEach(r=>{a.push(`${r.category},${r.count},$${r.estimated_cost.toFixed(2)}`)});const d=a.join(` `),c=new Blob([d],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(c),p=document.createElement("a");p.href=s,p.download=`vienna-analytics-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(s),j("Analytics report exported","success")}function L(){const[n,a]=x.useState("30d"),[d,c]=x.useState(!0),[s,p]=x.useState(null),r=x.useCallback(async()=>{c(!0);try{const[t,i]=await Promise.all([A(n),C(n)]),l=Number(i.current.executions),u=Number(i.current.completed),g=Number(i.current.rejected),k=l-u-g,y=Number(i.previous.executions),m=Number(i.previous.completed),S=Number(i.previous.rejected),b=t.approvalLatency.length>0?Math.round(t.approvalLatency.reduce((o,f)=>o+f.avg_seconds,0)/t.approvalLatency.length):0,v=t.agentRisk.filter(o=>o.status==="active").length,_=[{label:"Total Executions",current:l,previous:y,icon:"📊",color:"#818cf8"},{label:"Completed",current:u,previous:m,icon:"✅",color:"#10b981"},{label:"Rejected",current:g,previous:S,icon:"❌",color:"#ef4444"},{label:"Active Agents",current:v,previous:v,icon:"🤖",color:"#3b82f6"},{label:"Avg Approval Time",current:b,previous:b,unit:"s",icon:"⚡",color:"#06b6d4"},{label:"Success Rate",current:l>0?Math.round(u/l*100):0,previous:y>0?Math.round(m/y*100):0,unit:"%",icon:"📈",color:"#f59e0b"}],R=t.agentRisk.map(o=>({agent_id:o.agent_id,agent_name:o.agent_name||o.agent_id.slice(0,12),total_actions:Number(o.total_executions),successful:Number(o.total_executions)-Number(o.rejected_executions),failed:Number(o.rejected_executions),avg_latency_ms:0,status:o.status})).sort((o,f)=>f.total_actions-o.total_actions).slice(0,10),T={T0:.001,T1:.01,T2:.05,T3:.1},z=t.executionVolume.map(o=>({category:`${o.bucket} Executions`,count:Number(o.total),estimated_cost:Number(o.total)*(T[o.bucket]||.01)}));p({metrics:_,leaderboard:R,costs:z,timeRange:`Last ${n}`})}catch{j("Failed to load analytics","error",{label:"Retry",onClick:r})}finally{c(!1)}},[n]);return x.useEffect(()=>{r()},[r]),e.jsxs("div",{style:{padding:"28px 32px",maxWidth:"1400px",margin:"0 auto",fontFamily:"var(--font-sans)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",margin:0},children:"Analytics"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-tertiary)",marginTop:"4px"},children:"Performance metrics, agent leaderboard, and cost tracking"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("div",{style:{display:"flex",gap:"2px",background:"rgba(255,255,255,0.03)",borderRadius:"6px",padding:"2px"},children:["24h","7d","30d","90d"].map(t=>e.jsx("button",{onClick:()=>a(t),style:{padding:"5px 12px",fontSize:"11px",borderRadius:"4px",border:"none",cursor:"pointer",fontWeight:n===t?600:400,background:n===t?"rgba(255,255,255,0.08)":"transparent",color:n===t?"var(--text-primary)":"var(--text-tertiary)",fontFamily:"var(--font-sans)"},children:t},t))}),e.jsx("button",{onClick:()=>s&&F(s),disabled:!s,style:{padding:"6px 14px",borderRadius:"6px",fontSize:"12px",fontWeight:500,background:s?"rgba(16,185,129,0.1)":"rgba(255,255,255,0.03)",color:s?"#10b981":"var(--text-tertiary)",border:`1px solid ${s?"rgba(16,185,129,0.2)":"var(--border-subtle)"}`,cursor:s?"pointer":"not-allowed",fontFamily:"var(--font-mono)"},children:"📥 Export CSV"})]})]}),d?e.jsxs("div",{style:{padding:"80px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"28px",height:"28px",border:"2px solid var(--border-subtle)",borderTop:"2px solid #f59e0b",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),e.jsx("p",{style:{marginTop:"16px",fontSize:"13px",color:"var(--text-tertiary)"},children:"Loading analytics..."}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):s&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"12px",marginBottom:"24px"},children:s.metrics.map((t,i)=>{const l=$(t.current,t.previous);return e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"18px 20px",borderLeft:`3px solid ${t.color}`},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"28px",fontWeight:700,color:t.color,fontFamily:"var(--font-mono)",lineHeight:1},children:[t.current.toLocaleString(),t.unit||""]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"5px",textTransform:"uppercase",letterSpacing:"0.04em"},children:t.label})]}),e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("span",{style:{fontSize:"20px"},children:t.icon}),e.jsxs("div",{style:{fontSize:"11px",fontWeight:600,color:l.color,fontFamily:"var(--font-mono)",marginTop:"4px"},children:[l.arrow," ",l.text]}),e.jsx("div",{style:{fontSize:"9px",color:"var(--text-tertiary)"},children:"vs prev period"})]})]})},i)})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"16px"},children:[e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"12px",overflow:"hidden",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)"},children:e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:0},children:"🏆 Agent Performance Leaderboard"})}),s.leaderboard.length===0?e.jsx("div",{style:{padding:"40px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No agents found. Register your first agent to see performance data."}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["#","Agent","Actions","Success","Failed","Avg Latency"].map(t=>e.jsx("th",{style:{padding:"8px 14px",textAlign:"left",fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:t},t))})}),e.jsx("tbody",{children:s.leaderboard.map((t,i)=>e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.03)"},children:[e.jsx("td",{style:{padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:i<3?"#f59e0b":"var(--text-tertiary)",fontWeight:700},children:i<3?["🥇","🥈","🥉"][i]:`#${i+1}`}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:t.status==="active"?"#10b981":"#94a3b8"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)"},children:t.agent_name})]})}),e.jsx("td",{style:{padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600},children:t.total_actions}),e.jsx("td",{style:{padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"#10b981"},children:t.successful}),e.jsx("td",{style:{padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:t.failed>0?"#ef4444":"var(--text-tertiary)"},children:t.failed}),e.jsxs("td",{style:{padding:"10px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-tertiary)"},children:[t.avg_latency_ms,"ms"]})]},t.agent_id))})]})]}),e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"12px",overflow:"hidden",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)"},children:e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:0},children:"💰 Cost Tracking"})}),e.jsx("div",{style:{padding:"16px 20px"},children:s.costs.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No cost data available yet."}):e.jsxs(e.Fragment,{children:[s.costs.map((t,i)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 0",borderBottom:it+i.estimated_cost,0).toFixed(2)]})]})]})})]})]})]})]})}export{L as AnalyticsPage}; -//# sourceMappingURL=AnalyticsPage-Dsi6O5ZQ.js.map +//# sourceMappingURL=AnalyticsPage-DG4geVN6.js.map diff --git a/apps/console-proxy/public/assets/AnalyticsPremium-BfZNHtV9.js b/apps/console-proxy/public/assets/AnalyticsPremium-BfZNHtV9.js deleted file mode 100644 index 0bb47901..00000000 --- a/apps/console-proxy/public/assets/AnalyticsPremium-BfZNHtV9.js +++ /dev/null @@ -1,7 +0,0 @@ -import{c as J,r as v,b as B,j as e,R as V,Z as K}from"./index-D_7YXFSJ.js";import{P as Q}from"./PageLayout-CTYKc2go.js";import{B as P}from"./bot-CFwUaWgF.js";import{A as U}from"./activity-C-iTiNlh.js";import{C as ee}from"./circle-x-DJXSWLrE.js";import{C as te}from"./circle-check-BIUeiM-B.js";import{T as oe}from"./trending-up-xPmnKzgu.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const ne=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],se=J("dollar-sign",ne),F={T0:"#10b981",T1:"#f59e0b",T2:"#ef4444",T3:"#dc2626"},ie={green:"#10b981",amber:"#f59e0b",red:"#ef4444",blue:"#3b82f6",cyan:"#06b6d4"},re=(t,s)=>{const o={size:20,color:s,strokeWidth:1.5};switch(t){case"TrendingUp":return e.jsx(oe,{...o});case"CheckCircle2":return e.jsx(te,{...o});case"XCircle":return e.jsx(ee,{...o});case"Bot":return e.jsx(P,{...o});case"Zap":return e.jsx(K,{...o});default:return e.jsx(U,{...o})}};function ae({metric:t}){const[s,o]=V.useState(!1),i=t.previous>0?((t.value-t.previous)/t.previous*100).toFixed(1):null,r=i?parseFloat(i):0,g=r>0?"#10b981":r<0?"#ef4444":"#6b7280",d=ie[t.color];return e.jsxs("div",{onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"14px 16px",display:"flex",flexDirection:"column",gap:"10px",boxShadow:s?`0 0 0 1px ${d}40, 0 4px 16px rgba(0,0,0,0.6)`:"0 0 0 1px rgba(0,0,0,0.8), 0 2px 8px rgba(0,0,0,0.5)",transform:s?"translateY(-2px)":"translateY(0)",transition:"all 200ms cubic-bezier(0.4, 0, 0.2, 1)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"rgba(251, 191, 36, 0.7)",letterSpacing:"0.1em",fontFamily:"var(--font-mono)",marginBottom:"6px"},children:t.label}),e.jsxs("div",{style:{fontSize:"26px",fontWeight:700,color:d,fontFamily:"var(--font-mono)",lineHeight:1},children:[t.value.toLocaleString(),t.unit||""]})]}),e.jsx("span",{style:{display:"flex",alignItems:"center",justifyContent:"center"},children:re(t.icon,d)})]}),e.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"1px",height:"28px"},children:t.sparkline.map((j,a)=>e.jsx("div",{style:{flex:1,background:d,height:`${j}%`,opacity:.3+j/100*.7,transition:"all 200ms"}},a))}),i!==null&&e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"10px"},children:[e.jsx("span",{style:{color:"rgba(230, 225, 220, 0.5)",fontFamily:"var(--font-mono)"},children:"vs. prev. period"}),e.jsxs("span",{style:{color:g,fontWeight:700,fontFamily:"var(--font-mono)"},children:[r>0?"▲":r<0?"▼":"━"," ",Math.abs(r).toFixed(1),"%"]})]})]})}function le({agents:t}){return t.length===0?e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"32px",textAlign:"center"},children:[e.jsx("div",{style:{marginBottom:"8px"},children:e.jsx(P,{size:32,color:"#fbbf24",strokeWidth:1.5})}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(230, 225, 220, 0.5)"},children:"No agents registered yet"})]}):e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",background:"rgba(251, 191, 36, 0.05)"},children:e.jsx("h3",{style:{margin:0,fontSize:"12px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"🏆 AGENT PERFORMANCE"})}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(251, 191, 36, 0.1)"},children:["#","Agent","Actions","Success","Failed","Latency","Tier Dist"].map(s=>e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontSize:"9px",fontWeight:700,color:"rgba(251, 191, 36, 0.6)",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:s},s))})}),e.jsx("tbody",{children:t.map((s,o)=>{const i=s.total_actions>0?Math.round(s.successful/s.total_actions*100):0,r=Object.entries(s.risk_tier_dist);return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.02)"},children:[e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:o<3?"#fbbf24":"rgba(230, 225, 220, 0.4)",fontWeight:700},children:o<3?["🥇","🥈","🥉"][o]:`#${o+1}`}),e.jsxs("td",{style:{padding:"10px 12px"},children:[e.jsx("div",{style:{fontWeight:600,color:"#E6E1DC"},children:s.agent_name}),e.jsxs("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)"},children:[s.agent_id.slice(0,16),"..."]})]}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"#fbbf24",fontWeight:600},children:s.total_actions.toLocaleString()}),e.jsxs("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px"},children:[e.jsx("span",{style:{color:"#10b981",fontWeight:600},children:s.successful}),e.jsxs("span",{style:{color:"rgba(230, 225, 220, 0.3)",marginLeft:"4px"},children:["(",i,"%)"]})]}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:s.failed>0?"#ef4444":"rgba(230, 225, 220, 0.3)",fontWeight:s.failed>0?600:400},children:s.failed}),e.jsxs("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"rgba(230, 225, 220, 0.5)"},children:[s.avg_latency_ms,"ms"]}),e.jsx("td",{style:{padding:"10px 12px"},children:e.jsx("div",{style:{display:"flex",gap:"4px"},children:r.length===0?e.jsx("span",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.3)",fontFamily:"var(--font-mono)"},children:"—"}):r.map(([g,d])=>e.jsxs("span",{style:{fontSize:"9px",fontWeight:700,color:F[g]||"#6b7280",fontFamily:"var(--font-mono)"},children:[g,":",d]},g))})})]},s.agent_id)})})]})]})}function ce({costs:t}){const s=t.reduce((o,i)=>o+i.estimated_cost,0);return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",background:"rgba(251, 191, 36, 0.05)"},children:e.jsxs("h3",{style:{margin:0,fontSize:"12px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:[e.jsx(se,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"COST TRACKING"]})}),e.jsx("div",{style:{padding:"16px"},children:t.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"rgba(230, 225, 220, 0.4)",fontSize:"11px"},children:"No cost data available"}):e.jsxs(e.Fragment,{children:[t.map((o,i)=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 0",borderBottom:ie.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"8px 10px",background:"rgba(0, 0, 0, 0.2)",border:`1px solid ${s[o.status]}30`},children:[e.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:s[o.status],flexShrink:0}}),e.jsx("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)",width:"60px",flexShrink:0},children:new Date(o.timestamp).toLocaleTimeString()}),e.jsx("div",{style:{fontSize:"10px",color:"#E6E1DC",fontFamily:"var(--font-mono)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.agent}),e.jsx("div",{style:{fontSize:"10px",color:"rgba(230, 225, 220, 0.6)",flex:1},children:o.action}),e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:F[o.tier]||"#6b7280",fontFamily:"var(--font-mono)",padding:"2px 6px",background:`${F[o.tier]||"#6b7280"}20`,flexShrink:0},children:o.tier})]},i))})})]})}function je(){const[t,s]=v.useState(null),[o,i]=v.useState(!0),[r,g]=v.useState("7d"),d=v.useCallback(async()=>{var a,h,m,p,A;i(!0);try{const C=localStorage.getItem("vienna_access_token"),S={"Content-Type":"application/json"};C&&(S.Authorization=`Bearer ${C}`);const[I,L,R]=await Promise.all([fetch("/api/v1/dashboard",{credentials:"include",headers:S}).then(n=>n.json()).catch(()=>({success:!1})),fetch("/api/v1/fleet",{credentials:"include",headers:S}).then(n=>n.json()).catch(()=>({success:!1})),fetch("/api/v1/activity/feed?limit=100",{credentials:"include",headers:S}).then(n=>n.json()).catch(()=>({success:!1}))]),y=I.success?I.data:{},w=L.success?L.data:{},_=R.success?R.data:[],M=w.agents||[],pe=w.summary||{},x=((a=y.executions)==null?void 0:a.total)||0,xe=((h=y.executions)==null?void 0:h.recent_24h)||0,b=((m=y.proposals)==null?void 0:m.total)||0,W=((p=y.proposals)==null?void 0:p.pending)||0,l=((A=y.agents)==null?void 0:A.active)||0,z=b-W,T=b>0?Math.round(z/b*100):0,$=Math.floor(x*.9),H=Math.max(0,T-5),X=Math.floor((b-z)*.8),k=_.slice(0,60).reduce((n,c,f)=>(f%5===0&&n.push(_.slice(f,f+5).length),n),[]).slice(0,12).reverse(),N=k.map(n=>Math.floor(n*(T/100))),O=k.map(n=>Math.floor(n*((100-T)/100))),G=[{label:"TOTAL EXECUTIONS",value:x,previous:$,icon:"TrendingUp",sparkline:k.length>0?k:[0,0,0,0,0,0,0,0,0,0,0,0],color:"blue"},{label:"SUCCESS RATE",value:T,previous:H,unit:"%",icon:"CheckCircle2",sparkline:N.length>0?N:[0,0,0,0,0,0,0,0,0,0,0,0],color:"green"},{label:"FAILED",value:b-z,previous:X,icon:"XCircle",sparkline:O.length>0?O:[0,0,0,0,0,0,0,0,0,0,0,0],color:"red"},{label:"ACTIVE AGENTS",value:l,previous:M.length,icon:"Bot",sparkline:[l,l,l,l,l,l,l,l,l,l,l,l],color:"cyan"},{label:"PENDING APPROVAL",value:W,previous:0,icon:"Zap",sparkline:[0,0,0,0,0,0,0,0,0,0,0,0],color:"amber"}],Y=M.map(n=>{var D;const c=Number(n.actions_today||0),f=Number(n.error_rate||0),u=Math.floor(c*(f/100));return{agent_id:n.agent_id||n.id,agent_name:n.display_name||((D=n.agent_id)==null?void 0:D.slice(0,12))||"Unknown",total_actions:c,successful:c-u,failed:u,avg_latency_ms:Number(n.avg_latency_ms||0),last_activity:n.last_heartbeat||new Date().toISOString(),risk_tier_dist:{T0:Math.floor(c*.6),T1:Math.floor(c*.3),T2:Math.floor(c*.1)}}}).sort((n,c)=>c.total_actions-n.total_actions),E={T0:.001,T1:.01,T2:.05,T3:.1},Z=[{category:"T0 Executions",count:Math.floor(x*.6),estimated_cost:Math.floor(x*.6)*E.T0},{category:"T1 Executions",count:Math.floor(x*.3),estimated_cost:Math.floor(x*.3)*E.T1},{category:"T2 Executions",count:Math.floor(x*.1),estimated_cost:Math.floor(x*.1)*E.T2}],q=_.slice(0,20).map(n=>{var c,f,u;return{timestamp:n.timestamp||new Date().toISOString(),agent:((f=(c=n.agent)==null?void 0:c.id)==null?void 0:f.slice(0,16))||"Unknown",action:((u=n.type)==null?void 0:u.split(".")[1])||"action",tier:n.risk_tier||"T0",status:n.state==="complete"?"success":n.state==="failed"?"failed":"pending"}});s({metrics:G,agents:Y,costs:Z,timeline:q,period:r==="7d"?"Last 7 Days":r==="30d"?"Last 30 Days":"Last 90 Days"})}catch{B("Failed to load analytics","error")}finally{i(!1)}},[r]);v.useEffect(()=>{d()},[d]);const j=()=>{if(!t)return;const a=JSON.stringify(t,null,2),h=new Blob([a],{type:"application/json"}),m=URL.createObjectURL(h),p=document.createElement("a");p.href=m,p.download=`vienna-analytics-${new Date().toISOString().slice(0,10)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),URL.revokeObjectURL(m),B("Analytics exported","success")};return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs(Q,{title:"",description:"",children:[e.jsx("div",{style:{background:"linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:"#fbbf24",margin:0,fontFamily:"var(--font-mono)",letterSpacing:"0.02em"},children:"📈 ANALYTICS TERMINAL"}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.5)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:(t==null?void 0:t.period)||"Loading..."})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("div",{style:{display:"flex",gap:"4px"},children:["7d","30d","90d"].map(a=>e.jsx("button",{onClick:()=>g(a),style:{padding:"6px 12px",background:r===a?"rgba(251, 191, 36, 0.2)":"rgba(0, 0, 0, 0.3)",border:`1px solid ${r===a?"#fbbf24":"rgba(251, 191, 36, 0.2)"}`,color:r===a?"#fbbf24":"rgba(230, 225, 220, 0.5)",fontSize:"10px",fontWeight:700,cursor:"pointer",fontFamily:"var(--font-mono)"},children:a.toUpperCase()},a))}),e.jsx("button",{onClick:j,disabled:!t,style:{padding:"6px 14px",background:t?"rgba(16, 185, 129, 0.2)":"rgba(107, 114, 128, 0.2)",border:`1px solid ${t?"#10b981":"#6b7280"}`,color:t?"#10b981":"#6b7280",fontSize:"10px",fontWeight:700,cursor:t?"pointer":"default",fontFamily:"var(--font-mono)"},children:"📥 EXPORT JSON"})]})]})}),o?e.jsxs("div",{style:{padding:"80px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"32px",height:"32px",border:"3px solid rgba(251, 191, 36, 0.2)",borderTop:"3px solid #fbbf24",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),e.jsx("p",{style:{marginTop:"16px",fontSize:"12px",color:"rgba(230, 225, 220, 0.5)",fontFamily:"var(--font-mono)"},children:"LOADING ANALYTICS..."}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):t&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"12px"},children:t.metrics.map((a,h)=>e.jsx(ae,{metric:a},h))}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"12px"},children:[e.jsx(le,{agents:t.agents}),e.jsx(ce,{costs:t.costs})]}),e.jsx(de,{events:t.timeline})]})]})})})}export{je as AnalyticsPremium}; -//# sourceMappingURL=AnalyticsPremium-BfZNHtV9.js.map diff --git a/apps/console-proxy/public/assets/ApiKeysPage-BxpoSP6i.js b/apps/console-proxy/public/assets/ApiKeysPage-BxpoSP6i.js deleted file mode 100644 index 2823e61f..00000000 --- a/apps/console-proxy/public/assets/ApiKeysPage-BxpoSP6i.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r,j as e,a as h}from"./index-D_7YXFSJ.js";import{P as I}from"./PageLayout-CTYKc2go.js";async function F(){return h.get("/api-keys")}async function W(s){return h.post("/api-keys",s)}async function B(s){return h.post(`/api-keys/${s}/revoke`,{})}function D(){const[s,g]=r.useState([]),[a,d]=r.useState(!0),[c,l]=r.useState(null),[b,p]=r.useState(!1),[o,v]=r.useState(null),[C,m]=r.useState(!1),[y,j]=r.useState(null),x=r.useCallback(async()=>{try{l(null);const t=await F();g(t)}catch(t){l(t.message||"Failed to load API keys")}finally{d(!1)}},[]);r.useEffect(()=>{x()},[x]);const w=async(t,n)=>{m(!0);try{const i=await W({name:t,expires_in_days:n});v(i),p(!1),await x()}catch(i){alert(`Failed to create API key: ${i.message}`)}finally{m(!1)}},z=async(t,n)=>{if(confirm(`Revoke API key "${n}"? This action cannot be undone.`)){j(t);try{await B(t),await x()}catch(i){alert(`Failed to revoke API key: ${i.message}`)}finally{j(null)}}},f=t=>t?new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}):"—",R=t=>{if(t.revoked)return{text:"Revoked",color:"var(--text-muted)"};const n=new Date,i=new Date(t.expires_at);if(i{navigator.clipboard.writeText(t),k(!0),setTimeout(()=>k(!1),2e3)};return e.jsxs(I,{title:"API Keys",description:"Manage API keys for programmatic access",actions:e.jsx("button",{onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid rgba(124, 58, 237, 0.3)",background:"rgba(124, 58, 237, 0.08)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Create API Key"}),children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr",gap:"16px"},children:[o&&e.jsxs("div",{style:{background:"rgba(74, 222, 128, 0.06)",border:"1px solid rgba(74, 222, 128, 0.2)",borderRadius:"12px",padding:"20px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#10b981",marginBottom:"12px"},children:"✓ API Key Created"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginBottom:"12px"},children:o.warning}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",padding:"8px 12px"},children:[e.jsx("code",{style:{flex:1,fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-primary)",wordBreak:"break-all"},children:o.api_key}),e.jsx("button",{onClick:()=>A(o.api_key),style:{padding:"4px 8px",borderRadius:"4px",border:"1px solid rgba(74, 222, 128, 0.3)",background:S?"rgba(74, 222, 128, 0.15)":"rgba(74, 222, 128, 0.08)",color:"#10b981",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"background 0.2s"},children:S?"✓ Copied!":"Copy"})]}),e.jsx("button",{onClick:()=>v(null),style:{marginTop:"12px",padding:"6px 12px",borderRadius:"6px",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Dismiss"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:a?e.jsxs("div",{style:{padding:"40px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"20px",height:"20px",border:"2px solid var(--border-subtle)",borderTop:"2px solid #f59e0b",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsx("p",{style:{marginTop:"12px",fontSize:"12px",color:"var(--text-tertiary)"},children:"Loading API keys..."})]}):c?e.jsxs("div",{style:{padding:"40px",textAlign:"center"},children:[e.jsx("p",{style:{color:"#ef4444",fontSize:"12px"},children:c}),e.jsx("button",{onClick:x,style:{marginTop:"12px",padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(124, 58, 237, 0.3)",background:"rgba(124, 58, 237, 0.08)",color:"#f59e0b",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Retry"})]}):s.length===0?e.jsxs("div",{style:{padding:"40px",textAlign:"center"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--text-secondary)",marginBottom:"8px"},children:"No API keys found"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Create your first API key to get started"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 120px 140px 140px 140px 100px",gap:"16px",padding:"16px 20px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-subtle)",fontSize:"11px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:[e.jsx("div",{children:"Name"}),e.jsx("div",{children:"Key Prefix"}),e.jsx("div",{children:"Created"}),e.jsx("div",{children:"Last Used"}),e.jsx("div",{children:"Expires"}),e.jsx("div",{children:"Status"}),e.jsx("div",{})]}),s.map(t=>{const n=R(t),i=t.revoked,u=new Date(t.expires_at)z(t.id,t.name),disabled:y===t.id,style:{padding:"4px 8px",borderRadius:"4px",border:"1px solid rgba(248, 113, 113, 0.3)",background:"rgba(248, 113, 113, 0.08)",color:"#ef4444",fontSize:"10px",fontWeight:600,cursor:y===t.id?"wait":"pointer",fontFamily:"inherit",opacity:y===t.id?.6:1},children:y===t.id?"Revoking...":"Revoke"})})]},t.id)})]})}),e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px"},children:[e.jsx("h3",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"14px"},children:"API Usage"}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Rate Limit"}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:"60 req/min per key"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Authentication"}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-secondary)"},children:"Bearer Token"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Base URL"}),e.jsxs("span",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:[window.location.origin,"/api/v1"]})]})]})]}),b&&e.jsx(K,{onClose:()=>p(!1),onCreate:w,creating:C})]})}function K({onClose:s,onCreate:g,creating:a}){const[d,c]=r.useState(""),[l,b]=r.useState(90),p=o=>{o.preventDefault(),d.trim()&&g(d.trim(),l)};return e.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,fontFamily:"var(--font-sans)"},children:e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px",width:"400px",maxWidth:"90vw"},children:[e.jsx("h2",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:"Create API Key"}),e.jsxs("form",{onSubmit:p,children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"6px"},children:"Name"}),e.jsx("input",{type:"text",value:d,onChange:o=>c(o.target.value),placeholder:"My API Key",required:!0,style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:"1px solid var(--border-subtle)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:{display:"block",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"6px"},children:"Expires In"}),e.jsxs("select",{value:l,onChange:o=>b(Number(o.target.value)),style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:"1px solid var(--border-subtle)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"12px",fontFamily:"inherit"},children:[e.jsx("option",{value:30,children:"30 days"}),e.jsx("option",{value:90,children:"90 days"}),e.jsx("option",{value:365,children:"1 year"}),e.jsx("option",{value:730,children:"2 years"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{type:"button",onClick:s,disabled:a,style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"12px",fontWeight:600,cursor:a?"wait":"pointer",fontFamily:"inherit",opacity:a?.6:1},children:"Cancel"}),e.jsx("button",{type:"submit",disabled:a||!d.trim(),style:{padding:"8px 16px",borderRadius:"6px",border:"1px solid rgba(124, 58, 237, 0.3)",background:"rgba(124, 58, 237, 0.08)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:a||!d.trim()?"wait":"pointer",fontFamily:"inherit",opacity:a||!d.trim()?.6:1},children:a?"Creating...":"Create Key"})]})]})]})})}export{D as ApiKeysPage}; -//# sourceMappingURL=ApiKeysPage-BxpoSP6i.js.map diff --git a/apps/console-proxy/public/assets/ApprovalsPage-BhISXV7Q.js b/apps/console-proxy/public/assets/ApprovalsPage-BhISXV7Q.js deleted file mode 100644 index 276e24a5..00000000 --- a/apps/console-proxy/public/assets/ApprovalsPage-BhISXV7Q.js +++ /dev/null @@ -1,2 +0,0 @@ -import{d as Q,r as p,R as ne,j as e,b as S,C as re,e as ae,E as Y}from"./index-D_7YXFSJ.js";import{P as se}from"./PageLayout-CTYKc2go.js";import{d as K,a as G,l as ie,b as oe,c as le}from"./approvals-DjAVQ-Zj.js";import{C as de}from"./clock-DwbEOyPD.js";import{C as ce}from"./circle-x-DJXSWLrE.js";const F=43200,V=1440,J=Symbol.for("constructDateFrom");function q(t,r){return typeof t=="function"?t(r):t&&typeof t=="object"&&J in t?t[J](r):t instanceof Date?new t.constructor(r):new Date(r)}function N(t,r){return q(t,t)}let ue={};function me(){return ue}function $(t){const r=N(t),n=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()));return n.setUTCFullYear(r.getFullYear()),+t-+n}function I(t,...r){const n=q.bind(null,t||r.find(o=>typeof o=="object"));return r.map(n)}function W(t,r){const n=+N(t)-+N(r);return n<0?-1:n>0?1:n}function he(t){return q(t,Date.now())}function xe(t,r,n){const[o,a]=I(n==null?void 0:n.in,t,r),l=o.getFullYear()-a.getFullYear(),c=o.getMonth()-a.getMonth();return l*12+c}function pe(t){return r=>{const o=(t?Math[t]:Math.trunc)(r);return o===0?0:o}}function fe(t,r){return+N(t)-+N(r)}function ge(t,r){const n=N(t);return n.setHours(23,59,59,999),n}function ye(t,r){const n=N(t),o=n.getMonth();return n.setFullYear(n.getFullYear(),o+1,0),n.setHours(23,59,59,999),n}function be(t,r){const n=N(t);return+ge(n)==+ye(n)}function ve(t,r,n){const[o,a,l]=I(n==null?void 0:n.in,t,t,r),c=W(a,l),s=Math.abs(xe(a,l));if(s<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-c*s);let b=W(a,l)===-c;be(o)&&s===1&&W(o,l)===1&&(b=!1);const h=c*(s-+b);return h===0?0:h}function je(t,r,n){const o=fe(t,r)/1e3;return pe(n==null?void 0:n.roundingMethod)(o)}const we={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ke=(t,r,n)=>{let o;const a=we[t];return typeof a=="string"?o=a:r===1?o=a.one:o=a.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+o:o+" ago":o};function E(t){return(r={})=>{const n=r.width?String(r.width):t.defaultWidth;return t.formats[n]||t.formats[t.defaultWidth]}}const Se={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},Ne={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},De={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Me={date:E({formats:Se,defaultWidth:"full"}),time:E({formats:Ne,defaultWidth:"full"}),dateTime:E({formats:De,defaultWidth:"full"})},Ae={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},_e=(t,r,n,o)=>Ae[t];function _(t){return(r,n)=>{const o=n!=null&&n.context?String(n.context):"standalone";let a;if(o==="formatting"&&t.formattingValues){const c=t.defaultFormattingWidth||t.defaultWidth,s=n!=null&&n.width?String(n.width):c;a=t.formattingValues[s]||t.formattingValues[c]}else{const c=t.defaultWidth,s=n!=null&&n.width?String(n.width):t.defaultWidth;a=t.values[s]||t.values[c]}const l=t.argumentCallback?t.argumentCallback(r):r;return a[l]}}const Ce={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Pe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Te={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},Fe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},We={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},Re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},ze=(t,r)=>{const n=Number(t),o=n%100;if(o>20||o<10)switch(o%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Ee={ordinalNumber:ze,era:_({values:Ce,defaultWidth:"wide"}),quarter:_({values:Pe,defaultWidth:"wide",argumentCallback:t=>t-1}),month:_({values:Te,defaultWidth:"wide"}),day:_({values:Fe,defaultWidth:"wide"}),dayPeriod:_({values:We,defaultWidth:"wide",formattingValues:Re,defaultFormattingWidth:"wide"})};function C(t){return(r,n={})=>{const o=n.width,a=o&&t.matchPatterns[o]||t.matchPatterns[t.defaultMatchWidth],l=r.match(a);if(!l)return null;const c=l[0],s=o&&t.parsePatterns[o]||t.parsePatterns[t.defaultParseWidth],b=Array.isArray(s)?qe(s,x=>x.test(c)):Be(s,x=>x.test(c));let h;h=t.valueCallback?t.valueCallback(b):b,h=n.valueCallback?n.valueCallback(h):h;const j=r.slice(c.length);return{value:h,rest:j}}}function Be(t,r){for(const n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&r(t[n]))return n}function qe(t,r){for(let n=0;n{const o=r.match(t.matchPattern);if(!o)return null;const a=o[0],l=r.match(t.parsePattern);if(!l)return null;let c=t.valueCallback?t.valueCallback(l[0]):l[0];c=n.valueCallback?n.valueCallback(c):c;const s=r.slice(a.length);return{value:c,rest:s}}}const Le=/^(\d+)(th|st|nd|rd)?/i,Xe=/\d+/i,Oe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},He={any:[/^b/i,/^(a|c)/i]},Ye={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ve={any:[/1/i,/2/i,/3/i,/4/i]},Je={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},$e={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Ue={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Qe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ke={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ge={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Ze={ordinalNumber:Ie({matchPattern:Le,parsePattern:Xe,valueCallback:t=>parseInt(t,10)}),era:C({matchPatterns:Oe,defaultMatchWidth:"wide",parsePatterns:He,defaultParseWidth:"any"}),quarter:C({matchPatterns:Ye,defaultMatchWidth:"wide",parsePatterns:Ve,defaultParseWidth:"any",valueCallback:t=>t+1}),month:C({matchPatterns:Je,defaultMatchWidth:"wide",parsePatterns:$e,defaultParseWidth:"any"}),day:C({matchPatterns:Ue,defaultMatchWidth:"wide",parsePatterns:Qe,defaultParseWidth:"any"}),dayPeriod:C({matchPatterns:Ke,defaultMatchWidth:"any",parsePatterns:Ge,defaultParseWidth:"any"})},et={code:"en-US",formatDistance:ke,formatLong:Me,formatRelative:_e,localize:Ee,match:Ze,options:{weekStartsOn:0,firstWeekContainsDate:1}};function tt(t,r,n){const o=me(),a=(n==null?void 0:n.locale)??o.locale??et,l=2520,c=W(t,r);if(isNaN(c))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c}),[b,h]=I(n==null?void 0:n.in,...c>0?[r,t]:[t,r]),j=je(h,b),x=($(h)-$(b))/1e3,d=Math.round((j-x)/60);let u;if(d<2)return n!=null&&n.includeSeconds?j<5?a.formatDistance("lessThanXSeconds",5,s):j<10?a.formatDistance("lessThanXSeconds",10,s):j<20?a.formatDistance("lessThanXSeconds",20,s):j<40?a.formatDistance("halfAMinute",0,s):j<60?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",1,s):d===0?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",d,s);if(d<45)return a.formatDistance("xMinutes",d,s);if(d<90)return a.formatDistance("aboutXHours",1,s);if(dm.user),[c,s]=p.useState(!1),[b,h]=p.useState(!1),[j,x]=p.useState(""),[d,u]=p.useState(null);ne.useEffect(()=>{console.log("[ApprovalCard] Rendering approval:",{approval_id:t.approval_id,tier:t.tier,target_id:t.target_id,requested_at:t.requested_at,requested_at_type:typeof t.requested_at})},[t]);const v=async()=>{if(!l){u("Not authenticated");return}try{s(!0),u(null),await G(t.approval_id,(l==null?void 0:l.email)||"unknown"),r()}catch(m){console.error("Approve failed:",m),u(m instanceof Error?m.message:"Approval failed")}finally{s(!1)}},y=async()=>{if(!j.trim()){u("Denial reason is required");return}if(!l){u("Not authenticated");return}try{s(!0),u(null),await K(t.approval_id,(l==null?void 0:l.email)||"unknown",j),r()}catch(m){console.error("Deny failed:",m),u(m instanceof Error?m.message:"Denial failed")}finally{s(!1)}},w=t.is_expired,f=t.time_until_expiry_ms?Math.floor(t.time_until_expiry_ms/1e3/60):null,k=()=>{let m="rounded-lg border p-4 transition-all";return o&&(m+=" ring-2 ring-blue-500/50"),n?m+=" bg-amber-950/20 border-amber-500/30":m+=" bg-neutral-900/50 border-neutral-700/50",m};return e.jsxs("div",{className:k(),children:[e.jsx("div",{className:"flex items-start justify-between mb-3",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${t.tier==="T2"?"bg-red-900/30 text-red-400 border border-red-500/30":"bg-blue-900/30 text-blue-400 border border-blue-500/30"}`,children:t.tier}),e.jsx("span",{className:"text-neutral-400 text-xs",children:t.action_type})]}),e.jsx("h4",{className:"text-sm font-medium text-neutral-200",children:t.action_summary})]})}),e.jsxs("div",{className:"text-xs text-neutral-400 mb-3",children:[e.jsx("span",{className:"font-medium",children:"Target:"})," ",t.target_id]}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Requested:"})," ",e.jsx("span",{className:"text-neutral-300",children:t.requested_at?Z(t.requested_at,{addSuffix:!0}):"Unknown"})]}),f!==null&&e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Expires:"})," ",e.jsxs("span",{className:f<5?"text-amber-400 font-medium":"text-neutral-300",children:[f,"m"]})]})]}),a&&e.jsxs("div",{className:"mb-3 p-3 bg-neutral-950/50 rounded border border-neutral-700/30",children:[e.jsx("h5",{className:"text-xs font-medium text-neutral-400 mb-2",children:"Additional Details"}),e.jsxs("div",{className:"space-y-1 text-xs text-neutral-300",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Plan ID:"})," ",t.plan_id]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Execution ID:"})," ",t.execution_id]}),t.step_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Step ID:"})," ",t.step_id]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Requested by:"})," ",t.requested_by]}),t.metadata&&Object.keys(t.metadata).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"text-neutral-500",children:"Metadata:"}),e.jsx("pre",{className:"mt-1 p-2 bg-neutral-900 rounded text-xs overflow-x-auto",children:JSON.stringify(t.metadata,null,2)})]})]})]}),d&&e.jsx("div",{className:"mb-3 p-2 bg-red-900/20 border border-red-500/30 rounded text-xs text-red-400",children:d}),b&&e.jsx("div",{className:"mb-3",children:e.jsx("textarea",{value:j,onChange:m=>x(m.target.value),placeholder:"Reason for denial (required)",className:"w-full px-3 py-2 bg-neutral-950 border border-neutral-700 rounded text-sm text-neutral-200 placeholder-neutral-500 focus:outline-none focus:ring-1 focus:ring-blue-500",rows:2})}),!w&&e.jsx("div",{className:"flex gap-2",children:b?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:y,disabled:c||!j.trim(),className:"flex-1 px-3 py-1.5 bg-red-600 hover:bg-red-500 disabled:bg-neutral-700 disabled:text-neutral-500 text-white rounded text-sm font-medium transition-colors",children:c?"Denying...":"Confirm Deny"}),e.jsx("button",{onClick:()=>{h(!1),x(""),u(null)},disabled:c,className:"px-3 py-1.5 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded text-sm font-medium transition-colors",children:"Cancel"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:v,disabled:c,className:"flex-1 px-3 py-1.5 bg-green-600 hover:bg-green-500 disabled:bg-neutral-700 disabled:text-neutral-500 text-white rounded text-sm font-medium transition-colors",children:c?"Approving...":"Approve"}),e.jsx("button",{onClick:()=>h(!0),disabled:c,className:"flex-1 px-3 py-1.5 bg-neutral-700 hover:bg-neutral-600 disabled:bg-neutral-800 text-neutral-300 rounded text-sm font-medium transition-colors",children:"Deny"})]})}),w&&e.jsx("div",{className:"text-center py-2 text-xs text-neutral-500",children:"Expired"})]})}const nt=p.forwardRef(({onApprovalChange:t,focusedApprovalId:r,onApprovalFocus:n,showExpandedDetails:o},a)=>{const[l,c]=p.useState([]),[s,b]=p.useState(!0),[h,j]=p.useState(null),[x,d]=p.useState("all"),[u,v]=p.useState(new Set),[y,w]=p.useState(null),[f,k]=p.useState(""),[m,L]=p.useState(!1),D=Q(i=>i.user),P=async()=>{try{b(!0),j(null);const i={status:"pending"};x!=="all"&&(i.tier=x);const g=await ie(i);console.log("[PendingApprovalsList] Loaded approvals:",g.length),console.log("[PendingApprovalsList] First approval:",g[0]),c(g)}catch(i){console.error("[PendingApprovalsList] Load error:",i),j(i instanceof Error?i.message:"Failed to load approvals")}finally{b(!1)}};p.useEffect(()=>{P();const i=setInterval(P,1e4);return()=>clearInterval(i)},[x]);const M=()=>{P(),t&&t()};p.useImperativeHandle(a,()=>({approveApproval:async i=>{if(D)try{await G(i,D.email||"unknown"),S("Approval approved successfully","success"),M()}catch(g){console.error("Failed to approve:",g),S("Failed to approve","error")}},denyApproval:async i=>{if(!D)return;const g=prompt("Enter denial reason:");if(g!=null&&g.trim())try{await K(i,D.email||"unknown",g),S("Approval denied successfully","success"),M()}catch(A){console.error("Failed to deny:",A),S("Failed to deny approval","error")}}}));const X=(i,g)=>{v(A=>{const z=new Set(A);return g?z.add(i):z.delete(i),z})},ee=i=>{v(i?new Set(l.map(g=>g.approval_id)):new Set)},te=async i=>{if(u.size===0||!D)return;if(i==="deny"&&!f.trim()){S("Denial reason is required for bulk deny","error");return}L(!0);const g=Array.from(u);try{i==="approve"?(await oe(g,D.email||"unknown"),S(`Successfully approved ${g.length} approvals`,"success")):(await le(g,D.email||"unknown",f),S(`Successfully denied ${g.length} approvals`,"success")),v(new Set),w(null),k(""),M()}catch(A){console.error("Bulk action failed:",A),S(`Failed to ${i} approvals`,"error")}finally{L(!1)}},O=i=>{n&&n(i===r?null:i)};if(s&&l.length===0)return e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})});if(h)return e.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 rounded-lg p-4",children:[e.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",h]}),e.jsx("button",{onClick:P,className:"mt-2 text-red-300 hover:text-red-200 underline text-sm",children:"Retry"})]});const H=Date.now(),T=l.filter(i=>i.expires_at&&i.expires_at-H<5*60*1e3&&!i.is_expired),R=l.filter(i=>!i.is_expired&&!(i.expires_at&&i.expires_at-H<5*60*1e3));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("button",{onClick:()=>d("all"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:x==="all"?600:400,color:x==="all"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:x==="all"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:["All (",l.length,")"]}),e.jsx("button",{onClick:()=>d("T1"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:x==="T1"?600:400,color:x==="T1"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:x==="T1"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:"T1"}),e.jsx("button",{onClick:()=>d("T2"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:x==="T2"?600:400,color:x==="T2"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:x==="T2"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:"T2"})]}),l.length>0&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:u.size===l.length&&l.length>0,onChange:i=>ee(i.target.checked),style:{width:"16px",height:"16px",accentColor:"var(--text-primary)"}}),"Select All"]})})]}),u.size>0&&e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("span",{style:{fontSize:"14px",color:"var(--text-secondary)"},children:[u.size," selected"]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("button",{onClick:()=>w("approve"),disabled:m,style:{padding:"8px 16px",background:"#059669",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m?"not-allowed":"pointer",opacity:m?.6:1,fontFamily:"var(--font-sans)"},children:["Approve All (",u.size,")"]}),e.jsxs("button",{onClick:()=>w("deny"),disabled:m,style:{padding:"8px 16px",background:"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m?"not-allowed":"pointer",opacity:m?.6:1,fontFamily:"var(--font-sans)"},children:["Deny All (",u.size,")"]}),e.jsx("button",{onClick:()=>v(new Set),style:{padding:"8px 12px",background:"transparent",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"13px",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Clear"})]})]}),y&&e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"16px"},children:[e.jsxs("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",marginBottom:"12px"},children:[y==="approve"?"Bulk Approve":"Bulk Deny"," ",u.size," Approvals"]}),y==="deny"&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",color:"var(--text-secondary)",marginBottom:"6px"},children:"Denial Reason (required):"}),e.jsx("textarea",{value:f,onChange:i=>k(i.target.value),placeholder:"Enter reason for denying all selected approvals...",style:{width:"100%",padding:"8px 12px",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"13px",fontFamily:"var(--font-sans)",resize:"vertical",minHeight:"60px"},rows:3})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>{w(null),k("")},disabled:m,style:{padding:"8px 16px",background:"transparent",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"13px",cursor:m?"not-allowed":"pointer",fontFamily:"var(--font-sans)"},children:"Cancel"}),e.jsx("button",{onClick:()=>te(y),disabled:m||y==="deny"&&!f.trim(),style:{padding:"8px 16px",background:y==="approve"?"#059669":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m||y==="deny"&&!f.trim()?"not-allowed":"pointer",opacity:m||y==="deny"&&!f.trim()?.6:1,fontFamily:"var(--font-sans)"},children:m?"Processing...":`Confirm ${y==="approve"?"Approve":"Deny"}`})]})]}),l.length===0&&e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"text-neutral-500 mb-2",children:e.jsx("svg",{className:"w-12 h-12 mx-auto mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),e.jsx("p",{className:"text-neutral-400 text-sm",children:"No pending approvals"})]}),T.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),e.jsxs("h3",{className:"text-sm font-medium text-amber-400",children:["Expiring Soon (",T.length,")"]})]}),e.jsx("div",{className:"space-y-3",children:T.map(i=>e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[e.jsx("input",{type:"checkbox",checked:u.has(i.approval_id),onChange:g=>X(i.approval_id,g.target.checked),style:{width:"16px",height:"16px",marginTop:"4px",accentColor:"var(--text-primary)"}}),e.jsx("div",{style:{flex:1,cursor:"pointer"},onClick:()=>O(i.approval_id),children:e.jsx(U,{approval:i,onAction:M,urgent:!0,focused:r===i.approval_id,showExpandedDetails:r===i.approval_id&&o})})]},i.approval_id))})]}),R.length>0&&e.jsxs("div",{children:[T.length>0&&e.jsxs("h3",{className:"text-sm font-medium text-neutral-400 mb-3",children:["Pending (",R.length,")"]}),e.jsx("div",{className:"space-y-3",children:R.map(i=>e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[e.jsx("input",{type:"checkbox",checked:u.has(i.approval_id),onChange:g=>X(i.approval_id,g.target.checked),style:{width:"16px",height:"16px",marginTop:"4px",accentColor:"var(--text-primary)"}}),e.jsx("div",{style:{flex:1,cursor:"pointer"},onClick:()=>O(i.approval_id),children:e.jsx(U,{approval:i,onAction:M,focused:r===i.approval_id,showExpandedDetails:r===i.approval_id&&o})})]},i.approval_id))})]})]})});function rt({limit:t=50}){const[r,n]=p.useState([]),[o,a]=p.useState(!0),[l,c]=p.useState({total:0,approved:0,denied:0,avgResponseTime:0});return p.useEffect(()=>{(async()=>{try{const[b,h]=await Promise.all([fetch(`/api/v1/approvals?status=approved&limit=${t}`,{credentials:"include"}),fetch(`/api/v1/approvals?status=denied&limit=${t}`,{credentials:"include"})]),j=await b.json(),x=await h.json(),d=[...j.data||[],...x.data||[]].sort((f,k)=>k.reviewed_at-f.reviewed_at).slice(0,t);n(d);const u=d.filter(f=>f.status==="approved").length,v=d.filter(f=>f.status==="denied").length,y=d.filter(f=>f.reviewed_at&&f.requested_at).map(f=>f.reviewed_at-f.requested_at),w=y.length>0?y.reduce((f,k)=>f+k,0)/y.length:0;c({total:d.length,approved:u,denied:v,avgResponseTime:w})}catch(b){console.error("Failed to fetch approval history:",b)}finally{a(!1)}})()},[t]),o?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full mx-auto"}),e.jsx("p",{className:"text-neutral-400 mt-3",children:"Loading history..."})]}):e.jsxs("div",{className:"space-y-4",children:[r.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[e.jsx("div",{className:"text-sm text-neutral-400",children:"Total Decisions"}),e.jsx("div",{className:"text-2xl font-bold text-neutral-200 mt-1",children:l.total})]}),e.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[e.jsx("div",{className:"text-sm text-neutral-400",children:"Approved"}),e.jsx("div",{className:"text-2xl font-bold text-green-400 mt-1",children:l.approved})]}),e.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[e.jsx("div",{className:"text-sm text-neutral-400",children:"Denied"}),e.jsx("div",{className:"text-2xl font-bold text-red-400 mt-1",children:l.denied})]}),e.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[e.jsx("div",{className:"text-sm text-neutral-400",children:"Avg Response Time"}),e.jsxs("div",{className:"text-2xl font-bold text-blue-400 mt-1",children:[Math.round(l.avgResponseTime/1e3),"s"]})]})]}),r.length===0?e.jsxs("div",{className:"text-center py-12 bg-neutral-900/50 rounded-lg border border-neutral-700/50",children:[e.jsx(de,{className:"w-12 h-12 mx-auto mb-3 text-neutral-600"}),e.jsx("p",{className:"text-neutral-400",children:"No approval history yet"}),e.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:"Approved and denied requests will appear here"})]}):e.jsx("div",{className:"space-y-2",children:r.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-neutral-900/30 rounded-lg border border-neutral-700/30 hover:border-neutral-600/50 transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.status==="approved"?e.jsx(re,{className:"w-5 h-5 text-green-400 flex-shrink-0"}):e.jsx(ce,{className:"w-5 h-5 text-red-400 flex-shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-neutral-200 truncate",children:s.action_summary||s.action_type||"Action"}),e.jsxs("div",{className:"text-xs text-neutral-500 mt-1",children:[s.reviewed_by||"Unknown operator"," · ",Z(s.reviewed_at)," ago"]}),s.decision_reason&&e.jsxs("div",{className:"text-xs text-neutral-400 mt-1 italic",children:['"',s.decision_reason,'"']})]})]}),e.jsx("span",{className:`px-3 py-1 rounded text-xs font-medium flex-shrink-0 ${s.tier==="T2"?"bg-red-900/30 text-red-400 border border-red-700/50":"bg-blue-900/30 text-blue-400 border border-blue-700/50"}`,children:s.tier})]},s.approval_id))})]})}function dt(){const[t,r]=p.useState(0),[n,o]=p.useState("pending"),[a,l]=p.useState(null),[c,s]=p.useState(!1),{isMobile:b}=ae(),h=p.useRef(null),j=()=>{r(d=>d+1)};p.useEffect(()=>{const d=u=>{var v,y;if(!(n!=="pending"||((v=u.target)==null?void 0:v.tagName)==="INPUT"||((y=u.target)==null?void 0:y.tagName)==="TEXTAREA"))switch(u.key){case" ":u.preventDefault(),a&&s(w=>!w);break;case"a":case"A":u.preventDefault(),a&&h.current&&h.current.approveApproval(a);break;case"d":case"D":u.preventDefault(),a&&h.current&&h.current.denyApproval(a);break;case"Escape":u.preventDefault(),s(!1),l(null);break}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n,a]);const x=d=>{l(d),d&&s(!1)};return e.jsxs(se,{title:"Approvals",description:"Review and authorize pending T1/T2 agent actions",children:[e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"24px",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"0"},children:["pending","history"].map(d=>e.jsx("button",{onClick:()=>o(d),style:{padding:"8px 16px",fontSize:"13px",fontWeight:n===d?600:400,color:n===d?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:n===d?"2px solid var(--text-primary)":"2px solid transparent",borderRadius:0,cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms"},children:d==="pending"?"⏳ Pending":"📜 History"},d))}),n==="pending"&&e.jsx(Y,{children:e.jsx(nt,{ref:h,onApprovalChange:j,focusedApprovalId:a,onApprovalFocus:x,showExpandedDetails:c},t)}),n==="history"&&e.jsx(Y,{children:e.jsx(rt,{limit:100})}),n==="pending"&&e.jsx("div",{style:{position:"fixed",bottom:"0",left:"0",right:"0",background:"var(--bg-secondary)",borderTop:"1px solid var(--border-subtle)",padding:"8px 16px",fontSize:"12px",color:"var(--text-tertiary)",textAlign:"center",zIndex:1e3,fontFamily:"var(--font-mono)"},children:"⌨️ Space: expand · A: approve · D: deny · Esc: close"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:b?"1fr":"repeat(3, 1fr)",gap:"12px",marginTop:"24px",marginBottom:n==="pending"?"40px":"0"},children:[e.jsx(B,{tier:"T0",label:"Auto-Approve",desc:"Read-only, status checks, internal queries",color:"#94a3b8"}),e.jsx(B,{tier:"T1",label:"Single Approval",desc:"Config changes, service restarts, data writes",color:"#f59e0b"}),e.jsx(B,{tier:"T2",label:"Multi-Party",desc:"Deployments, payments, data deletion",color:"#ef4444"})]})]})}function B({tier:t,label:r,desc:n,color:o}){return e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"12px",padding:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:o,fontFamily:"var(--font-mono)"},children:t}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:r})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)",lineHeight:1.5},children:n})]})}export{dt as ApprovalsPage}; -//# sourceMappingURL=ApprovalsPage-BhISXV7Q.js.map diff --git a/apps/console-proxy/public/assets/ApprovalsPage-BuPTwH8y.js b/apps/console-proxy/public/assets/ApprovalsPage-BuPTwH8y.js new file mode 100644 index 00000000..7112a900 --- /dev/null +++ b/apps/console-proxy/public/assets/ApprovalsPage-BuPTwH8y.js @@ -0,0 +1,2 @@ +import{e as P,f as K,r as x,R as re,j as t,g as S,C as ae,h as se,E as $}from"./index-C0nK3ekl.js";import{P as oe}from"./PageLayout-D94mSHCV.js";import{C as ie}from"./clock-C0m9VzJk.js";import{C as le}from"./circle-x-DX5Kt33e.js";async function de(e){const r=new URLSearchParams;return e!=null&&e.status&&r.append("status",e.status),e!=null&&e.tier&&r.append("tier",e.tier),e!=null&&e.target_id&&r.append("target_id",e.target_id),e!=null&&e.limit&&r.append("limit",e.limit.toString()),await P.get(`/approvals?${r.toString()}`)}async function G(e,r,n){return await P.post(`/approvals/${e}/approve`,{reviewed_by:r,decision_reason:null})}async function Z(e,r,n){return await P.post(`/approvals/${e}/deny`,{reviewed_by:r,decision_reason:n})}async function ce(e,r,n){return await P.post("/approvals/bulk/approve",{approval_ids:e,reviewed_by:r,decision_reason:null})}async function ue(e,r,n){return await P.post("/approvals/bulk/deny",{approval_ids:e,reviewed_by:r,decision_reason:n})}const W=43200,V=1440,J=Symbol.for("constructDateFrom");function L(e,r){return typeof e=="function"?e(r):e&&typeof e=="object"&&J in e?e[J](r):e instanceof Date?new e.constructor(r):new Date(r)}function N(e,r){return L(e,e)}let me={};function pe(){return me}function U(e){const r=N(e),n=new Date(Date.UTC(r.getFullYear(),r.getMonth(),r.getDate(),r.getHours(),r.getMinutes(),r.getSeconds(),r.getMilliseconds()));return n.setUTCFullYear(r.getFullYear()),+e-+n}function I(e,...r){const n=L.bind(null,e||r.find(o=>typeof o=="object"));return r.map(n)}function R(e,r){const n=+N(e)-+N(r);return n<0?-1:n>0?1:n}function he(e){return L(e,Date.now())}function xe(e,r,n){const[o,a]=I(n==null?void 0:n.in,e,r),l=o.getFullYear()-a.getFullYear(),c=o.getMonth()-a.getMonth();return l*12+c}function fe(e){return r=>{const o=(e?Math[e]:Math.trunc)(r);return o===0?0:o}}function ge(e,r){return+N(e)-+N(r)}function ye(e,r){const n=N(e);return n.setHours(23,59,59,999),n}function be(e,r){const n=N(e),o=n.getMonth();return n.setFullYear(n.getFullYear(),o+1,0),n.setHours(23,59,59,999),n}function ve(e,r){const n=N(e);return+ye(n)==+be(n)}function je(e,r,n){const[o,a,l]=I(n==null?void 0:n.in,e,e,r),c=R(a,l),s=Math.abs(xe(a,l));if(s<1)return 0;a.getMonth()===1&&a.getDate()>27&&a.setDate(30),a.setMonth(a.getMonth()-c*s);let b=R(a,l)===-c;ve(o)&&s===1&&R(o,l)===1&&(b=!1);const p=c*(s-+b);return p===0?0:p}function we(e,r,n){const o=ge(e,r)/1e3;return fe(n==null?void 0:n.roundingMethod)(o)}const ke={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},Se=(e,r,n)=>{let o;const a=ke[e];return typeof a=="string"?o=a:r===1?o=a.one:o=a.other.replace("{{count}}",r.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+o:o+" ago":o};function B(e){return(r={})=>{const n=r.width?String(r.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const Ne={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},De={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Me={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},Ae={date:B({formats:Ne,defaultWidth:"full"}),time:B({formats:De,defaultWidth:"full"}),dateTime:B({formats:Me,defaultWidth:"full"})},_e={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},Ce=(e,r,n,o)=>_e[e];function _(e){return(r,n)=>{const o=n!=null&&n.context?String(n.context):"standalone";let a;if(o==="formatting"&&e.formattingValues){const c=e.defaultFormattingWidth||e.defaultWidth,s=n!=null&&n.width?String(n.width):c;a=e.formattingValues[s]||e.formattingValues[c]}else{const c=e.defaultWidth,s=n!=null&&n.width?String(n.width):e.defaultWidth;a=e.values[s]||e.values[c]}const l=e.argumentCallback?e.argumentCallback(r):r;return a[l]}}const Pe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},Te={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},Fe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},We={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},Re={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ze={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},Ee=(e,r)=>{const n=Number(e),o=n%100;if(o>20||o<10)switch(o%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},Be={ordinalNumber:Ee,era:_({values:Pe,defaultWidth:"wide"}),quarter:_({values:Te,defaultWidth:"wide",argumentCallback:e=>e-1}),month:_({values:Fe,defaultWidth:"wide"}),day:_({values:We,defaultWidth:"wide"}),dayPeriod:_({values:Re,defaultWidth:"wide",formattingValues:ze,defaultFormattingWidth:"wide"})};function C(e){return(r,n={})=>{const o=n.width,a=o&&e.matchPatterns[o]||e.matchPatterns[e.defaultMatchWidth],l=r.match(a);if(!l)return null;const c=l[0],s=o&&e.parsePatterns[o]||e.parsePatterns[e.defaultParseWidth],b=Array.isArray(s)?Le(s,h=>h.test(c)):qe(s,h=>h.test(c));let p;p=e.valueCallback?e.valueCallback(b):b,p=n.valueCallback?n.valueCallback(p):p;const j=r.slice(c.length);return{value:p,rest:j}}}function qe(e,r){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&r(e[n]))return n}function Le(e,r){for(let n=0;n{const o=r.match(e.matchPattern);if(!o)return null;const a=o[0],l=r.match(e.parsePattern);if(!l)return null;let c=e.valueCallback?e.valueCallback(l[0]):l[0];c=n.valueCallback?n.valueCallback(c):c;const s=r.slice(a.length);return{value:c,rest:s}}}const Xe=/^(\d+)(th|st|nd|rd)?/i,Oe=/\d+/i,He={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},Ye={any:[/^b/i,/^(a|c)/i]},$e={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},Ve={any:[/1/i,/2/i,/3/i,/4/i]},Je={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},Ue={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},Qe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Ke={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},Ge={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Ze={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},et={ordinalNumber:Ie({matchPattern:Xe,parsePattern:Oe,valueCallback:e=>parseInt(e,10)}),era:C({matchPatterns:He,defaultMatchWidth:"wide",parsePatterns:Ye,defaultParseWidth:"any"}),quarter:C({matchPatterns:$e,defaultMatchWidth:"wide",parsePatterns:Ve,defaultParseWidth:"any",valueCallback:e=>e+1}),month:C({matchPatterns:Je,defaultMatchWidth:"wide",parsePatterns:Ue,defaultParseWidth:"any"}),day:C({matchPatterns:Qe,defaultMatchWidth:"wide",parsePatterns:Ke,defaultParseWidth:"any"}),dayPeriod:C({matchPatterns:Ge,defaultMatchWidth:"any",parsePatterns:Ze,defaultParseWidth:"any"})},tt={code:"en-US",formatDistance:Se,formatLong:Ae,formatRelative:Ce,localize:Be,match:et,options:{weekStartsOn:0,firstWeekContainsDate:1}};function nt(e,r,n){const o=pe(),a=(n==null?void 0:n.locale)??o.locale??tt,l=2520,c=R(e,r);if(isNaN(c))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:c}),[b,p]=I(n==null?void 0:n.in,...c>0?[r,e]:[e,r]),j=we(p,b),h=(U(p)-U(b))/1e3,d=Math.round((j-h)/60);let u;if(d<2)return n!=null&&n.includeSeconds?j<5?a.formatDistance("lessThanXSeconds",5,s):j<10?a.formatDistance("lessThanXSeconds",10,s):j<20?a.formatDistance("lessThanXSeconds",20,s):j<40?a.formatDistance("halfAMinute",0,s):j<60?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",1,s):d===0?a.formatDistance("lessThanXMinutes",1,s):a.formatDistance("xMinutes",d,s);if(d<45)return a.formatDistance("xMinutes",d,s);if(d<90)return a.formatDistance("aboutXHours",1,s);if(dm.user),[c,s]=x.useState(!1),[b,p]=x.useState(!1),[j,h]=x.useState(""),[d,u]=x.useState(null);re.useEffect(()=>{console.log("[ApprovalCard] Rendering approval:",{approval_id:e.approval_id,tier:e.tier,target_id:e.target_id,requested_at:e.requested_at,requested_at_type:typeof e.requested_at})},[e]);const v=async()=>{if(!l){u("Not authenticated");return}try{s(!0),u(null),await G(e.approval_id,(l==null?void 0:l.email)||"unknown"),r()}catch(m){console.error("Approve failed:",m),u(m instanceof Error?m.message:"Approval failed")}finally{s(!1)}},y=async()=>{if(!j.trim()){u("Denial reason is required");return}if(!l){u("Not authenticated");return}try{s(!0),u(null),await Z(e.approval_id,(l==null?void 0:l.email)||"unknown",j),r()}catch(m){console.error("Deny failed:",m),u(m instanceof Error?m.message:"Denial failed")}finally{s(!1)}},w=e.is_expired,f=e.time_until_expiry_ms?Math.floor(e.time_until_expiry_ms/1e3/60):null,k=()=>{let m="rounded-lg border p-4 transition-all";return o&&(m+=" ring-2 ring-blue-500/50"),n?m+=" bg-amber-950/20 border-amber-500/30":m+=" bg-neutral-900/50 border-neutral-700/50",m};return t.jsxs("div",{className:k(),children:[t.jsx("div",{className:"flex items-start justify-between mb-3",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[t.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${e.tier==="T2"?"bg-red-900/30 text-red-400 border border-red-500/30":"bg-blue-900/30 text-blue-400 border border-blue-500/30"}`,children:e.tier}),t.jsx("span",{className:"text-neutral-400 text-xs",children:e.action_type})]}),t.jsx("h4",{className:"text-sm font-medium text-neutral-200",children:e.action_summary})]})}),t.jsxs("div",{className:"text-xs text-neutral-400 mb-3",children:[t.jsx("span",{className:"font-medium",children:"Target:"})," ",e.target_id]}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-3 text-xs",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Requested:"})," ",t.jsx("span",{className:"text-neutral-300",children:e.requested_at?ee(e.requested_at,{addSuffix:!0}):"Unknown"})]}),f!==null&&t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Expires:"})," ",t.jsxs("span",{className:f<5?"text-amber-400 font-medium":"text-neutral-300",children:[f,"m"]})]})]}),a&&t.jsxs("div",{className:"mb-3 p-3 bg-neutral-950/50 rounded border border-neutral-700/30",children:[t.jsx("h5",{className:"text-xs font-medium text-neutral-400 mb-2",children:"Additional Details"}),t.jsxs("div",{className:"space-y-1 text-xs text-neutral-300",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Plan ID:"})," ",e.plan_id]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Execution ID:"})," ",e.execution_id]}),e.step_id&&t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Step ID:"})," ",e.step_id]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Requested by:"})," ",e.requested_by]}),e.metadata&&Object.keys(e.metadata).length>0&&t.jsxs("div",{children:[t.jsx("span",{className:"text-neutral-500",children:"Metadata:"}),t.jsx("pre",{className:"mt-1 p-2 bg-neutral-900 rounded text-xs overflow-x-auto",children:JSON.stringify(e.metadata,null,2)})]})]})]}),d&&t.jsx("div",{className:"mb-3 p-2 bg-red-900/20 border border-red-500/30 rounded text-xs text-red-400",children:d}),b&&t.jsx("div",{className:"mb-3",children:t.jsx("textarea",{value:j,onChange:m=>h(m.target.value),placeholder:"Reason for denial (required)",className:"w-full px-3 py-2 bg-neutral-950 border border-neutral-700 rounded text-sm text-neutral-200 placeholder-neutral-500 focus:outline-none focus:ring-1 focus:ring-blue-500",rows:2})}),!w&&t.jsx("div",{className:"flex gap-2",children:b?t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:y,disabled:c||!j.trim(),className:"flex-1 px-3 py-1.5 bg-red-600 hover:bg-red-500 disabled:bg-neutral-700 disabled:text-neutral-500 text-white rounded text-sm font-medium transition-colors",children:c?"Denying...":"Confirm Deny"}),t.jsx("button",{onClick:()=>{p(!1),h(""),u(null)},disabled:c,className:"px-3 py-1.5 bg-neutral-700 hover:bg-neutral-600 text-neutral-300 rounded text-sm font-medium transition-colors",children:"Cancel"})]}):t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:v,disabled:c,className:"flex-1 px-3 py-1.5 bg-green-600 hover:bg-green-500 disabled:bg-neutral-700 disabled:text-neutral-500 text-white rounded text-sm font-medium transition-colors",children:c?"Approving...":"Approve"}),t.jsx("button",{onClick:()=>p(!0),disabled:c,className:"flex-1 px-3 py-1.5 bg-neutral-700 hover:bg-neutral-600 disabled:bg-neutral-800 text-neutral-300 rounded text-sm font-medium transition-colors",children:"Deny"})]})}),w&&t.jsx("div",{className:"text-center py-2 text-xs text-neutral-500",children:"Expired"})]})}const rt=x.forwardRef(({onApprovalChange:e,focusedApprovalId:r,onApprovalFocus:n,showExpandedDetails:o},a)=>{const[l,c]=x.useState([]),[s,b]=x.useState(!0),[p,j]=x.useState(null),[h,d]=x.useState("all"),[u,v]=x.useState(new Set),[y,w]=x.useState(null),[f,k]=x.useState(""),[m,X]=x.useState(!1),D=K(i=>i.user),T=async()=>{try{b(!0),j(null);const i={status:"pending"};h!=="all"&&(i.tier=h);const g=await de(i);console.log("[PendingApprovalsList] Loaded approvals:",g.length),console.log("[PendingApprovalsList] First approval:",g[0]),c(g)}catch(i){console.error("[PendingApprovalsList] Load error:",i),j(i instanceof Error?i.message:"Failed to load approvals")}finally{b(!1)}};x.useEffect(()=>{T();const i=setInterval(T,1e4);return()=>clearInterval(i)},[h]);const M=()=>{T(),e&&e()};x.useImperativeHandle(a,()=>({approveApproval:async i=>{if(D)try{await G(i,D.email||"unknown"),S("Approval approved successfully","success"),M()}catch(g){console.error("Failed to approve:",g),S("Failed to approve","error")}},denyApproval:async i=>{if(!D)return;const g=prompt("Enter denial reason:");if(g!=null&&g.trim())try{await Z(i,D.email||"unknown",g),S("Approval denied successfully","success"),M()}catch(A){console.error("Failed to deny:",A),S("Failed to deny approval","error")}}}));const O=(i,g)=>{v(A=>{const E=new Set(A);return g?E.add(i):E.delete(i),E})},te=i=>{v(i?new Set(l.map(g=>g.approval_id)):new Set)},ne=async i=>{if(u.size===0||!D)return;if(i==="deny"&&!f.trim()){S("Denial reason is required for bulk deny","error");return}X(!0);const g=Array.from(u);try{i==="approve"?(await ce(g,D.email||"unknown"),S(`Successfully approved ${g.length} approvals`,"success")):(await ue(g,D.email||"unknown",f),S(`Successfully denied ${g.length} approvals`,"success")),v(new Set),w(null),k(""),M()}catch(A){console.error("Bulk action failed:",A),S(`Failed to ${i} approvals`,"error")}finally{X(!1)}},H=i=>{n&&n(i===r?null:i)};if(s&&l.length===0)return t.jsx("div",{className:"flex items-center justify-center py-8",children:t.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"})});if(p)return t.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 rounded-lg p-4",children:[t.jsxs("p",{className:"text-red-400 text-sm",children:["Error: ",p]}),t.jsx("button",{onClick:T,className:"mt-2 text-red-300 hover:text-red-200 underline text-sm",children:"Retry"})]});const Y=Date.now(),F=l.filter(i=>i.expires_at&&i.expires_at-Y<5*60*1e3&&!i.is_expired),z=l.filter(i=>!i.is_expired&&!(i.expires_at&&i.expires_at-Y<5*60*1e3));return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"8px"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("button",{onClick:()=>d("all"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:h==="all"?600:400,color:h==="all"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:h==="all"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:["All (",l.length,")"]}),t.jsx("button",{onClick:()=>d("T1"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:h==="T1"?600:400,color:h==="T1"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:h==="T1"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:"T1"}),t.jsx("button",{onClick:()=>d("T2"),style:{padding:"8px 16px",fontSize:"14px",fontWeight:h==="T2"?600:400,color:h==="T2"?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:h==="T2"?"2px solid var(--text-primary)":"2px solid transparent",cursor:"pointer",transition:"all 150ms"},children:"T2"})]}),l.length>0&&t.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"13px",color:"var(--text-secondary)",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:u.size===l.length&&l.length>0,onChange:i=>te(i.target.checked),style:{width:"16px",height:"16px",accentColor:"var(--text-primary)"}}),"Select All"]})})]}),u.size>0&&t.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"12px 16px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("span",{style:{fontSize:"14px",color:"var(--text-secondary)"},children:[u.size," selected"]}),t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsxs("button",{onClick:()=>w("approve"),disabled:m,style:{padding:"8px 16px",background:"#059669",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m?"not-allowed":"pointer",opacity:m?.6:1,fontFamily:"var(--font-sans)"},children:["Approve All (",u.size,")"]}),t.jsxs("button",{onClick:()=>w("deny"),disabled:m,style:{padding:"8px 16px",background:"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m?"not-allowed":"pointer",opacity:m?.6:1,fontFamily:"var(--font-sans)"},children:["Deny All (",u.size,")"]}),t.jsx("button",{onClick:()=>v(new Set),style:{padding:"8px 12px",background:"transparent",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"13px",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Clear"})]})]}),y&&t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"16px"},children:[t.jsxs("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",marginBottom:"12px"},children:[y==="approve"?"Bulk Approve":"Bulk Deny"," ",u.size," Approvals"]}),y==="deny"&&t.jsxs("div",{style:{marginBottom:"16px"},children:[t.jsx("label",{style:{display:"block",fontSize:"13px",color:"var(--text-secondary)",marginBottom:"6px"},children:"Denial Reason (required):"}),t.jsx("textarea",{value:f,onChange:i=>k(i.target.value),placeholder:"Enter reason for denying all selected approvals...",style:{width:"100%",padding:"8px 12px",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"13px",fontFamily:"var(--font-sans)",resize:"vertical",minHeight:"60px"},rows:3})]}),t.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[t.jsx("button",{onClick:()=>{w(null),k("")},disabled:m,style:{padding:"8px 16px",background:"transparent",color:"var(--text-tertiary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"13px",cursor:m?"not-allowed":"pointer",fontFamily:"var(--font-sans)"},children:"Cancel"}),t.jsx("button",{onClick:()=>ne(y),disabled:m||y==="deny"&&!f.trim(),style:{padding:"8px 16px",background:y==="approve"?"#059669":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"13px",fontWeight:500,cursor:m||y==="deny"&&!f.trim()?"not-allowed":"pointer",opacity:m||y==="deny"&&!f.trim()?.6:1,fontFamily:"var(--font-sans)"},children:m?"Processing...":`Confirm ${y==="approve"?"Approve":"Deny"}`})]})]}),l.length===0&&t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"text-neutral-500 mb-2",children:t.jsx("svg",{className:"w-12 h-12 mx-auto mb-3 opacity-50",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}),t.jsx("p",{className:"text-neutral-400 text-sm",children:"No pending approvals"})]}),F.length>0&&t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[t.jsx("div",{className:"w-2 h-2 rounded-full bg-amber-500 animate-pulse"}),t.jsxs("h3",{className:"text-sm font-medium text-amber-400",children:["Expiring Soon (",F.length,")"]})]}),t.jsx("div",{className:"space-y-3",children:F.map(i=>t.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[t.jsx("input",{type:"checkbox",checked:u.has(i.approval_id),onChange:g=>O(i.approval_id,g.target.checked),style:{width:"16px",height:"16px",marginTop:"4px",accentColor:"var(--text-primary)"}}),t.jsx("div",{style:{flex:1,cursor:"pointer"},onClick:()=>H(i.approval_id),children:t.jsx(Q,{approval:i,onAction:M,urgent:!0,focused:r===i.approval_id,showExpandedDetails:r===i.approval_id&&o})})]},i.approval_id))})]}),z.length>0&&t.jsxs("div",{children:[F.length>0&&t.jsxs("h3",{className:"text-sm font-medium text-neutral-400 mb-3",children:["Pending (",z.length,")"]}),t.jsx("div",{className:"space-y-3",children:z.map(i=>t.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"flex-start"},children:[t.jsx("input",{type:"checkbox",checked:u.has(i.approval_id),onChange:g=>O(i.approval_id,g.target.checked),style:{width:"16px",height:"16px",marginTop:"4px",accentColor:"var(--text-primary)"}}),t.jsx("div",{style:{flex:1,cursor:"pointer"},onClick:()=>H(i.approval_id),children:t.jsx(Q,{approval:i,onAction:M,focused:r===i.approval_id,showExpandedDetails:r===i.approval_id&&o})})]},i.approval_id))})]})]})});function at({limit:e=50}){const[r,n]=x.useState([]),[o,a]=x.useState(!0),[l,c]=x.useState({total:0,approved:0,denied:0,avgResponseTime:0});return x.useEffect(()=>{(async()=>{try{const[b,p]=await Promise.all([fetch(`/api/v1/approvals?status=approved&limit=${e}`,{credentials:"include"}),fetch(`/api/v1/approvals?status=denied&limit=${e}`,{credentials:"include"})]),j=await b.json(),h=await p.json(),d=[...j.data||[],...h.data||[]].sort((f,k)=>k.reviewed_at-f.reviewed_at).slice(0,e);n(d);const u=d.filter(f=>f.status==="approved").length,v=d.filter(f=>f.status==="denied").length,y=d.filter(f=>f.reviewed_at&&f.requested_at).map(f=>f.reviewed_at-f.requested_at),w=y.length>0?y.reduce((f,k)=>f+k,0)/y.length:0;c({total:d.length,approved:u,denied:v,avgResponseTime:w})}catch(b){console.error("Failed to fetch approval history:",b)}finally{a(!1)}})()},[e]),o?t.jsxs("div",{className:"text-center py-12",children:[t.jsx("div",{className:"animate-spin w-8 h-8 border-2 border-blue-500 border-t-transparent rounded-full mx-auto"}),t.jsx("p",{className:"text-neutral-400 mt-3",children:"Loading history..."})]}):t.jsxs("div",{className:"space-y-4",children:[r.length>0&&t.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-6",children:[t.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[t.jsx("div",{className:"text-sm text-neutral-400",children:"Total Decisions"}),t.jsx("div",{className:"text-2xl font-bold text-neutral-200 mt-1",children:l.total})]}),t.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[t.jsx("div",{className:"text-sm text-neutral-400",children:"Approved"}),t.jsx("div",{className:"text-2xl font-bold text-green-400 mt-1",children:l.approved})]}),t.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[t.jsx("div",{className:"text-sm text-neutral-400",children:"Denied"}),t.jsx("div",{className:"text-2xl font-bold text-red-400 mt-1",children:l.denied})]}),t.jsxs("div",{className:"bg-neutral-900/50 rounded-lg border border-neutral-700/50 p-4",children:[t.jsx("div",{className:"text-sm text-neutral-400",children:"Avg Response Time"}),t.jsxs("div",{className:"text-2xl font-bold text-blue-400 mt-1",children:[Math.round(l.avgResponseTime/1e3),"s"]})]})]}),r.length===0?t.jsxs("div",{className:"text-center py-12 bg-neutral-900/50 rounded-lg border border-neutral-700/50",children:[t.jsx(ie,{className:"w-12 h-12 mx-auto mb-3 text-neutral-600"}),t.jsx("p",{className:"text-neutral-400",children:"No approval history yet"}),t.jsx("p",{className:"text-sm text-neutral-500 mt-1",children:"Approved and denied requests will appear here"})]}):t.jsx("div",{className:"space-y-2",children:r.map(s=>t.jsxs("div",{className:"flex items-center justify-between p-4 bg-neutral-900/30 rounded-lg border border-neutral-700/30 hover:border-neutral-600/50 transition-colors",children:[t.jsxs("div",{className:"flex items-center gap-4 flex-1",children:[s.status==="approved"?t.jsx(ae,{className:"w-5 h-5 text-green-400 flex-shrink-0"}):t.jsx(le,{className:"w-5 h-5 text-red-400 flex-shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("div",{className:"text-sm font-medium text-neutral-200 truncate",children:s.action_summary||s.action_type||"Action"}),t.jsxs("div",{className:"text-xs text-neutral-500 mt-1",children:[s.reviewed_by||"Unknown operator"," · ",ee(s.reviewed_at)," ago"]}),s.decision_reason&&t.jsxs("div",{className:"text-xs text-neutral-400 mt-1 italic",children:['"',s.decision_reason,'"']})]})]}),t.jsx("span",{className:`px-3 py-1 rounded text-xs font-medium flex-shrink-0 ${s.tier==="T2"?"bg-red-900/30 text-red-400 border border-red-700/50":"bg-blue-900/30 text-blue-400 border border-blue-700/50"}`,children:s.tier})]},s.approval_id))})]})}function dt(){const[e,r]=x.useState(0),[n,o]=x.useState("pending"),[a,l]=x.useState(null),[c,s]=x.useState(!1),{isMobile:b}=se(),p=x.useRef(null),j=()=>{r(d=>d+1)};x.useEffect(()=>{const d=u=>{var v,y;if(!(n!=="pending"||((v=u.target)==null?void 0:v.tagName)==="INPUT"||((y=u.target)==null?void 0:y.tagName)==="TEXTAREA"))switch(u.key){case" ":u.preventDefault(),a&&s(w=>!w);break;case"a":case"A":u.preventDefault(),a&&p.current&&p.current.approveApproval(a);break;case"d":case"D":u.preventDefault(),a&&p.current&&p.current.denyApproval(a);break;case"Escape":u.preventDefault(),s(!1),l(null);break}};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[n,a]);const h=d=>{l(d),d&&s(!1)};return t.jsxs(oe,{title:"Approvals",description:"Review and authorize pending T1/T2 agent actions",children:[t.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"24px",borderBottom:"1px solid var(--border-subtle)",paddingBottom:"0"},children:["pending","history"].map(d=>t.jsx("button",{onClick:()=>o(d),style:{padding:"8px 16px",fontSize:"13px",fontWeight:n===d?600:400,color:n===d?"var(--text-primary)":"var(--text-tertiary)",background:"transparent",border:"none",borderBottom:n===d?"2px solid var(--text-primary)":"2px solid transparent",borderRadius:0,cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms"},children:d==="pending"?"⏳ Pending":"📜 History"},d))}),n==="pending"&&t.jsx($,{children:t.jsx(rt,{ref:p,onApprovalChange:j,focusedApprovalId:a,onApprovalFocus:h,showExpandedDetails:c},e)}),n==="history"&&t.jsx($,{children:t.jsx(at,{limit:100})}),n==="pending"&&t.jsx("div",{style:{position:"fixed",bottom:"0",left:"0",right:"0",background:"var(--bg-secondary)",borderTop:"1px solid var(--border-subtle)",padding:"8px 16px",fontSize:"12px",color:"var(--text-tertiary)",textAlign:"center",zIndex:1e3,fontFamily:"var(--font-mono)"},children:"⌨️ Space: expand · A: approve · D: deny · Esc: close"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:b?"1fr":"repeat(3, 1fr)",gap:"12px",marginTop:"24px",marginBottom:n==="pending"?"40px":"0"},children:[t.jsx(q,{tier:"T0",label:"Auto-Approve",desc:"Read-only, status checks, internal queries",color:"#94a3b8"}),t.jsx(q,{tier:"T1",label:"Single Approval",desc:"Config changes, service restarts, data writes",color:"#f59e0b"}),t.jsx(q,{tier:"T2",label:"Multi-Party",desc:"Deployments, payments, data deletion",color:"#ef4444"})]})]})}function q({tier:e,label:r,desc:n,color:o}){return t.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"12px",padding:"16px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[t.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:o,fontFamily:"var(--font-mono)"},children:e}),t.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:r})]}),t.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)",lineHeight:1.5},children:n})]})}export{dt as ApprovalsPage}; +//# sourceMappingURL=ApprovalsPage-BuPTwH8y.js.map diff --git a/apps/console-proxy/public/assets/ApprovalsPremium-CdjJuruO.js b/apps/console-proxy/public/assets/ApprovalsPremium-CdjJuruO.js deleted file mode 100644 index 6bbf0f34..00000000 --- a/apps/console-proxy/public/assets/ApprovalsPremium-CdjJuruO.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as n,j as e,X as q,T as M,C,d as P,w as I,A as L}from"./index-D_7YXFSJ.js";import{g as B,a as T,d as $,l as D}from"./approvals-DjAVQ-Zj.js";import{C as E}from"./clock-DwbEOyPD.js";import{C as z}from"./circle-x-DJXSWLrE.js";function H({approvalId:s,onClose:o,onApprove:x,onDeny:u}){const[v,g]=n.useState(null),[b,h]=n.useState(!0),[c,p]=n.useState(null);n.useEffect(()=>{w()},[s]);const w=async()=>{try{const d=await B(s);g(d)}catch(d){console.error("Failed to load approval detail:",d)}finally{h(!1)}},f=async()=>{p("approve");try{await T(s,"operator","Approved via console"),x==null||x(),o()}catch(d){console.error("Approve failed:",d)}finally{p(null)}},_=async()=>{p("deny");try{await $(s,"operator","Denied via console"),u==null||u(),o()}catch(d){console.error("Deny failed:",d)}finally{p(null)}};if(b)return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.8)"},children:e.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-subtle)",borderTopColor:"var(--accent-primary)"}})});if(!v)return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.8)"},onClick:o,children:e.jsxs("div",{className:"rounded-lg p-6 max-w-md",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("h2",{className:"text-lg font-bold mb-2",style:{color:"var(--text-primary)"},children:"Warrant Not Found"}),e.jsxs("p",{className:"text-sm mb-4",style:{color:"var(--text-secondary)"},children:["Approval ID: ",s]}),e.jsx("button",{onClick:o,className:"px-4 py-2 rounded-lg font-semibold",style:{background:"var(--accent-primary)",color:"#000"},children:"Close"})]})});const{approval:a,plan:j,execution:m}=v,A=a.tier==="T1"?"text-red-500":"text-amber-500",N=a.tier==="T1"?"rgba(239, 68, 68, 0.3)":"rgba(245, 158, 11, 0.3)";return e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",style:{background:"rgba(0, 0, 0, 0.85)"},onClick:o,children:e.jsxs("div",{className:"rounded-lg max-w-4xl w-full max-h-[90vh] overflow-y-auto",style:{background:"var(--bg-secondary)",border:`1px solid ${N}`},onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{className:"sticky top-0 p-6 flex items-center justify-between",style:{background:"var(--bg-secondary)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold mb-1",style:{color:"var(--text-primary)"},children:"Warrant Detail"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-xs font-mono font-semibold uppercase px-2 py-0.5 rounded ${A}`,style:{background:a.tier==="T1"?"rgba(239, 68, 68, 0.15)":"rgba(245, 158, 11, 0.15)",border:`1px solid ${N}`},children:a.tier}),e.jsx("span",{className:"text-xs font-mono",style:{color:"var(--text-muted)"},children:a.approval_id})]})]}),e.jsx("button",{onClick:o,className:"p-2 rounded-lg hover:opacity-80 transition-opacity",style:{background:"var(--bg-app)"},children:e.jsx(q,{size:20,style:{color:"var(--text-tertiary)"}})})]}),e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Requested Action"}),e.jsxs("div",{className:"rounded p-4",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:[e.jsx("p",{className:"text-base font-medium mb-2",style:{color:"var(--text-primary)"},children:a.action_summary}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono",style:{color:"var(--text-tertiary)"},children:[e.jsxs("span",{children:["Type: ",a.action_type]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Target: ",a.target_id]}),e.jsx("span",{children:"•"}),e.jsxs("span",{children:["Requested: ",new Date(a.requested_at).toLocaleString()]})]})]})]}),j&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Execution Plan"}),e.jsx("div",{className:"rounded p-4 font-mono text-xs",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:e.jsx("pre",{className:"whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:JSON.stringify(j,null,2)})})]}),m&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Execution Context"}),e.jsx("div",{className:"rounded p-4",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-xs",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--text-muted)"},children:"Execution ID:"}),e.jsx("span",{className:"ml-2 font-mono",style:{color:"var(--text-secondary)"},children:a.execution_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--text-muted)"},children:"Plan ID:"}),e.jsx("span",{className:"ml-2 font-mono",style:{color:"var(--text-secondary)"},children:a.plan_id})]}),a.step_id&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--text-muted)"},children:"Step ID:"}),e.jsx("span",{className:"ml-2 font-mono",style:{color:"var(--text-secondary)"},children:a.step_id})]}),e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",style:{color:"var(--text-muted)"},children:"Requested By:"}),e.jsx("span",{className:"ml-2 font-mono",style:{color:"var(--text-secondary)"},children:a.requested_by})]})]})})]}),a.metadata&&Object.keys(a.metadata).length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-xs font-bold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:"Additional Context"}),e.jsx("div",{className:"rounded p-4 font-mono text-xs",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:e.jsx("pre",{className:"whitespace-pre-wrap",style:{color:"var(--text-secondary)"},children:JSON.stringify(a.metadata,null,2)})})]}),a.is_expired&&e.jsxs("div",{className:"rounded p-3 flex items-center gap-3",style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)"},children:[e.jsx(M,{className:"text-red-500 shrink-0",size:18}),e.jsx("span",{className:"text-sm text-red-500 font-semibold",children:"This warrant has expired and cannot be approved."})]}),a.expires_at&&!a.is_expired&&e.jsxs("div",{className:"rounded p-3 flex items-center gap-3",style:{background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.3)"},children:[e.jsx(E,{className:"text-amber-500 shrink-0",size:18}),e.jsxs("span",{className:"text-sm text-amber-500 font-semibold",children:["Expires: ",new Date(a.expires_at).toLocaleString()]})]})]}),a.status==="pending"&&!a.is_expired&&e.jsxs("div",{className:"sticky bottom-0 p-6 flex items-center gap-3",style:{background:"var(--bg-secondary)",borderTop:"1px solid var(--border-subtle)"},children:[e.jsxs("button",{onClick:f,disabled:c==="approve",className:"flex-1 py-3 rounded-lg font-bold text-sm uppercase tracking-wider transition-colors flex items-center justify-center gap-2",style:{background:"rgba(16, 185, 129, 0.9)",color:"#fff"},children:[e.jsx(C,{size:18}),c==="approve"?"Approving...":"Approve"]}),e.jsxs("button",{onClick:_,disabled:c==="deny",className:"flex-1 py-3 rounded-lg font-bold text-sm uppercase tracking-wider transition-colors flex items-center justify-center gap-2",style:{background:"rgba(239, 68, 68, 0.9)",color:"#fff"},children:[e.jsx(z,{size:18}),c==="deny"?"Denying...":"Deny"]})]})]})})}function Q(){const[s,o]=n.useState([]),[x,u]=n.useState([]),[v,g]=n.useState(!0),[b,h]=n.useState(!1),[c,p]=n.useState(null),[w,f]=n.useState({approved:0,denied:0}),[_,a]=n.useState(null),j=P(),m=n.useCallback(async(t=!1)=>{t&&h(!0);try{const[l,r,i]=await Promise.all([D({status:"pending",limit:50}),D({status:"approved",limit:10}),D({status:"denied",limit:10})]);o(Array.isArray(l)?l:l.data||[]);const y=[...Array.isArray(r)?r:r.data||[],...Array.isArray(i)?i:i.data||[]].sort((k,R)=>(R.reviewed_at||0)-(k.reviewed_at||0)).slice(0,10);u(y)}catch(l){console.error("Failed to load approvals:",l)}finally{g(!1),h(!1)}},[]);n.useEffect(()=>{m()},[m]),n.useEffect(()=>{const t=setInterval(()=>m(),15e3);return()=>clearInterval(t)},[m]),n.useEffect(()=>{const t=l=>{if(l.target instanceof HTMLInputElement||l.target instanceof HTMLTextAreaElement||s.length===0||c)return;const r=s[0];(l.key==="a"||l.key==="A")&&A(r.approval_id),(l.key==="d"||l.key==="D")&&N(r.approval_id)};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[s,c]);const A=async t=>{var l;p(t);try{await T(t,((l=j.user)==null?void 0:l.email)||"operator","Approved via console"),o(r=>r.filter(i=>i.approval_id!==t)),f(r=>({...r,approved:r.approved+1}))}catch(r){console.error("Approve failed:",r)}finally{p(null)}},N=async t=>{var l;p(t);try{await $(t,((l=j.user)==null?void 0:l.email)||"operator","Denied via console"),o(r=>r.filter(i=>i.approval_id!==t)),f(r=>({...r,denied:r.denied+1}))}catch(r){console.error("Deny failed:",r)}finally{p(null)}};if(v)return e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-subtle)",borderTopColor:"var(--accent-primary)"}})});const d=s.filter(t=>t.tier==="T2").length;return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsxs("div",{style:{position:"relative",zIndex:1},className:"space-y-6 max-w-5xl mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",style:{color:"var(--text-primary)"},children:"Approvals"}),e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--text-tertiary)"},children:"High-urgency queue for critical agent authorizations"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>m(!0),disabled:b,className:"p-2 rounded-lg transition-colors hover:opacity-80",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(I,{size:16,className:b?"animate-spin":"",style:{color:"var(--text-tertiary)"}})}),e.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 rounded-lg",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold",style:{color:"var(--text-muted)"},children:"Queue"}),e.jsxs("span",{className:"text-sm font-mono font-bold",style:{color:"var(--accent-primary)"},children:[s.length," pending"]})]}),e.jsx(E,{size:18,style:{color:"var(--text-tertiary)"}})]})]})]}),d>0&&e.jsxs("div",{className:"rounded-lg py-3 px-4 flex items-center gap-3",style:{background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.2)"},children:[e.jsx(L,{className:"text-red-400 shrink-0",size:18}),e.jsxs("span",{className:"text-[13px] font-semibold text-red-300",children:[d," tier-2 warrant",d!==1?"s":""," pending approval"]})]}),s.length===0?e.jsxs("div",{className:"rounded-lg p-12 text-center",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-4",style:{background:"rgba(16,185,129,0.1)"},children:e.jsx(C,{className:"text-emerald-500",size:32})}),e.jsx("h2",{className:"text-xl font-bold mb-2",style:{color:"var(--text-primary)"},children:"All Clear"}),e.jsx("p",{className:"text-sm",style:{color:"var(--text-muted)"},children:"No pending approvals in the queue."})]}):e.jsx("div",{className:"space-y-3",children:s.map((t,l)=>{const r=t.tier==="T2",i=r?"rgba(239,68,68,0.3)":"rgba(245,158,11,0.2)",y=c===t.approval_id;return e.jsxs("div",{className:`rounded-lg p-5 transition-all cursor-pointer hover:opacity-95 ${y?"opacity-50":""}`,style:{background:"var(--bg-secondary)",border:`1px solid ${i}`},onClick:()=>a(t.approval_id),children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`px-2 py-1 rounded text-[10px] font-bold uppercase tracking-wider border ${r?"bg-red-500/10 text-red-400 border-red-500/30":"bg-amber-500/10 text-amber-400 border-amber-500/30"}`,children:t.tier}),e.jsxs("div",{className:"flex flex-col",children:[e.jsx("span",{className:"font-mono text-sm font-semibold",style:{color:"var(--accent-primary)"},children:t.approval_id}),e.jsxs("span",{className:"font-mono text-[11px]",style:{color:"var(--text-muted)"},children:["Agent: ",t.target_id||t.requested_by]})]})]}),t.expires_at&&e.jsxs("div",{className:"flex flex-col items-end",children:[e.jsx("span",{className:"text-[10px] uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Timeout"}),e.jsx(F,{expiresAt:t.expires_at,isT2:r})]})]}),e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider mb-1 font-semibold",style:{color:"var(--text-muted)"},children:"Requested Action"}),e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--text-primary)"},children:[t.action_type,": ",t.action_summary]})]}),e.jsx("div",{className:"flex items-center justify-between mb-4 pb-3",style:{borderBottom:"1px solid var(--border-subtle)"},children:e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:["Status: ",e.jsx("span",{className:r?"text-red-400":"text-amber-400",children:t.status})]}),e.jsxs("span",{children:["Submitted: ",t.requested_at?S(t.requested_at):"—"]})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:k=>{k.stopPropagation(),A(t.approval_id)},disabled:y,className:"flex-1 bg-emerald-600 hover:bg-emerald-700 text-white px-4 py-2.5 rounded-lg font-bold text-[13px] uppercase tracking-wider transition-colors flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(C,{size:16})," Approve"]}),e.jsxs("button",{onClick:k=>{k.stopPropagation(),N(t.approval_id)},disabled:y,className:"flex-1 bg-red-600 hover:bg-red-700 text-white px-4 py-2.5 rounded-lg font-bold text-[13px] uppercase tracking-wider transition-colors flex items-center justify-center gap-2 disabled:opacity-50",children:[e.jsx(z,{size:16})," Deny"]})]}),l===0&&e.jsxs("div",{className:"mt-2.5 flex items-center gap-4 text-[10px] font-mono",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1.5 py-0.5 rounded",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:"A"})," Approve"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"px-1.5 py-0.5 rounded",style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)"},children:"D"})," Deny"]})]})]},t.approval_id)})}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"Pending"}),e.jsx("div",{className:"font-mono text-2xl font-bold",style:{color:"var(--accent-primary)"},children:s.length})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"Approved (session)"}),e.jsx("div",{className:"font-mono text-2xl font-bold text-emerald-500",children:w.approved})]}),e.jsxs("div",{className:"rounded-lg p-4",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] uppercase tracking-wider mb-1",style:{color:"var(--text-muted)"},children:"Denied (session)"}),e.jsx("div",{className:"font-mono text-2xl font-bold text-red-500",children:w.denied})]})]}),x.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsx("h2",{className:"text-lg font-bold mb-3",style:{color:"var(--text-primary)"},children:"Recent Decisions"}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{style:{borderBottom:"1px solid var(--border-subtle)"},children:e.jsxs("tr",{children:[e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Agent"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Action"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Requested By"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Reviewed By"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Decision"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Time to Resolution"}),e.jsx("th",{className:"py-2 px-4 text-left text-[10px] font-semibold uppercase tracking-wider",style:{color:"var(--text-muted)"},children:"Reviewed At"})]})}),e.jsx("tbody",{children:x.map((t,l)=>{var y;const r=t.reviewed_at&&t.requested_at?O(t.reviewed_at-t.requested_at):"—",i=t.status==="approved";return e.jsxs("tr",{style:{borderBottom:la(null),onApprove:()=>{m(),f(t=>({...t,approved:t.approved+1}))},onDeny:()=>{m(),f(t=>({...t,denied:t.denied+1}))}})]})})}function F({expiresAt:s,isT2:o}){const[x,u]=n.useState("");return n.useEffect(()=>{const v=()=>{const b=s-Date.now();if(b<=0){u("EXPIRED");return}const h=Math.floor(b/6e4),c=Math.floor(b%6e4/1e3);u(`${h}m ${c.toString().padStart(2,"0")}s`)};v();const g=setInterval(v,1e3);return()=>clearInterval(g)},[s]),e.jsx("span",{className:`font-mono text-sm font-bold ${o?"text-red-400":"text-amber-400"}`,children:x})}function S(s){const o=Date.now()-s;return o<6e4?`${Math.floor(o/1e3)}s ago`:o<36e5?`${Math.floor(o/6e4)}m ago`:`${Math.floor(o/36e5)}h ago`}function O(s){return s<1e3?`${s}ms`:s<6e4?`${Math.floor(s/1e3)}s`:s<36e5?`${Math.floor(s/6e4)}m ${Math.floor(s%6e4/1e3)}s`:`${Math.floor(s/36e5)}h ${Math.floor(s%36e5/6e4)}m`}export{Q as default}; -//# sourceMappingURL=ApprovalsPremium-CdjJuruO.js.map diff --git a/apps/console-proxy/public/assets/CompliancePage-Bpt_D9yK.js b/apps/console-proxy/public/assets/CompliancePage-C5o8sfAA.js similarity index 99% rename from apps/console-proxy/public/assets/CompliancePage-Bpt_D9yK.js rename to apps/console-proxy/public/assets/CompliancePage-C5o8sfAA.js index a20e5500..e58baefc 100644 --- a/apps/console-proxy/public/assets/CompliancePage-Bpt_D9yK.js +++ b/apps/console-proxy/public/assets/CompliancePage-C5o8sfAA.js @@ -1,2 +1,2 @@ -import{a as j,r as d,j as e}from"./index-D_7YXFSJ.js";const g={getQuickStats:(s=30)=>j.get("/compliance/quick-stats",{period:s}),listReports:(s=50,i=0)=>j.get("/compliance/reports",{limit:s,offset:i}),getReport:s=>j.get(`/compliance/reports/${s}`),generateReport:s=>j.post("/compliance/reports/generate",s),deleteReport:s=>j.delete(`/compliance/reports/${s}`),getPdfUrl:s=>`/api/v1/compliance/reports/${s}/pdf`,getCsvUrl:s=>`/api/v1/compliance/reports/${s}/csv`,listTemplates:()=>j.get("/compliance/templates"),createTemplate:s=>j.post("/compliance/templates",s),updateTemplate:(s,i)=>j.put(`/compliance/templates/${s}`,i),createSchedule:s=>j.post("/compliance/schedule",s)},B={executive_summary:"Executive Summary",governance_overview:"Governance Overview",action_volume:"Action Volume",policy_compliance:"Policy Compliance",agent_performance:"Agent Performance",risk_analysis:"Risk Analysis",approval_metrics:"Approval Metrics",violations_incidents:"Violations & Incidents",integration_health:"Integration Health",recommendations:"Recommendations"},M=Object.keys(B),t={page:{padding:"0"},statsGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"12px",marginBottom:"28px"},statCard:s=>({background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"20px",textAlign:"center"}),statValue:s=>({fontSize:"32px",fontWeight:700,color:s,lineHeight:1.1}),statLabel:{fontSize:"11px",color:"#94a3b8",marginTop:"6px",textTransform:"uppercase",letterSpacing:"0.5px"},statUnit:{fontSize:"14px",fontWeight:400,color:"#64748b"},periodBar:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},periodBtn:s=>({padding:"6px 14px",fontSize:"12px",fontWeight:s?600:400,color:s?"#f59e0b":"#94a3b8",background:s?"rgba(245,158,11,0.15)":"transparent",border:"1px solid "+(s?"rgba(245,158,11,0.3)":"rgba(255,255,255,0.08)"),borderRadius:"0",cursor:"pointer",marginLeft:"6px"}),tabBar:{display:"flex",gap:"2px",marginBottom:"24px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},tab:s=>({padding:"10px 18px",fontSize:"13px",fontWeight:s?600:400,color:s?"var(--text-primary)":"#94a3b8",background:"transparent",border:"none",borderBottom:s?"2px solid var(--text-primary)":"2px solid transparent",borderRadius:0,cursor:"pointer"}),primaryBtn:{padding:"10px 20px",fontSize:"13px",fontWeight:600,color:"#fff",background:"#f59e0b",border:"none",borderRadius:"0",cursor:"pointer"},secondaryBtn:{padding:"8px 16px",fontSize:"12px",fontWeight:500,color:"#f59e0b",background:"rgba(245,158,11,0.1)",border:"1px solid rgba(245,158,11,0.2)",borderRadius:"0",cursor:"pointer"},dangerBtn:{padding:"6px 12px",fontSize:"11px",fontWeight:500,color:"#ef4444",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:"0",cursor:"pointer"},ghostBtn:{padding:"6px 12px",fontSize:"11px",fontWeight:500,color:"#94a3b8",background:"transparent",border:"1px solid rgba(251, 191, 36, 0.15)",borderRadius:"0",cursor:"pointer"},overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},modal:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",padding:"28px",width:"520px",maxHeight:"80vh",overflow:"auto"},modalTitle:{fontSize:"18px",fontWeight:700,color:"#e2e8f0",marginBottom:"20px"},formGroup:{marginBottom:"16px"},label:{display:"block",fontSize:"12px",fontWeight:600,color:"#94a3b8",marginBottom:"6px",textTransform:"uppercase",letterSpacing:"0.5px"},select:{width:"100%",padding:"10px 12px",fontSize:"13px",color:"#e2e8f0",background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",outline:"none"},input:{width:"100%",padding:"10px 12px",fontSize:"13px",color:"#e2e8f0",background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",outline:"none"},checkbox:{marginRight:"8px"},checkboxLabel:{fontSize:"13px",color:"#cbd5e1",cursor:"pointer"},table:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},th:{padding:"10px 12px",textAlign:"left",fontWeight:600,color:"#94a3b8",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},td:{padding:"10px 12px",borderBottom:"1px solid rgba(251, 191, 36, 0.1)",color:"#cbd5e1"},viewerWrapper:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"0",overflow:"hidden",border:"1px solid rgba(251, 191, 36, 0.2)"},viewerToolbar:{display:"flex",gap:"8px",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",background:"var(--bg-panel, #0F1419)",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},viewerContent:{padding:"32px 40px",background:"var(--surface-secondary, #12131a)"},viewerNav:{position:"sticky",top:0,display:"flex",flexDirection:"column",gap:"2px",padding:"12px",background:"var(--bg-app, #0A0E14)",borderRight:"1px solid rgba(251, 191, 36, 0.15)",minWidth:"200px"},viewerNavItem:s=>({padding:"8px 12px",fontSize:"12px",fontWeight:s?600:400,color:s?"#f59e0b":"#64748b",background:s?"rgba(245,158,11,0.08)":"transparent",border:"none",borderRadius:"0",cursor:"pointer",textAlign:"left"}),badge:(s,i)=>({display:"inline-block",padding:"2px 10px",borderRadius:"0",fontSize:"11px",fontWeight:600,color:s,background:i}),statusBadge:s=>{const i={ready:["#166534","#dcfce7"],generating:["#854d0e","#fef9c3"],failed:["#991b1b","#fee2e2"],scheduled:["#1e40af","#dbeafe"]},[l,r]=i[s]||["#64748b","#f1f5f9"];return{display:"inline-block",padding:"2px 10px",borderRadius:"0",fontSize:"11px",fontWeight:600,color:l,background:r}},sectionBlock:{marginBottom:"32px",color:"#e2e8f0"},sectionTitle:{fontSize:"18px",fontWeight:700,color:"#e2e8f0",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},kpiGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"10px",marginBottom:"16px"},kpiCard:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.15)",borderRadius:"0",padding:"14px",textAlign:"center"},kpiValue:(s="#e2e8f0")=>({fontSize:"24px",fontWeight:700,color:s}),kpiLabel:{fontSize:"10px",color:"rgba(255,255,255,0.6)",marginTop:"2px",textTransform:"uppercase",letterSpacing:"0.5px"},barRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},barLabel:{width:"120px",fontSize:"12px",fontWeight:500,color:"rgba(255,255,255,0.6)",textAlign:"right"},barTrack:{flex:1,height:"16px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden"},barFill:(s,i)=>({width:`${s}%`,height:"100%",background:i,borderRadius:"0"}),barValue:{width:"36px",fontSize:"12px",fontWeight:600,color:"rgba(255,255,255,0.6)"},dataTable:{width:"100%",borderCollapse:"collapse",fontSize:"12px",marginBottom:"12px"},dtTh:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"rgba(255,255,255,0.6)",borderBottom:"2px solid rgba(255,255,255,0.08)",background:"var(--bg-panel, #0F1419)",fontSize:"10px",textTransform:"uppercase"},dtTd:{padding:"8px 10px",borderBottom:"1px solid rgba(251, 191, 36, 0.1)",color:"#e2e8f0"},trustBar:s=>({display:"inline-flex",alignItems:"center",gap:"4px",color:s>=80?"#22c55e":s>=60?"#f59e0b":"#ef4444"}),highlight:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"14px 18px",marginTop:"12px"},highlightItem:{fontSize:"13px",color:"rgba(255,255,255,0.6)",marginBottom:"4px",lineHeight:1.5},rec:s=>{const i={critical:["#fef2f2","#ef4444"],warning:["#fffbeb","#f59e0b"],info:["#eff6ff","#3b82f6"]},[l,r]=i[s]||["#f8fafc","#94a3b8"];return{padding:"12px 14px",borderRadius:"0",marginBottom:"8px",borderLeft:`4px solid ${r}`,background:l}},recCategory:{fontSize:"11px",fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.5px",marginLeft:"8px"},recMessage:{fontSize:"13px",color:"#e2e8f0",margin:"4px 0"},recAction:{fontSize:"12px",color:"rgba(255,255,255,0.6)",fontStyle:"italic"},callout:s=>({padding:"10px 14px",borderRadius:"0",marginBottom:"8px",fontSize:"13px",background:s==="green"?"rgba(34, 197, 94, 0.15)":"rgba(245, 158, 11, 0.15)",borderLeft:`4px solid ${s==="green"?"#22c55e":"#f59e0b"}`,color:"#e2e8f0"}),empty:{textAlign:"center",padding:"60px 20px",color:"rgba(255,255,255,0.6)"},spinner:{display:"inline-block",width:"16px",height:"16px",border:"2px solid #f59e0b",borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite"}};function oe(){const[s,i]=d.useState("dashboard"),[l,r]=d.useState(30),[o,c]=d.useState(null),[h,x]=d.useState([]),[b,f]=d.useState(0),[w,m]=d.useState([]),[y,S]=d.useState(null),[R,C]=d.useState(""),[A,a]=d.useState(!1),[v,_]=d.useState(!1),[ie,D]=d.useState(!1),[L,z]=d.useState(""),I=d.useCallback(async()=>{try{const n=await g.getQuickStats(l);c(n)}catch{}},[l]),T=d.useCallback(async()=>{try{const n=await g.listReports();x(n.reports),f(n.total)}catch{}},[]),V=d.useCallback(async()=>{try{const n=await g.listTemplates();m(n)}catch{}},[]);d.useEffect(()=>{I()},[I]),d.useEffect(()=>{T(),V()},[T,V]);const G=async n=>{D(!0);try{const u=await g.getReport(n);S(u);const k=typeof u.report_data=="string"?JSON.parse(u.report_data):u.report_data,$=Object.keys(k.sections||{})[0]||"";C($),i("viewer")}catch(u){z(u.message)}finally{D(!1)}},E=async n=>{if(confirm("Delete this report?"))try{await g.deleteReport(n),T()}catch(u){z(u.message)}},F=n=>{a(!1),T();const u=setInterval(async()=>{try{const k=await g.getReport(n.id);(k.status==="ready"||k.status==="failed")&&(clearInterval(u),T(),k.status==="ready"&&G(k.id))}catch{clearInterval(u)}},2e3)};return e.jsxs("div",{style:t.page,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#e2e8f0",margin:0},children:"Compliance Reports"}),e.jsx("p",{style:{fontSize:"13px",color:"#94a3b8",marginTop:"4px"},children:"Board-ready governance reports with real data"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>_(!0),children:"Schedule Report"}),e.jsx("button",{style:t.primaryBtn,onClick:()=>a(!0),children:"Generate Report"})]})]}),e.jsx("div",{style:t.tabBar,children:["dashboard","history","viewer","schedules"].map(n=>e.jsx("button",{style:t.tab(s===n),onClick:()=>i(n),children:n==="dashboard"?"📊 Dashboard":n==="history"?"📋 Reports":n==="viewer"?"📄 Viewer":"⏰ Schedules"},n))}),L&&e.jsxs("div",{style:{padding:"10px 14px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:"0",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:[L," ",e.jsx("button",{onClick:()=>z(""),style:{float:"right",background:"none",border:"none",color:"#ef4444",cursor:"pointer"},children:"✕"})]}),s==="dashboard"&&e.jsxs("div",{children:[e.jsxs("div",{style:t.periodBar,children:[e.jsx("span",{style:{fontSize:"13px",color:"#94a3b8"},children:"Reporting period"}),e.jsx("div",{children:[7,30,90,365].map(n=>e.jsx("button",{style:t.periodBtn(l===n),onClick:()=>r(n),children:n===365?"1y":`${n}d`},n))})]}),o?e.jsxs("div",{style:t.statsGrid,children:[e.jsxs("div",{style:t.statCard("#f59e0b"),children:[e.jsx("div",{style:t.statValue("#f59e0b"),children:o.total_actions.toLocaleString()}),e.jsx("div",{style:t.statLabel,children:"Actions Governed"})]}),e.jsxs("div",{style:t.statCard(o.compliance_rate>=95?"#22c55e":"#ef4444"),children:[e.jsxs("div",{style:t.statValue(o.compliance_rate>=95?"#10b981":"#ef4444"),children:[o.compliance_rate,"%"]}),e.jsx("div",{style:t.statLabel,children:"Compliance Rate"})]}),e.jsxs("div",{style:t.statCard(o.policy_violations>10?"#ef4444":o.policy_violations>0?"#f59e0b":"#22c55e"),children:[e.jsx("div",{style:t.statValue(o.policy_violations>10?"#ef4444":o.policy_violations>0?"#f59e0b":"#10b981"),children:o.policy_violations}),e.jsx("div",{style:t.statLabel,children:"Policy Violations"})]}),e.jsxs("div",{style:t.statCard("#3b82f6"),children:[e.jsxs("div",{style:t.statValue("#60a5fa"),children:[o.avg_approval_time_minutes,e.jsx("span",{style:t.statUnit,children:" min"})]}),e.jsx("div",{style:t.statLabel,children:"Avg Approval Time"})]}),e.jsxs("div",{style:t.statCard(o.unauthorized_executions>0?"#ef4444":"#22c55e"),children:[e.jsx("div",{style:t.statValue(o.unauthorized_executions>0?"#ef4444":"#10b981"),children:o.unauthorized_executions}),e.jsx("div",{style:t.statLabel,children:"Unauthorized Executions"})]}),e.jsxs("div",{style:t.statCard(o.fleet_health_score>=80?"#22c55e":o.fleet_health_score>=60?"#f59e0b":"#ef4444"),children:[e.jsxs("div",{style:t.statValue(o.fleet_health_score>=80?"#10b981":o.fleet_health_score>=60?"#f59e0b":"#ef4444"),children:[o.fleet_health_score,e.jsx("span",{style:t.statUnit,children:"/100"})]}),e.jsx("div",{style:t.statLabel,children:"Fleet Health Score"})]})]}):e.jsxs("div",{style:t.empty,children:[e.jsx("div",{style:t.spinner})," Loading stats..."]}),e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#e2e8f0",marginBottom:"12px"},children:"Recent Reports"}),h.length>0?e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Title"}),e.jsx("th",{style:t.th,children:"Type"}),e.jsx("th",{style:t.th,children:"Status"}),e.jsx("th",{style:t.th,children:"Generated"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:h.slice(0,5).map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.title}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.badge("#f59e0b","rgba(245,158,11,0.15)"),children:n.report_type})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.statusBadge(n.status),children:n.status})}),e.jsx("td",{style:t.td,children:new Date(n.generated_at).toLocaleDateString()}),e.jsx("td",{style:t.td,children:n.status==="ready"&&e.jsx("button",{style:t.ghostBtn,onClick:()=>G(n.id),children:"View"})})]},n.id))})]}):e.jsx("div",{style:t.empty,children:"No reports yet. Generate your first compliance report above."})]}),s==="history"&&e.jsxs("div",{children:[e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Title"}),e.jsx("th",{style:t.th,children:"Type"}),e.jsx("th",{style:t.th,children:"Period"}),e.jsx("th",{style:t.th,children:"Generated By"}),e.jsx("th",{style:t.th,children:"Date"}),e.jsx("th",{style:t.th,children:"Status"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:h.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.title}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.badge("#f59e0b","rgba(245,158,11,0.15)"),children:n.report_type})}),e.jsxs("td",{style:{...t.td,fontSize:"11px"},children:[new Date(n.period_start).toLocaleDateString()," – ",new Date(n.period_end).toLocaleDateString()]}),e.jsx("td",{style:t.td,children:n.generated_by}),e.jsx("td",{style:t.td,children:new Date(n.generated_at).toLocaleString()}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.statusBadge(n.status),children:n.status})}),e.jsxs("td",{style:{...t.td,display:"flex",gap:"4px"},children:[n.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{style:t.ghostBtn,onClick:()=>G(n.id),children:"View"}),e.jsx("a",{href:g.getPdfUrl(n.id),target:"_blank",rel:"noreferrer",style:{...t.ghostBtn,textDecoration:"none"},children:"PDF"}),e.jsx("a",{href:g.getCsvUrl(n.id),style:{...t.ghostBtn,textDecoration:"none"},children:"CSV"})]}),e.jsx("button",{style:t.dangerBtn,onClick:()=>E(n.id),children:"Delete"})]})]},n.id))})]}),h.length===0&&e.jsx("div",{style:t.empty,children:"No reports generated yet."})]}),s==="viewer"&&(y?e.jsx(U,{report:y,activeSection:R,onSectionChange:C,onBack:()=>{S(null),i("history")}}):e.jsx("div",{style:t.empty,children:"Select a report from the History tab to view it."})),s==="schedules"&&e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("button",{style:t.primaryBtn,onClick:()=>_(!0),children:"+ Add Schedule"})}),h.filter(n=>n.schedule_cron).length>0?e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Report Type"}),e.jsx("th",{style:t.th,children:"Schedule"}),e.jsx("th",{style:t.th,children:"Recipients"})]})}),e.jsx("tbody",{children:h.filter(n=>n.schedule_cron).map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.report_type}),e.jsx("td",{style:t.td,children:e.jsx("code",{style:{fontSize:"12px",color:"#f59e0b"},children:n.schedule_cron})}),e.jsx("td",{style:t.td,children:(n.recipients||[]).join(", ")||"—"})]},n.id))})]}):e.jsx("div",{style:t.empty,children:"No scheduled reports. Set up recurring report generation."})]}),A&&e.jsx(P,{templates:w,onClose:()=>a(!1),onGenerated:F}),v&&e.jsx(N,{onClose:()=>_(!1),onCreated:()=>{_(!1),T()}})]})}function P({templates:s,onClose:i,onGenerated:l}){const[r,o]=d.useState("quarterly"),[c,h]=d.useState(""),[x,b]=d.useState([...M]),[f,w]=d.useState(""),[m,y]=d.useState(""),[S,R]=d.useState(!1),C=a=>{b(v=>v.includes(a)?v.filter(_=>_!==a):[...v,a])},A=async()=>{R(!0);try{const a={report_type:r,sections:x};c&&(a.template_id=c),r==="custom"&&f&&(a.period_start=f),r==="custom"&&m&&(a.period_end=m);const v=await g.generateReport(a);l(v)}catch(a){alert("Generation failed: "+a.message)}finally{R(!1)}};return e.jsx("div",{style:t.overlay,onClick:i,children:e.jsxs("div",{style:t.modal,onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{style:t.modalTitle,children:"Generate Compliance Report"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Report Type"}),e.jsxs("select",{style:t.select,value:r,onChange:a=>o(a.target.value),children:[e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"quarterly",children:"Quarterly"}),e.jsx("option",{value:"annual",children:"Annual"}),e.jsx("option",{value:"custom",children:"Custom Range"})]})]}),r==="custom"&&e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsxs("div",{style:{...t.formGroup,flex:1},children:[e.jsx("label",{style:t.label,children:"Start Date"}),e.jsx("input",{type:"date",style:t.input,value:f,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{style:{...t.formGroup,flex:1},children:[e.jsx("label",{style:t.label,children:"End Date"}),e.jsx("input",{type:"date",style:t.input,value:m,onChange:a=>y(a.target.value)})]})]}),s.length>0&&e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Template"}),e.jsxs("select",{style:t.select,value:c,onChange:a=>h(a.target.value),children:[e.jsx("option",{value:"",children:"All Sections (Default)"}),s.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Sections"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:M.map(a=>e.jsxs("label",{style:{...t.checkboxLabel,display:"flex",alignItems:"center"},children:[e.jsx("input",{type:"checkbox",style:t.checkbox,checked:x.includes(a),onChange:()=>C(a)}),B[a]]},a))})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"20px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:i,children:"Cancel"}),e.jsx("button",{style:{...t.primaryBtn,opacity:S?.6:1},disabled:S,onClick:A,children:S?"Generating...":"Generate Report"})]})]})})}function N({onClose:s,onCreated:i}){const[l,r]=d.useState("weekly"),[o,c]=d.useState("weekly"),[h,x]=d.useState(""),[b,f]=d.useState(!1),w={daily:"0 8 * * *",weekly:"0 8 * * 1",monthly:"0 8 1 * *"},m=async()=>{f(!0);try{await g.createSchedule({report_type:l,schedule_cron:w[o]||"0 8 * * 1",recipients:h.split(",").map(y=>y.trim()).filter(Boolean)}),i()}catch(y){alert("Failed: "+y.message)}finally{f(!1)}};return e.jsx("div",{style:t.overlay,onClick:s,children:e.jsxs("div",{style:t.modal,onClick:y=>y.stopPropagation(),children:[e.jsx("h2",{style:t.modalTitle,children:"Schedule Recurring Report"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Report Type"}),e.jsxs("select",{style:t.select,value:l,onChange:y=>r(y.target.value),children:[e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"quarterly",children:"Quarterly"})]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Frequency"}),e.jsxs("select",{style:t.select,value:o,onChange:y=>c(y.target.value),children:[e.jsx("option",{value:"daily",children:"Daily (8:00 AM)"}),e.jsx("option",{value:"weekly",children:"Weekly (Monday 8:00 AM)"}),e.jsx("option",{value:"monthly",children:"Monthly (1st, 8:00 AM)"})]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Recipients (comma-separated emails)"}),e.jsx("input",{style:t.input,placeholder:"ciso@company.com, cto@company.com",value:h,onChange:y=>x(y.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"20px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:s,children:"Cancel"}),e.jsx("button",{style:{...t.primaryBtn,opacity:b?.6:1},disabled:b,onClick:m,children:b?"Creating...":"Create Schedule"})]})]})})}function U({report:s,activeSection:i,onSectionChange:l,onBack:r}){const c=(typeof s.report_data=="string"?JSON.parse(s.report_data):s.report_data).sections||{},h=Object.keys(c);return e.jsxs("div",{style:t.viewerWrapper,children:[e.jsxs("div",{style:t.viewerToolbar,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{onClick:r,style:{...t.ghostBtn,color:"#64748b"},children:"← Back"}),e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"#e2e8f0"},children:s.title})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("a",{href:g.getPdfUrl(s.id),target:"_blank",rel:"noreferrer",style:{...t.primaryBtn,textDecoration:"none",fontSize:"12px",padding:"8px 14px",background:"#f59e0b"},children:"Download PDF"}),e.jsx("a",{href:g.getCsvUrl(s.id),style:{...t.secondaryBtn,textDecoration:"none",color:"#f59e0b",borderColor:"rgba(245,158,11,0.2)"},children:"Export CSV"})]})]}),e.jsxs("div",{style:{display:"flex"},children:[e.jsx("div",{style:t.viewerNav,children:h.map((x,b)=>e.jsxs("button",{style:t.viewerNavItem(i===x),onClick:()=>l(x),children:[b+1,". ",B[x]||x]},x))}),e.jsxs("div",{style:t.viewerContent,children:[e.jsxs("div",{style:{marginBottom:"32px",borderBottom:"3px solid #f59e0b",paddingBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:"#f59e0b",letterSpacing:"2px",marginBottom:"8px"},children:"VIENNA OS"}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:"#e2e8f0",margin:"0 0 6px"},children:s.title}),e.jsxs("div",{style:{fontSize:"13px",color:"rgba(255,255,255,0.6)"},children:["Period: ",e.jsx("strong",{children:new Date(s.period_start).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})," — ",e.jsx("strong",{children:new Date(s.period_end).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})," · ","Generated: ",new Date(s.generated_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]}),h.map((x,b)=>e.jsx("div",{id:`section-${x}`,style:t.sectionBlock,children:e.jsx(O,{sectionKey:x,data:c[x],index:b+1})},x))]})]})]})}function O({sectionKey:s,data:i,index:l}){if(!i||i.error)return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[l,". ",B[s]||s]}),e.jsx("p",{style:{color:"#94a3b8",fontStyle:"italic"},children:(i==null?void 0:i.error)||"No data available"})]});switch(s){case"executive_summary":return e.jsx(q,{data:i,index:l});case"governance_overview":return e.jsx(H,{data:i,index:l});case"action_volume":return e.jsx(Q,{data:i,index:l});case"policy_compliance":return e.jsx(J,{data:i,index:l});case"agent_performance":return e.jsx(K,{data:i,index:l});case"risk_analysis":return e.jsx(X,{data:i,index:l});case"approval_metrics":return e.jsx(Y,{data:i,index:l});case"violations_incidents":return e.jsx(Z,{data:i,index:l});case"integration_health":return e.jsx(ee,{data:i,index:l});case"recommendations":return e.jsx(te,{data:i,index:l});default:return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[l,". ",s]}),e.jsx("pre",{style:{fontSize:"11px",color:"#64748b"},children:JSON.stringify(i,null,2)})]})}}function q({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Executive Summary"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:((l=s.total_actions_governed)==null?void 0:l.toLocaleString())||"0",label:"Actions Governed"}),e.jsx(p,{value:`${s.policy_compliance_rate||0}%`,label:"Compliance Rate",color:(s.policy_compliance_rate||0)>=95?"#16a34a":"#dc2626"}),e.jsx(p,{value:String(s.unauthorized_executions||0),label:"Unauthorized Executions",color:s.unauthorized_executions===0?"#16a34a":"#dc2626"}),e.jsx(p,{value:`${s.fleet_health_score||0}/100`,label:"Fleet Health",color:(s.fleet_health_score||0)>=80?"#16a34a":"#f59e0b"}),e.jsx(p,{value:String(s.active_agents||0),label:"Active Agents"}),e.jsx(p,{value:`${s.avg_approval_time_minutes||0} min`,label:"Avg Approval Time"})]}),((r=s.highlights)==null?void 0:r.length)>0&&e.jsx("div",{style:t.highlight,children:s.highlights.map((o,c)=>e.jsxs("p",{style:t.highlightItem,children:["• ",o]},c))})]})}function H({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Governance Overview"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.active_rules_count||0),label:"Active Rules"}),e.jsx(p,{value:String(s.rules_added_in_period||0),label:"Rules Added"})]}),((l=s.action_distribution)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Default Action Distribution"}),e.jsx(W,{items:s.action_distribution.map(r=>({label:r.action,value:r.count,color:r.action==="deny"?"#ef4444":r.action==="require_approval"?"#f59e0b":"#22c55e"}))})]})]})}function Q({data:s,index:i}){var l,r,o;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Action Volume"]}),e.jsx("div",{style:t.kpiGrid,children:e.jsx(p,{value:(s.total_intents||0).toLocaleString(),label:"Total Intents"})}),((l=s.by_risk_tier)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Risk Tier"}),e.jsx(W,{items:s.by_risk_tier.map(c=>({label:c.tier,value:c.count,color:c.tier==="T2"?"#ef4444":c.tier==="T1"?"#f59e0b":"#22c55e"}))})]}),((r=s.by_action_type)==null?void 0:r.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Action Type"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Count"}),e.jsx("th",{style:t.dtTh,children:"%"})]})}),e.jsx("tbody",{children:s.by_action_type.map(c=>{const h=s.total_intents>0?Math.round(c.count/s.total_intents*100):0;return e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:c.type}),e.jsx("td",{style:t.dtTd,children:c.count}),e.jsxs("td",{style:t.dtTd,children:[e.jsx(se,{pct:h})," ",h,"%"]})]},c.type)})})]})]}),((o=s.daily_trend)==null?void 0:o.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Daily Trend"}),e.jsx(re,{data:s.daily_trend})]})]})}function J({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Policy Compliance"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:(s.total_evaluations||0).toLocaleString(),label:"Rules Evaluated"}),e.jsx(p,{value:`${s.match_rate||0}%`,label:"Match Rate"})]}),((l=s.top_triggered_rules)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Top Triggered Rules"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Rule"}),e.jsx("th",{style:t.dtTh,children:"Triggered"}),e.jsx("th",{style:t.dtTh,children:"Block Rate"})]})}),e.jsx("tbody",{children:s.top_triggered_rules.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:r.name}),e.jsx("td",{style:t.dtTd,children:r.times_triggered}),e.jsx("td",{style:t.dtTd,children:e.jsxs("span",{style:t.badge(r.block_rate>50?"#991b1b":"#854d0e",r.block_rate>50?"#fee2e2":"#fef9c3"),children:[r.block_rate,"%"]})})]},r.rule_id))})]})]})]})}function K({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Agent Performance"]}),s.best_performer&&e.jsxs("div",{style:t.callout("green"),children:["🏆 Best Performer: ",e.jsx("strong",{children:s.best_performer.name})," (Trust: ",s.best_performer.trust_score,"/100)"]}),s.worst_performer&&e.jsxs("div",{style:t.callout("yellow"),children:["⚠️ Needs Attention: ",e.jsx("strong",{children:s.worst_performer.name})," (Trust: ",s.worst_performer.trust_score,"/100)"]}),((l=s.scorecards)==null?void 0:l.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Status"}),e.jsx("th",{style:t.dtTh,children:"Actions"}),e.jsx("th",{style:t.dtTh,children:"Approval"}),e.jsx("th",{style:t.dtTh,children:"Error"}),e.jsx("th",{style:t.dtTh,children:"Latency"}),e.jsx("th",{style:t.dtTh,children:"Trust"})]})}),e.jsx("tbody",{children:s.scorecards.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:{...t.dtTd,fontWeight:600},children:r.display_name}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(r.status==="active"?"#166534":r.status==="suspended"?"#991b1b":"#64748b",r.status==="active"?"#dcfce7":r.status==="suspended"?"#fee2e2":"#f1f5f9"),children:r.status})}),e.jsx("td",{style:t.dtTd,children:r.total_actions}),e.jsxs("td",{style:t.dtTd,children:[r.approval_rate,"%"]}),e.jsxs("td",{style:{...t.dtTd,color:r.error_rate>10?"#ef4444":r.error_rate>5?"#f59e0b":"#22c55e"},children:[r.error_rate,"%"]}),e.jsxs("td",{style:t.dtTd,children:[r.avg_latency_ms,"ms"]}),e.jsx("td",{style:t.dtTd,children:e.jsx(le,{score:r.trust_score})})]},r.agent_id))})]})]})}function X({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Risk Analysis"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(((l=s.high_risk_actions)==null?void 0:l.total)||0),label:"High-Risk (T2) Actions",color:"#ef4444"}),e.jsx(p,{value:String(s.scope_creep_attempts||0),label:"Scope Creep Attempts"}),e.jsx(p,{value:String(s.anomalies_detected||0),label:"Anomalies Detected"})]}),((r=s.top_denials)==null?void 0:r.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Top Denial Reasons"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Action"}),e.jsx("th",{style:t.dtTh,children:"Denials"})]})}),e.jsx("tbody",{children:s.top_denials.map((o,c)=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:o.agent_id}),e.jsx("td",{style:t.dtTd,children:o.action_type}),e.jsx("td",{style:t.dtTd,children:o.count})]},c))})]})]})]})}function Y({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Approval Metrics"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_approvals_requested||0),label:"Approvals Requested"}),e.jsx(p,{value:`${s.avg_time_to_approval_minutes||0} min`,label:"Avg Time to Approval"}),e.jsx(p,{value:`${s.approval_rate||0}%`,label:"Approval Rate",color:"#16a34a"})]}),((l=s.by_tier)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Tier"}),e.jsx(W,{items:s.by_tier.map(r=>({label:r.tier,value:r.count,color:"#f59e0b"}))})]})]})}function Z({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Violations & Incidents"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_violations||0),label:"Total Violations",color:s.total_violations>0?"#ef4444":"#16a34a"}),e.jsx(p,{value:String(s.unresolved_count||0),label:"Unresolved",color:s.unresolved_count>0?"#f59e0b":"#16a34a"})]}),((l=s.by_severity)==null?void 0:l.length)>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:s.by_severity.map(o=>e.jsxs("span",{style:t.badge(o.severity==="critical"?"#991b1b":o.severity==="warning"?"#854d0e":"#1e40af",o.severity==="critical"?"#fee2e2":o.severity==="warning"?"#fef9c3":"#dbeafe"),children:[o.severity,": ",o.count]},o.severity))}),((r=s.incident_timeline)==null?void 0:r.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Time"}),e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Severity"}),e.jsx("th",{style:t.dtTh,children:"Message"}),e.jsx("th",{style:t.dtTh,children:"Resolved"})]})}),e.jsx("tbody",{children:s.incident_timeline.slice(0,15).map(o=>e.jsxs("tr",{children:[e.jsx("td",{style:{...t.dtTd,fontSize:"11px",whiteSpace:"nowrap"},children:new Date(o.created_at).toLocaleString()}),e.jsx("td",{style:t.dtTd,children:o.agent_id}),e.jsx("td",{style:t.dtTd,children:o.alert_type}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(o.severity==="critical"?"#991b1b":o.severity==="warning"?"#854d0e":"#1e40af",o.severity==="critical"?"#fee2e2":o.severity==="warning"?"#fef9c3":"#dbeafe"),children:o.severity})}),e.jsx("td",{style:{...t.dtTd,fontSize:"11px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis"},children:o.message}),e.jsx("td",{style:t.dtTd,children:o.resolved?"✅":"❌"})]},o.id))})]})]})}function ee({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Integration Health"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_active||0),label:"Active Integrations"}),e.jsx(p,{value:`${s.overall_delivery_rate||100}%`,label:"Delivery Rate",color:"#16a34a"})]}),((l=s.integrations)==null?void 0:l.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Name"}),e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Status"}),e.jsx("th",{style:t.dtTh,children:"Success Rate"}),e.jsx("th",{style:t.dtTh,children:"Events"})]})}),e.jsx("tbody",{children:s.integrations.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:r.name}),e.jsx("td",{style:t.dtTd,children:r.type}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(r.enabled?"#166534":"#64748b",r.enabled?"#dcfce7":"#f1f5f9"),children:r.enabled?"Active":"Disabled"})}),e.jsxs("td",{style:t.dtTd,children:[r.delivery_success_rate,"%"]}),e.jsx("td",{style:t.dtTd,children:r.events_in_period})]},r.name))})]})]})}function te({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Recommendations"]}),((l=s.items)==null?void 0:l.length)>0?s.items.map((r,o)=>e.jsxs("div",{style:t.rec(r.severity),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"4px"},children:[e.jsx("span",{style:t.badge(r.severity==="critical"?"#991b1b":r.severity==="warning"?"#854d0e":"#1e40af",r.severity==="critical"?"#fee2e2":r.severity==="warning"?"#fef9c3":"#dbeafe"),children:r.severity.toUpperCase()}),e.jsx("span",{style:t.recCategory,children:r.category})]}),e.jsx("p",{style:t.recMessage,children:r.message}),e.jsxs("p",{style:t.recAction,children:["→ ",r.action]})]},o)):e.jsx("p",{style:{color:"#94a3b8",fontStyle:"italic"},children:"No recommendations at this time. Governance posture is strong. ✅"})]})}function p({value:s,label:i,color:l}){return e.jsxs("div",{style:t.kpiCard,children:[e.jsx("div",{style:t.kpiValue(l||"#1a1a2e"),children:s}),e.jsx("div",{style:t.kpiLabel,children:i})]})}function W({items:s}){const i=Math.max(...s.map(l=>l.value),1);return e.jsx("div",{children:s.map((l,r)=>e.jsxs("div",{style:t.barRow,children:[e.jsx("span",{style:t.barLabel,children:l.label}),e.jsx("div",{style:t.barTrack,children:e.jsx("div",{style:t.barFill(l.value/i*100,l.color)})}),e.jsx("span",{style:t.barValue,children:l.value})]},r))})}function se({pct:s}){return e.jsx("span",{style:{display:"inline-block",width:"60px",height:"6px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden",verticalAlign:"middle",marginRight:"4px"},children:e.jsx("span",{style:{display:"block",width:`${s}%`,height:"100%",background:"#f59e0b",borderRadius:"0"}})})}function re({data:s}){const i=Math.max(...s.map(l=>l.count),1);return e.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"2px",height:"60px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},children:s.map((l,r)=>e.jsx("div",{title:`${l.date}: ${l.count}`,style:{flex:1,minWidth:"3px",background:"#f59e0b",borderRadius:"2px 2px 0 0",opacity:.8,height:`${Math.max(4,l.count/i*56)}px`}},r))})}function le({score:s}){const i=s>=80?"#22c55e":s>=60?"#f59e0b":"#ef4444";return e.jsxs("span",{style:t.trustBar(s),children:[e.jsx("span",{style:{width:"40px",height:"5px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden",display:"inline-block"},children:e.jsx("span",{style:{display:"block",width:`${s}%`,height:"100%",background:i,borderRadius:"0"}})}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600},children:s})]})}export{oe as CompliancePage}; -//# sourceMappingURL=CompliancePage-Bpt_D9yK.js.map +import{e as j,r as d,j as e}from"./index-C0nK3ekl.js";const g={getQuickStats:(s=30)=>j.get("/compliance/quick-stats",{period:s}),listReports:(s=50,i=0)=>j.get("/compliance/reports",{limit:s,offset:i}),getReport:s=>j.get(`/compliance/reports/${s}`),generateReport:s=>j.post("/compliance/reports/generate",s),deleteReport:s=>j.delete(`/compliance/reports/${s}`),getPdfUrl:s=>`/api/v1/compliance/reports/${s}/pdf`,getCsvUrl:s=>`/api/v1/compliance/reports/${s}/csv`,listTemplates:()=>j.get("/compliance/templates"),createTemplate:s=>j.post("/compliance/templates",s),updateTemplate:(s,i)=>j.put(`/compliance/templates/${s}`,i),createSchedule:s=>j.post("/compliance/schedule",s)},B={executive_summary:"Executive Summary",governance_overview:"Governance Overview",action_volume:"Action Volume",policy_compliance:"Policy Compliance",agent_performance:"Agent Performance",risk_analysis:"Risk Analysis",approval_metrics:"Approval Metrics",violations_incidents:"Violations & Incidents",integration_health:"Integration Health",recommendations:"Recommendations"},M=Object.keys(B),t={page:{padding:"0"},statsGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"12px",marginBottom:"28px"},statCard:s=>({background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"20px",textAlign:"center"}),statValue:s=>({fontSize:"32px",fontWeight:700,color:s,lineHeight:1.1}),statLabel:{fontSize:"11px",color:"#94a3b8",marginTop:"6px",textTransform:"uppercase",letterSpacing:"0.5px"},statUnit:{fontSize:"14px",fontWeight:400,color:"#64748b"},periodBar:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},periodBtn:s=>({padding:"6px 14px",fontSize:"12px",fontWeight:s?600:400,color:s?"#f59e0b":"#94a3b8",background:s?"rgba(245,158,11,0.15)":"transparent",border:"1px solid "+(s?"rgba(245,158,11,0.3)":"rgba(255,255,255,0.08)"),borderRadius:"0",cursor:"pointer",marginLeft:"6px"}),tabBar:{display:"flex",gap:"2px",marginBottom:"24px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},tab:s=>({padding:"10px 18px",fontSize:"13px",fontWeight:s?600:400,color:s?"var(--text-primary)":"#94a3b8",background:"transparent",border:"none",borderBottom:s?"2px solid var(--text-primary)":"2px solid transparent",borderRadius:0,cursor:"pointer"}),primaryBtn:{padding:"10px 20px",fontSize:"13px",fontWeight:600,color:"#fff",background:"#f59e0b",border:"none",borderRadius:"0",cursor:"pointer"},secondaryBtn:{padding:"8px 16px",fontSize:"12px",fontWeight:500,color:"#f59e0b",background:"rgba(245,158,11,0.1)",border:"1px solid rgba(245,158,11,0.2)",borderRadius:"0",cursor:"pointer"},dangerBtn:{padding:"6px 12px",fontSize:"11px",fontWeight:500,color:"#ef4444",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:"0",cursor:"pointer"},ghostBtn:{padding:"6px 12px",fontSize:"11px",fontWeight:500,color:"#94a3b8",background:"transparent",border:"1px solid rgba(251, 191, 36, 0.15)",borderRadius:"0",cursor:"pointer"},overlay:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},modal:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",padding:"28px",width:"520px",maxHeight:"80vh",overflow:"auto"},modalTitle:{fontSize:"18px",fontWeight:700,color:"#e2e8f0",marginBottom:"20px"},formGroup:{marginBottom:"16px"},label:{display:"block",fontSize:"12px",fontWeight:600,color:"#94a3b8",marginBottom:"6px",textTransform:"uppercase",letterSpacing:"0.5px"},select:{width:"100%",padding:"10px 12px",fontSize:"13px",color:"#e2e8f0",background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",outline:"none"},input:{width:"100%",padding:"10px 12px",fontSize:"13px",color:"#e2e8f0",background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",outline:"none"},checkbox:{marginRight:"8px"},checkboxLabel:{fontSize:"13px",color:"#cbd5e1",cursor:"pointer"},table:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},th:{padding:"10px 12px",textAlign:"left",fontWeight:600,color:"#94a3b8",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.5px"},td:{padding:"10px 12px",borderBottom:"1px solid rgba(251, 191, 36, 0.1)",color:"#cbd5e1"},viewerWrapper:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"0",overflow:"hidden",border:"1px solid rgba(251, 191, 36, 0.2)"},viewerToolbar:{display:"flex",gap:"8px",alignItems:"center",justifyContent:"space-between",padding:"12px 20px",background:"var(--bg-panel, #0F1419)",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},viewerContent:{padding:"32px 40px",background:"var(--surface-secondary, #12131a)"},viewerNav:{position:"sticky",top:0,display:"flex",flexDirection:"column",gap:"2px",padding:"12px",background:"var(--bg-app, #0A0E14)",borderRight:"1px solid rgba(251, 191, 36, 0.15)",minWidth:"200px"},viewerNavItem:s=>({padding:"8px 12px",fontSize:"12px",fontWeight:s?600:400,color:s?"#f59e0b":"#64748b",background:s?"rgba(245,158,11,0.08)":"transparent",border:"none",borderRadius:"0",cursor:"pointer",textAlign:"left"}),badge:(s,i)=>({display:"inline-block",padding:"2px 10px",borderRadius:"0",fontSize:"11px",fontWeight:600,color:s,background:i}),statusBadge:s=>{const i={ready:["#166534","#dcfce7"],generating:["#854d0e","#fef9c3"],failed:["#991b1b","#fee2e2"],scheduled:["#1e40af","#dbeafe"]},[l,r]=i[s]||["#64748b","#f1f5f9"];return{display:"inline-block",padding:"2px 10px",borderRadius:"0",fontSize:"11px",fontWeight:600,color:l,background:r}},sectionBlock:{marginBottom:"32px",color:"#e2e8f0"},sectionTitle:{fontSize:"18px",fontWeight:700,color:"#e2e8f0",marginBottom:"12px",paddingBottom:"8px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},kpiGrid:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"10px",marginBottom:"16px"},kpiCard:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.15)",borderRadius:"0",padding:"14px",textAlign:"center"},kpiValue:(s="#e2e8f0")=>({fontSize:"24px",fontWeight:700,color:s}),kpiLabel:{fontSize:"10px",color:"rgba(255,255,255,0.6)",marginTop:"2px",textTransform:"uppercase",letterSpacing:"0.5px"},barRow:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},barLabel:{width:"120px",fontSize:"12px",fontWeight:500,color:"rgba(255,255,255,0.6)",textAlign:"right"},barTrack:{flex:1,height:"16px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden"},barFill:(s,i)=>({width:`${s}%`,height:"100%",background:i,borderRadius:"0"}),barValue:{width:"36px",fontSize:"12px",fontWeight:600,color:"rgba(255,255,255,0.6)"},dataTable:{width:"100%",borderCollapse:"collapse",fontSize:"12px",marginBottom:"12px"},dtTh:{padding:"8px 10px",textAlign:"left",fontWeight:600,color:"rgba(255,255,255,0.6)",borderBottom:"2px solid rgba(255,255,255,0.08)",background:"var(--bg-panel, #0F1419)",fontSize:"10px",textTransform:"uppercase"},dtTd:{padding:"8px 10px",borderBottom:"1px solid rgba(251, 191, 36, 0.1)",color:"#e2e8f0"},trustBar:s=>({display:"inline-flex",alignItems:"center",gap:"4px",color:s>=80?"#22c55e":s>=60?"#f59e0b":"#ef4444"}),highlight:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",padding:"14px 18px",marginTop:"12px"},highlightItem:{fontSize:"13px",color:"rgba(255,255,255,0.6)",marginBottom:"4px",lineHeight:1.5},rec:s=>{const i={critical:["#fef2f2","#ef4444"],warning:["#fffbeb","#f59e0b"],info:["#eff6ff","#3b82f6"]},[l,r]=i[s]||["#f8fafc","#94a3b8"];return{padding:"12px 14px",borderRadius:"0",marginBottom:"8px",borderLeft:`4px solid ${r}`,background:l}},recCategory:{fontSize:"11px",fontWeight:600,color:"#64748b",textTransform:"uppercase",letterSpacing:"0.5px",marginLeft:"8px"},recMessage:{fontSize:"13px",color:"#e2e8f0",margin:"4px 0"},recAction:{fontSize:"12px",color:"rgba(255,255,255,0.6)",fontStyle:"italic"},callout:s=>({padding:"10px 14px",borderRadius:"0",marginBottom:"8px",fontSize:"13px",background:s==="green"?"rgba(34, 197, 94, 0.15)":"rgba(245, 158, 11, 0.15)",borderLeft:`4px solid ${s==="green"?"#22c55e":"#f59e0b"}`,color:"#e2e8f0"}),empty:{textAlign:"center",padding:"60px 20px",color:"rgba(255,255,255,0.6)"},spinner:{display:"inline-block",width:"16px",height:"16px",border:"2px solid #f59e0b",borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 0.8s linear infinite"}};function oe(){const[s,i]=d.useState("dashboard"),[l,r]=d.useState(30),[o,c]=d.useState(null),[h,x]=d.useState([]),[b,f]=d.useState(0),[w,m]=d.useState([]),[y,S]=d.useState(null),[R,C]=d.useState(""),[A,a]=d.useState(!1),[v,_]=d.useState(!1),[ie,D]=d.useState(!1),[L,z]=d.useState(""),I=d.useCallback(async()=>{try{const n=await g.getQuickStats(l);c(n)}catch{}},[l]),T=d.useCallback(async()=>{try{const n=await g.listReports();x(n.reports),f(n.total)}catch{}},[]),V=d.useCallback(async()=>{try{const n=await g.listTemplates();m(n)}catch{}},[]);d.useEffect(()=>{I()},[I]),d.useEffect(()=>{T(),V()},[T,V]);const G=async n=>{D(!0);try{const u=await g.getReport(n);S(u);const k=typeof u.report_data=="string"?JSON.parse(u.report_data):u.report_data,$=Object.keys(k.sections||{})[0]||"";C($),i("viewer")}catch(u){z(u.message)}finally{D(!1)}},E=async n=>{if(confirm("Delete this report?"))try{await g.deleteReport(n),T()}catch(u){z(u.message)}},F=n=>{a(!1),T();const u=setInterval(async()=>{try{const k=await g.getReport(n.id);(k.status==="ready"||k.status==="failed")&&(clearInterval(u),T(),k.status==="ready"&&G(k.id))}catch{clearInterval(u)}},2e3)};return e.jsxs("div",{style:t.page,children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"#e2e8f0",margin:0},children:"Compliance Reports"}),e.jsx("p",{style:{fontSize:"13px",color:"#94a3b8",marginTop:"4px"},children:"Board-ready governance reports with real data"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:()=>_(!0),children:"Schedule Report"}),e.jsx("button",{style:t.primaryBtn,onClick:()=>a(!0),children:"Generate Report"})]})]}),e.jsx("div",{style:t.tabBar,children:["dashboard","history","viewer","schedules"].map(n=>e.jsx("button",{style:t.tab(s===n),onClick:()=>i(n),children:n==="dashboard"?"📊 Dashboard":n==="history"?"📋 Reports":n==="viewer"?"📄 Viewer":"⏰ Schedules"},n))}),L&&e.jsxs("div",{style:{padding:"10px 14px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:"0",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:[L," ",e.jsx("button",{onClick:()=>z(""),style:{float:"right",background:"none",border:"none",color:"#ef4444",cursor:"pointer"},children:"✕"})]}),s==="dashboard"&&e.jsxs("div",{children:[e.jsxs("div",{style:t.periodBar,children:[e.jsx("span",{style:{fontSize:"13px",color:"#94a3b8"},children:"Reporting period"}),e.jsx("div",{children:[7,30,90,365].map(n=>e.jsx("button",{style:t.periodBtn(l===n),onClick:()=>r(n),children:n===365?"1y":`${n}d`},n))})]}),o?e.jsxs("div",{style:t.statsGrid,children:[e.jsxs("div",{style:t.statCard("#f59e0b"),children:[e.jsx("div",{style:t.statValue("#f59e0b"),children:o.total_actions.toLocaleString()}),e.jsx("div",{style:t.statLabel,children:"Actions Governed"})]}),e.jsxs("div",{style:t.statCard(o.compliance_rate>=95?"#22c55e":"#ef4444"),children:[e.jsxs("div",{style:t.statValue(o.compliance_rate>=95?"#10b981":"#ef4444"),children:[o.compliance_rate,"%"]}),e.jsx("div",{style:t.statLabel,children:"Compliance Rate"})]}),e.jsxs("div",{style:t.statCard(o.policy_violations>10?"#ef4444":o.policy_violations>0?"#f59e0b":"#22c55e"),children:[e.jsx("div",{style:t.statValue(o.policy_violations>10?"#ef4444":o.policy_violations>0?"#f59e0b":"#10b981"),children:o.policy_violations}),e.jsx("div",{style:t.statLabel,children:"Policy Violations"})]}),e.jsxs("div",{style:t.statCard("#3b82f6"),children:[e.jsxs("div",{style:t.statValue("#60a5fa"),children:[o.avg_approval_time_minutes,e.jsx("span",{style:t.statUnit,children:" min"})]}),e.jsx("div",{style:t.statLabel,children:"Avg Approval Time"})]}),e.jsxs("div",{style:t.statCard(o.unauthorized_executions>0?"#ef4444":"#22c55e"),children:[e.jsx("div",{style:t.statValue(o.unauthorized_executions>0?"#ef4444":"#10b981"),children:o.unauthorized_executions}),e.jsx("div",{style:t.statLabel,children:"Unauthorized Executions"})]}),e.jsxs("div",{style:t.statCard(o.fleet_health_score>=80?"#22c55e":o.fleet_health_score>=60?"#f59e0b":"#ef4444"),children:[e.jsxs("div",{style:t.statValue(o.fleet_health_score>=80?"#10b981":o.fleet_health_score>=60?"#f59e0b":"#ef4444"),children:[o.fleet_health_score,e.jsx("span",{style:t.statUnit,children:"/100"})]}),e.jsx("div",{style:t.statLabel,children:"Fleet Health Score"})]})]}):e.jsxs("div",{style:t.empty,children:[e.jsx("div",{style:t.spinner})," Loading stats..."]}),e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#e2e8f0",marginBottom:"12px"},children:"Recent Reports"}),h.length>0?e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Title"}),e.jsx("th",{style:t.th,children:"Type"}),e.jsx("th",{style:t.th,children:"Status"}),e.jsx("th",{style:t.th,children:"Generated"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:h.slice(0,5).map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.title}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.badge("#f59e0b","rgba(245,158,11,0.15)"),children:n.report_type})}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.statusBadge(n.status),children:n.status})}),e.jsx("td",{style:t.td,children:new Date(n.generated_at).toLocaleDateString()}),e.jsx("td",{style:t.td,children:n.status==="ready"&&e.jsx("button",{style:t.ghostBtn,onClick:()=>G(n.id),children:"View"})})]},n.id))})]}):e.jsx("div",{style:t.empty,children:"No reports yet. Generate your first compliance report above."})]}),s==="history"&&e.jsxs("div",{children:[e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Title"}),e.jsx("th",{style:t.th,children:"Type"}),e.jsx("th",{style:t.th,children:"Period"}),e.jsx("th",{style:t.th,children:"Generated By"}),e.jsx("th",{style:t.th,children:"Date"}),e.jsx("th",{style:t.th,children:"Status"}),e.jsx("th",{style:t.th,children:"Actions"})]})}),e.jsx("tbody",{children:h.map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.title}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.badge("#f59e0b","rgba(245,158,11,0.15)"),children:n.report_type})}),e.jsxs("td",{style:{...t.td,fontSize:"11px"},children:[new Date(n.period_start).toLocaleDateString()," – ",new Date(n.period_end).toLocaleDateString()]}),e.jsx("td",{style:t.td,children:n.generated_by}),e.jsx("td",{style:t.td,children:new Date(n.generated_at).toLocaleString()}),e.jsx("td",{style:t.td,children:e.jsx("span",{style:t.statusBadge(n.status),children:n.status})}),e.jsxs("td",{style:{...t.td,display:"flex",gap:"4px"},children:[n.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{style:t.ghostBtn,onClick:()=>G(n.id),children:"View"}),e.jsx("a",{href:g.getPdfUrl(n.id),target:"_blank",rel:"noreferrer",style:{...t.ghostBtn,textDecoration:"none"},children:"PDF"}),e.jsx("a",{href:g.getCsvUrl(n.id),style:{...t.ghostBtn,textDecoration:"none"},children:"CSV"})]}),e.jsx("button",{style:t.dangerBtn,onClick:()=>E(n.id),children:"Delete"})]})]},n.id))})]}),h.length===0&&e.jsx("div",{style:t.empty,children:"No reports generated yet."})]}),s==="viewer"&&(y?e.jsx(U,{report:y,activeSection:R,onSectionChange:C,onBack:()=>{S(null),i("history")}}):e.jsx("div",{style:t.empty,children:"Select a report from the History tab to view it."})),s==="schedules"&&e.jsxs("div",{children:[e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("button",{style:t.primaryBtn,onClick:()=>_(!0),children:"+ Add Schedule"})}),h.filter(n=>n.schedule_cron).length>0?e.jsxs("table",{style:t.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.th,children:"Report Type"}),e.jsx("th",{style:t.th,children:"Schedule"}),e.jsx("th",{style:t.th,children:"Recipients"})]})}),e.jsx("tbody",{children:h.filter(n=>n.schedule_cron).map(n=>e.jsxs("tr",{children:[e.jsx("td",{style:t.td,children:n.report_type}),e.jsx("td",{style:t.td,children:e.jsx("code",{style:{fontSize:"12px",color:"#f59e0b"},children:n.schedule_cron})}),e.jsx("td",{style:t.td,children:(n.recipients||[]).join(", ")||"—"})]},n.id))})]}):e.jsx("div",{style:t.empty,children:"No scheduled reports. Set up recurring report generation."})]}),A&&e.jsx(P,{templates:w,onClose:()=>a(!1),onGenerated:F}),v&&e.jsx(N,{onClose:()=>_(!1),onCreated:()=>{_(!1),T()}})]})}function P({templates:s,onClose:i,onGenerated:l}){const[r,o]=d.useState("quarterly"),[c,h]=d.useState(""),[x,b]=d.useState([...M]),[f,w]=d.useState(""),[m,y]=d.useState(""),[S,R]=d.useState(!1),C=a=>{b(v=>v.includes(a)?v.filter(_=>_!==a):[...v,a])},A=async()=>{R(!0);try{const a={report_type:r,sections:x};c&&(a.template_id=c),r==="custom"&&f&&(a.period_start=f),r==="custom"&&m&&(a.period_end=m);const v=await g.generateReport(a);l(v)}catch(a){alert("Generation failed: "+a.message)}finally{R(!1)}};return e.jsx("div",{style:t.overlay,onClick:i,children:e.jsxs("div",{style:t.modal,onClick:a=>a.stopPropagation(),children:[e.jsx("h2",{style:t.modalTitle,children:"Generate Compliance Report"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Report Type"}),e.jsxs("select",{style:t.select,value:r,onChange:a=>o(a.target.value),children:[e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"quarterly",children:"Quarterly"}),e.jsx("option",{value:"annual",children:"Annual"}),e.jsx("option",{value:"custom",children:"Custom Range"})]})]}),r==="custom"&&e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsxs("div",{style:{...t.formGroup,flex:1},children:[e.jsx("label",{style:t.label,children:"Start Date"}),e.jsx("input",{type:"date",style:t.input,value:f,onChange:a=>w(a.target.value)})]}),e.jsxs("div",{style:{...t.formGroup,flex:1},children:[e.jsx("label",{style:t.label,children:"End Date"}),e.jsx("input",{type:"date",style:t.input,value:m,onChange:a=>y(a.target.value)})]})]}),s.length>0&&e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Template"}),e.jsxs("select",{style:t.select,value:c,onChange:a=>h(a.target.value),children:[e.jsx("option",{value:"",children:"All Sections (Default)"}),s.map(a=>e.jsx("option",{value:a.id,children:a.name},a.id))]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Sections"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px"},children:M.map(a=>e.jsxs("label",{style:{...t.checkboxLabel,display:"flex",alignItems:"center"},children:[e.jsx("input",{type:"checkbox",style:t.checkbox,checked:x.includes(a),onChange:()=>C(a)}),B[a]]},a))})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"20px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:i,children:"Cancel"}),e.jsx("button",{style:{...t.primaryBtn,opacity:S?.6:1},disabled:S,onClick:A,children:S?"Generating...":"Generate Report"})]})]})})}function N({onClose:s,onCreated:i}){const[l,r]=d.useState("weekly"),[o,c]=d.useState("weekly"),[h,x]=d.useState(""),[b,f]=d.useState(!1),w={daily:"0 8 * * *",weekly:"0 8 * * 1",monthly:"0 8 1 * *"},m=async()=>{f(!0);try{await g.createSchedule({report_type:l,schedule_cron:w[o]||"0 8 * * 1",recipients:h.split(",").map(y=>y.trim()).filter(Boolean)}),i()}catch(y){alert("Failed: "+y.message)}finally{f(!1)}};return e.jsx("div",{style:t.overlay,onClick:s,children:e.jsxs("div",{style:t.modal,onClick:y=>y.stopPropagation(),children:[e.jsx("h2",{style:t.modalTitle,children:"Schedule Recurring Report"}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Report Type"}),e.jsxs("select",{style:t.select,value:l,onChange:y=>r(y.target.value),children:[e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"quarterly",children:"Quarterly"})]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Frequency"}),e.jsxs("select",{style:t.select,value:o,onChange:y=>c(y.target.value),children:[e.jsx("option",{value:"daily",children:"Daily (8:00 AM)"}),e.jsx("option",{value:"weekly",children:"Weekly (Monday 8:00 AM)"}),e.jsx("option",{value:"monthly",children:"Monthly (1st, 8:00 AM)"})]})]}),e.jsxs("div",{style:t.formGroup,children:[e.jsx("label",{style:t.label,children:"Recipients (comma-separated emails)"}),e.jsx("input",{style:t.input,placeholder:"ciso@company.com, cto@company.com",value:h,onChange:y=>x(y.target.value)})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end",marginTop:"20px"},children:[e.jsx("button",{style:t.secondaryBtn,onClick:s,children:"Cancel"}),e.jsx("button",{style:{...t.primaryBtn,opacity:b?.6:1},disabled:b,onClick:m,children:b?"Creating...":"Create Schedule"})]})]})})}function U({report:s,activeSection:i,onSectionChange:l,onBack:r}){const c=(typeof s.report_data=="string"?JSON.parse(s.report_data):s.report_data).sections||{},h=Object.keys(c);return e.jsxs("div",{style:t.viewerWrapper,children:[e.jsxs("div",{style:t.viewerToolbar,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{onClick:r,style:{...t.ghostBtn,color:"#64748b"},children:"← Back"}),e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"#e2e8f0"},children:s.title})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("a",{href:g.getPdfUrl(s.id),target:"_blank",rel:"noreferrer",style:{...t.primaryBtn,textDecoration:"none",fontSize:"12px",padding:"8px 14px",background:"#f59e0b"},children:"Download PDF"}),e.jsx("a",{href:g.getCsvUrl(s.id),style:{...t.secondaryBtn,textDecoration:"none",color:"#f59e0b",borderColor:"rgba(245,158,11,0.2)"},children:"Export CSV"})]})]}),e.jsxs("div",{style:{display:"flex"},children:[e.jsx("div",{style:t.viewerNav,children:h.map((x,b)=>e.jsxs("button",{style:t.viewerNavItem(i===x),onClick:()=>l(x),children:[b+1,". ",B[x]||x]},x))}),e.jsxs("div",{style:t.viewerContent,children:[e.jsxs("div",{style:{marginBottom:"32px",borderBottom:"3px solid #f59e0b",paddingBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:700,color:"#f59e0b",letterSpacing:"2px",marginBottom:"8px"},children:"VIENNA OS"}),e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:"#e2e8f0",margin:"0 0 6px"},children:s.title}),e.jsxs("div",{style:{fontSize:"13px",color:"rgba(255,255,255,0.6)"},children:["Period: ",e.jsx("strong",{children:new Date(s.period_start).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})," — ",e.jsx("strong",{children:new Date(s.period_end).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})})," · ","Generated: ",new Date(s.generated_at).toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})]})]}),h.map((x,b)=>e.jsx("div",{id:`section-${x}`,style:t.sectionBlock,children:e.jsx(O,{sectionKey:x,data:c[x],index:b+1})},x))]})]})]})}function O({sectionKey:s,data:i,index:l}){if(!i||i.error)return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[l,". ",B[s]||s]}),e.jsx("p",{style:{color:"#94a3b8",fontStyle:"italic"},children:(i==null?void 0:i.error)||"No data available"})]});switch(s){case"executive_summary":return e.jsx(q,{data:i,index:l});case"governance_overview":return e.jsx(H,{data:i,index:l});case"action_volume":return e.jsx(Q,{data:i,index:l});case"policy_compliance":return e.jsx(J,{data:i,index:l});case"agent_performance":return e.jsx(K,{data:i,index:l});case"risk_analysis":return e.jsx(X,{data:i,index:l});case"approval_metrics":return e.jsx(Y,{data:i,index:l});case"violations_incidents":return e.jsx(Z,{data:i,index:l});case"integration_health":return e.jsx(ee,{data:i,index:l});case"recommendations":return e.jsx(te,{data:i,index:l});default:return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[l,". ",s]}),e.jsx("pre",{style:{fontSize:"11px",color:"#64748b"},children:JSON.stringify(i,null,2)})]})}}function q({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Executive Summary"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:((l=s.total_actions_governed)==null?void 0:l.toLocaleString())||"0",label:"Actions Governed"}),e.jsx(p,{value:`${s.policy_compliance_rate||0}%`,label:"Compliance Rate",color:(s.policy_compliance_rate||0)>=95?"#16a34a":"#dc2626"}),e.jsx(p,{value:String(s.unauthorized_executions||0),label:"Unauthorized Executions",color:s.unauthorized_executions===0?"#16a34a":"#dc2626"}),e.jsx(p,{value:`${s.fleet_health_score||0}/100`,label:"Fleet Health",color:(s.fleet_health_score||0)>=80?"#16a34a":"#f59e0b"}),e.jsx(p,{value:String(s.active_agents||0),label:"Active Agents"}),e.jsx(p,{value:`${s.avg_approval_time_minutes||0} min`,label:"Avg Approval Time"})]}),((r=s.highlights)==null?void 0:r.length)>0&&e.jsx("div",{style:t.highlight,children:s.highlights.map((o,c)=>e.jsxs("p",{style:t.highlightItem,children:["• ",o]},c))})]})}function H({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Governance Overview"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.active_rules_count||0),label:"Active Rules"}),e.jsx(p,{value:String(s.rules_added_in_period||0),label:"Rules Added"})]}),((l=s.action_distribution)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Default Action Distribution"}),e.jsx(W,{items:s.action_distribution.map(r=>({label:r.action,value:r.count,color:r.action==="deny"?"#ef4444":r.action==="require_approval"?"#f59e0b":"#22c55e"}))})]})]})}function Q({data:s,index:i}){var l,r,o;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Action Volume"]}),e.jsx("div",{style:t.kpiGrid,children:e.jsx(p,{value:(s.total_intents||0).toLocaleString(),label:"Total Intents"})}),((l=s.by_risk_tier)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Risk Tier"}),e.jsx(W,{items:s.by_risk_tier.map(c=>({label:c.tier,value:c.count,color:c.tier==="T2"?"#ef4444":c.tier==="T1"?"#f59e0b":"#22c55e"}))})]}),((r=s.by_action_type)==null?void 0:r.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Action Type"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Count"}),e.jsx("th",{style:t.dtTh,children:"%"})]})}),e.jsx("tbody",{children:s.by_action_type.map(c=>{const h=s.total_intents>0?Math.round(c.count/s.total_intents*100):0;return e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:c.type}),e.jsx("td",{style:t.dtTd,children:c.count}),e.jsxs("td",{style:t.dtTd,children:[e.jsx(se,{pct:h})," ",h,"%"]})]},c.type)})})]})]}),((o=s.daily_trend)==null?void 0:o.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Daily Trend"}),e.jsx(re,{data:s.daily_trend})]})]})}function J({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Policy Compliance"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:(s.total_evaluations||0).toLocaleString(),label:"Rules Evaluated"}),e.jsx(p,{value:`${s.match_rate||0}%`,label:"Match Rate"})]}),((l=s.top_triggered_rules)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Top Triggered Rules"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Rule"}),e.jsx("th",{style:t.dtTh,children:"Triggered"}),e.jsx("th",{style:t.dtTh,children:"Block Rate"})]})}),e.jsx("tbody",{children:s.top_triggered_rules.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:r.name}),e.jsx("td",{style:t.dtTd,children:r.times_triggered}),e.jsx("td",{style:t.dtTd,children:e.jsxs("span",{style:t.badge(r.block_rate>50?"#991b1b":"#854d0e",r.block_rate>50?"#fee2e2":"#fef9c3"),children:[r.block_rate,"%"]})})]},r.rule_id))})]})]})]})}function K({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Agent Performance"]}),s.best_performer&&e.jsxs("div",{style:t.callout("green"),children:["🏆 Best Performer: ",e.jsx("strong",{children:s.best_performer.name})," (Trust: ",s.best_performer.trust_score,"/100)"]}),s.worst_performer&&e.jsxs("div",{style:t.callout("yellow"),children:["⚠️ Needs Attention: ",e.jsx("strong",{children:s.worst_performer.name})," (Trust: ",s.worst_performer.trust_score,"/100)"]}),((l=s.scorecards)==null?void 0:l.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Status"}),e.jsx("th",{style:t.dtTh,children:"Actions"}),e.jsx("th",{style:t.dtTh,children:"Approval"}),e.jsx("th",{style:t.dtTh,children:"Error"}),e.jsx("th",{style:t.dtTh,children:"Latency"}),e.jsx("th",{style:t.dtTh,children:"Trust"})]})}),e.jsx("tbody",{children:s.scorecards.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:{...t.dtTd,fontWeight:600},children:r.display_name}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(r.status==="active"?"#166534":r.status==="suspended"?"#991b1b":"#64748b",r.status==="active"?"#dcfce7":r.status==="suspended"?"#fee2e2":"#f1f5f9"),children:r.status})}),e.jsx("td",{style:t.dtTd,children:r.total_actions}),e.jsxs("td",{style:t.dtTd,children:[r.approval_rate,"%"]}),e.jsxs("td",{style:{...t.dtTd,color:r.error_rate>10?"#ef4444":r.error_rate>5?"#f59e0b":"#22c55e"},children:[r.error_rate,"%"]}),e.jsxs("td",{style:t.dtTd,children:[r.avg_latency_ms,"ms"]}),e.jsx("td",{style:t.dtTd,children:e.jsx(le,{score:r.trust_score})})]},r.agent_id))})]})]})}function X({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Risk Analysis"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(((l=s.high_risk_actions)==null?void 0:l.total)||0),label:"High-Risk (T2) Actions",color:"#ef4444"}),e.jsx(p,{value:String(s.scope_creep_attempts||0),label:"Scope Creep Attempts"}),e.jsx(p,{value:String(s.anomalies_detected||0),label:"Anomalies Detected"})]}),((r=s.top_denials)==null?void 0:r.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"Top Denial Reasons"}),e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Action"}),e.jsx("th",{style:t.dtTh,children:"Denials"})]})}),e.jsx("tbody",{children:s.top_denials.map((o,c)=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:o.agent_id}),e.jsx("td",{style:t.dtTd,children:o.action_type}),e.jsx("td",{style:t.dtTd,children:o.count})]},c))})]})]})]})}function Y({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Approval Metrics"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_approvals_requested||0),label:"Approvals Requested"}),e.jsx(p,{value:`${s.avg_time_to_approval_minutes||0} min`,label:"Avg Time to Approval"}),e.jsx(p,{value:`${s.approval_rate||0}%`,label:"Approval Rate",color:"#16a34a"})]}),((l=s.by_tier)==null?void 0:l.length)>0&&e.jsxs(e.Fragment,{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#334155",margin:"16px 0 8px"},children:"By Tier"}),e.jsx(W,{items:s.by_tier.map(r=>({label:r.tier,value:r.count,color:"#f59e0b"}))})]})]})}function Z({data:s,index:i}){var l,r;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Violations & Incidents"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_violations||0),label:"Total Violations",color:s.total_violations>0?"#ef4444":"#16a34a"}),e.jsx(p,{value:String(s.unresolved_count||0),label:"Unresolved",color:s.unresolved_count>0?"#f59e0b":"#16a34a"})]}),((l=s.by_severity)==null?void 0:l.length)>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:s.by_severity.map(o=>e.jsxs("span",{style:t.badge(o.severity==="critical"?"#991b1b":o.severity==="warning"?"#854d0e":"#1e40af",o.severity==="critical"?"#fee2e2":o.severity==="warning"?"#fef9c3":"#dbeafe"),children:[o.severity,": ",o.count]},o.severity))}),((r=s.incident_timeline)==null?void 0:r.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Time"}),e.jsx("th",{style:t.dtTh,children:"Agent"}),e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Severity"}),e.jsx("th",{style:t.dtTh,children:"Message"}),e.jsx("th",{style:t.dtTh,children:"Resolved"})]})}),e.jsx("tbody",{children:s.incident_timeline.slice(0,15).map(o=>e.jsxs("tr",{children:[e.jsx("td",{style:{...t.dtTd,fontSize:"11px",whiteSpace:"nowrap"},children:new Date(o.created_at).toLocaleString()}),e.jsx("td",{style:t.dtTd,children:o.agent_id}),e.jsx("td",{style:t.dtTd,children:o.alert_type}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(o.severity==="critical"?"#991b1b":o.severity==="warning"?"#854d0e":"#1e40af",o.severity==="critical"?"#fee2e2":o.severity==="warning"?"#fef9c3":"#dbeafe"),children:o.severity})}),e.jsx("td",{style:{...t.dtTd,fontSize:"11px",maxWidth:"300px",overflow:"hidden",textOverflow:"ellipsis"},children:o.message}),e.jsx("td",{style:t.dtTd,children:o.resolved?"✅":"❌"})]},o.id))})]})]})}function ee({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Integration Health"]}),e.jsxs("div",{style:t.kpiGrid,children:[e.jsx(p,{value:String(s.total_active||0),label:"Active Integrations"}),e.jsx(p,{value:`${s.overall_delivery_rate||100}%`,label:"Delivery Rate",color:"#16a34a"})]}),((l=s.integrations)==null?void 0:l.length)>0&&e.jsxs("table",{style:t.dataTable,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{style:t.dtTh,children:"Name"}),e.jsx("th",{style:t.dtTh,children:"Type"}),e.jsx("th",{style:t.dtTh,children:"Status"}),e.jsx("th",{style:t.dtTh,children:"Success Rate"}),e.jsx("th",{style:t.dtTh,children:"Events"})]})}),e.jsx("tbody",{children:s.integrations.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:t.dtTd,children:r.name}),e.jsx("td",{style:t.dtTd,children:r.type}),e.jsx("td",{style:t.dtTd,children:e.jsx("span",{style:t.badge(r.enabled?"#166534":"#64748b",r.enabled?"#dcfce7":"#f1f5f9"),children:r.enabled?"Active":"Disabled"})}),e.jsxs("td",{style:t.dtTd,children:[r.delivery_success_rate,"%"]}),e.jsx("td",{style:t.dtTd,children:r.events_in_period})]},r.name))})]})]})}function te({data:s,index:i}){var l;return e.jsxs("div",{children:[e.jsxs("h2",{style:t.sectionTitle,children:[i,". Recommendations"]}),((l=s.items)==null?void 0:l.length)>0?s.items.map((r,o)=>e.jsxs("div",{style:t.rec(r.severity),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"4px"},children:[e.jsx("span",{style:t.badge(r.severity==="critical"?"#991b1b":r.severity==="warning"?"#854d0e":"#1e40af",r.severity==="critical"?"#fee2e2":r.severity==="warning"?"#fef9c3":"#dbeafe"),children:r.severity.toUpperCase()}),e.jsx("span",{style:t.recCategory,children:r.category})]}),e.jsx("p",{style:t.recMessage,children:r.message}),e.jsxs("p",{style:t.recAction,children:["→ ",r.action]})]},o)):e.jsx("p",{style:{color:"#94a3b8",fontStyle:"italic"},children:"No recommendations at this time. Governance posture is strong. ✅"})]})}function p({value:s,label:i,color:l}){return e.jsxs("div",{style:t.kpiCard,children:[e.jsx("div",{style:t.kpiValue(l||"#1a1a2e"),children:s}),e.jsx("div",{style:t.kpiLabel,children:i})]})}function W({items:s}){const i=Math.max(...s.map(l=>l.value),1);return e.jsx("div",{children:s.map((l,r)=>e.jsxs("div",{style:t.barRow,children:[e.jsx("span",{style:t.barLabel,children:l.label}),e.jsx("div",{style:t.barTrack,children:e.jsx("div",{style:t.barFill(l.value/i*100,l.color)})}),e.jsx("span",{style:t.barValue,children:l.value})]},r))})}function se({pct:s}){return e.jsx("span",{style:{display:"inline-block",width:"60px",height:"6px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden",verticalAlign:"middle",marginRight:"4px"},children:e.jsx("span",{style:{display:"block",width:`${s}%`,height:"100%",background:"#f59e0b",borderRadius:"0"}})})}function re({data:s}){const i=Math.max(...s.map(l=>l.count),1);return e.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"2px",height:"60px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)"},children:s.map((l,r)=>e.jsx("div",{title:`${l.date}: ${l.count}`,style:{flex:1,minWidth:"3px",background:"#f59e0b",borderRadius:"2px 2px 0 0",opacity:.8,height:`${Math.max(4,l.count/i*56)}px`}},r))})}function le({score:s}){const i=s>=80?"#22c55e":s>=60?"#f59e0b":"#ef4444";return e.jsxs("span",{style:t.trustBar(s),children:[e.jsx("span",{style:{width:"40px",height:"5px",background:"rgba(255,255,255,0.08)",borderRadius:"0",overflow:"hidden",display:"inline-block"},children:e.jsx("span",{style:{display:"block",width:`${s}%`,height:"100%",background:i,borderRadius:"0"}})}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600},children:s})]})}export{oe as CompliancePage}; +//# sourceMappingURL=CompliancePage-C5o8sfAA.js.map diff --git a/apps/console-proxy/public/assets/CompliancePremium-BpLUmZne.js b/apps/console-proxy/public/assets/CompliancePremium-BpLUmZne.js deleted file mode 100644 index fcb935d8..00000000 --- a/apps/console-proxy/public/assets/CompliancePremium-BpLUmZne.js +++ /dev/null @@ -1,19 +0,0 @@ -import{r as u,b as v,j as e,S as T,R as B}from"./index-D_7YXFSJ.js";import{P as M}from"./PageLayout-CTYKc2go.js";import{A as U}from"./activity-C-iTiNlh.js";import{C as V}from"./circle-check-BIUeiM-B.js";const A={critical:"#dc2626",high:"#ef4444",medium:"#f59e0b",low:"#fbbf24"},$={open:"#ef4444",investigating:"#f59e0b",resolved:"#10b981"},F={success:"#10b981",failure:"#ef4444",partial:"#f59e0b"};function N({score:t}){const[o,d]=B.useState(!1),c=t.overall>=90?"#10b981":t.overall>=75?"#f59e0b":"#ef4444",p=t.trend==="up"?"▲":t.trend==="down"?"▼":"━",j=t.trend==="up"?"#10b981":t.trend==="down"?"#ef4444":"#6b7280";return e.jsxs("div",{onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{background:"linear-gradient(135deg, rgba(16, 185, 129, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%)",border:"2px solid rgba(251, 191, 36, 0.3)",padding:"24px",boxShadow:o?"0 0 30px rgba(16, 185, 129, 0.4)":"0 0 20px rgba(251, 191, 36, 0.2)",transform:o?"translateY(-2px)":"translateY(0)",transition:"all 300ms cubic-bezier(0.4, 0, 0.2, 1)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"rgba(251, 191, 36, 0.7)",letterSpacing:"0.1em",fontFamily:"var(--font-mono)",marginBottom:"6px"},children:"COMPLIANCE SCORE"}),e.jsxs("div",{style:{fontSize:"56px",fontWeight:700,color:c,fontFamily:"var(--font-mono)",lineHeight:1},children:[t.overall,e.jsx("span",{style:{fontSize:"24px",color:"rgba(230, 225, 220, 0.5)"},children:"/100"})]})]}),e.jsxs("div",{style:{textAlign:"right"},children:[e.jsx("div",{style:{fontSize:"18px",fontWeight:700,color:j,fontFamily:"var(--font-mono)"},children:p}),e.jsx("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)"},children:t.trend.toUpperCase()})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:"1px",height:"32px",marginBottom:"16px"},children:t.sparkline.map((x,f)=>e.jsx("div",{style:{flex:1,background:c,height:`${x}%`,opacity:.3+x/100*.7}},f))}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[{label:"Policy",value:t.policy_adherence},{label:"Approval",value:t.approval_compliance},{label:"Audit",value:t.audit_coverage},{label:"Risk",value:t.risk_mitigation}].map(({label:x,value:f})=>e.jsxs("div",{style:{background:"rgba(0, 0, 0, 0.3)",padding:"10px",border:"1px solid rgba(251, 191, 36, 0.15)"},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"rgba(251, 191, 36, 0.6)",marginBottom:"4px",fontFamily:"var(--font-mono)"},children:x.toUpperCase()}),e.jsx("div",{style:{fontSize:"20px",fontWeight:700,color:f>=90?"#10b981":f>=75?"#f59e0b":"#ef4444",fontFamily:"var(--font-mono)"},children:f})]},x))})]})}function H({policies:t}){return t.length===0?e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"32px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"8px"},children:"📋"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(230, 225, 220, 0.5)"},children:"No policies defined yet"})]}):e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",background:"rgba(251, 191, 36, 0.05)"},children:e.jsxs("h3",{style:{margin:0,fontSize:"12px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:[e.jsx(U,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"POLICY ADHERENCE"]})}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(251, 191, 36, 0.1)"},children:["Policy","Evaluations","Compliant","Violations","Compliance %","Last Violation"].map(o=>e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontSize:"9px",fontWeight:700,color:"rgba(251, 191, 36, 0.6)",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:o},o))})}),e.jsx("tbody",{children:t.map(o=>{const d=o.total_evaluations>0?Math.round(o.compliant/o.total_evaluations*100):100,c=d>=90?"#10b981":d>=75?"#f59e0b":"#ef4444";return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.02)"},children:[e.jsxs("td",{style:{padding:"10px 12px"},children:[e.jsx("div",{style:{fontWeight:600,color:"#E6E1DC"},children:o.policy_name}),e.jsxs("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)"},children:[o.policy_id.slice(0,16),"..."]})]}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"rgba(230, 225, 220, 0.7)"},children:o.total_evaluations.toLocaleString()}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"#10b981",fontWeight:600},children:o.compliant.toLocaleString()}),e.jsx("td",{style:{padding:"10px 12px",fontFamily:"var(--font-mono)",fontSize:"11px",color:o.violations>0?"#ef4444":"rgba(230, 225, 220, 0.3)",fontWeight:o.violations>0?600:400},children:o.violations}),e.jsx("td",{style:{padding:"10px 12px"},children:e.jsxs("div",{style:{display:"inline-block",padding:"4px 10px",background:`${c}20`,color:c,fontFamily:"var(--font-mono)",fontWeight:700,fontSize:"11px"},children:[d,"%"]})}),e.jsx("td",{style:{padding:"10px 12px",fontSize:"10px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)"},children:o.last_violation?new Date(o.last_violation).toLocaleDateString():"—"})]},o.policy_id)})})]})]})}function Y({violations:t}){return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",background:"rgba(251, 191, 36, 0.05)"},children:e.jsx("h3",{style:{margin:0,fontSize:"12px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"🚨 VIOLATIONS & INCIDENTS"})}),e.jsx("div",{style:{padding:"12px 16px",maxHeight:"400px",overflowY:"auto"},children:t.length===0?e.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"rgba(230, 225, 220, 0.4)",fontSize:"11px"},children:[e.jsx(V,{size:14,style:{display:"inline-block",marginRight:"6px",verticalAlign:"middle"},color:"#10b981",strokeWidth:2}),"No violations recorded"]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map(o=>e.jsxs("div",{style:{padding:"12px 14px",background:"rgba(0, 0, 0, 0.2)",border:`1px solid ${A[o.severity]}30`},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"6px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:A[o.severity],fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:o.severity.toUpperCase()}),e.jsx("div",{style:{fontSize:"9px",padding:"2px 6px",background:`${$[o.status]}20`,color:$[o.status],fontFamily:"var(--font-mono)",fontWeight:600},children:o.status.toUpperCase()})]}),e.jsx("div",{style:{fontSize:"11px",color:"#E6E1DC",marginBottom:"4px",fontWeight:500},children:o.policy_name}),e.jsx("div",{style:{fontSize:"10px",color:"rgba(230, 225, 220, 0.6)",marginBottom:"6px"},children:o.description}),e.jsxs("div",{style:{display:"flex",gap:"12px",fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)"},children:[e.jsx("span",{children:new Date(o.timestamp).toLocaleString()}),e.jsxs("span",{children:["Agent: ",o.agent_id.slice(0,12),"..."]}),e.jsxs("span",{children:["Action: ",o.action_type]})]})]},o.id))})})]})}function G({entries:t}){return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",background:"rgba(251, 191, 36, 0.05)"},children:e.jsx("h3",{style:{margin:0,fontSize:"12px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"📜 AUDIT TRAIL"})}),e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"11px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(251, 191, 36, 0.1)"},children:["Timestamp","Event","User","Action","Outcome","Details"].map(o=>e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",fontSize:"9px",fontWeight:700,color:"rgba(251, 191, 36, 0.6)",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:o},o))})}),e.jsx("tbody",{children:t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,style:{padding:"32px",textAlign:"center",color:"rgba(230, 225, 220, 0.4)",fontSize:"11px"},children:"No audit entries"})}):t.map(o=>e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.02)"},children:[e.jsx("td",{style:{padding:"10px 12px",fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)",whiteSpace:"nowrap"},children:new Date(o.timestamp).toLocaleString()}),e.jsx("td",{style:{padding:"10px 12px",fontSize:"10px",color:"rgba(230, 225, 220, 0.7)",fontFamily:"var(--font-mono)"},children:o.event_type}),e.jsx("td",{style:{padding:"10px 12px",fontSize:"10px",color:"#E6E1DC"},children:o.user}),e.jsx("td",{style:{padding:"10px 12px",fontSize:"10px",color:"rgba(230, 225, 220, 0.7)"},children:o.action}),e.jsx("td",{style:{padding:"10px 12px"},children:e.jsx("span",{style:{fontSize:"9px",padding:"2px 6px",background:`${F[o.outcome]}20`,color:F[o.outcome],fontFamily:"var(--font-mono)",fontWeight:600},children:o.outcome.toUpperCase()})}),e.jsx("td",{style:{padding:"10px 12px",fontSize:"10px",color:"rgba(230, 225, 220, 0.5)",maxWidth:"200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.details})]},o.id))})]})]})}function Z(){const[t,o]=u.useState(null),[d,c]=u.useState(!0),[p,j]=u.useState("30d"),x=u.useCallback(async()=>{var a;c(!0);try{const r=localStorage.getItem("vienna_access_token"),g={"Content-Type":"application/json"};r&&(g.Authorization=`Bearer ${r}`);const[b,m,n,_,S]=await Promise.all([fetch("/api/v1/compliance/quick-stats",{credentials:"include",headers:g}).then(i=>i.json()).catch(()=>({success:!1})),fetch("/api/v1/policies",{credentials:"include",headers:g}).then(i=>i.json()).catch(()=>({success:!1})),fetch("/api/v1/proposals?state=denied&limit=20",{credentials:"include",headers:g}).then(i=>i.json()).catch(()=>({success:!1})),fetch("/api/v1/activity/feed?limit=50",{credentials:"include",headers:g}).then(i=>i.json()).catch(()=>({success:!1})),fetch("/api/v1/compliance/reports?limit=10",{credentials:"include",headers:g}).then(i=>i.json()).catch(()=>({success:!1}))]),E=b.success?b.data:{},k=m.success?m.data:[],z=n.success?n.data:[],O=_.success?_.data:[],q=S.success?((a=S.data)==null?void 0:a.rows)||S.data||[]:[],L=E.compliance_rate||0,l=Math.round(L),D={overall:l,policy_adherence:Math.min(100,l+5),approval_compliance:l,audit_coverage:Math.min(100,l+3),risk_mitigation:Math.max(0,l-5),trend:l>=90?"up":l>=75?"stable":"down",sparkline:[l-10,l-5,l-2,l,l+2,l+5].map(i=>Math.max(0,Math.min(100,i)))},P=k.slice(0,10).map(i=>{var w;const s=z.filter(C=>C.policy_id===i.id),h=s.length||1,y=s.filter(C=>C.state==="denied").length;return{policy_id:i.id,policy_name:i.name||`Policy ${i.id.slice(0,8)}`,total_evaluations:h,compliant:Math.max(0,h-y),violations:y,last_violation:((w=s[0])==null?void 0:w.evaluated_at)||null}}),W=z.slice(0,10).map(i=>{var s;return{id:i.id,timestamp:i.created_at||new Date().toISOString(),policy_name:((s=k.find(h=>h.id===i.policy_id))==null?void 0:s.name)||"Unknown Policy",agent_id:i.agent_id||"unknown",action_type:i.action_type||"unknown",severity:"high",status:"open",description:"Proposal denied by policy evaluation"}}),I=O.slice(0,20).map(i=>{var s,h,y;return{id:i.id,timestamp:i.timestamp||new Date().toISOString(),event_type:i.type||"system.event",user:((s=i.agent)==null?void 0:s.display_name)||"system",agent_id:(h=i.agent)==null?void 0:h.id,action:((y=i.type)==null?void 0:y.split(".")[1])||"action",outcome:"success",details:`${i.type}`}});o({score:D,policies:P,violations:W,audit_trail:I,period:p==="7d"?"Last 7 Days":p==="30d"?"Last 30 Days":"Last 90 Days"})}catch{v("Failed to load compliance data","error")}finally{c(!1)}},[p]);u.useEffect(()=>{x()},[x]);const f=()=>{const a=window.open("","_blank");if(!a||!t){v("Unable to open print window","error");return}a.document.write(` - Vienna OS Compliance Report - -

Vienna OS — Compliance Report

-

Generated: ${new Date().toLocaleString()}

-

Compliance Score

-
Overall Score${t.score.overall}/100
-

Policy Adherence

- - ${t.policies.map(r=>``).join("")} -
PolicyEvaluationsCompliantViolations
${r.policy_name}${r.total_evaluations}${r.compliant}${r.violations}
- `),a.document.close(),a.print(),v("PDF report opened for printing","success")},R=()=>{if(!t)return;const r=["Vienna OS Compliance Report",`Generated: ${new Date().toISOString()}`,`Period: ${t.period}`,"",`Overall Score: ${t.score.overall}/100`,`Policy Adherence: ${t.score.policy_adherence}`,`Approval Compliance: ${t.score.approval_compliance}`,`Audit Coverage: ${t.score.audit_coverage}`,`Risk Mitigation: ${t.score.risk_mitigation}`,"","--- Policy Adherence ---","Policy,Evaluations,Compliant,Violations,Compliance %",...t.policies.map(n=>`${n.policy_name},${n.total_evaluations},${n.compliant},${n.violations},${Math.round(n.compliant/n.total_evaluations*100)}%`),"","--- Violations ---","Timestamp,Severity,Status,Policy,Agent,Action,Description",...t.violations.map(n=>`${n.timestamp},${n.severity},${n.status},${n.policy_name},${n.agent_id},${n.action_type},${n.description}`)].join(` -`),g=new Blob([r],{type:"text/csv"}),b=URL.createObjectURL(g),m=document.createElement("a");m.href=b,m.download=`vienna-compliance-${new Date().toISOString().slice(0,10)}.csv`,document.body.appendChild(m),m.click(),document.body.removeChild(m),URL.revokeObjectURL(b),v("Compliance report exported","success")};return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs(M,{title:"",description:"",children:[e.jsx("div",{style:{background:"linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:"24px",fontWeight:700,color:"#10b981",margin:0,fontFamily:"var(--font-mono)",letterSpacing:"0.02em"},children:[e.jsx(T,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"COMPLIANCE TERMINAL"]}),e.jsxs("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.5)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:[(t==null?void 0:t.period)||"Loading..."," — SOC 2 Audit Ready"]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsx("div",{style:{display:"flex",gap:"4px"},children:["7d","30d","90d"].map(a=>e.jsx("button",{onClick:()=>j(a),style:{padding:"6px 12px",background:p===a?"rgba(16, 185, 129, 0.2)":"rgba(0, 0, 0, 0.3)",border:`1px solid ${p===a?"#10b981":"rgba(251, 191, 36, 0.2)"}`,color:p===a?"#10b981":"rgba(230, 225, 220, 0.5)",fontSize:"10px",fontWeight:700,cursor:"pointer",fontFamily:"var(--font-mono)"},children:a.toUpperCase()},a))}),e.jsx("button",{onClick:R,disabled:!t,style:{padding:"6px 14px",background:t?"rgba(16, 185, 129, 0.2)":"rgba(107, 114, 128, 0.2)",border:`1px solid ${t?"#10b981":"#6b7280"}`,color:t?"#10b981":"#6b7280",fontSize:"10px",fontWeight:700,cursor:t?"pointer":"default",fontFamily:"var(--font-mono)"},children:"📥 CSV"}),e.jsx("button",{onClick:f,disabled:!t,style:{padding:"6px 14px",background:t?"rgba(245, 158, 11, 0.2)":"rgba(107, 114, 128, 0.2)",border:`1px solid ${t?"#f59e0b":"#6b7280"}`,color:t?"#f59e0b":"#6b7280",fontSize:"10px",fontWeight:700,cursor:t?"pointer":"default",fontFamily:"var(--font-mono)"},children:"📄 PDF"})]})]})}),d?e.jsxs("div",{style:{padding:"80px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"32px",height:"32px",border:"3px solid rgba(16, 185, 129, 0.2)",borderTop:"3px solid #10b981",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),e.jsx("p",{style:{marginTop:"16px",fontSize:"12px",color:"rgba(230, 225, 220, 0.5)",fontFamily:"var(--font-mono)"},children:"LOADING COMPLIANCE DATA..."}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):t&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsx(N,{score:t.score}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"12px"},children:[e.jsx(H,{policies:t.policies}),e.jsx(Y,{violations:t.violations})]}),e.jsx(G,{entries:t.audit_trail})]})]})})})}export{Z as CompliancePremium}; -//# sourceMappingURL=CompliancePremium-BpLUmZne.js.map diff --git a/apps/console-proxy/public/assets/ConnectAgentPage-B2q_drgu.js b/apps/console-proxy/public/assets/ConnectAgentPage-BeQD2oWm.js similarity index 98% rename from apps/console-proxy/public/assets/ConnectAgentPage-B2q_drgu.js rename to apps/console-proxy/public/assets/ConnectAgentPage-BeQD2oWm.js index 712380ee..07e377d4 100644 --- a/apps/console-proxy/public/assets/ConnectAgentPage-B2q_drgu.js +++ b/apps/console-proxy/public/assets/ConnectAgentPage-BeQD2oWm.js @@ -1,4 +1,4 @@ -import{u as F,d as K,r as n,a as u,j as e,R as E}from"./index-D_7YXFSJ.js";import{P as L}from"./PageLayout-CTYKc2go.js";function Y(){const h=F(),v=K(r=>r.tenant),b=(v==null?void 0:v.id)||"unknown",[a,s]=n.useState(1),[o,j]=n.useState(null),[x,k]=n.useState("openai"),[l,S]=n.useState(""),[i,m]=n.useState(null),[d,c]=n.useState(!1),[p,g]=n.useState(null),[z,w]=n.useState([]);n.useEffect(()=>{C()},[]);const C=async()=>{try{const r=await u.get("/policy-templates/packs");w(r.packs||[{id:"soc2",name:"SOC 2",description:"Security controls for data handling and system availability",templates:[{id:"access-control",name:"Access Control",description:"User authentication and authorization"},{id:"data-protection",name:"Data Protection",description:"Encryption and data handling policies"}]},{id:"financial",name:"Financial",description:"Controls for financial operations and transactions",templates:[{id:"transaction-limits",name:"Transaction Limits",description:"Spending and transfer limits"},{id:"dual-approval",name:"Dual Approval",description:"Multi-person approval for high-value actions"}]},{id:"hipaa",name:"HIPAA",description:"Healthcare data privacy and security compliance",templates:[{id:"phi-protection",name:"PHI Protection",description:"Protected health information handling"},{id:"access-audit",name:"Access Auditing",description:"Healthcare data access logging"}]},{id:"dev-safety",name:"Development Safety",description:"Safe deployment and development practices",templates:[{id:"deployment-gates",name:"Deployment Gates",description:"Production deployment controls"},{id:"code-review",name:"Code Review",description:"Automated code review requirements"}]}])}catch{}},P=async()=>{var r,t;c(!0),g(null);try{await u.post("/connect/test",{method:o,provider:x,apiKey:o==="api-proxy"?l:void 0}),s(3)}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Connection test failed")}finally{c(!1)}},R=async()=>{var r,t;if(i){c(!0),g(null);try{await u.post("/connect/activate-pack",{policy_pack_id:i,tenant_id:b}),s(4)}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Failed to activate policy pack")}finally{c(!1)}}},W=async()=>{var r,t;c(!0),g(null);try{const y=await u.post("/intent",{agent_id:"connect-wizard-test",action_type:"test_action",description:"Test action from Connect Your Agent wizard",context:{integration_method:o,provider:o==="api-proxy"?x:void 0},risk_tier:1})}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Failed to send test action")}finally{c(!1)}},f=r=>{navigator.clipboard.writeText(r)},B=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:"Choose Integration Method"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:0},children:"How would you like to connect your agent to Vienna?"})]}),e.jsx("div",{style:{display:"grid",gap:16,maxWidth:600},children:[{id:"api-proxy",icon:"🔑",title:"API Key Proxy",description:"Paste your LLM API key. Vienna wraps it and governs every call.",recommended:!0},{id:"sdk",icon:"📦",title:"SDK Integration",description:"Add 5 lines to your agent code.",recommended:!1},{id:"webhook",icon:"🔌",title:"Webhook",description:"Point your agent's webhook to Vienna.",recommended:!1}].map(r=>e.jsxs("div",{onClick:()=>{j(r.id),s(2)},style:{padding:20,border:"1px solid var(--border-subtle)",borderRadius:8,cursor:"pointer",background:"var(--bg-primary)",transition:"all 150ms",position:"relative"},onMouseEnter:t=>{t.currentTarget.style.borderColor="var(--border-primary)",t.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:t=>{t.currentTarget.style.borderColor="var(--border-subtle)",t.currentTarget.style.background="var(--bg-primary)"},children:[r.recommended&&e.jsx("div",{style:{position:"absolute",top:-8,right:16,background:"#f59e0b",color:"white",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Recommended"}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{fontSize:24,marginTop:2},children:r.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",marginBottom:4},children:r.title}),e.jsx("div",{style:{fontSize:14,color:"var(--text-secondary)"},children:r.description})]}),e.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:"→"})]})]},r.id))})]}),A=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsxs("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:["Configure ",o==="api-proxy"?"API Proxy":o==="sdk"?"SDK":"Webhook"]}),e.jsxs("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:0},children:[o==="api-proxy"&&"Provide your LLM API key to enable proxied governance",o==="sdk"&&"Copy the integration code to your agent",o==="webhook"&&"Configure your webhook endpoint"]})]}),o==="api-proxy"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Provider"}),e.jsxs("select",{value:x,onChange:r=>k(r.target.value),style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-primary)",color:"var(--text-primary)",fontSize:14},children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"API Key"}),e.jsx("input",{type:"password",placeholder:`Enter your ${x} API key`,value:l,onChange:r=>S(r.target.value),style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-primary)",color:"var(--text-primary)",fontSize:14,fontFamily:"var(--font-mono)"}})]}),e.jsxs("div",{style:{padding:16,background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:20},children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--text-secondary)",marginBottom:8},children:"Vienna Proxy URL"}),e.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",wordBreak:"break-all",background:"var(--bg-primary)",padding:8,borderRadius:4,border:"1px solid var(--border-subtle)"},children:["https://console.regulator.ai/api/v1/proxy/",b,"/v1/chat/completions"]})]}),e.jsx("button",{onClick:P,disabled:!l||d,style:{padding:"10px 20px",background:l?"#f59e0b":"var(--bg-tertiary)",color:l?"white":"var(--text-tertiary)",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:l?"pointer":"not-allowed",transition:"background 150ms"},children:d?"Testing...":"Test Connection"})]}),o==="sdk"&&e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Install Command"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"8px 12px"},children:[e.jsx("code",{style:{flex:1,fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)"},children:"npm install vienna-os"}),e.jsx("button",{onClick:()=>f("npm install vienna-os"),style:{padding:"4px 8px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,fontSize:10,color:"var(--text-secondary)",cursor:"pointer"},children:"Copy"})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Integration Code"}),e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:12,position:"relative"},children:[e.jsx("button",{onClick:()=>f(`import { Vienna } from 'vienna-os'; +import{u as F,f as K,r as n,e as u,j as e,R as E}from"./index-C0nK3ekl.js";import{P as L}from"./PageLayout-D94mSHCV.js";function Y(){const h=F(),v=K(r=>r.tenant),b=(v==null?void 0:v.id)||"unknown",[a,s]=n.useState(1),[o,j]=n.useState(null),[x,k]=n.useState("openai"),[l,S]=n.useState(""),[i,m]=n.useState(null),[d,c]=n.useState(!1),[p,g]=n.useState(null),[z,w]=n.useState([]);n.useEffect(()=>{C()},[]);const C=async()=>{try{const r=await u.get("/policy-templates/packs");w(r.packs||[{id:"soc2",name:"SOC 2",description:"Security controls for data handling and system availability",templates:[{id:"access-control",name:"Access Control",description:"User authentication and authorization"},{id:"data-protection",name:"Data Protection",description:"Encryption and data handling policies"}]},{id:"financial",name:"Financial",description:"Controls for financial operations and transactions",templates:[{id:"transaction-limits",name:"Transaction Limits",description:"Spending and transfer limits"},{id:"dual-approval",name:"Dual Approval",description:"Multi-person approval for high-value actions"}]},{id:"hipaa",name:"HIPAA",description:"Healthcare data privacy and security compliance",templates:[{id:"phi-protection",name:"PHI Protection",description:"Protected health information handling"},{id:"access-audit",name:"Access Auditing",description:"Healthcare data access logging"}]},{id:"dev-safety",name:"Development Safety",description:"Safe deployment and development practices",templates:[{id:"deployment-gates",name:"Deployment Gates",description:"Production deployment controls"},{id:"code-review",name:"Code Review",description:"Automated code review requirements"}]}])}catch{}},P=async()=>{var r,t;c(!0),g(null);try{await u.post("/connect/test",{method:o,provider:x,apiKey:o==="api-proxy"?l:void 0}),s(3)}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Connection test failed")}finally{c(!1)}},R=async()=>{var r,t;if(i){c(!0),g(null);try{await u.post("/connect/activate-pack",{policy_pack_id:i,tenant_id:b}),s(4)}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Failed to activate policy pack")}finally{c(!1)}}},W=async()=>{var r,t;c(!0),g(null);try{const y=await u.post("/intent",{agent_id:"connect-wizard-test",action_type:"test_action",description:"Test action from Connect Your Agent wizard",context:{integration_method:o,provider:o==="api-proxy"?x:void 0},risk_tier:1})}catch(y){g(((t=(r=y.response)==null?void 0:r.data)==null?void 0:t.error)||"Failed to send test action")}finally{c(!1)}},f=r=>{navigator.clipboard.writeText(r)},B=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:"Choose Integration Method"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:0},children:"How would you like to connect your agent to Vienna?"})]}),e.jsx("div",{style:{display:"grid",gap:16,maxWidth:600},children:[{id:"api-proxy",icon:"🔑",title:"API Key Proxy",description:"Paste your LLM API key. Vienna wraps it and governs every call.",recommended:!0},{id:"sdk",icon:"📦",title:"SDK Integration",description:"Add 5 lines to your agent code.",recommended:!1},{id:"webhook",icon:"🔌",title:"Webhook",description:"Point your agent's webhook to Vienna.",recommended:!1}].map(r=>e.jsxs("div",{onClick:()=>{j(r.id),s(2)},style:{padding:20,border:"1px solid var(--border-subtle)",borderRadius:8,cursor:"pointer",background:"var(--bg-primary)",transition:"all 150ms",position:"relative"},onMouseEnter:t=>{t.currentTarget.style.borderColor="var(--border-primary)",t.currentTarget.style.background="var(--bg-secondary)"},onMouseLeave:t=>{t.currentTarget.style.borderColor="var(--border-subtle)",t.currentTarget.style.background="var(--bg-primary)"},children:[r.recommended&&e.jsx("div",{style:{position:"absolute",top:-8,right:16,background:"#f59e0b",color:"white",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:4,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Recommended"}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("div",{style:{fontSize:24,marginTop:2},children:r.icon}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",marginBottom:4},children:r.title}),e.jsx("div",{style:{fontSize:14,color:"var(--text-secondary)"},children:r.description})]}),e.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:"→"})]})]},r.id))})]}),A=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsxs("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:["Configure ",o==="api-proxy"?"API Proxy":o==="sdk"?"SDK":"Webhook"]}),e.jsxs("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:0},children:[o==="api-proxy"&&"Provide your LLM API key to enable proxied governance",o==="sdk"&&"Copy the integration code to your agent",o==="webhook"&&"Configure your webhook endpoint"]})]}),o==="api-proxy"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Provider"}),e.jsxs("select",{value:x,onChange:r=>k(r.target.value),style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-primary)",color:"var(--text-primary)",fontSize:14},children:[e.jsx("option",{value:"openai",children:"OpenAI"}),e.jsx("option",{value:"anthropic",children:"Anthropic"}),e.jsx("option",{value:"google",children:"Google"}),e.jsx("option",{value:"custom",children:"Custom"})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("label",{style:{display:"block",fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"API Key"}),e.jsx("input",{type:"password",placeholder:`Enter your ${x} API key`,value:l,onChange:r=>S(r.target.value),style:{width:"100%",padding:"10px 12px",border:"1px solid var(--border-subtle)",borderRadius:6,background:"var(--bg-primary)",color:"var(--text-primary)",fontSize:14,fontFamily:"var(--font-mono)"}})]}),e.jsxs("div",{style:{padding:16,background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,marginBottom:20},children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--text-secondary)",marginBottom:8},children:"Vienna Proxy URL"}),e.jsxs("div",{style:{fontFamily:"var(--font-mono)",fontSize:11,color:"var(--text-primary)",wordBreak:"break-all",background:"var(--bg-primary)",padding:8,borderRadius:4,border:"1px solid var(--border-subtle)"},children:["https://console.regulator.ai/api/v1/proxy/",b,"/v1/chat/completions"]})]}),e.jsx("button",{onClick:P,disabled:!l||d,style:{padding:"10px 20px",background:l?"#f59e0b":"var(--bg-tertiary)",color:l?"white":"var(--text-tertiary)",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:l?"pointer":"not-allowed",transition:"background 150ms"},children:d?"Testing...":"Test Connection"})]}),o==="sdk"&&e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Install Command"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:"8px 12px"},children:[e.jsx("code",{style:{flex:1,fontFamily:"var(--font-mono)",fontSize:12,color:"var(--text-primary)"},children:"npm install vienna-os"}),e.jsx("button",{onClick:()=>f("npm install vienna-os"),style:{padding:"4px 8px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:4,fontSize:10,color:"var(--text-secondary)",cursor:"pointer"},children:"Copy"})]})]}),e.jsxs("div",{style:{marginBottom:20},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:8},children:"Integration Code"}),e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,padding:12,position:"relative"},children:[e.jsx("button",{onClick:()=>f(`import { Vienna } from 'vienna-os'; const vienna = new Vienna({ apiKey: 'vos_YOUR_KEY', endpoint: 'https://console.regulator.ai' @@ -17,4 +17,4 @@ const result = await vienna.govern('deploy_to_prod', { env: 'production' });`})] "context": { "version": "1.2.3" }, "risk_tier": 2 }`})})]}),e.jsx("button",{onClick:()=>s(3),style:{padding:"10px 20px",background:"#f59e0b",color:"white",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"Continue"})]}),p&&e.jsx("div",{style:{marginTop:16,padding:"10px 12px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:6,color:"#ef4444",fontSize:14},children:p})]}),I=()=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:"Select Policy Pack"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:14,margin:0},children:"Choose a pre-configured policy pack or skip to configure policies later."})]}),e.jsxs("div",{style:{display:"grid",gap:16,maxWidth:700,marginBottom:32},children:[z.map(r=>e.jsxs("div",{onClick:()=>m(r.id),style:{padding:20,border:`2px solid ${i===r.id?"#f59e0b":"var(--border-subtle)"}`,borderRadius:8,cursor:"pointer",background:i===r.id?"rgba(124, 58, 237, 0.05)":"var(--bg-primary)",transition:"all 150ms"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:600,color:"var(--text-primary)",marginBottom:4},children:r.name}),e.jsx("div",{style:{fontSize:14,color:"var(--text-secondary)"},children:r.description})]}),i===r.id&&e.jsx("div",{style:{width:20,height:20,borderRadius:"50%",background:"#f59e0b",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:12},children:"✓"})]}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:r.templates.map(t=>e.jsx("div",{style:{fontSize:11,color:"var(--text-tertiary)",background:"var(--bg-secondary)",padding:"2px 6px",borderRadius:3},children:t.name},t.id))})]},r.id)),e.jsxs("div",{onClick:()=>m(null),style:{padding:20,border:`1px dashed ${i===null?"#f59e0b":"var(--border-subtle)"}`,borderRadius:8,cursor:"pointer",background:i===null?"rgba(124, 58, 237, 0.05)":"transparent",textAlign:"center",transition:"all 150ms"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-secondary)",marginBottom:4},children:"Skip — I'll configure policies later"}),e.jsx("div",{style:{fontSize:12,color:"var(--text-tertiary)"},children:"Proceed without applying a policy pack"})]})]}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsx("button",{onClick:()=>s(2),style:{padding:"10px 16px",background:"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:14,cursor:"pointer"},children:"← Back"}),e.jsx("button",{onClick:i?R:()=>s(4),disabled:d,style:{padding:"10px 20px",background:"#f59e0b",color:"white",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",opacity:d?.7:1},children:d?"Activating...":i?"Activate Policy Pack":"Continue"})]}),p&&e.jsx("div",{style:{marginTop:16,padding:"10px 12px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:6,color:"#ef4444",fontSize:14},children:p})]}),_=()=>e.jsxs("div",{style:{textAlign:"center",maxWidth:500,margin:"0 auto"},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:"🎉"}),e.jsx("h2",{style:{fontSize:24,fontWeight:600,color:"var(--text-primary)",margin:"0 0 16px"},children:"Your Agent is Connected!"}),e.jsx("p",{style:{color:"var(--text-secondary)",fontSize:16,marginBottom:32,lineHeight:1.5},children:"Vienna is now protecting your agent. Try sending a test action through the governance pipeline."}),e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:8,padding:24,marginBottom:24},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-primary)",marginBottom:16},children:"Test Your Integration"}),e.jsx("button",{onClick:W,disabled:d,style:{width:"100%",padding:"12px 20px",background:"#10b981",color:"white",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer",marginBottom:16,opacity:d?.7:1},children:d?"Sending...":"Send Test Action"}),p&&e.jsx("div",{style:{padding:"8px 12px",background:"rgba(239,68,68,0.1)",border:"1px solid rgba(239,68,68,0.2)",borderRadius:6,color:"#ef4444",fontSize:12},children:p})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"center"},children:[e.jsx("button",{onClick:()=>h("/fleet"),style:{padding:"10px 16px",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-subtle)",borderRadius:6,fontSize:14,cursor:"pointer"},children:"View Fleet"}),e.jsx("button",{onClick:()=>h("/"),style:{padding:"10px 20px",background:"#f59e0b",color:"white",border:"none",borderRadius:6,fontSize:14,fontWeight:500,cursor:"pointer"},children:"Go to Dashboard"})]})]}),T=()=>e.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:40},children:[1,2,3,4].map(r=>e.jsxs(E.Fragment,{children:[e.jsx("div",{style:{width:32,height:32,borderRadius:"50%",background:r<=a?"#f59e0b":"var(--bg-tertiary)",color:r<=a?"white":"var(--text-tertiary)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600},children:re.jsxs("button",{onClick:t.action,disabled:!t.enabled,style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 14px",background:t.enabled?`${t.color}20`:"rgba(107, 114, 128, 0.1)",border:`1px solid ${t.enabled?`${t.color}40`:"rgba(107, 114, 128, 0.2)"}`,color:t.enabled?t.color:"#6b7280",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:t.enabled?"pointer":"not-allowed",transition:"all 150ms",letterSpacing:"0.05em"},onMouseEnter:s=>{t.enabled&&(s.currentTarget.style.transform="translateY(-1px)",s.currentTarget.style.boxShadow=`0 4px 12px ${t.color}40`)},onMouseLeave:s=>{s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none"},children:[t.icon,t.label]},t.id))]})}function m({label:i,value:t,unit:s,color:l,pulse:f}){const[a,y]=g.useState(!1);return e.jsxs("div",{onMouseEnter:()=>y(!0),onMouseLeave:()=>y(!1),style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",display:"flex",flexDirection:"column",gap:"8px",position:"relative",overflow:"hidden",boxShadow:a?`0 0 20px ${l}40`:"0 0 0 1px rgba(0,0,0,0.8)",transform:a?"translateY(-2px)":"translateY(0)",transition:"all 200ms cubic-bezier(0.4, 0, 0.2, 1)"},children:[f&&e.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",width:"8px",height:"8px",borderRadius:"50%",background:l,boxShadow:`0 0 8px ${l}`,animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}),e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"rgba(251, 191, 36, 0.7)",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:i}),e.jsxs("div",{style:{fontSize:"36px",fontWeight:700,color:l,fontFamily:"var(--font-mono)",lineHeight:1},children:[t,s&&e.jsx("span",{style:{fontSize:"16px",color:"rgba(230, 225, 220, 0.5)",marginLeft:"4px"},children:s})]}),e.jsx("style",{children:` - @keyframes pulse { - 0%, 100% { opacity: 1; } - 50% { opacity: 0.3; } - } - `})]})}function v({label:i,status:t,detail:s,action:l}){const a={healthy:{color:"#10b981",glow:"rgba(16, 185, 129, 0.4)",label:"OPERATIONAL"},degraded:{color:"#f59e0b",glow:"rgba(245, 158, 11, 0.4)",label:"DEGRADED"},critical:{color:"#ef4444",glow:"rgba(239, 68, 68, 0.4)",label:"CRITICAL"}}[t];return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:`1px solid ${a.color}40`,padding:"14px 16px",boxShadow:`0 0 12px ${a.glow}`},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"8px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"#E6E1DC"},children:i}),e.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:a.color,boxShadow:`0 0 8px ${a.glow}`,animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}})]}),e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:a.color,marginBottom:"6px",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:a.label}),e.jsx("div",{style:{fontSize:"10px",color:"rgba(230, 225, 220, 0.6)",fontFamily:"var(--font-mono)"},children:s}),l&&e.jsx("button",{onClick:l,style:{marginTop:"10px",padding:"6px 10px",background:`${a.color}20`,border:`1px solid ${a.color}40`,color:a.color,fontSize:"9px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",width:"100%",letterSpacing:"0.05em"},children:"INVESTIGATE →"})]})}function B(){const i=C(),[t,s]=g.useState({activeAgents:0,totalAgents:0,warrantsToday:0,avgTrust:0,pendingApprovals:0,avgLatencyMs:0,systemStatus:"healthy"}),[l,f]=g.useState(!0),[a,y]=g.useState(!0),p=g.useCallback(async()=>{var n;f(!0);try{const r=localStorage.getItem("vienna_access_token"),x={"Content-Type":"application/json"};r&&(x.Authorization=`Bearer ${r}`);const[u,d,o]=await Promise.all([fetch("/api/v1/fleet/agents",{credentials:"include",headers:x}).then(c=>c.json()).catch(()=>({success:!1})),fetch("/api/v1/executions/stats",{credentials:"include",headers:x}).then(c=>c.json()).catch(()=>({success:!1})),fetch("/api/v1/dashboard?range=24h",{credentials:"include",headers:x}).then(c=>c.json()).catch(()=>({success:!1}))]),h=(u.success?u.data:u.agents)||[],j=d.success?d.data:{},S=o.success?o.data:{},A=S.overview||{};s({activeAgents:h.filter(c=>c.status==="active").length,totalAgents:h.length,warrantsToday:Number(j.total_executions||A.executions_period||0),avgTrust:h.length>0?h.reduce((c,w)=>c+(Number(w.trust_score)||0),0)/h.length:0,pendingApprovals:Number(A.pending_approvals||j.pending_approval||0),avgLatencyMs:Number(((n=S.systemHealth)==null?void 0:n.latencyMs)||0),systemStatus:"healthy"})}catch{}finally{f(!1)}},[]);g.useEffect(()=>{p()},[p]),g.useEffect(()=>{if(!a)return;const n=setInterval(p,3e4);return()=>clearInterval(n)},[a,p]);const T=[{id:"start-tour",label:"START TOUR",icon:e.jsx(M,{size:12}),color:"#d4af37",action:()=>{window.startGuidedTour&&window.startGuidedTour()},enabled:!0},{id:"refresh",label:"REFRESH",icon:e.jsx(z,{size:12}),color:"#10b981",action:p,enabled:!0},{id:"pause-all",label:a?"PAUSE AUTO":"RESUME AUTO",icon:a?e.jsx(R,{size:12}):e.jsx(k,{size:12}),color:"#f59e0b",action:()=>y(!a),enabled:!0},{id:"approve-all",label:"APPROVE QUEUE",icon:e.jsx(I,{size:12}),color:"#10b981",action:async()=>{try{const n=localStorage.getItem("vienna_access_token"),r={"Content-Type":"application/json"};n&&(r.Authorization=`Bearer ${n}`);const d=((await(await fetch("/api/v1/approvals",{credentials:"include",headers:r})).json()).data||[]).filter(o=>o.status==="pending");if(d.length===0){b("No pending approvals in queue","info");return}for(const o of d)await fetch(`/api/v1/approvals/${o.approval_id||o.id}/approve`,{method:"POST",credentials:"include",headers:r,body:JSON.stringify({reason:"Batch approved from dashboard"})});b(`Approved ${d.length} pending requests`,"success"),p()}catch(n){b("Batch approve failed: "+n.message,"error")}},enabled:t.pendingApprovals>0},{id:"emergency",label:"EMERGENCY HALT",icon:e.jsx(L,{size:12}),color:"#ef4444",action:async()=>{if(confirm("⚠️ Halt ALL agent operations? This will suspend every active agent."))try{const n=localStorage.getItem("vienna_access_token"),r={"Content-Type":"application/json"};n&&(r.Authorization=`Bearer ${n}`);const d=((await(await fetch("/api/v1/fleet/agents",{credentials:"include",headers:r})).json()).data||[]).filter(o=>o.status==="active");for(const o of d)await fetch(`/api/v1/agents/${o.id}`,{method:"PUT",credentials:"include",headers:r,body:JSON.stringify({status:"suspended"})});b(`Emergency halt: ${d.length} agents suspended`,"warning"),p()}catch(n){b("Emergency halt failed: "+n.message,"error")}},enabled:!0},{id:"terminal",label:"CONSOLE",icon:e.jsx(O,{size:12}),color:"#06b6d4",action:()=>i("/workspace"),enabled:!0}];return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs($,{title:"",description:"",children:[e.jsx("div",{style:{background:"linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:"24px",fontWeight:700,color:"#10b981",margin:0,fontFamily:"var(--font-mono)",letterSpacing:"0.02em"},children:[e.jsx(N,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"MISSION CONTROL"]}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.5)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:"Live Agent Governance Dashboard"})]}),e.jsxs("div",{style:{fontSize:"11px",fontFamily:"var(--font-mono)",color:t.systemStatus==="healthy"?"#10b981":"#ef4444",fontWeight:700,display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:t.systemStatus==="healthy"?"#10b981":"#ef4444",boxShadow:`0 0 8px ${t.systemStatus==="healthy"?"rgba(16, 185, 129, 0.6)":"rgba(239, 68, 68, 0.6)"}`,animation:"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite"}}),t.systemStatus.toUpperCase()]})]})}),e.jsx(D,{actions:T}),l?e.jsxs("div",{style:{padding:"80px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"32px",height:"32px",border:"3px solid rgba(16, 185, 129, 0.2)",borderTop:"3px solid #10b981",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),e.jsx("p",{style:{marginTop:"16px",fontSize:"12px",color:"rgba(230, 225, 220, 0.5)",fontFamily:"var(--font-mono)"},children:"LOADING MISSION CONTROL..."}),e.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[e.jsx(m,{label:"ACTIVE AGENTS",value:t.activeAgents,color:"#10b981",pulse:!0}),e.jsx(m,{label:"WARRANTS TODAY",value:t.warrantsToday.toLocaleString(),color:"#fbbf24"}),e.jsx(m,{label:"AVG TRUST",value:t.avgTrust.toFixed(1),unit:"%",color:"#06b6d4"}),e.jsx(m,{label:"PENDING",value:t.pendingApprovals,color:t.pendingApprovals>10?"#f59e0b":"#10b981",pulse:t.pendingApprovals>10})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"12px"},children:[e.jsx(v,{label:"Governance Engine",status:t.avgLatencyMs<100?"healthy":"degraded",detail:`Avg latency: ${t.avgLatencyMs}ms`,action:()=>i("/analytics")}),e.jsx(v,{label:"Approval Queue",status:t.pendingApprovals<20?"healthy":"degraded",detail:`${t.pendingApprovals} pending approvals`,action:()=>i("/approvals")}),e.jsx(v,{label:"Fleet Status",status:t.activeAgents>=t.totalAgents*.8?"healthy":"degraded",detail:`${t.activeAgents} active of ${t.totalAgents} total`,action:()=>i("/fleet")})]}),e.jsxs("div",{style:{background:"linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(245, 158, 11, 0.1) 100%)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px 20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"rgba(251, 191, 36, 0.7)",letterSpacing:"0.1em",fontFamily:"var(--font-mono)",marginBottom:"4px"},children:"SYSTEM PERFORMANCE"}),e.jsxs("div",{style:{fontSize:"13px",color:"#E6E1DC",fontFamily:"var(--font-mono)"},children:["All systems nominal • ",t.warrantsToday.toLocaleString()," warrants processed today • ",t.avgLatencyMs,"ms average latency"]})]}),e.jsxs("div",{style:{fontSize:"24px",fontWeight:700,color:"#10b981",fontFamily:"var(--font-mono)"},children:[(t.activeAgents/Math.max(t.totalAgents,1)*100).toFixed(0),"%"]})]})]})]})})})}export{B as DashboardControl}; -//# sourceMappingURL=DashboardControl-BkG73T-T.js.map diff --git a/apps/console-proxy/public/assets/DashboardPremium-D1X6YCtJ.js b/apps/console-proxy/public/assets/DashboardPremium-D1X6YCtJ.js deleted file mode 100644 index 850f8c9f..00000000 --- a/apps/console-proxy/public/assets/DashboardPremium-D1X6YCtJ.js +++ /dev/null @@ -1,7 +0,0 @@ -import{c as U,r as u,y as N,u as V,j as e,T as O,w as B,C as _,S as q}from"./index-D_7YXFSJ.js";import{T as Y}from"./trending-up-xPmnKzgu.js";import{C as D}from"./circle-x-DJXSWLrE.js";import{C as X}from"./clock-DwbEOyPD.js";import{A as M}from"./activity-C-iTiNlh.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const K=[["path",{d:"M5 12h14",key:"1ays0h"}]],Q=U("minus",K),P="/api/v1";function Z(){const a=u.useRef(null),s=u.useRef(null),r=u.useRef(0),c=N(d=>d.setSSEConnected),n=N(d=>d.setSystemStatus),o=N(d=>d.addObjective),p=N(d=>d.updateObjective),l=N(d=>d.addDecision),S=N(d=>d.removeDecision),f=()=>{a.current&&a.current.close(),console.log("[SSE] Attempting connection...");const d=localStorage.getItem("vienna_access_token"),T=d?`${P}/stream?token=${encodeURIComponent(d)}`:`${P}/stream`,m=new EventSource(T);a.current=m,m.onopen=()=>{console.log("[SSE] Connected to Vienna event stream"),c(!0),r.current=0},m.addEventListener("system.status",i=>{try{const t=JSON.parse(i.data);n(t)}catch(t){console.error("[SSE] Failed to parse system.status event:",t)}}),m.addEventListener("execution.paused",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Execution paused:",t)}catch(t){console.error("[SSE] Failed to parse execution.paused event:",t)}}),m.addEventListener("execution.resumed",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Execution resumed:",t)}catch(t){console.error("[SSE] Failed to parse execution.resumed event:",t)}}),m.addEventListener("provider.health",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Provider health update:",t)}catch(t){console.error("[SSE] Failed to parse provider.health event:",t)}}),m.addEventListener("service.health",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Service health update:",t)}catch(t){console.error("[SSE] Failed to parse service.health event:",t)}}),m.addEventListener("objective.created",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Objective created:",t),o(t)}catch(t){console.error("[SSE] Failed to parse objective.created event:",t)}}),m.addEventListener("objective.updated",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Objective updated:",t),p(t.objective_id,t)}catch(t){console.error("[SSE] Failed to parse objective.updated event:",t)}}),m.addEventListener("objective.completed",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Objective completed:",t),p(t.objective_id,{...t,status:"completed"})}catch(t){console.error("[SSE] Failed to parse objective.completed event:",t)}}),m.addEventListener("approval.created",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Approval created:",t),l(t)}catch(t){console.error("[SSE] Failed to parse approval.created event:",t)}}),m.addEventListener("approval.approved",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Approval approved:",t),S(t.approval_id||t.decision_id)}catch(t){console.error("[SSE] Failed to parse approval.approved event:",t)}}),m.addEventListener("approval.denied",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Approval denied:",t),S(t.approval_id||t.decision_id)}catch(t){console.error("[SSE] Failed to parse approval.denied event:",t)}}),m.addEventListener("execution.started",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Execution started:",t)}catch(t){console.error("[SSE] Failed to parse execution.started event:",t)}}),m.addEventListener("execution.completed",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Execution completed:",t),t.objective_id&&p(t.objective_id,{status:"completed"})}catch(t){console.error("[SSE] Failed to parse execution.completed event:",t)}}),m.addEventListener("execution.failed",i=>{try{const t=JSON.parse(i.data);console.log("[SSE] Execution failed:",t),t.objective_id&&p(t.objective_id,{status:"failed"})}catch(t){console.error("[SSE] Failed to parse execution.failed event:",t)}}),m.onerror=i=>{if(console.warn("[SSE] Connection error (non-critical):",i),m.close(),!localStorage.getItem("vienna_access_token")){console.warn("[SSE] No auth token — skipping reconnect");return}if(r.current>=5){console.warn("[SSE] Max reconnect attempts reached — stopping");return}const E=Math.min(1e3*Math.pow(2,r.current),3e4);r.current++,console.log(`[SSE] Reconnecting in ${E/1e3}s (attempt ${r.current})`),s.current=setTimeout(()=>{f()},E)}};return u.useEffect(()=>(f(),()=>{console.log("[SSE] Disconnecting from Vienna event stream"),s.current&&clearTimeout(s.current),a.current&&a.current.close(),c(!1)}),[]),{connected:N(d=>d.sseConnected)}}const $=({label:a,value:s,trend:r,trendDirection:c,sparklineData:n,color:o="green",loading:p})=>{const l={green:"bg-emerald-500",amber:"bg-amber-500",blue:"bg-blue-500",red:"bg-red-500"},S={up:"text-emerald-500",down:"text-red-500",stable:"text-zinc-500"};return p?e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-3.5 flex flex-col animate-pulse",children:[e.jsx("div",{className:"h-3 w-20 bg-white/[0.06] rounded mb-3"}),e.jsx("div",{className:"h-7 w-14 bg-white/[0.06] rounded mb-4"}),e.jsx("div",{className:"flex gap-px items-end h-6",children:Array.from({length:10},(f,d)=>e.jsx("div",{className:"flex-1 bg-white/[0.04]",style:{height:`${20+d*7%60}%`}},d))})]}):e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-3.5 flex flex-col hover:border-white/[0.12] transition-colors",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("div",{className:"text-[10px] font-mono text-zinc-500 uppercase tracking-widest",children:a}),r&&e.jsxs("div",{className:`text-[10px] font-bold font-mono ${S[c||"stable"]} flex items-center gap-1`,children:[r," ",c==="up"&&e.jsx(Y,{size:10}),c==="stable"&&e.jsx(Q,{size:10})]})]}),e.jsx("div",{className:`text-[26px] font-bold font-mono mt-1 leading-none ${o==="amber"?"text-amber-500":o==="red"?"text-red-400":"text-white"}`,children:s}),e.jsx("div",{className:"mt-3 flex gap-px items-end h-6",children:n.map((f,d)=>e.jsx("div",{className:`flex-1 ${l[o]}`,style:{height:`${Math.max(f,2)}%`,opacity:d===n.length-1?1:.15+f/100*.7}},d))})]})},I={T0:{label:"T0",color:"text-emerald-400",bg:"bg-emerald-500",desc:"Auto-approved"},T1:{label:"T1",color:"text-blue-400",bg:"bg-blue-500",desc:"Policy-gated"},T2:{label:"T2",color:"text-amber-400",bg:"bg-amber-500",desc:"Human review"},T3:{label:"T3",color:"text-red-400",bg:"bg-red-500",desc:"Multi-party sign-off"},unclassified:{label:"—",color:"text-zinc-500",bg:"bg-zinc-600",desc:"Unclassified"}},ee=({data:a,loading:s})=>{const r=a.reduce((n,o)=>n+Number(o.count),0),c=["T0","T1","T2","T3","unclassified"].map(n=>{const o=a.find(p=>p.risk_tier===n);return{tier:n,count:o?Number(o.count):0}}).filter(n=>n.count>0);return e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[11px] font-mono text-zinc-500 uppercase tracking-widest",children:"Risk Distribution"}),e.jsxs("span",{className:"text-[10px] font-mono text-zinc-600",children:[r," warrants"]})]}),s?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(n=>e.jsx("div",{className:"h-6 bg-white/[0.04] animate-pulse"},n))}):c.length===0?e.jsx("div",{className:"text-center py-6 text-zinc-600 text-xs font-mono",children:"No warrants issued yet"}):e.jsx("div",{className:"space-y-3",children:c.map(({tier:n,count:o})=>{const p=I[n]||I.unclassified,l=r>0?o/r*100:0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[11px] font-mono font-bold ${p.color}`,children:p.label}),e.jsx("span",{className:"text-[10px] text-zinc-600 font-mono",children:p.desc})]}),e.jsxs("span",{className:"text-[11px] font-mono text-zinc-400",children:[o," ",e.jsxs("span",{className:"text-zinc-600",children:["(",l.toFixed(0),"%)"]})]})]}),e.jsx("div",{className:"h-1.5 bg-white/[0.04] overflow-hidden",children:e.jsx("div",{className:`h-full ${p.bg} transition-all duration-500`,style:{width:`${l}%`,opacity:.8}})})]},n)})})]})},te=({data:a,loading:s})=>{if(s||!a)return e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4 animate-pulse",children:[e.jsx("div",{className:"h-3 w-32 bg-white/[0.06] rounded mb-4"}),e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(o=>e.jsx("div",{className:"h-8 bg-white/[0.04]"},o))})]});const r=a.pending+a.approved+a.denied+a.expired,c=a.avg_resolution_seconds?Math.round(a.avg_resolution_seconds/60):null,n=[{label:"Approved",count:a.approved,icon:e.jsx(_,{size:12}),color:"text-emerald-400",bar:"bg-emerald-500"},{label:"Denied",count:a.denied,icon:e.jsx(D,{size:12}),color:"text-red-400",bar:"bg-red-500"},{label:"Pending",count:a.pending,icon:e.jsx(X,{size:12}),color:"text-amber-400",bar:"bg-amber-500"},{label:"Expired",count:a.expired,icon:e.jsx(O,{size:12}),color:"text-zinc-500",bar:"bg-zinc-600"}];return e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[11px] font-mono text-zinc-500 uppercase tracking-widest",children:"Approval Pipeline"}),c!==null&&e.jsxs("span",{className:"text-[10px] font-mono text-zinc-600",children:["avg ",c,"m resolution"]})]}),e.jsx("div",{className:"space-y-2.5",children:n.map(o=>{const p=r>0?o.count/r*100:0;return e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`${o.color} shrink-0`,children:o.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center justify-between mb-0.5",children:[e.jsx("span",{className:"text-[11px] font-mono text-zinc-400",children:o.label}),e.jsx("span",{className:`text-[12px] font-mono font-bold ${o.color}`,children:o.count})]}),e.jsx("div",{className:"h-1 bg-white/[0.04] overflow-hidden",children:e.jsx("div",{className:`h-full ${o.bar} transition-all duration-500`,style:{width:`${p}%`,opacity:.7}})})]})]},o.label)})}),a.new_this_period>0&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/[0.04] text-[10px] font-mono text-zinc-600",children:[a.new_this_period," new requests this period"]})]})},se={warrant_issued:{icon:e.jsx(q,{size:11}),color:"text-emerald-400"},warrant_revoked:{icon:e.jsx(D,{size:11}),color:"text-red-400"},policy_created:{icon:e.jsx(_,{size:11}),color:"text-blue-400"},policy_updated:{icon:e.jsx(_,{size:11}),color:"text-blue-400"},agent_registered:{icon:e.jsx(M,{size:11}),color:"text-amber-400"},approval_granted:{icon:e.jsx(_,{size:11}),color:"text-emerald-400"},approval_denied:{icon:e.jsx(D,{size:11}),color:"text-red-400"},execution_completed:{icon:e.jsx(_,{size:11}),color:"text-emerald-400"},execution_rejected:{icon:e.jsx(O,{size:11}),color:"text-red-400"}},ae=a=>{const s=a.details||{};switch(a.event_type){case"warrant_issued":return`Warrant issued for ${s.agent_id||"agent"} → ${s.action||s.objective||"action"}`;case"warrant_revoked":return`Warrant revoked: ${s.warrant_id||s.reason||"manual revocation"}`;case"policy_created":return`Policy "${s.name||s.policy_id||"policy"}" created`;case"policy_updated":return`Policy "${s.name||s.policy_id||"policy"}" updated`;case"agent_registered":return`Agent "${s.display_name||s.agent_id||"agent"}" registered`;case"approval_granted":return`Approval granted: ${s.action||s.intent_id||"request"} (${s.approver||a.actor})`;case"approval_denied":return`Approval denied: ${s.action||s.intent_id||"request"} (${s.approver||a.actor})`;case"execution_completed":return`Execution complete: ${s.objective||s.execution_id||"task"}`;case"execution_rejected":return`Execution rejected: ${s.reason||s.execution_id||"task"}`;default:return s.event||s.message||a.event_type.replace(/_/g," ")}},ne=({events:a,loading:s})=>e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-[11px] font-mono text-zinc-500 uppercase tracking-widest",children:"Governance Log"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full animate-pulse"}),e.jsx("span",{className:"text-[9px] font-mono text-zinc-600 uppercase",children:"Live"})]})]}),s?e.jsx("div",{className:"space-y-2",children:Array.from({length:6},(r,c)=>e.jsxs("div",{className:"flex gap-3 p-2 bg-white/[0.02] animate-pulse",children:[e.jsx("div",{className:"h-3 w-14 bg-white/[0.06] rounded"}),e.jsx("div",{className:"h-3 flex-1 bg-white/[0.04] rounded"})]},c))}):a.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"text-zinc-600 text-xs font-mono mb-1",children:"No governance events yet"}),e.jsx("div",{className:"text-zinc-700 text-[10px] font-mono",children:"Connect an agent and submit an intent to see the pipeline in action"})]}):e.jsx("div",{className:"space-y-1 max-h-[380px] overflow-y-auto",children:a.map(r=>{const c=se[r.event_type]||{icon:e.jsx(M,{size:11}),color:"text-zinc-500"},n=new Date(r.created_at).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return e.jsxs("div",{className:"flex items-start gap-2.5 py-1.5 px-2 hover:bg-white/[0.02] transition-colors group",children:[e.jsx("div",{className:`mt-0.5 shrink-0 ${c.color}`,children:c.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] text-zinc-300 font-mono truncate",children:ae(r)}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsx("span",{className:"text-[9px] font-mono text-zinc-600",children:n}),r.actor&&e.jsx("span",{className:"text-[9px] font-mono text-zinc-700",children:r.actor})]})]})]},r.id)})})]}),re=({checks:a,loading:s})=>{const r={operational:"bg-emerald-500",degraded:"bg-amber-500",warning:"bg-red-500"},c={operational:"text-emerald-500",degraded:"text-amber-500",warning:"text-red-500"};return e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4",children:[e.jsx("h3",{className:"text-[11px] font-mono text-zinc-500 uppercase tracking-widest mb-3",children:"System Health"}),s?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(n=>e.jsx("div",{className:"h-10 bg-white/[0.04] animate-pulse"},n))}):e.jsx("div",{className:"space-y-2",children:a.map((n,o)=>e.jsxs("div",{className:"flex items-center gap-3 py-2 px-2.5 bg-white/[0.02] border border-white/[0.04]",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${r[n.status]} ${n.status==="operational"?"":"animate-pulse"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[11px] font-mono text-zinc-300",children:n.label}),e.jsx("div",{className:"text-[9px] font-mono text-zinc-600",children:n.detail})]}),e.jsx("span",{className:`text-[9px] font-mono font-bold uppercase tracking-wider ${c[n.status]}`,children:n.status})]},o))})]})},oe=({data:a,loading:s})=>{const r=Math.max(...a.map(c=>Number(c.executions)),1);return e.jsxs("div",{className:"bg-[#0d0e14] border border-white/[0.06] p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-[11px] font-mono text-zinc-500 uppercase tracking-widest",children:"Execution Throughput"}),e.jsx("span",{className:"text-[10px] font-mono text-zinc-600",children:"24h"})]}),s?e.jsx("div",{className:"h-24 bg-white/[0.04] animate-pulse"}):a.length===0?e.jsx("div",{className:"h-24 flex items-center justify-center text-zinc-700 text-[10px] font-mono",children:"No executions in this period"}):e.jsx("div",{className:"flex items-end gap-px h-24",children:a.map((c,n)=>{const o=Number(c.executions)/r*100,p=Number(c.rejected),l=p>0;return e.jsxs("div",{className:"flex-1 flex flex-col items-stretch justify-end gap-0",title:`${c.executions} executions${l?`, ${p} rejected`:""}`,children:[l&&e.jsx("div",{className:"bg-red-500/60",style:{height:`${p/r*100}%`,minHeight:"2px"}}),e.jsx("div",{className:"bg-emerald-500/70 hover:bg-emerald-500 transition-colors",style:{height:`${o-(l?p/r*100:0)}%`,minHeight:"1px"}})]},n)})}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 pt-2 border-t border-white/[0.04]",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-emerald-500/70"}),e.jsx("span",{className:"text-[9px] font-mono text-zinc-600",children:"Completed"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:"w-2 h-2 bg-red-500/60"}),e.jsx("span",{className:"text-[9px] font-mono text-zinc-600",children:"Rejected"})]})]})]})};function xe(){const a=V(),[s,r]=u.useState(!0),[c,n]=u.useState(!1),[o,p]=u.useState(null),[l,S]=u.useState({activeAgents:0,totalAgents:0,warrantsToday:0,pendingApprovals:0,policyEvals:0,avgTrust:0,avgLatencyMs:0,totalWarrants:0,activeWarrants:0,activePolicies:0,executionsPeriod:0,auditEventsPeriod:0,openIncidents:0}),[f,d]=u.useState([]),[T,m]=u.useState(null),[i,t]=u.useState([]),[L,R]=u.useState([]),[E,J]=u.useState([]),[k,W]=u.useState({});Z();const z=u.useCallback(()=>{const b=localStorage.getItem("vienna_access_token"),h={"Content-Type":"application/json"};return b&&(h.Authorization=`Bearer ${b}`),h},[]),y=u.useCallback(async(b=!1)=>{b&&n(!0);const h=z();try{const j=await(await fetch("/api/v1/dashboard",{credentials:"include",headers:h})).json();if(j.success&&j.data){const x=j.data,g=x.overview||{},F=x.agents||[],H=F.filter(v=>(v==null?void 0:v.status)==="active").reduce((v,C)=>v+Number(C.count||0),0),G=F.reduce((v,C)=>v+Number(C.count||0),0);if(S({activeAgents:H,totalAgents:Number(g.total_agents)||G,warrantsToday:Number(g.active_warrants)||0,pendingApprovals:Number(g.pending_approvals)||0,policyEvals:Number(g.evaluations_period)||0,avgTrust:0,avgLatencyMs:0,totalWarrants:Number(g.total_warrants)||0,activeWarrants:Number(g.active_warrants)||0,activePolicies:Number(g.active_policies)||0,executionsPeriod:Number(g.executions_period)||0,auditEventsPeriod:Number(g.audit_events_period)||0,openIncidents:Number(g.open_incidents)||0}),x.riskDistribution&&d(x.riskDistribution),x.approvals&&m({pending:Number(x.approvals.pending)||0,approved:Number(x.approvals.approved)||0,denied:Number(x.approvals.denied)||0,expired:Number(x.approvals.expired)||0,avg_resolution_seconds:x.approvals.avg_resolution_seconds?Number(x.approvals.avg_resolution_seconds):null,new_this_period:Number(x.approvals.new_this_period)||0}),x.executionTrend&&R(x.executionTrend),x.recentActivity&&t(x.recentActivity),x.systemHealth){const v=x.systemHealth;J([{label:"Database",status:"operational",detail:`${Number(v.active_api_keys)||0} active API keys`},{label:"Webhook Delivery",status:Number(v.failed_webhooks_1h)>0?"degraded":"operational",detail:Number(v.failed_webhooks_1h)>0?`${v.failed_webhooks_1h} failed in last hour`:`${Number(v.active_webhooks)||0} active webhooks`},{label:"Integrations",status:"operational",detail:`${Number(v.active_integrations)||0} connected`}])}p(null)}}catch(w){console.error("[Dashboard] Load failed:",w),p("Failed to load dashboard data")}finally{r(!1),n(!1)}},[z]);u.useEffect(()=>{y()},[y]),u.useEffect(()=>{const b=setInterval(()=>y(),3e4);return()=>clearInterval(b)},[y]),u.useEffect(()=>{const b=z();Promise.all([fetch("/api/v1/dashboard/sparklines?metric=executions&range=24h&points=10",{credentials:"include",headers:b}).then(h=>h.json()).catch(()=>null),fetch("/api/v1/dashboard/sparklines?metric=evaluations&range=24h&points=10",{credentials:"include",headers:b}).then(h=>h.json()).catch(()=>null),fetch("/api/v1/dashboard/sparklines?metric=approvals&range=24h&points=10",{credentials:"include",headers:b}).then(h=>h.json()).catch(()=>null),fetch("/api/v1/dashboard/sparklines?metric=audit&range=24h&points=10",{credentials:"include",headers:b}).then(h=>h.json()).catch(()=>null)]).then(([h,w,j,x])=>{W({executions:(h==null?void 0:h.points)||new Array(10).fill(0),evaluations:(w==null?void 0:w.points)||new Array(10).fill(0),approvals:(j==null?void 0:j.points)||new Array(10).fill(0),audit:(x==null?void 0:x.points)||new Array(10).fill(0)})})},[z]);const A=new Array(10).fill(0);return e.jsxs("div",{className:"space-y-4",children:[o&&e.jsxs("div",{className:"bg-red-500/[0.08] border border-red-500/20 py-2.5 px-4 flex items-center gap-3",children:[e.jsx(O,{className:"text-red-400 shrink-0",size:14}),e.jsx("span",{className:"text-[11px] text-red-300/80 font-mono flex-1",children:o}),e.jsx("button",{onClick:()=>y(!0),className:"text-red-400 hover:text-white transition-colors text-[10px] font-mono font-bold",children:"RETRY"})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("h1",{className:"text-[13px] font-mono font-bold text-white uppercase tracking-wider",children:"Mission Control"}),!s&&e.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-0.5 bg-emerald-500/[0.08] border border-emerald-500/20",children:[e.jsx("div",{className:"w-1.5 h-1.5 bg-emerald-500 rounded-full animate-pulse"}),e.jsxs("span",{className:"text-[9px] font-mono text-emerald-500 uppercase",children:[l.totalAgents," agent",l.totalAgents!==1?"s":""," · ",l.activePolicies," polic",l.activePolicies!==1?"ies":"y"]})]})]}),e.jsxs("button",{onClick:()=>y(!0),disabled:c,className:"flex items-center gap-1.5 px-2 py-1 text-[10px] font-mono text-zinc-500 hover:text-white border border-white/[0.06] hover:border-white/[0.12] transition-colors",children:[e.jsx(B,{size:10,className:c?"animate-spin":""}),c?"REFRESHING":"REFRESH"]})]}),!s&&l.totalAgents===0&&l.totalWarrants===0&&e.jsxs("div",{className:"border-2 border-dashed border-amber-500/20 p-8 text-center",children:[e.jsx("div",{className:"text-[11px] font-mono text-amber-500 uppercase tracking-widest mb-2",children:"Getting Started"}),e.jsx("p",{className:"text-sm text-zinc-400 font-mono mb-6 max-w-lg mx-auto",children:"Connect your first agent, define a governance policy, and submit a test intent to see the full warrant pipeline."}),e.jsxs("div",{className:"flex items-center justify-center gap-4",children:[e.jsx("button",{onClick:()=>a("/connect"),className:"px-4 py-2 bg-amber-500 text-black text-[11px] font-mono font-bold hover:bg-amber-400 transition-colors cursor-pointer",style:{border:"none"},children:"CONNECT AGENT →"}),e.jsx("button",{onClick:()=>a("/demo"),className:"px-4 py-2 border border-amber-500/30 text-amber-500 text-[11px] font-mono font-bold hover:border-amber-500 transition-colors cursor-pointer",style:{background:"transparent"},children:"TRY DEMO"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsx($,{label:"Executions (24h)",value:s?"—":l.executionsPeriod.toLocaleString(),sparklineData:k.executions||A,color:"green",loading:s}),e.jsx($,{label:"Policy Evaluations",value:s?"—":l.policyEvals.toLocaleString(),sparklineData:k.evaluations||A,color:"blue",loading:s}),e.jsx($,{label:"Active Warrants",value:s?"—":l.activeWarrants,trend:l.totalWarrants>0?`${l.totalWarrants} total`:void 0,trendDirection:"stable",sparklineData:k.approvals||A,color:"amber",loading:s}),e.jsx($,{label:"Pending Approvals",value:s?"—":l.pendingApprovals,trend:l.openIncidents>0?`${l.openIncidents} incident${l.openIncidents>1?"s":""}`:void 0,trendDirection:l.openIncidents>0?"up":"stable",sparklineData:k.audit||A,color:l.pendingApprovals>20?"red":"amber",loading:s})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-3",children:[e.jsx(ne,{events:i,loading:s}),e.jsx(oe,{data:L,loading:s})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(ee,{data:f,loading:s}),e.jsx(te,{data:T,loading:s}),e.jsx(re,{checks:E,loading:s})]})]})]})}export{xe as default}; -//# sourceMappingURL=DashboardPremium-D1X6YCtJ.js.map diff --git a/apps/console-proxy/public/assets/DemoModePage-C4H2jnTf.js b/apps/console-proxy/public/assets/DemoModePage-C4H2jnTf.js deleted file mode 100644 index b5808aa7..00000000 --- a/apps/console-proxy/public/assets/DemoModePage-C4H2jnTf.js +++ /dev/null @@ -1,12 +0,0 @@ -import{c as j,r as d,j as e,T as E,C as M}from"./index-D_7YXFSJ.js";import{T as A}from"./terminal-ybst6913.js";import{C as v}from"./clock-DwbEOyPD.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const I=[["path",{d:"M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z",key:"kmsa83"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],O=j("circle-play",I);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const q=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],L=j("rotate-ccw",q);function F(){var g,f;const[o,u]=d.useState(null),[N,c]=d.useState(!1),[m,x]=d.useState(0),[a,p]=d.useState([]),i=[{id:"quick-tour",name:"Quick Tour (2 min)",description:"Basic governance flow: 3 agents, 5 intents, 1 denial",duration:"2 minutes",events:12},{id:"compliance-demo",name:"Compliance Audit (5 min)",description:"SOC 2 scenario: 5 agents, 15 intents, policy violations, audit trail",duration:"5 minutes",events:35},{id:"risk-escalation",name:"Risk Escalation (3 min)",description:"T2/T3 actions, human approval flow, execution monitoring",duration:"3 minutes",events:18},{id:"multi-agent",name:"Multi-Agent Fleet (10 min)",description:"20 agents, parallel workflows, fleet coordination",duration:"10 minutes",events:80}],y=async t=>{u(t),c(!0),x(0),p([]);try{await fetch("/api/v1/demo/seed",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({scenario:t})})}catch{}const h=i.find(s=>s.id===t);if(!h)return;const b=parseInt(h.duration)*60*1e3,S=b/100,C=setInterval(()=>{x(s=>s>=100?(clearInterval(C),c(!1),100):s+1)},S),l=[],_=["agent-alpha","agent-beta","agent-gamma","agent-delta","agent-epsilon"],R=["deploy_infrastructure","query_database","send_email","update_config","delete_resource","create_user","modify_permissions"],D=["T0","T1","T2","T3"],P=["approved","approved","approved","denied","complete"],r=(s,n)=>s[n%s.length];for(let s=0;s{p(n=>[...n,l[s]])},s/l.length*b)},w=()=>{u(null),c(!1),x(0),p([])},k=t=>{switch(t){case"approved":case"complete":return e.jsx(M,{className:"w-4 h-4 text-green-400"});case"denied":case"failed":return e.jsx(E,{className:"w-4 h-4 text-red-400"});case"pending":return e.jsx(v,{className:"w-4 h-4 text-amber-400"})}},T=t=>{switch(t){case"T0":return"text-green-400";case"T1":return"text-amber-400";case"T2":return"text-red-400";case"T3":return"text-red-600";default:return"text-gray-400"}};return e.jsx("div",{className:"relative min-h-screen bg-[#0a0a0a] text-[#e4e4e4] overflow-hidden",children:e.jsxs("div",{className:"relative z-10 max-w-7xl mx-auto px-6 py-12",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx(A,{className:"w-8 h-8 text-[#d4af37]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-[#d4af37] font-mono",children:"Demo Mode"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"One-click governance scenarios for sales and demos"})]})]}),!o&&e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6 mb-12",children:i.map(t=>e.jsxs("button",{onClick:()=>y(t.id),className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6 text-left hover:border-[#d4af37]/60 hover:shadow-[0_0_20px_rgba(212,175,55,0.15)] transition-all duration-300 group",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsx("h3",{className:"text-lg font-bold text-[#d4af37] font-mono group-hover:text-[#d4af37]/90",children:t.name}),e.jsx(O,{className:"w-6 h-6 text-[#d4af37]/60 group-hover:text-[#d4af37]"})]}),e.jsx("p",{className:"text-sm text-gray-400 mb-4",children:t.description}),e.jsxs("div",{className:"flex items-center gap-4 text-xs font-mono",children:[e.jsxs("span",{className:"text-gray-500",children:[e.jsx(v,{className:"w-3 h-3 inline mr-1"}),t.duration]}),e.jsxs("span",{className:"text-gray-500",children:[t.events," events"]})]})]},t.id))}),o&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-[#d4af37] font-mono",children:(g=i.find(t=>t.id===o))==null?void 0:g.name}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:(f=i.find(t=>t.id===o))==null?void 0:f.description})]}),e.jsxs("button",{onClick:w,className:"px-4 py-2 bg-red-500/20 text-red-400 rounded border border-red-500/40 hover:bg-red-500/30 transition-colors flex items-center gap-2 font-mono text-sm",children:[e.jsx(L,{className:"w-4 h-4"}),"Reset"]})]}),e.jsx("div",{className:"relative w-full h-3 bg-[#2a2a2a] rounded-full overflow-hidden",children:e.jsx("div",{className:"absolute top-0 left-0 h-full bg-gradient-to-r from-[#d4af37] to-amber-500 transition-all duration-300",style:{width:`${m}%`}})}),e.jsxs("div",{className:"flex justify-between mt-2 text-xs font-mono text-gray-500",children:[e.jsxs("span",{children:[m,"%"]}),e.jsx("span",{children:N?"Running...":m===100?"Complete":"Ready"})]})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsx("h4",{className:"text-sm font-bold text-[#d4af37] font-mono mb-4 uppercase tracking-wider",children:"Governance Timeline"}),e.jsxs("div",{className:"space-y-2 max-h-[500px] overflow-y-auto scrollbar-thin scrollbar-thumb-[#d4af37]/20 scrollbar-track-transparent",children:[a.length===0&&e.jsx("div",{className:"text-center py-12 text-gray-500 text-sm font-mono",children:"No events yet. Demo will start shortly..."}),a.map(t=>e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-[#0a0a0a]/60 rounded border border-gray-800 hover:border-[#d4af37]/40 transition-colors",children:[e.jsx("div",{className:"flex-shrink-0",children:k(t.status)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono",children:[e.jsx("span",{className:"text-gray-400",children:t.type.toUpperCase()}),e.jsx("span",{className:"text-gray-600",children:"•"}),e.jsx("span",{className:"text-gray-400",children:t.agent}),e.jsx("span",{className:"text-gray-600",children:"•"}),e.jsx("span",{className:T(t.tier),children:t.tier})]}),e.jsx("div",{className:"text-sm text-[#e4e4e4] mt-1 truncate",children:t.action})]}),e.jsx("div",{className:"flex-shrink-0 text-xs font-mono text-gray-500",children:new Date(t.timestamp).toLocaleTimeString()})]},t.id))]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-4",children:[e.jsx("div",{className:"text-xs font-mono text-gray-500 uppercase mb-1",children:"Total Events"}),e.jsx("div",{className:"text-2xl font-bold text-[#d4af37] font-mono",children:a.length})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-4",children:[e.jsx("div",{className:"text-xs font-mono text-gray-500 uppercase mb-1",children:"Approved"}),e.jsx("div",{className:"text-2xl font-bold text-green-400 font-mono",children:a.filter(t=>t.status==="approved"||t.status==="complete").length})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-4",children:[e.jsx("div",{className:"text-xs font-mono text-gray-500 uppercase mb-1",children:"Denied"}),e.jsx("div",{className:"text-2xl font-bold text-red-400 font-mono",children:a.filter(t=>t.status==="denied"||t.status==="failed").length})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-4",children:[e.jsx("div",{className:"text-xs font-mono text-gray-500 uppercase mb-1",children:"High Risk"}),e.jsx("div",{className:"text-2xl font-bold text-amber-400 font-mono",children:a.filter(t=>t.tier==="T2"||t.tier==="T3").length})]})]})]})]})})}export{F as default}; -//# sourceMappingURL=DemoModePage-C4H2jnTf.js.map diff --git a/apps/console-proxy/public/assets/EmbedWidgetPage-BDFnGg9J.js b/apps/console-proxy/public/assets/EmbedWidgetPage-BDFnGg9J.js deleted file mode 100644 index 1008eea7..00000000 --- a/apps/console-proxy/public/assets/EmbedWidgetPage-BDFnGg9J.js +++ /dev/null @@ -1,13 +0,0 @@ -import{c,r as n,j as e,D as x}from"./index-D_7YXFSJ.js";import{a as m,C as h}from"./copy-DPJWkP7J.js";import{E as p}from"./eye-46CiQ26c.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const b=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],f=c("external-link",b);function y(){const[s,t]=n.useState({theme:"terminal",showAgents:!0,showWarrants:!0,showApprovals:!0,showPolicies:!0,refreshInterval:60,size:"medium"}),[d,r]=n.useState(!1),l=()=>``,o=async()=>{await navigator.clipboard.writeText(l()),r(!0),setTimeout(()=>r(!1),2e3)};return e.jsx("div",{className:"relative min-h-screen bg-[#0a0a0a] text-[#e4e4e4] overflow-hidden",children:e.jsxs("div",{className:"relative z-10 max-w-6xl mx-auto px-6 py-12",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8",children:[e.jsx(m,{className:"w-8 h-8 text-[#d4af37]"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-[#d4af37] font-mono",children:"Embeddable Widget Generator"}),e.jsx("p",{className:"text-sm text-gray-400 mt-1",children:"Generate embeddable governance stats for your website, docs, or blog"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsx("h2",{className:"text-lg font-bold text-[#d4af37] font-mono mb-6 uppercase tracking-wider",children:"Widget Configuration"}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-xs font-mono text-gray-400 uppercase mb-2",children:"Theme"}),e.jsx("div",{className:"flex gap-3",children:["light","dark","terminal"].map(a=>e.jsx("button",{onClick:()=>t({...s,theme:a}),className:`flex-1 py-2 px-4 rounded border font-mono text-xs uppercase transition-all ${s.theme===a?"bg-[#d4af37] text-black border-[#d4af37]":"bg-[#0a0a0a]/60 text-gray-400 border-gray-800 hover:border-[#d4af37]/40"}`,children:a},a))})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-xs font-mono text-gray-400 uppercase mb-2",children:"Size"}),e.jsx("div",{className:"flex gap-3",children:["small","medium","large"].map(a=>e.jsx("button",{onClick:()=>t({...s,size:a}),className:`flex-1 py-2 px-4 rounded border font-mono text-xs uppercase transition-all ${s.size===a?"bg-[#d4af37] text-black border-[#d4af37]":"bg-[#0a0a0a]/60 text-gray-400 border-gray-800 hover:border-[#d4af37]/40"}`,children:a},a))}),e.jsxs("div",{className:"mt-2 text-xs font-mono text-gray-500",children:[s.size==="small"&&"300×200px",s.size==="medium"&&"400×300px",s.size==="large"&&"600×400px"]})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("label",{className:"block text-xs font-mono text-gray-400 uppercase mb-2",children:"Visible Metrics"}),e.jsx("div",{className:"space-y-2",children:[{key:"showAgents",label:"Active Agents"},{key:"showWarrants",label:"Warrants Issued"},{key:"showApprovals",label:"Pending Approvals"},{key:"showPolicies",label:"Active Policies"}].map(a=>e.jsxs("label",{className:"flex items-center gap-3 cursor-pointer group",children:[e.jsx("input",{type:"checkbox",checked:s[a.key],onChange:i=>t({...s,[a.key]:i.target.checked}),className:"w-4 h-4 accent-[#d4af37]"}),e.jsx("span",{className:"text-sm text-gray-300 group-hover:text-[#d4af37] transition-colors",children:a.label})]},a.key))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-mono text-gray-400 uppercase mb-2",children:"Refresh Interval (seconds)"}),e.jsx("input",{type:"number",min:"10",max:"300",value:s.refreshInterval,onChange:a=>t({...s,refreshInterval:parseInt(a.target.value)||60}),className:"w-full px-4 py-2 bg-[#0a0a0a]/60 border border-gray-800 rounded text-gray-300 font-mono text-sm focus:outline-none focus:border-[#d4af37]/60"})]})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-[#d4af37] font-mono uppercase tracking-wider",children:"Live Preview"}),e.jsx(p,{className:"w-5 h-5 text-[#d4af37]/60"})]}),e.jsx("div",{className:`rounded border overflow-hidden ${s.theme==="terminal"?"bg-[#0a0a0a] border-[#d4af37]/20":s.theme==="dark"?"bg-gray-900 border-gray-700":"bg-white border-gray-300"}`,style:{width:s.size==="small"?"300px":s.size==="medium"?"400px":"100%",height:s.size==="small"?"200px":s.size==="medium"?"300px":"400px"},children:e.jsx(g,{config:s})})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-lg font-bold text-[#d4af37] font-mono uppercase tracking-wider",children:"Embed Code"}),e.jsx("button",{onClick:o,className:"flex items-center gap-2 px-3 py-1.5 bg-[#d4af37]/20 text-[#d4af37] rounded border border-[#d4af37]/40 hover:bg-[#d4af37]/30 transition-colors text-xs font-mono",children:d?e.jsxs(e.Fragment,{children:[e.jsx(x,{className:"w-4 h-4"}),"Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{className:"w-4 h-4"}),"Copy"]})})]}),e.jsx("pre",{className:"bg-[#0a0a0a]/80 border border-gray-800 rounded p-4 overflow-x-auto text-xs text-gray-300 font-mono",children:l()})]}),e.jsxs("div",{className:"bg-[#1a1a1a]/80 backdrop-blur-sm border border-[#d4af37]/20 rounded-lg p-6",children:[e.jsx("h2",{className:"text-lg font-bold text-[#d4af37] font-mono mb-4 uppercase tracking-wider",children:"Usage Instructions"}),e.jsxs("div",{className:"space-y-4 text-sm text-gray-300",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-[#d4af37] mb-2 font-mono text-xs uppercase",children:"1. Copy the code"}),e.jsx("p",{className:"text-gray-400 leading-relaxed",children:'Click the "Copy" button above to copy the embed code to your clipboard.'})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-[#d4af37] mb-2 font-mono text-xs uppercase",children:"2. Paste into HTML"}),e.jsx("p",{className:"text-gray-400 leading-relaxed",children:"Add the iframe code to your website, documentation, or blog post where you want the stats widget to appear."})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-bold text-[#d4af37] mb-2 font-mono text-xs uppercase",children:"3. Customize"}),e.jsx("p",{className:"text-gray-400 leading-relaxed",children:"Adjust the configuration options on the left to match your site's design and data requirements."})]}),e.jsxs("div",{className:"pt-4 border-t border-gray-800",children:[e.jsx("h3",{className:"font-bold text-[#d4af37] mb-2 font-mono text-xs uppercase",children:"Example Use Cases"}),e.jsxs("ul",{className:"space-y-2 text-gray-400",children:[e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#d4af37] mt-1",children:"•"}),e.jsx("span",{children:"Add to your homepage to showcase live governance metrics"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#d4af37] mt-1",children:"•"}),e.jsx("span",{children:"Embed in documentation for transparency"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#d4af37] mt-1",children:"•"}),e.jsx("span",{children:"Include in blog posts about your AI governance practices"})]}),e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"text-[#d4af37] mt-1",children:"•"}),e.jsx("span",{children:"Share with stakeholders in compliance reports"})]})]})]}),e.jsx("div",{className:"pt-4 border-t border-gray-800",children:e.jsxs("a",{href:"https://docs.regulator.ai/embed-widget",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-[#d4af37] hover:text-[#d4af37]/80 transition-colors font-mono text-xs",children:[e.jsx(f,{className:"w-4 h-4"}),"View full documentation"]})})]})]})]})]})]})})}function g({config:s}){const[t,d]=n.useState({agents:24,warrants:1847,approvals:3,policies:15});n.useEffect(()=>{const a=setInterval(()=>{d({agents:24,warrants:t.warrants+1,approvals:t.approvals>0?t.approvals-1:3,policies:15})},s.refreshInterval*1e3);return()=>clearInterval(a)},[s.refreshInterval]);const r=s.theme==="terminal"?"#d4af37":s.theme==="dark"?"#10b981":"#059669",l=s.theme==="terminal"?"#0a0a0a":s.theme==="dark"?"#111827":"#ffffff",o=s.theme==="light"?"#6b7280":"#9ca3af";return e.jsxs("div",{className:"p-6 h-full flex flex-col",style:{background:l},children:[e.jsx("h3",{className:"text-lg font-bold font-mono mb-4",style:{color:r},children:"Vienna OS Stats"}),e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-4",children:[s.showAgents&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-mono uppercase mb-1",style:{color:o},children:"Active Agents"}),e.jsx("div",{className:"text-3xl font-bold font-mono",style:{color:r},children:t.agents})]}),s.showWarrants&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-mono uppercase mb-1",style:{color:o},children:"Warrants"}),e.jsx("div",{className:"text-3xl font-bold font-mono",style:{color:r},children:t.warrants})]}),s.showApprovals&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-mono uppercase mb-1",style:{color:o},children:"Pending"}),e.jsx("div",{className:"text-3xl font-bold font-mono",style:{color:r},children:t.approvals})]}),s.showPolicies&&e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-mono uppercase mb-1",style:{color:o},children:"Policies"}),e.jsx("div",{className:"text-3xl font-bold font-mono",style:{color:r},children:t.policies})]})]}),e.jsx("div",{className:"text-xs font-mono mt-4 pt-4 border-t",style:{color:o,borderColor:o+"40"},children:"Powered by Vienna OS"})]})}export{y as default}; -//# sourceMappingURL=EmbedWidgetPage-BDFnGg9J.js.map diff --git a/apps/console-proxy/public/assets/ExecutionPage-CdXjf9HJ.js b/apps/console-proxy/public/assets/ExecutionPage-CzELhGv6.js similarity index 99% rename from apps/console-proxy/public/assets/ExecutionPage-CdXjf9HJ.js rename to apps/console-proxy/public/assets/ExecutionPage-CzELhGv6.js index f4eb06e8..8c1f078f 100644 --- a/apps/console-proxy/public/assets/ExecutionPage-CdXjf9HJ.js +++ b/apps/console-proxy/public/assets/ExecutionPage-CzELhGv6.js @@ -1,7 +1,7 @@ -import{a as x,r as a,j as e,R as C,e as M}from"./index-D_7YXFSJ.js";const A={async getStatus(){return await x.get("/system/status")}};function N(){const[r,o]=a.useState([{name:"Intent",count:null,status:"unknown"},{name:"Plan",count:null,status:"unknown"},{name:"Policy",count:null,status:"unknown"},{name:"Warrant",count:null,status:"unknown"},{name:"Execution",count:null,status:"unknown"},{name:"Verification",count:null,status:"unknown"}]),[c,l]=a.useState(null);a.useEffect(()=>{n();const s=setInterval(n,1e4);return()=>clearInterval(s)},[]);const n=async()=>{try{const s=await A.getStatus(),i=[{name:"Intent",count:null,status:"unknown"},{name:"Plan",count:null,status:"unknown"},{name:"Policy",count:null,status:"unknown"},{name:"Warrant",count:null,status:"unknown"},{name:"Execution",count:s.active_envelopes||0,status:s.active_envelopes>0?"active":"idle"},{name:"Verification",count:null,status:"unknown"}];o(i),l(null)}catch(s){console.error("[ExecutionPipeline] Error fetching status:",s),l(s instanceof Error?s.message:"Unknown error")}},p=s=>{switch(s){case"active":return"active";case"idle":return"idle";default:return"unknown"}};return c?e.jsxs("div",{className:"execution-pipeline-status",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h3",{children:"Execution Pipeline"})}),e.jsx("div",{className:"panel-body",children:e.jsxs("div",{className:"error-state",children:["Error: ",c]})})]}):e.jsxs("div",{className:"execution-pipeline-status",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h3",{children:"Execution Pipeline"})}),e.jsx("div",{className:"panel-body",children:e.jsx("div",{className:"pipeline-container",children:r.map((s,i)=>e.jsxs(C.Fragment,{children:[e.jsxs("div",{className:`pipeline-stage ${p(s.status)}`,children:[e.jsx("div",{className:"stage-name",children:s.name}),e.jsx("div",{className:"stage-value",children:s.count!==null?s.count:"—"})]}),i{const l=a.useMemo(()=>{const n=[],p=r.find(d=>d.stage==="requested"),s=r.find(d=>d.stage==="evaluated"),i=r.find(d=>d.stage==="approved"),g=r.find(d=>d.stage==="denied"),h=r.find(d=>d.stage==="executed"),b=r.find(d=>d.stage==="blocked");return p&&n.push(p),s&&n.push(s),(i||g)&&n.push(i||g),(h||b)&&n.push(h||b),n},[r]);return l.length===0?e.jsx("div",{style:{padding:"16px",backgroundColor:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-tertiary)",fontSize:"12px",textAlign:"center"},children:"No warrant timeline available"}):e.jsxs("div",{style:{backgroundColor:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 4px"},children:"📜 Warrant Lifecycle"}),o&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["ID: ",o]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0",overflowX:"auto"},children:l.map((n,p)=>{const s=P[n.stage],i=D(n.status),g=p===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",flex:"0 0 auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"50%",backgroundColor:`${i}15`,border:`2px solid ${i}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",flexShrink:0,animation:n.status==="pending"?"pulse 2s infinite":void 0},title:`${s.label} - ${n.status}`,children:s.icon}),e.jsxs("div",{style:{textAlign:"center",minWidth:"80px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:s.label}),n.timestamp&&e.jsx("div",{style:{fontSize:"9px",color:"var(--text-tertiary)",marginTop:"2px"},title:new Date(n.timestamp).toLocaleString(),children:$(n.timestamp)}),n.actor&&e.jsx("div",{style:{fontSize:"8px",color:"var(--text-muted)",marginTop:"1px"},children:n.actor})]})]}),!g&&e.jsx("div",{style:{width:"40px",height:"2px",backgroundColor:i,margin:"0 16px",opacity:.6,flexShrink:0,position:"relative"},children:e.jsx("div",{style:{position:"absolute",right:"-6px",top:"-3px",width:"0",height:"0",borderLeft:`6px solid ${i}`,borderTop:"3px solid transparent",borderBottom:"3px solid transparent",opacity:.6}})})]},`${n.stage}-${p}`)})}),e.jsx("style",{children:` +import{e as x,r as a,j as e,R as C,h as M}from"./index-C0nK3ekl.js";const A={async getStatus(){return await x.get("/system/status")}};function N(){const[r,o]=a.useState([{name:"Intent",count:null,status:"unknown"},{name:"Plan",count:null,status:"unknown"},{name:"Policy",count:null,status:"unknown"},{name:"Warrant",count:null,status:"unknown"},{name:"Execution",count:null,status:"unknown"},{name:"Verification",count:null,status:"unknown"}]),[c,l]=a.useState(null);a.useEffect(()=>{n();const s=setInterval(n,1e4);return()=>clearInterval(s)},[]);const n=async()=>{try{const s=await A.getStatus(),i=[{name:"Intent",count:null,status:"unknown"},{name:"Plan",count:null,status:"unknown"},{name:"Policy",count:null,status:"unknown"},{name:"Warrant",count:null,status:"unknown"},{name:"Execution",count:s.active_envelopes||0,status:s.active_envelopes>0?"active":"idle"},{name:"Verification",count:null,status:"unknown"}];o(i),l(null)}catch(s){console.error("[ExecutionPipeline] Error fetching status:",s),l(s instanceof Error?s.message:"Unknown error")}},p=s=>{switch(s){case"active":return"active";case"idle":return"idle";default:return"unknown"}};return c?e.jsxs("div",{className:"execution-pipeline-status",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h3",{children:"Execution Pipeline"})}),e.jsx("div",{className:"panel-body",children:e.jsxs("div",{className:"error-state",children:["Error: ",c]})})]}):e.jsxs("div",{className:"execution-pipeline-status",children:[e.jsx("div",{className:"panel-header",children:e.jsx("h3",{children:"Execution Pipeline"})}),e.jsx("div",{className:"panel-body",children:e.jsx("div",{className:"pipeline-container",children:r.map((s,i)=>e.jsxs(C.Fragment,{children:[e.jsxs("div",{className:`pipeline-stage ${p(s.status)}`,children:[e.jsx("div",{className:"stage-name",children:s.name}),e.jsx("div",{className:"stage-value",children:s.count!==null?s.count:"—"})]}),i{const l=a.useMemo(()=>{const n=[],p=r.find(d=>d.stage==="requested"),s=r.find(d=>d.stage==="evaluated"),i=r.find(d=>d.stage==="approved"),g=r.find(d=>d.stage==="denied"),h=r.find(d=>d.stage==="executed"),b=r.find(d=>d.stage==="blocked");return p&&n.push(p),s&&n.push(s),(i||g)&&n.push(i||g),(h||b)&&n.push(h||b),n},[r]);return l.length===0?e.jsx("div",{style:{padding:"16px",backgroundColor:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-tertiary)",fontSize:"12px",textAlign:"center"},children:"No warrant timeline available"}):e.jsxs("div",{style:{backgroundColor:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 4px"},children:"📜 Warrant Lifecycle"}),o&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:["ID: ",o]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"0",overflowX:"auto"},children:l.map((n,p)=>{const s=P[n.stage],i=D(n.status),g=p===l.length-1;return e.jsxs("div",{style:{display:"flex",alignItems:"center",flex:"0 0 auto"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"32px",height:"32px",borderRadius:"50%",backgroundColor:`${i}15`,border:`2px solid ${i}`,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",flexShrink:0,animation:n.status==="pending"?"pulse 2s infinite":void 0},title:`${s.label} - ${n.status}`,children:s.icon}),e.jsxs("div",{style:{textAlign:"center",minWidth:"80px"},children:[e.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",textTransform:"uppercase",letterSpacing:"0.04em"},children:s.label}),n.timestamp&&e.jsx("div",{style:{fontSize:"9px",color:"var(--text-tertiary)",marginTop:"2px"},title:new Date(n.timestamp).toLocaleString(),children:$(n.timestamp)}),n.actor&&e.jsx("div",{style:{fontSize:"8px",color:"var(--text-muted)",marginTop:"1px"},children:n.actor})]})]}),!g&&e.jsx("div",{style:{width:"40px",height:"2px",backgroundColor:i,margin:"0 16px",opacity:.6,flexShrink:0,position:"relative"},children:e.jsx("div",{style:{position:"absolute",right:"-6px",top:"-3px",width:"0",height:"0",borderLeft:`6px solid ${i}`,borderTop:"3px solid transparent",borderBottom:"3px solid transparent",opacity:.6}})})]},`${n.stage}-${p}`)})}),e.jsx("style",{children:` @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } } `})]})},f={getActive:()=>x.get("/execution/active"),getQueue:()=>x.get("/execution/queue"),getBlocked:()=>x.get("/execution/blocked"),getMetrics:()=>x.get("/execution/metrics"),getHealth:()=>x.get("/execution/health"),getIntegrity:()=>x.get("/execution/integrity"),pause:(r,o)=>x.post("/execution/pause",{operator:r,reason:o}),resume:r=>x.post("/execution/resume",{operator:r}),checkIntegrity:r=>x.post("/execution/integrity-check",{operator:r}),emergencyOverride:(r,o,c,l)=>x.post("/execution/emergency-override",{operator:r,reason:o,duration_minutes:c,metternich_approval_id:l})};function L(){const[r,o]=a.useState(null),[c,l]=a.useState(!0);a.useEffect(()=>{n()},[]);const n=async()=>{try{const i=await fetch("/api/v1/settings/execution-modes",{credentials:"include",headers:{Authorization:`Bearer ${localStorage.getItem("vienna_access_token")}`}});if(i.ok){const g=await i.json();o(g.data)}}catch{}finally{l(!1)}},p=i=>i==="direct"?"⚡":"🔄",s=i=>i==="direct"?"#f59e0b":"#3b82f6";return c||!r?null:e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"16px 20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Current Execution Mode Configuration"}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:["T0","T1","T2","T3"].map(i=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"4px 8px",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"11px"},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:i}),e.jsxs("span",{style:{color:s(r[i]),display:"flex",alignItems:"center",gap:"2px"},children:[p(r[i]),e.jsx("span",{style:{fontSize:"10px",fontWeight:500},children:r[i]==="direct"?"Direct":"Passback"})]})]},i))})]}),e.jsx("a",{href:"/settings",style:{padding:"6px 12px",borderRadius:"6px",border:"1px solid rgba(124, 58, 237, 0.3)",background:"rgba(124, 58, 237, 0.08)",color:"#f59e0b",fontSize:"11px",fontWeight:600,textDecoration:"none",display:"flex",alignItems:"center",gap:"4px",transition:"all 150ms"},onMouseEnter:i=>{i.currentTarget.style.background="rgba(124, 58, 237, 0.12)"},onMouseLeave:i=>{i.currentTarget.style.background="rgba(124, 58, 237, 0.08)"},children:"⚙️ Configure"})]})}function O(){const[r,o]=a.useState([]),[c,l]=a.useState(null),[n,p]=a.useState(null),[s,i]=a.useState([]),[g,h]=a.useState(!1),[b,d]=a.useState(!0),[k,w]=a.useState(null),{isMobile:j}=M(),v=a.useCallback(async()=>{try{const[t,u,y]=await Promise.all([f.getActive().catch(()=>[]),f.getQueue().catch(()=>null),f.getMetrics().catch(()=>null)]);o(Array.isArray(t)?t:[]),l(u&&typeof u=="object"?u:null),p(y&&typeof y=="object"?y:null),w(null)}catch(t){w(t instanceof Error?t.message:"Unknown error")}},[]),S=a.useCallback(async()=>{try{const t=await fetch("/api/v1/execution-records?limit=20",{credentials:"include"});if(t.ok){const u=await t.json(),y=(u==null?void 0:u.data)??u;i(Array.isArray(y)?y:[])}}catch{}},[]);a.useEffect(()=>{d(!0),Promise.all([v(),S()]).finally(()=>{d(!1)});const t=setInterval(()=>{v(),S()},5e3);return()=>clearInterval(t)},[v,S]);const E=async()=>{try{await f.pause("console-operator","Manual pause from console"),h(!0),v()}catch{}},z=async()=>{try{await f.resume("console-operator"),h(!1),v()}catch{}},R=async()=>{if(window.confirm("EMERGENCY OVERRIDE: This will bypass all governance for 15 minutes. Are you sure?"))try{await f.emergencyOverride("console-operator","Emergency override from console",15,"console-emergency"),v()}catch{}},T=(t,u)=>{const y=new Date(t),m=new Date().getTime()-y.getTime();return m<1e3?`${m}ms`:m<6e4?`${Math.floor(m/1e3)}s`:`${Math.floor(m/6e4)}m ${Math.floor(m%6e4/1e3)}s`},I=t=>{switch(t){case"executing":return"text-blue-400";case"completed":return"text-emerald-400";case"failed":return"text-red-400";case"approved":return"text-amber-400";default:return"text-slate-400"}},W=t=>t==="vienna_direct"?"Vienna Direct":"Agent Passback",_=t=>{switch(t){case"T0":return"text-emerald-400 bg-emerald-500/10 border-emerald-500/20";case"T1":return"text-blue-400 bg-blue-500/10 border-blue-500/20";case"T2":return"text-amber-400 bg-amber-500/10 border-amber-500/20";case"T3":return"text-red-400 bg-red-500/10 border-red-500/20";default:return"text-slate-400 bg-slate-500/10 border-slate-500/20"}};return b?e.jsx("div",{className:"max-w-7xl mx-auto",children:e.jsx("div",{style:{padding:"24px 0",textAlign:"center",color:"var(--text-secondary)"},children:"Loading execution pipeline..."})}):e.jsxs("div",{className:"max-w-7xl mx-auto space-y-6",children:[e.jsx(L,{}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"24px",fontWeight:600,color:"var(--text-primary)",margin:0,display:"flex",alignItems:"center",gap:"12px"},children:"▶️ Execution Pipeline"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--text-tertiary)",margin:"4px 0 0 0"},children:"Live execution pipeline visualization and controls"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[g?e.jsx("button",{onClick:z,style:{background:"var(--accent-primary)",border:"1px solid var(--accent-primary)",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:500,color:"white",cursor:"pointer",transition:"all 150ms ease"},children:"▶️ Resume"}):e.jsx("button",{onClick:E,style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:500,color:"var(--text-primary)",cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:t=>{t.currentTarget.style.background="var(--bg-tertiary)"},onMouseLeave:t=>{t.currentTarget.style.background="var(--bg-secondary)"},children:"⏸️ Pause"}),e.jsx("button",{onClick:R,style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"8px",padding:"8px 16px",fontSize:"13px",fontWeight:500,color:"#f87171",cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:t=>{t.currentTarget.style.background="rgba(239, 68, 68, 0.15)"},onMouseLeave:t=>{t.currentTarget.style.background="rgba(239, 68, 68, 0.1)"},children:"🚨 Emergency Override"})]})]}),k&&e.jsxs("div",{style:{background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.2)",borderRadius:"12px",padding:"16px",color:"#f87171",fontSize:"14px"},children:["Error: ",k]}),r.length>0&&r[0]&&e.jsx("div",{style:{marginBottom:"24px"},children:e.jsx(B,{stages:[{stage:"requested",status:"complete",timestamp:r[0].started_at},{stage:"evaluated",status:"complete",timestamp:r[0].started_at},{stage:"approved",status:r[0].state==="executing"?"complete":"pending",timestamp:r[0].started_at},{stage:"executed",status:r[0].state==="completed"?"complete":"pending",timestamp:r[0].started_at}],warrantsId:r[0].envelope_id})}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:e.jsx(N,{})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr",gap:"24px"},children:[e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"20px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-secondary)"},children:e.jsxs("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:0,display:"flex",alignItems:"center",gap:"8px"},children:["🔄 Active Executions",e.jsx("span",{style:{background:"var(--accent-primary)",color:"white",fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"12px"},children:r.length})]})}),e.jsx("div",{style:{padding:"20px"},children:r.length===0?e.jsx("div",{style:{textAlign:"center",color:"var(--text-tertiary)",fontSize:"14px"},children:"No active executions"}):e.jsx("div",{style:{display:"grid",gap:"12px"},children:r.slice(0,5).map(t=>e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"12px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start",marginBottom:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--text-primary)"},children:t.action_type||t.envelope_id.slice(0,8)}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:t.envelope_id})]}),e.jsx("div",{style:{fontSize:"11px",fontWeight:500,padding:"2px 6px",borderRadius:"4px",background:"var(--accent-primary)",color:"white"},children:t.state})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"11px",color:"var(--text-tertiary)"},children:[e.jsxs("span",{children:["Started: ",new Date(t.started_at).toLocaleTimeString()]}),e.jsx("span",{children:T(t.started_at)})]})]},t.envelope_id))})})]}),e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"20px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-secondary)"},children:e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:0,display:"flex",alignItems:"center",gap:"8px"},children:"📋 Queue Status"})}),e.jsx("div",{style:{padding:"20px"},children:c?e.jsxs("div",{style:{display:"grid",gap:"16px"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr",gap:"12px"},children:[e.jsxs("div",{style:{background:"var(--bg-secondary)",borderRadius:"8px",padding:"16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"var(--accent-primary)",marginBottom:"4px"},children:c.queued}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:"Queued"})]}),e.jsxs("div",{style:{background:"var(--bg-secondary)",borderRadius:"8px",padding:"16px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"24px",fontWeight:600,color:"#f87171",marginBottom:"4px"},children:c.blocked||0}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:"Blocked"})]})]}),n&&e.jsxs("div",{style:{background:"var(--bg-secondary)",borderRadius:"8px",padding:"16px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--text-primary)",marginBottom:"12px"},children:"Pipeline Throughput"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:j?"1fr":"1fr 1fr 1fr",gap:"8px",fontSize:"11px",color:"var(--text-tertiary)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)"},children:n.total_executed||0}),e.jsx("div",{children:"Processed"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)"},children:n.success_rate!=null?`${(n.success_rate*100).toFixed(1)}%`:"0%"}),e.jsx("div",{children:"Success Rate"})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)"},children:n.avg_latency_ms?`${n.avg_latency_ms}ms`:"0ms"}),e.jsx("div",{children:"Avg Time"})]})]})]})]}):e.jsx("div",{style:{textAlign:"center",color:"var(--text-tertiary)",fontSize:"14px"},children:"Loading queue status..."})})]})]}),e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"20px",borderBottom:"1px solid var(--border-subtle)",background:"var(--bg-secondary)"},children:e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:0,display:"flex",alignItems:"center",gap:"8px"},children:"📜 Recent Execution History"})}),e.jsx("div",{style:{padding:"20px"},children:s.length===0?e.jsx("div",{style:{textAlign:"center",color:"var(--text-tertiary)",fontSize:"14px"},children:"No execution records found"}):e.jsx("div",{style:{display:"grid",gap:"8px"},children:s.slice(0,10).map(t=>e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"12px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"12px",flex:1},children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--text-primary)",marginBottom:"2px"},children:t.action}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:[t.agent_id," • ",new Date(t.created_at).toLocaleString()]})]})}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"10px",fontWeight:600,padding:"2px 6px",borderRadius:"4px",border:"1px solid",fontFamily:"var(--font-mono)"},className:_(t.risk_tier),children:t.risk_tier}),e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"12px",background:t.mode==="vienna_direct"?"rgba(124, 58, 237, 0.1)":"rgba(59, 130, 246, 0.1)",color:t.mode==="vienna_direct"?"#f59e0b":"#60a5fa"},children:W(t.mode)}),e.jsx("span",{style:{fontSize:"11px",fontWeight:500,padding:"2px 8px",borderRadius:"12px",color:I(t.status)},children:t.status})]})]},t.id))})})]})]})}export{O as ExecutionPage}; -//# sourceMappingURL=ExecutionPage-CdXjf9HJ.js.map +//# sourceMappingURL=ExecutionPage-CzELhGv6.js.map diff --git a/apps/console-proxy/public/assets/ExecutionsPage-B56L-9ov.js b/apps/console-proxy/public/assets/ExecutionsPage-VSi5gxch.js similarity index 99% rename from apps/console-proxy/public/assets/ExecutionsPage-B56L-9ov.js rename to apps/console-proxy/public/assets/ExecutionsPage-VSi5gxch.js index c704f082..a186b8d4 100644 --- a/apps/console-proxy/public/assets/ExecutionsPage-B56L-9ov.js +++ b/apps/console-proxy/public/assets/ExecutionsPage-VSi5gxch.js @@ -1,4 +1,4 @@ -import{j as e,r as f,b as A}from"./index-D_7YXFSJ.js";function K(t){if(!t)return"—";const r=typeof t=="string"?parseInt(t):t;return isNaN(r)?"—":r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${(r/6e4).toFixed(1)}m`}const _=({value:t,label:r,color:n,icon:a,subtext:l})=>e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"18px 20px",borderLeft:`3px solid ${n}`,flex:"1 1 0",minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"26px",fontWeight:700,color:n,fontFamily:"var(--font-mono)",lineHeight:1,marginBottom:"4px"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",fontWeight:500},children:r}),l&&e.jsx("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:l})]}),e.jsx("div",{style:{fontSize:"28px",opacity:.5,flexShrink:0},children:a})]}),Y=({stats:t,loading:r=!1})=>{if(r)return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",marginBottom:"20px"},children:[...Array(6)].map((u,p)=>e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"18px 20px",height:"80px",animation:"pulse 2s infinite",opacity:.5}},p))});if(!t)return null;const n=Number(t.total_executions)||0,a=Number(t.executed)||0,l=Number(t.denied)||0,g=Number(t.pending)||0,c=Number(t.failed)||0,d=Number(t.executing)||0,i=t.avg_latency_ms||t.avg_duration_ms||0,x=n>0?Math.round((a+l+c)/n*100):0;return e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("style",{children:` +import{j as e,r as f,g as A}from"./index-C0nK3ekl.js";function K(t){if(!t)return"—";const r=typeof t=="string"?parseInt(t):t;return isNaN(r)?"—":r<1e3?`${r}ms`:r<6e4?`${(r/1e3).toFixed(1)}s`:`${(r/6e4).toFixed(1)}m`}const _=({value:t,label:r,color:n,icon:a,subtext:l})=>e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"18px 20px",borderLeft:`3px solid ${n}`,flex:"1 1 0",minWidth:0,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"12px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"26px",fontWeight:700,color:n,fontFamily:"var(--font-mono)",lineHeight:1,marginBottom:"4px"},children:t}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.04em",fontWeight:500},children:r}),l&&e.jsx("div",{style:{fontSize:"9px",color:"var(--text-muted)",marginTop:"2px"},children:l})]}),e.jsx("div",{style:{fontSize:"28px",opacity:.5,flexShrink:0},children:a})]}),Y=({stats:t,loading:r=!1})=>{if(r)return e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"12px",marginBottom:"20px"},children:[...Array(6)].map((u,p)=>e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"18px 20px",height:"80px",animation:"pulse 2s infinite",opacity:.5}},p))});if(!t)return null;const n=Number(t.total_executions)||0,a=Number(t.executed)||0,l=Number(t.denied)||0,g=Number(t.pending)||0,c=Number(t.failed)||0,d=Number(t.executing)||0,i=t.avg_latency_ms||t.avg_duration_ms||0,x=n>0?Math.round((a+l+c)/n*100):0;return e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("style",{children:` @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } @@ -11,4 +11,4 @@ import{j as e,r as f,b as A}from"./index-D_7YXFSJ.js";function K(t){if(!t)return @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } } @keyframes spin { to { transform: rotate(360deg); } } `}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:"22px",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",margin:0,display:"flex",alignItems:"center",gap:"10px"},children:["Executions",L>0&&e.jsxs("span",{style:{padding:"2px 8px",borderRadius:"10px",fontSize:"11px",fontWeight:600,background:"rgba(16,185,129,0.15)",color:"#10b981",animation:"pulse 2s infinite"},children:["+",L," new"]})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-tertiary)",marginTop:"4px"},children:"Managed execution pipeline — real-time lifecycle monitoring"})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:()=>oe(y),disabled:y.length===0,style:{padding:"8px 14px",borderRadius:"6px",fontSize:"12px",fontWeight:500,background:y.length>0?"rgba(16,185,129,0.1)":"rgba(255,255,255,0.03)",color:y.length>0?"#10b981":"var(--text-tertiary)",border:`1px solid ${y.length>0?"rgba(16,185,129,0.2)":"var(--border-subtle)"}`,cursor:y.length>0?"pointer":"not-allowed",fontFamily:"var(--font-mono)",display:"flex",alignItems:"center",gap:"6px"},children:"📥 Export CSV"}),e.jsx("button",{onClick:()=>{g(!0),m()},style:{padding:"8px 14px",borderRadius:"6px",fontSize:"12px",fontWeight:500,background:"rgba(255,255,255,0.06)",color:"var(--text-secondary)",border:"1px solid var(--border-subtle)",cursor:"pointer",fontFamily:"var(--font-mono)"},children:"↻ Refresh"})]})]}),e.jsx(Y,{stats:n,loading:l}),e.jsx(ne,{filters:c,onChange:d,onClear:()=>d(I),activeCount:j}),j>0&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginBottom:"8px"},children:["Showing ",y.length," of ",t.length," executions"]}),e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:"12px",overflow:"hidden",border:"1px solid var(--border-subtle)"},children:l?e.jsxs("div",{style:{padding:"48px",textAlign:"center"},children:[e.jsx("div",{style:{display:"inline-block",width:"24px",height:"24px",border:"2px solid var(--border-subtle)",borderTop:"2px solid #f59e0b",borderRadius:"50%",animation:"spin 0.8s linear infinite"}}),e.jsx("p",{style:{marginTop:"12px",fontSize:"12px",color:"var(--text-tertiary)"},children:"Loading executions..."})]}):y.length===0?e.jsxs("div",{style:{padding:"60px 24px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"48px",marginBottom:"16px"},children:j>0?"🔍":"🔄"}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px"},children:j>0?"No matching executions":"No executions yet"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-tertiary)",maxWidth:"400px",margin:"0 auto",lineHeight:1.6},children:j>0?"Try adjusting your filters or clearing them to see all executions.":"Executions appear here when intents are submitted through the governance pipeline."}),j>0&&e.jsx("button",{onClick:()=>d(I),style:{marginTop:"16px",padding:"8px 16px",fontSize:"12px",borderRadius:"6px",border:"none",background:"rgba(245,158,11,0.1)",color:"#f59e0b",cursor:"pointer",fontWeight:500},children:"Clear all filters"})]}):e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px",minWidth:"700px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Execution","State","Tier","Objective","Steps","Duration","Created"].map(o=>e.jsx("th",{style:{padding:"11px 14px",textAlign:"left",fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:o},o))})}),e.jsx("tbody",{children:y.map(o=>e.jsxs("tr",{onClick:()=>B(o.execution_id),style:{cursor:"pointer",background:i===o.execution_id?"rgba(245,158,11,0.05)":"transparent",borderBottom:"1px solid rgba(255,255,255,0.03)",transition:"background 100ms"},onMouseEnter:b=>{b.currentTarget.style.background="rgba(255,255,255,0.02)"},onMouseLeave:b=>{b.currentTarget.style.background=i===o.execution_id?"rgba(245,158,11,0.05)":"transparent"},children:[e.jsxs("td",{style:{padding:"11px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-primary)",fontWeight:500},children:[o.execution_id.slice(0,16),"…"]}),e.jsx("td",{style:{padding:"11px 14px"},children:e.jsx(re,{state:o.state,tier:o.risk_tier})}),e.jsx("td",{style:{padding:"11px 14px"},children:e.jsx(X,{tier:o.risk_tier})}),e.jsx("td",{style:{padding:"11px 14px",maxWidth:"260px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",color:"var(--text-secondary)"},children:o.objective}),e.jsx("td",{style:{padding:"11px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-tertiary)"},children:o.step_count}),e.jsx("td",{style:{padding:"11px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-tertiary)"},children:ie(o.duration_ms)}),e.jsx("td",{style:{padding:"11px 14px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-tertiary)"},children:se(o.created_at)})]},o.execution_id))})]})})}),q&&e.jsx(ae,{detail:u,loading:k,onClose:G})]})}function pe({timeline:t}){return t.length?e.jsxs("div",{style:{position:"relative",paddingLeft:"20px"},children:[e.jsx("div",{style:{position:"absolute",left:"7px",top:"8px",bottom:"8px",width:"2px",background:"rgba(245,158,11,0.15)"}}),t.map((r,n)=>{var a;return e.jsxs("div",{style:{position:"relative",paddingBottom:"14px",paddingLeft:"16px"},children:[e.jsx("div",{style:{position:"absolute",left:"-16px",top:"6px",width:"10px",height:"10px",borderRadius:"50%",background:((a=z[r.state])==null?void 0:a.dot)||"#94a3b8",border:"2px solid rgba(0,0,0,0.3)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"2px"},children:[e.jsx(E,{state:r.state}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:r.detail})]}),e.jsxs("div",{style:{fontSize:"10px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:[new Date(r.timestamp).toLocaleString(),r.actor&&e.jsxs(e.Fragment,{children:[" · ",r.actor]})]})]},n)})]}):e.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"12px"},children:"No timeline entries"})}function ce({steps:t}){return t.length?e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.map((r,n)=>{var l;const a=r.status==="complete";return e.jsxs("div",{style:{background:a?"rgba(16,185,129,0.04)":"rgba(239,68,68,0.04)",border:`1px solid ${a?"rgba(16,185,129,0.12)":"rgba(239,68,68,0.12)"}`,borderRadius:"8px",padding:"12px 14px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("span",{style:{fontSize:"11px",fontWeight:700,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",width:"20px"},children:["#",r.step_index]}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:r.step_name}),e.jsx(E,{state:r.status})]}),e.jsxs("div",{style:{display:"flex",gap:"14px",fontSize:"11px",fontFamily:"var(--font-mono)",color:"var(--text-tertiary)"},children:[r.adapter_id&&e.jsx("span",{title:r.adapter_id,children:"🔌 adapter"}),e.jsxs("span",{children:["⏱ ",r.latency_ms,"ms"]}),((l=r.result)==null?void 0:l.status_code)&&e.jsxs("span",{children:["HTTP ",r.result.status_code]})]})]}),r.error&&e.jsxs("div",{style:{marginTop:"6px",fontSize:"11px",color:"#ef4444",fontFamily:"var(--font-mono)",padding:"4px 0 0 30px"},children:["⚠ ",r.error]})]},n)})}):e.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"12px"},children:"No steps recorded"})}function xe({events:t}){return t.length?e.jsxs("div",{style:{background:"rgba(0,0,0,0.1)",borderRadius:"8px",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"40px 1fr 80px 120px",gap:"0",fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"8px 12px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("span",{children:"#"}),e.jsx("span",{children:"Event"}),e.jsx("span",{children:"Stage"}),e.jsx("span",{children:"Time"})]}),t.map((r,n)=>e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"40px 1fr 80px 120px",gap:"0",padding:"6px 12px",borderBottom:"1px solid rgba(255,255,255,0.03)",fontSize:"11px",fontFamily:"var(--font-mono)"},children:[e.jsx("span",{style:{color:"var(--text-tertiary)"},children:r.sequence_num}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:r.event_type}),e.jsx("span",{style:{color:"var(--text-tertiary)"},children:r.stage}),e.jsx("span",{style:{color:"var(--text-tertiary)"},children:new Date(r.event_timestamp||r.created_at).toLocaleTimeString()})]},n))]}):e.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"12px"},children:"No ledger events"})}function ge({result:t}){if(!t)return e.jsx("p",{style:{color:"var(--text-tertiary)",fontSize:"12px"},children:"No result data"});let r=t;if(typeof t=="string")try{r=JSON.parse(t)}catch{}return e.jsx("pre",{style:{background:"rgba(0,0,0,0.15)",borderRadius:"8px",padding:"14px",fontSize:"11px",fontFamily:"var(--font-mono)",color:"var(--text-secondary)",overflow:"auto",maxHeight:"500px",whiteSpace:"pre-wrap",wordBreak:"break-all",margin:0,lineHeight:1.6},children:JSON.stringify(r,null,2)})}export{be as ExecutionsPage}; -//# sourceMappingURL=ExecutionsPage-B56L-9ov.js.map +//# sourceMappingURL=ExecutionsPage-VSi5gxch.js.map diff --git a/apps/console-proxy/public/assets/FleetDashboardPage-Cd5radQs.js b/apps/console-proxy/public/assets/FleetDashboardPage-nC3mT2F1.js similarity index 99% rename from apps/console-proxy/public/assets/FleetDashboardPage-Cd5radQs.js rename to apps/console-proxy/public/assets/FleetDashboardPage-nC3mT2F1.js index 3ad75b5c..501f6265 100644 --- a/apps/console-proxy/public/assets/FleetDashboardPage-Cd5radQs.js +++ b/apps/console-proxy/public/assets/FleetDashboardPage-nC3mT2F1.js @@ -1,2 +1,2 @@ -import{j as e,r as g,R as oe}from"./index-D_7YXFSJ.js";import{f as T}from"./fleet-Bmy_93a8.js";const se={T0:"#10b981",T1:"#10b981",T2:"#fbbf24",T3:"#ef4444"},ie={T0:"AUTO_APPROVE",T1:"POLICY_GATE",T2:"HUMAN_GATE",T3:"STRICT_HALT"},d={card:"var(--bg-primary)",cardHover:"var(--bg-secondary)",border:"var(--border-subtle)",borderActive:"var(--border-default)",borderStrong:"var(--border-strong)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},le={active:d.green,idle:d.yellow,suspended:d.red,terminated:d.textMuted},de={"Active Warrant":d.green,"No Warrant":d.textMuted,Expired:d.red},P={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"};function ae(n){if(!n)return"never";const o=Date.now()-new Date(n).getTime();if(o<0)return"just now";const s=Math.floor(o/1e3);if(s<60)return`${s}s ago`;const l=Math.floor(s/60);if(l<60)return`${l}m ago`;const a=Math.floor(l/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function ce(n,o=3e5){return n?Date.now()-new Date(n).getTime()>o:!0}function xe(n){return n>70?d.green:n>=40?d.yellow:d.red}function ue({status:n}){const o=le[n]||d.textMuted,s=n==="active";return e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:o,boxShadow:s?`0 0 6px ${o}`:"none",animation:s?"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite":"none"}})}function G({text:n,color:o,small:s}){return e.jsx("span",{style:{...P,fontSize:s?9:10,fontWeight:600,color:o,background:`${o}18`,border:`1px solid ${o}33`,borderRadius:3,padding:s?"1px 4px":"2px 6px",textTransform:"uppercase",letterSpacing:"0.04em",whiteSpace:"nowrap"},children:n})}function pe({score:n}){const o=xe(n);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:[e.jsx("div",{style:{flex:1,height:6,background:"rgba(255,255,255,0.08)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${n}%`,height:"100%",background:o,borderRadius:3,transition:"width 300ms ease"}})}),e.jsx("span",{style:{...P,fontSize:11,color:o,fontWeight:600,minWidth:24,textAlign:"right"},children:n})]})}function ge({agent:n,riskTier:o,warrantStatus:s,onClick:l,onAdjustTrust:a,onSuspend:p,onActivate:i}){const h=ce(n.last_heartbeat),v=se[o],C=ie[o];return e.jsxs("div",{onClick:l,style:{background:d.card,border:`1px solid ${d.border}`,borderLeft:`4px solid ${v}`,borderRadius:6,padding:16,cursor:l?"pointer":"default",transition:"all 200ms ease",display:"flex",flexDirection:"column",gap:12,height:"100%"},onMouseEnter:c=>{l&&(c.currentTarget.style.background=d.cardHover,c.currentTarget.style.borderColor=d.borderActive,c.currentTarget.style.boxShadow="0 8px 24px rgba(0,0,0,0.3)")},onMouseLeave:c=>{c.currentTarget.style.background=d.card,c.currentTarget.style.borderColor=d.border,c.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0},children:[e.jsx(ue,{status:n.status}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:d.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.display_name}),e.jsx("div",{style:{...P,fontSize:10,color:d.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.agent_id})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3,alignItems:"flex-end"},children:[e.jsx(G,{text:o,color:v,small:!0}),e.jsx("span",{style:{...P,fontSize:9,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.03em"},children:C})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Trust Score"}),e.jsx(pe,{score:n.trust_score})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Last Activity"}),e.jsx("span",{style:{...P,fontSize:11,color:h?d.red:d.textSecondary},children:ae(n.last_heartbeat)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Warrant"}),e.jsx(G,{text:s,color:de[s]||d.textMuted})]}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[n.status==="suspended"?e.jsx("button",{onClick:c=>{c.stopPropagation(),i==null||i()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.green}33`,background:"rgba(16,185,129,0.1)",color:d.green,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=`${d.green}66`,c.currentTarget.style.background="rgba(16,185,129,0.15)"},onMouseLeave:c=>{c.currentTarget.style.borderColor=`${d.green}33`,c.currentTarget.style.background="rgba(16,185,129,0.1)"},children:"⚡ Activate"}):e.jsx("button",{onClick:c=>{c.stopPropagation(),p==null||p()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.red}33`,background:"rgba(239,68,68,0.1)",color:d.red,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=`${d.red}66`,c.currentTarget.style.background="rgba(239,68,68,0.15)"},onMouseLeave:c=>{c.currentTarget.style.borderColor=`${d.red}33`,c.currentTarget.style.background="rgba(239,68,68,0.1)"},children:"⏸ Suspend"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),a==null||a()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.borderStrong}`,background:"transparent",color:d.textSecondary,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=d.borderActive,c.currentTarget.style.color=d.textPrimary},onMouseLeave:c=>{c.currentTarget.style.borderColor=d.borderStrong,c.currentTarget.style.color=d.textSecondary},children:"🎚 Adjust"})]})]})}const u={card:"var(--bg-primary)",border:"var(--border-subtle)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",blue:"var(--info-text)",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},E={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"};function W({label:n,value:o,unit:s,color:l,secondaryValue:a,children:p}){return e.jsxs("div",{style:{background:u.card,border:`1px solid ${u.border}`,borderRadius:6,padding:"12px 16px",flex:"1 1 0",minWidth:140},children:[e.jsx("div",{style:{fontSize:10,color:u.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:4,marginBottom:4},children:[e.jsx("div",{style:{...E,fontSize:24,fontWeight:700,color:l||u.textPrimary,lineHeight:1},children:o}),s&&e.jsx("span",{style:{...E,fontSize:11,color:u.textSecondary,fontWeight:500},children:s})]}),a&&e.jsxs("div",{style:{...E,fontSize:10,color:u.textMuted,display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:a.label}),e.jsx("span",{children:a.value})]}),p]})}function ye({activeCount:n,idleCount:o,suspendedCount:s}){const l=n+o+s;if(l===0)return null;const a=n/l*100,p=o/l*100,i=s/l*100;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[e.jsxs("div",{style:{display:"flex",height:4,borderRadius:2,overflow:"hidden",flex:1,background:"rgba(255,255,255,0.08)"},children:[a>0&&e.jsx("div",{style:{width:`${a}%`,background:u.green}}),p>0&&e.jsx("div",{style:{width:`${p}%`,background:u.yellow}}),i>0&&e.jsx("div",{style:{width:`${i}%`,background:u.red}})]}),e.jsxs("div",{style:{display:"flex",gap:8,fontSize:9,color:u.textMuted,whiteSpace:"nowrap"},children:[e.jsxs("span",{style:{color:u.green},children:["●",n]}),e.jsxs("span",{style:{color:u.yellow},children:["●",o]}),e.jsxs("span",{style:{color:u.red},children:["●",s]})]})]})}function he({totalAgents:n,activeAgents:o,idleAgents:s,suspendedAgents:l,avgTrustScore:a,t0Count:p,t1Count:i,t2Count:h,t3Count:v,pendingApprovals:C,actionsToday:c,avgLatencyMs:M,unresolvedAlerts:m}){const k=a>70?u.green:a>=40?u.yellow:u.red;return e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[e.jsx(W,{label:"Total Agents",value:n,color:u.textPrimary,secondaryValue:{label:"Registered",value:n},children:e.jsx(ye,{activeCount:o,idleCount:s,suspendedCount:l})}),e.jsx(W,{label:"Avg Trust Score",value:Math.round(a),unit:"%",color:k,secondaryValue:{label:"Fleet health",value:k===u.green?"✓ Good":k===u.yellow?"⚠ Fair":"✗ Low"}}),e.jsx(W,{label:"Actions Today",value:c,color:u.blue,secondaryValue:{label:"Real-time",value:"flowing"}}),e.jsx(W,{label:"Avg Latency",value:M,unit:"ms",color:M>1e3?u.yellow:u.green,secondaryValue:{label:"Status",value:M>1e3?"⚠ Slow":"✓ Fast"}}),e.jsx(W,{label:"Unresolved Alerts",value:m,color:m>0?u.yellow:u.green,secondaryValue:{label:"Status",value:m>0?`${m} pending`:"All clear"}}),C>0&&e.jsx(W,{label:"⚡ Pending Approvals",value:C,color:u.yellow,secondaryValue:{label:"Status",value:"Awaiting"}})]})}const t={card:"var(--bg-primary)",cardHover:"var(--bg-secondary)",border:"var(--border-subtle)",borderActive:"var(--border-default)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",blue:"var(--info-text)",amber:"var(--accent-primary)",cyan:"#06b6d4",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},fe={active:t.green,idle:t.yellow,suspended:t.red,terminated:t.textMuted},I={info:t.blue,warning:t.yellow,critical:t.red},be={executed:t.green,approved:t.green,denied:t.yellow,failed:t.red,timeout:t.textMuted},me={autonomous:t.amber,"semi-autonomous":t.blue,supervised:t.cyan},x={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"},ve=15e3;function H(n){if(!n)return"never";const o=Date.now()-new Date(n).getTime();if(o<0)return"just now";const s=Math.floor(o/1e3);if(s<60)return`${s}s ago`;const l=Math.floor(s/60);if(l<60)return`${l}m ago`;const a=Math.floor(l/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function je(n,o=3e5){return n?Date.now()-new Date(n).getTime()>o:!0}function F(n){return n>70?t.green:n>=40?t.yellow:t.red}function B(n){return n>85?"T0":n>65?"T1":n>40?"T2":"T3"}function Se(n){if(n.warrant_status){if(n.warrant_status==="active")return"Active Warrant";if(n.warrant_status==="expired")return"Expired"}return"No Warrant"}function we({score:n}){const o=F(n);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{width:60,height:6,background:"rgba(255,255,255,0.08)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${n}%`,height:"100%",background:o,borderRadius:3,transition:"width 300ms ease"}})}),e.jsx("span",{style:{...x,fontSize:11,color:o,fontWeight:600},children:n})]})}function Te({status:n}){const o=fe[n]||t.textMuted;return e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:o,boxShadow:n==="active"?`0 0 6px ${o}`:"none"}})}function O({text:n,color:o}){return e.jsx("span",{style:{...x,fontSize:10,fontWeight:600,color:o,background:`${o}18`,border:`1px solid ${o}33`,borderRadius:3,padding:"1px 6px",textTransform:"uppercase",letterSpacing:"0.04em"},children:n})}function ke({detail:n}){const{metrics:o,recentActivity:s,alerts:l}=n,a=Object.entries(o.actionsByType).sort((i,h)=>h[1]-i[1]).slice(0,5),p=a.length>0?a[0][1]:1;return e.jsx("tr",{children:e.jsx("td",{colSpan:11,style:{padding:0,border:"none"},children:e.jsxs("div",{style:{background:"#161f2e",borderTop:`1px solid ${t.border}`,borderBottom:`1px solid ${t.border}`,padding:"16px 20px",display:"grid",gridTemplateColumns:"1fr 1fr 1.5fr",gap:20},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Metrics"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px 16px"},children:[["Actions/Day",o.actionsToday],["Actions/Week",o.actionsThisWeek],["Avg Latency",`${o.avgLatencyMs}ms`],["Approval %",`${o.approvalRate}%`],["Error %",`${o.errorRate}%`],["Denied %",`${o.deniedRate}%`]].map(([i,h])=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,color:t.textMuted},children:i}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary},children:h})]},i))}),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:6,letterSpacing:"0.05em"},children:"Top Actions"}),a.map(([i,h])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[e.jsx("span",{style:{...x,fontSize:10,color:t.textSecondary,width:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),e.jsx("div",{style:{flex:1,height:4,background:"rgba(255,255,255,0.06)",borderRadius:2},children:e.jsx("div",{style:{width:`${h/p*100}%`,height:"100%",background:t.blue,borderRadius:2}})}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted,width:24,textAlign:"right"},children:h})]},i))]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:["Active Alerts (",l.length,")"]}),l.length===0?e.jsx("div",{style:{fontSize:12,color:t.textMuted},children:"No active alerts"}):l.slice(0,4).map(i=>e.jsxs("div",{style:{background:t.card,border:`1px solid ${I[i.severity]}33`,borderLeft:`3px solid ${I[i.severity]}`,borderRadius:4,padding:"6px 10px",marginBottom:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[e.jsx(O,{text:i.severity,color:I[i.severity]}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted},children:i.alert_type})]}),e.jsx("div",{style:{fontSize:11,color:t.textSecondary,lineHeight:1.3},children:i.message})]},i.id))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Recent Activity"}),e.jsx("div",{style:{maxHeight:200,overflowY:"auto"},children:s.map(i=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0",borderBottom:`1px solid ${t.border}`},children:[e.jsx(O,{text:i.result,color:be[i.result]||t.textMuted}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary,flex:1},children:i.action_type}),i.risk_tier&&e.jsx(O,{text:i.risk_tier,color:t.textSecondary}),e.jsxs("span",{style:{...x,fontSize:10,color:t.textMuted},children:[i.latency_ms,"ms"]}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted,width:55,textAlign:"right"},children:H(i.created_at)})]},i.id))})]})]})})})}function Ce({agent:n,onSuspend:o,onActivate:s,onAdjustTrust:l}){const[a,p]=g.useState(!1);return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),p(!a)},style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,cursor:"pointer",padding:"2px 6px",fontSize:14,lineHeight:1},children:"⋯"}),a&&e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{position:"absolute",right:0,top:"100%",marginTop:4,background:t.card,border:`1px solid ${t.borderActive}`,borderRadius:6,padding:4,zIndex:100,minWidth:140,boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[n.status==="suspended"?e.jsx(D,{label:"⚡ Activate",onClick:()=>{s(n.agent_id),p(!1)}}):e.jsx(D,{label:"⏸ Suspend",onClick:()=>{o(n.agent_id),p(!1)},color:t.red}),e.jsx(D,{label:"🎚 Adjust Trust",onClick:()=>{l(n.agent_id),p(!1)}})]})]})}function D({label:n,onClick:o,color:s}){return e.jsx("button",{onClick:o,style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",color:s||t.textSecondary,fontSize:12,padding:"6px 10px",borderRadius:4,cursor:"pointer"},onMouseEnter:l=>{l.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:l=>{l.currentTarget.style.background="none"},children:n})}function J({alerts:n,onResolve:o}){return e.jsxs("div",{style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:6,padding:16,maxHeight:360,overflowY:"auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:t.textPrimary,textTransform:"uppercase",letterSpacing:"0.05em"},children:["🚨 Alerts (",n.length,")"]})}),n.length===0?e.jsx("div",{style:{fontSize:12,color:t.textMuted,textAlign:"center",padding:20},children:"All clear — no active alerts"}):n.map(s=>e.jsxs("div",{style:{borderLeft:`3px solid ${I[s.severity]}`,background:`${I[s.severity]}08`,borderRadius:4,padding:"8px 12px",marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(O,{text:s.severity,color:I[s.severity]}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary,fontWeight:600},children:s.agent_name||s.agent_id}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted},children:s.alert_type})]}),e.jsx("button",{onClick:()=>o(s.id),style:{background:"none",border:`1px solid ${t.border}`,borderRadius:3,color:t.textMuted,fontSize:10,padding:"2px 8px",cursor:"pointer"},onMouseEnter:l=>{l.currentTarget.style.borderColor=t.green,l.currentTarget.style.color=t.green},onMouseLeave:l=>{l.currentTarget.style.borderColor=t.border,l.currentTarget.style.color=t.textMuted},children:"Resolve"})]}),e.jsx("div",{style:{fontSize:11,color:t.textSecondary,lineHeight:1.4},children:s.message}),e.jsx("div",{style:{...x,fontSize:10,color:t.textMuted,marginTop:4},children:H(s.created_at)})]},s.id))]})}function Me({agentId:n,currentScore:o,onSubmit:s,onClose:l}){const[a,p]=g.useState(o);return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:l,children:e.jsxs("div",{style:{background:t.card,border:`1px solid ${t.borderActive}`,borderRadius:8,padding:24,width:320,boxShadow:"0 16px 48px rgba(0,0,0,0.5)"},onClick:i=>i.stopPropagation(),children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:t.textPrimary,marginBottom:4},children:"Adjust Trust Score"}),e.jsx("div",{style:{...x,fontSize:12,color:t.textMuted,marginBottom:16},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[e.jsx("input",{type:"range",min:0,max:100,value:a,onChange:i=>p(parseInt(i.target.value)),style:{flex:1,accentColor:F(a)}}),e.jsx("span",{style:{...x,fontSize:18,fontWeight:700,color:F(a),width:36,textAlign:"right"},children:a})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:l,style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,fontSize:12,padding:"6px 14px",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:()=>s(a),style:{background:t.blue,border:"none",borderRadius:4,color:"#fff",fontSize:12,fontWeight:600,padding:"6px 14px",cursor:"pointer"},children:"Apply"})]})]})})}function Re(){const[n,o]=g.useState(null),[s,l]=g.useState([]),[a,p]=g.useState(!0),[i,h]=g.useState(null),[v,C]=g.useState(null),[c,M]=g.useState(null),[m,k]=g.useState(null),[K,Q]=g.useState(new Date),[L,X]=g.useState(""),[R,q]=g.useState("all"),[j,_]=g.useState(new Set),[A,N]=g.useState("cards"),f=g.useCallback(async()=>{try{const[r,y]=await Promise.all([T.getOverview(),T.getAlerts()]);o(r),l(y),h(null),Q(new Date)}catch(r){h(r instanceof Error?r.message:"Failed to load fleet data")}finally{p(!1)}},[]);g.useEffect(()=>{f();const r=setInterval(f,ve);return()=>clearInterval(r)},[f]),g.useEffect(()=>{if(!v){M(null);return}T.getAgent(v).then(M).catch(()=>M(null))},[v]);const V=async r=>{await T.suspend(r),f()},U=async r=>{await T.activate(r),f()},Z=async r=>{m&&(await T.adjustTrust(m.agentId,r),k(null),f())},Y=async r=>{await T.resolveAlert(r),f()};if(a)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:400,color:t.textMuted},children:e.jsx("div",{style:{...x,fontSize:14},children:"Loading fleet data..."})});if(i||!n)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:400},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:14,color:t.red,marginBottom:8},children:["⚠ ",i||"No data"]}),e.jsx("button",{onClick:f,style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,padding:"6px 14px",fontSize:12,cursor:"pointer"},children:"Retry"})]})});const{agents:b,summary:S}=n,w=b.filter(r=>!(L&&!r.display_name.toLowerCase().includes(L.toLowerCase())&&!r.agent_id.toLowerCase().includes(L.toLowerCase())||R!=="all"&&r.status!==R)),ee=r=>{_(y=>{const $=new Set(y);return $.has(r)?$.delete(r):$.add(r),$})},te=()=>{j.size===w.length?_(new Set):_(new Set(w.map(r=>r.agent_id)))},re=async()=>{if(confirm(`Suspend ${j.size} agents?`)){for(const r of j)await T.suspend(r);_(new Set),f()}},ne=async()=>{if(confirm(`Activate ${j.size} agents?`)){for(const r of j)await T.activate(r);_(new Set),f()}};return S.trendData.map(r=>r.count),e.jsxs("div",{style:{maxWidth:1400,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:18,fontWeight:700,color:t.textPrimary,margin:0,letterSpacing:"-0.01em"},children:"Agent Fleet"}),e.jsxs("div",{style:{...x,fontSize:11,color:t.textMuted,marginTop:2},children:["Governance Dashboard — ",S.totalAgents," agents registered"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("div",{style:{display:"flex",gap:2,background:"rgba(255,255,255,0.03)",borderRadius:4,padding:2},children:[e.jsx("button",{onClick:()=>N("cards"),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:A==="cards"?600:400,background:A==="cards"?"rgba(255,255,255,0.08)":"transparent",color:A==="cards"?t.textPrimary:t.textMuted},children:"⊞ Cards"}),e.jsx("button",{onClick:()=>N("table"),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:A==="table"?600:400,background:A==="table"?"rgba(255,255,255,0.08)":"transparent",color:A==="table"?t.textPrimary:t.textMuted},children:"▦ Table"})]}),e.jsxs("div",{style:{...x,fontSize:10,color:t.textMuted},children:["Updated ",K.toLocaleTimeString()]}),e.jsx("button",{onClick:f,style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,padding:"4px 10px",fontSize:11,cursor:"pointer"},onMouseEnter:r=>{r.currentTarget.style.borderColor=t.blue},onMouseLeave:r=>{r.currentTarget.style.borderColor=t.border},children:"↻ Refresh"})]})]}),e.jsx(he,{totalAgents:S.totalAgents,activeAgents:S.activeAgents,idleAgents:b.filter(r=>r.status==="idle").length,suspendedAgents:b.filter(r=>r.status==="suspended").length,avgTrustScore:b.length>0?b.reduce((r,y)=>r+y.trust_score,0)/b.length:0,t0Count:b.filter(r=>B(r.trust_score)==="T0").length,t1Count:b.filter(r=>B(r.trust_score)==="T1").length,t2Count:b.filter(r=>B(r.trust_score)==="T2").length,t3Count:b.filter(r=>B(r.trust_score)==="T3").length,pendingApprovals:0,actionsToday:S.actionsToday,avgLatencyMs:S.avgLatencyMs,unresolvedAlerts:S.unresolvedAlerts}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{type:"text",placeholder:"Search agents...",value:L,onChange:r=>X(r.target.value),style:{padding:"6px 12px",fontSize:12,borderRadius:4,border:`1px solid ${t.border}`,background:"rgba(255,255,255,0.04)",color:t.textPrimary,width:200,fontFamily:"inherit",outline:"none"}}),e.jsx("div",{style:{display:"flex",gap:2,background:"rgba(255,255,255,0.03)",borderRadius:4,padding:2},children:[{key:"all",label:"All"},{key:"active",label:"🟢 Active"},{key:"idle",label:"🟡 Idle"},{key:"suspended",label:"🔴 Suspended"}].map(r=>e.jsx("button",{onClick:()=>q(r.key),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:R===r.key?600:400,background:R===r.key?"rgba(255,255,255,0.08)":"transparent",color:R===r.key?t.textPrimary:t.textMuted},children:r.label},r.key))}),(L||R!=="all")&&e.jsxs("span",{style:{...x,fontSize:10,color:t.textMuted},children:[w.length," of ",b.length]})]}),j.size>0&&e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,padding:"8px 12px",background:"rgba(59,130,246,0.08)",borderRadius:6,border:"1px solid rgba(59,130,246,0.15)"},children:[e.jsxs("span",{style:{fontSize:12,color:t.blue,fontWeight:600},children:[j.size," selected"]}),e.jsx("button",{onClick:ne,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid rgba(16,185,129,0.3)",background:"rgba(16,185,129,0.1)",color:t.green,cursor:"pointer",fontWeight:500},children:"⚡ Activate All"}),e.jsx("button",{onClick:re,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:t.red,cursor:"pointer",fontWeight:500},children:"⏸ Suspend All"}),e.jsx("button",{onClick:()=>_(new Set),style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.textMuted,cursor:"pointer"},children:"Clear"})]}),A==="cards"?e.jsxs("div",{style:{display:"grid",gridTemplateColumns:window.innerWidth>768?"1fr 340px":"1fr",gap:16},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:w.length===0?e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",minHeight:300,color:t.textMuted,flexDirection:"column",gap:12},children:[e.jsx("div",{style:{fontSize:16},children:"📭"}),e.jsx("div",{style:{fontSize:14,fontWeight:600},children:"No agents registered yet"}),e.jsx("div",{style:{fontSize:11,color:t.textMuted},children:'Connect your first agent to get started. Click "Connect Agent" in settings.'})]}):w.map(r=>e.jsx(ge,{agent:r,riskTier:B(r.trust_score),warrantStatus:Se(r),onClick:()=>C(r.agent_id===v?null:r.agent_id),onAdjustTrust:()=>k({agentId:r.agent_id,score:r.trust_score}),onSuspend:()=>V(r.agent_id),onActivate:()=>U(r.agent_id)},r.agent_id))}),e.jsx(J,{alerts:s,onResolve:Y})]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:window.innerWidth>768?"1fr 340px":"1fr",gap:16},children:[e.jsx("div",{style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden"},children:e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"800px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`},children:[e.jsx("th",{style:{padding:"10px 10px",width:28},children:e.jsx("input",{type:"checkbox",checked:w.length>0&&j.size===w.length,onChange:te,style:{cursor:"pointer",accentColor:t.blue}})}),["","Agent","Type","Trust","Actions","Latency","Errors","Alerts","Last Seen",""].map((r,y)=>e.jsx("th",{style:{textAlign:"left",padding:"10px 10px",fontSize:10,fontWeight:600,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.06em",whiteSpace:"nowrap",...y===0?{width:24}:{}},children:r},y))]})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:11,style:{padding:"40px 20px",textAlign:"center",color:t.textMuted},children:[e.jsx("div",{style:{fontSize:14,marginBottom:8},children:"No agents registered"}),e.jsx("div",{style:{fontSize:11,color:t.textMuted},children:"Agents will appear here once they connect to Vienna OS"})]})}):w.map(r=>{const y=v===r.agent_id,$=je(r.last_heartbeat);return e.jsxs(oe.Fragment,{children:[e.jsxs("tr",{onClick:()=>C(y?null:r.agent_id),style:{borderBottom:`1px solid ${t.border}`,cursor:"pointer",background:y?"#161f2e":"transparent",transition:"background 150ms"},onMouseEnter:z=>{y||(z.currentTarget.style.background=t.cardHover)},onMouseLeave:z=>{y||(z.currentTarget.style.background="transparent")},children:[e.jsx("td",{style:{padding:"8px 10px",textAlign:"center"},onClick:z=>z.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:j.has(r.agent_id),onChange:()=>ee(r.agent_id),style:{cursor:"pointer",accentColor:t.blue}})}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"center"},children:e.jsx(Te,{status:r.status})}),e.jsxs("td",{style:{padding:"8px 10px"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:t.textPrimary,lineHeight:1.2},children:r.display_name}),e.jsx("div",{style:{...x,fontSize:10,color:t.textMuted},children:r.agent_id})]}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx(O,{text:r.agent_type,color:me[r.agent_type]||t.textMuted})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx(we,{score:r.trust_score})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx("span",{style:{...x,fontSize:12,color:t.textPrimary},children:r.actions_today})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsxs("span",{style:{...x,fontSize:12,color:r.avg_latency_ms>1e3?t.yellow:t.textSecondary},children:[r.avg_latency_ms,"ms"]})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsxs("span",{style:{...x,fontSize:12,color:r.error_rate>10?t.red:t.textSecondary},children:[r.error_rate,"%"]})}),e.jsx("td",{style:{padding:"8px 10px"},children:r.unresolved_alerts>0?e.jsx("span",{style:{...x,fontSize:12,color:t.yellow,fontWeight:700},children:r.unresolved_alerts}):e.jsx("span",{style:{...x,fontSize:12,color:t.textMuted},children:"0"})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx("span",{style:{...x,fontSize:11,color:$?t.red:t.textMuted},children:H(r.last_heartbeat)})}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right"},children:e.jsx(Ce,{agent:r,onSuspend:V,onActivate:U,onAdjustTrust:z=>k({agentId:z,score:r.trust_score})})})]}),y&&c&&e.jsx(ke,{detail:c})]},r.agent_id)})})]})})}),e.jsx(J,{alerts:s,onResolve:Y})]}),S.agentsNeedingAttention.length>0&&e.jsxs("div",{style:{marginTop:16,background:t.card,border:`1px solid ${t.red}33`,borderRadius:6,padding:16},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:t.red,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"⚠ Agents Needing Attention"}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:S.agentsNeedingAttention.map(r=>e.jsxs("div",{style:{background:"rgba(248,113,113,0.06)",border:`1px solid ${t.red}22`,borderRadius:4,padding:"6px 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...x,fontSize:12,color:t.textPrimary,fontWeight:600},children:r.display_name}),e.jsx("span",{style:{fontSize:11,color:t.red},children:r.reason})]},r.agent_id))})]}),m&&e.jsx(Me,{agentId:m.agentId,currentScore:m.score,onSubmit:Z,onClose:()=>k(null)})]})}export{Re as FleetDashboardPage}; -//# sourceMappingURL=FleetDashboardPage-Cd5radQs.js.map +import{j as e,r as g,R as oe}from"./index-C0nK3ekl.js";import{f as T}from"./fleet-ClHE8wrR.js";const se={T0:"#10b981",T1:"#10b981",T2:"#fbbf24",T3:"#ef4444"},ie={T0:"AUTO_APPROVE",T1:"POLICY_GATE",T2:"HUMAN_GATE",T3:"STRICT_HALT"},d={card:"var(--bg-primary)",cardHover:"var(--bg-secondary)",border:"var(--border-subtle)",borderActive:"var(--border-default)",borderStrong:"var(--border-strong)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},le={active:d.green,idle:d.yellow,suspended:d.red,terminated:d.textMuted},de={"Active Warrant":d.green,"No Warrant":d.textMuted,Expired:d.red},P={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"};function ae(n){if(!n)return"never";const o=Date.now()-new Date(n).getTime();if(o<0)return"just now";const s=Math.floor(o/1e3);if(s<60)return`${s}s ago`;const l=Math.floor(s/60);if(l<60)return`${l}m ago`;const a=Math.floor(l/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function ce(n,o=3e5){return n?Date.now()-new Date(n).getTime()>o:!0}function xe(n){return n>70?d.green:n>=40?d.yellow:d.red}function ue({status:n}){const o=le[n]||d.textMuted,s=n==="active";return e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:o,boxShadow:s?`0 0 6px ${o}`:"none",animation:s?"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite":"none"}})}function G({text:n,color:o,small:s}){return e.jsx("span",{style:{...P,fontSize:s?9:10,fontWeight:600,color:o,background:`${o}18`,border:`1px solid ${o}33`,borderRadius:3,padding:s?"1px 4px":"2px 6px",textTransform:"uppercase",letterSpacing:"0.04em",whiteSpace:"nowrap"},children:n})}function pe({score:n}){const o=xe(n);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,width:"100%"},children:[e.jsx("div",{style:{flex:1,height:6,background:"rgba(255,255,255,0.08)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${n}%`,height:"100%",background:o,borderRadius:3,transition:"width 300ms ease"}})}),e.jsx("span",{style:{...P,fontSize:11,color:o,fontWeight:600,minWidth:24,textAlign:"right"},children:n})]})}function ge({agent:n,riskTier:o,warrantStatus:s,onClick:l,onAdjustTrust:a,onSuspend:p,onActivate:i}){const h=ce(n.last_heartbeat),v=se[o],C=ie[o];return e.jsxs("div",{onClick:l,style:{background:d.card,border:`1px solid ${d.border}`,borderLeft:`4px solid ${v}`,borderRadius:6,padding:16,cursor:l?"pointer":"default",transition:"all 200ms ease",display:"flex",flexDirection:"column",gap:12,height:"100%"},onMouseEnter:c=>{l&&(c.currentTarget.style.background=d.cardHover,c.currentTarget.style.borderColor=d.borderActive,c.currentTarget.style.boxShadow="0 8px 24px rgba(0,0,0,0.3)")},onMouseLeave:c=>{c.currentTarget.style.background=d.card,c.currentTarget.style.borderColor=d.border,c.currentTarget.style.boxShadow="none"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,minWidth:0},children:[e.jsx(ue,{status:n.status}),e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{style:{fontSize:15,fontWeight:700,color:d.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.display_name}),e.jsx("div",{style:{...P,fontSize:10,color:d.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.agent_id})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3,alignItems:"flex-end"},children:[e.jsx(G,{text:o,color:v,small:!0}),e.jsx("span",{style:{...P,fontSize:9,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.03em"},children:C})]})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:"Trust Score"}),e.jsx(pe,{score:n.trust_score})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Last Activity"}),e.jsx("span",{style:{...P,fontSize:11,color:h?d.red:d.textSecondary},children:ae(n.last_heartbeat)})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("div",{style:{fontSize:10,color:d.textMuted,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Warrant"}),e.jsx(G,{text:s,color:de[s]||d.textMuted})]}),e.jsxs("div",{style:{display:"flex",gap:6,marginTop:4},children:[n.status==="suspended"?e.jsx("button",{onClick:c=>{c.stopPropagation(),i==null||i()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.green}33`,background:"rgba(16,185,129,0.1)",color:d.green,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=`${d.green}66`,c.currentTarget.style.background="rgba(16,185,129,0.15)"},onMouseLeave:c=>{c.currentTarget.style.borderColor=`${d.green}33`,c.currentTarget.style.background="rgba(16,185,129,0.1)"},children:"⚡ Activate"}):e.jsx("button",{onClick:c=>{c.stopPropagation(),p==null||p()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.red}33`,background:"rgba(239,68,68,0.1)",color:d.red,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=`${d.red}66`,c.currentTarget.style.background="rgba(239,68,68,0.15)"},onMouseLeave:c=>{c.currentTarget.style.borderColor=`${d.red}33`,c.currentTarget.style.background="rgba(239,68,68,0.1)"},children:"⏸ Suspend"}),e.jsx("button",{onClick:c=>{c.stopPropagation(),a==null||a()},style:{flex:1,padding:"6px 10px",fontSize:11,fontWeight:600,border:`1px solid ${d.borderStrong}`,background:"transparent",color:d.textSecondary,borderRadius:4,cursor:"pointer",transition:"all 150ms ease"},onMouseEnter:c=>{c.currentTarget.style.borderColor=d.borderActive,c.currentTarget.style.color=d.textPrimary},onMouseLeave:c=>{c.currentTarget.style.borderColor=d.borderStrong,c.currentTarget.style.color=d.textSecondary},children:"🎚 Adjust"})]})]})}const u={card:"var(--bg-primary)",border:"var(--border-subtle)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",blue:"var(--info-text)",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},E={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"};function W({label:n,value:o,unit:s,color:l,secondaryValue:a,children:p}){return e.jsxs("div",{style:{background:u.card,border:`1px solid ${u.border}`,borderRadius:6,padding:"12px 16px",flex:"1 1 0",minWidth:140},children:[e.jsx("div",{style:{fontSize:10,color:u.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:4,marginBottom:4},children:[e.jsx("div",{style:{...E,fontSize:24,fontWeight:700,color:l||u.textPrimary,lineHeight:1},children:o}),s&&e.jsx("span",{style:{...E,fontSize:11,color:u.textSecondary,fontWeight:500},children:s})]}),a&&e.jsxs("div",{style:{...E,fontSize:10,color:u.textMuted,display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{children:a.label}),e.jsx("span",{children:a.value})]}),p]})}function ye({activeCount:n,idleCount:o,suspendedCount:s}){const l=n+o+s;if(l===0)return null;const a=n/l*100,p=o/l*100,i=s/l*100;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[e.jsxs("div",{style:{display:"flex",height:4,borderRadius:2,overflow:"hidden",flex:1,background:"rgba(255,255,255,0.08)"},children:[a>0&&e.jsx("div",{style:{width:`${a}%`,background:u.green}}),p>0&&e.jsx("div",{style:{width:`${p}%`,background:u.yellow}}),i>0&&e.jsx("div",{style:{width:`${i}%`,background:u.red}})]}),e.jsxs("div",{style:{display:"flex",gap:8,fontSize:9,color:u.textMuted,whiteSpace:"nowrap"},children:[e.jsxs("span",{style:{color:u.green},children:["●",n]}),e.jsxs("span",{style:{color:u.yellow},children:["●",o]}),e.jsxs("span",{style:{color:u.red},children:["●",s]})]})]})}function he({totalAgents:n,activeAgents:o,idleAgents:s,suspendedAgents:l,avgTrustScore:a,t0Count:p,t1Count:i,t2Count:h,t3Count:v,pendingApprovals:C,actionsToday:c,avgLatencyMs:M,unresolvedAlerts:m}){const k=a>70?u.green:a>=40?u.yellow:u.red;return e.jsxs("div",{style:{display:"flex",gap:10,marginBottom:16,flexWrap:"wrap"},children:[e.jsx(W,{label:"Total Agents",value:n,color:u.textPrimary,secondaryValue:{label:"Registered",value:n},children:e.jsx(ye,{activeCount:o,idleCount:s,suspendedCount:l})}),e.jsx(W,{label:"Avg Trust Score",value:Math.round(a),unit:"%",color:k,secondaryValue:{label:"Fleet health",value:k===u.green?"✓ Good":k===u.yellow?"⚠ Fair":"✗ Low"}}),e.jsx(W,{label:"Actions Today",value:c,color:u.blue,secondaryValue:{label:"Real-time",value:"flowing"}}),e.jsx(W,{label:"Avg Latency",value:M,unit:"ms",color:M>1e3?u.yellow:u.green,secondaryValue:{label:"Status",value:M>1e3?"⚠ Slow":"✓ Fast"}}),e.jsx(W,{label:"Unresolved Alerts",value:m,color:m>0?u.yellow:u.green,secondaryValue:{label:"Status",value:m>0?`${m} pending`:"All clear"}}),C>0&&e.jsx(W,{label:"⚡ Pending Approvals",value:C,color:u.yellow,secondaryValue:{label:"Status",value:"Awaiting"}})]})}const t={card:"var(--bg-primary)",cardHover:"var(--bg-secondary)",border:"var(--border-subtle)",borderActive:"var(--border-default)",green:"var(--success-text)",yellow:"var(--warning-text)",red:"var(--error-text)",blue:"var(--info-text)",amber:"var(--accent-primary)",cyan:"#06b6d4",textPrimary:"var(--text-primary)",textSecondary:"var(--text-secondary)",textMuted:"var(--text-tertiary)"},fe={active:t.green,idle:t.yellow,suspended:t.red,terminated:t.textMuted},I={info:t.blue,warning:t.yellow,critical:t.red},be={executed:t.green,approved:t.green,denied:t.yellow,failed:t.red,timeout:t.textMuted},me={autonomous:t.amber,"semi-autonomous":t.blue,supervised:t.cyan},x={fontFamily:"'JetBrains Mono', 'Fira Code', 'SF Mono', monospace"},ve=15e3;function H(n){if(!n)return"never";const o=Date.now()-new Date(n).getTime();if(o<0)return"just now";const s=Math.floor(o/1e3);if(s<60)return`${s}s ago`;const l=Math.floor(s/60);if(l<60)return`${l}m ago`;const a=Math.floor(l/60);return a<24?`${a}h ago`:`${Math.floor(a/24)}d ago`}function je(n,o=3e5){return n?Date.now()-new Date(n).getTime()>o:!0}function F(n){return n>70?t.green:n>=40?t.yellow:t.red}function B(n){return n>85?"T0":n>65?"T1":n>40?"T2":"T3"}function Se(n){if(n.warrant_status){if(n.warrant_status==="active")return"Active Warrant";if(n.warrant_status==="expired")return"Expired"}return"No Warrant"}function we({score:n}){const o=F(n);return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{width:60,height:6,background:"rgba(255,255,255,0.08)",borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${n}%`,height:"100%",background:o,borderRadius:3,transition:"width 300ms ease"}})}),e.jsx("span",{style:{...x,fontSize:11,color:o,fontWeight:600},children:n})]})}function Te({status:n}){const o=fe[n]||t.textMuted;return e.jsx("span",{style:{display:"inline-block",width:8,height:8,borderRadius:"50%",background:o,boxShadow:n==="active"?`0 0 6px ${o}`:"none"}})}function O({text:n,color:o}){return e.jsx("span",{style:{...x,fontSize:10,fontWeight:600,color:o,background:`${o}18`,border:`1px solid ${o}33`,borderRadius:3,padding:"1px 6px",textTransform:"uppercase",letterSpacing:"0.04em"},children:n})}function ke({detail:n}){const{metrics:o,recentActivity:s,alerts:l}=n,a=Object.entries(o.actionsByType).sort((i,h)=>h[1]-i[1]).slice(0,5),p=a.length>0?a[0][1]:1;return e.jsx("tr",{children:e.jsx("td",{colSpan:11,style:{padding:0,border:"none"},children:e.jsxs("div",{style:{background:"#161f2e",borderTop:`1px solid ${t.border}`,borderBottom:`1px solid ${t.border}`,padding:"16px 20px",display:"grid",gridTemplateColumns:"1fr 1fr 1.5fr",gap:20},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Metrics"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"6px 16px"},children:[["Actions/Day",o.actionsToday],["Actions/Week",o.actionsThisWeek],["Avg Latency",`${o.avgLatencyMs}ms`],["Approval %",`${o.approvalRate}%`],["Error %",`${o.errorRate}%`],["Denied %",`${o.deniedRate}%`]].map(([i,h])=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,color:t.textMuted},children:i}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary},children:h})]},i))}),e.jsxs("div",{style:{marginTop:12},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:6,letterSpacing:"0.05em"},children:"Top Actions"}),a.map(([i,h])=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:3},children:[e.jsx("span",{style:{...x,fontSize:10,color:t.textSecondary,width:120,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i}),e.jsx("div",{style:{flex:1,height:4,background:"rgba(255,255,255,0.06)",borderRadius:2},children:e.jsx("div",{style:{width:`${h/p*100}%`,height:"100%",background:t.blue,borderRadius:2}})}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted,width:24,textAlign:"right"},children:h})]},i))]})]}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:["Active Alerts (",l.length,")"]}),l.length===0?e.jsx("div",{style:{fontSize:12,color:t.textMuted},children:"No active alerts"}):l.slice(0,4).map(i=>e.jsxs("div",{style:{background:t.card,border:`1px solid ${I[i.severity]}33`,borderLeft:`3px solid ${I[i.severity]}`,borderRadius:4,padding:"6px 10px",marginBottom:6},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:2},children:[e.jsx(O,{text:i.severity,color:I[i.severity]}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted},children:i.alert_type})]}),e.jsx("div",{style:{fontSize:11,color:t.textSecondary,lineHeight:1.3},children:i.message})]},i.id))]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,textTransform:"uppercase",marginBottom:8,letterSpacing:"0.05em"},children:"Recent Activity"}),e.jsx("div",{style:{maxHeight:200,overflowY:"auto"},children:s.map(i=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 0",borderBottom:`1px solid ${t.border}`},children:[e.jsx(O,{text:i.result,color:be[i.result]||t.textMuted}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary,flex:1},children:i.action_type}),i.risk_tier&&e.jsx(O,{text:i.risk_tier,color:t.textSecondary}),e.jsxs("span",{style:{...x,fontSize:10,color:t.textMuted},children:[i.latency_ms,"ms"]}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted,width:55,textAlign:"right"},children:H(i.created_at)})]},i.id))})]})]})})})}function Ce({agent:n,onSuspend:o,onActivate:s,onAdjustTrust:l}){const[a,p]=g.useState(!1);return e.jsxs("div",{style:{position:"relative"},children:[e.jsx("button",{onClick:i=>{i.stopPropagation(),p(!a)},style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,cursor:"pointer",padding:"2px 6px",fontSize:14,lineHeight:1},children:"⋯"}),a&&e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{position:"absolute",right:0,top:"100%",marginTop:4,background:t.card,border:`1px solid ${t.borderActive}`,borderRadius:6,padding:4,zIndex:100,minWidth:140,boxShadow:"0 8px 24px rgba(0,0,0,0.4)"},children:[n.status==="suspended"?e.jsx(D,{label:"⚡ Activate",onClick:()=>{s(n.agent_id),p(!1)}}):e.jsx(D,{label:"⏸ Suspend",onClick:()=>{o(n.agent_id),p(!1)},color:t.red}),e.jsx(D,{label:"🎚 Adjust Trust",onClick:()=>{l(n.agent_id),p(!1)}})]})]})}function D({label:n,onClick:o,color:s}){return e.jsx("button",{onClick:o,style:{display:"block",width:"100%",textAlign:"left",background:"none",border:"none",color:s||t.textSecondary,fontSize:12,padding:"6px 10px",borderRadius:4,cursor:"pointer"},onMouseEnter:l=>{l.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:l=>{l.currentTarget.style.background="none"},children:n})}function J({alerts:n,onResolve:o}){return e.jsxs("div",{style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:6,padding:16,maxHeight:360,overflowY:"auto"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:e.jsxs("div",{style:{fontSize:13,fontWeight:600,color:t.textPrimary,textTransform:"uppercase",letterSpacing:"0.05em"},children:["🚨 Alerts (",n.length,")"]})}),n.length===0?e.jsx("div",{style:{fontSize:12,color:t.textMuted,textAlign:"center",padding:20},children:"All clear — no active alerts"}):n.map(s=>e.jsxs("div",{style:{borderLeft:`3px solid ${I[s.severity]}`,background:`${I[s.severity]}08`,borderRadius:4,padding:"8px 12px",marginBottom:8},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx(O,{text:s.severity,color:I[s.severity]}),e.jsx("span",{style:{...x,fontSize:11,color:t.textPrimary,fontWeight:600},children:s.agent_name||s.agent_id}),e.jsx("span",{style:{...x,fontSize:10,color:t.textMuted},children:s.alert_type})]}),e.jsx("button",{onClick:()=>o(s.id),style:{background:"none",border:`1px solid ${t.border}`,borderRadius:3,color:t.textMuted,fontSize:10,padding:"2px 8px",cursor:"pointer"},onMouseEnter:l=>{l.currentTarget.style.borderColor=t.green,l.currentTarget.style.color=t.green},onMouseLeave:l=>{l.currentTarget.style.borderColor=t.border,l.currentTarget.style.color=t.textMuted},children:"Resolve"})]}),e.jsx("div",{style:{fontSize:11,color:t.textSecondary,lineHeight:1.4},children:s.message}),e.jsx("div",{style:{...x,fontSize:10,color:t.textMuted,marginTop:4},children:H(s.created_at)})]},s.id))]})}function Me({agentId:n,currentScore:o,onSubmit:s,onClose:l}){const[a,p]=g.useState(o);return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:l,children:e.jsxs("div",{style:{background:t.card,border:`1px solid ${t.borderActive}`,borderRadius:8,padding:24,width:320,boxShadow:"0 16px 48px rgba(0,0,0,0.5)"},onClick:i=>i.stopPropagation(),children:[e.jsx("div",{style:{fontSize:14,fontWeight:600,color:t.textPrimary,marginBottom:4},children:"Adjust Trust Score"}),e.jsx("div",{style:{...x,fontSize:12,color:t.textMuted,marginBottom:16},children:n}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:16},children:[e.jsx("input",{type:"range",min:0,max:100,value:a,onChange:i=>p(parseInt(i.target.value)),style:{flex:1,accentColor:F(a)}}),e.jsx("span",{style:{...x,fontSize:18,fontWeight:700,color:F(a),width:36,textAlign:"right"},children:a})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:l,style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,fontSize:12,padding:"6px 14px",cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:()=>s(a),style:{background:t.blue,border:"none",borderRadius:4,color:"#fff",fontSize:12,fontWeight:600,padding:"6px 14px",cursor:"pointer"},children:"Apply"})]})]})})}function Re(){const[n,o]=g.useState(null),[s,l]=g.useState([]),[a,p]=g.useState(!0),[i,h]=g.useState(null),[v,C]=g.useState(null),[c,M]=g.useState(null),[m,k]=g.useState(null),[K,Q]=g.useState(new Date),[L,X]=g.useState(""),[R,q]=g.useState("all"),[j,_]=g.useState(new Set),[A,N]=g.useState("cards"),f=g.useCallback(async()=>{try{const[r,y]=await Promise.all([T.getOverview(),T.getAlerts()]);o(r),l(y),h(null),Q(new Date)}catch(r){h(r instanceof Error?r.message:"Failed to load fleet data")}finally{p(!1)}},[]);g.useEffect(()=>{f();const r=setInterval(f,ve);return()=>clearInterval(r)},[f]),g.useEffect(()=>{if(!v){M(null);return}T.getAgent(v).then(M).catch(()=>M(null))},[v]);const V=async r=>{await T.suspend(r),f()},U=async r=>{await T.activate(r),f()},Z=async r=>{m&&(await T.adjustTrust(m.agentId,r),k(null),f())},Y=async r=>{await T.resolveAlert(r),f()};if(a)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:400,color:t.textMuted},children:e.jsx("div",{style:{...x,fontSize:14},children:"Loading fleet data..."})});if(i||!n)return e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",minHeight:400},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:14,color:t.red,marginBottom:8},children:["⚠ ",i||"No data"]}),e.jsx("button",{onClick:f,style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,padding:"6px 14px",fontSize:12,cursor:"pointer"},children:"Retry"})]})});const{agents:b,summary:S}=n,w=b.filter(r=>!(L&&!r.display_name.toLowerCase().includes(L.toLowerCase())&&!r.agent_id.toLowerCase().includes(L.toLowerCase())||R!=="all"&&r.status!==R)),ee=r=>{_(y=>{const $=new Set(y);return $.has(r)?$.delete(r):$.add(r),$})},te=()=>{j.size===w.length?_(new Set):_(new Set(w.map(r=>r.agent_id)))},re=async()=>{if(confirm(`Suspend ${j.size} agents?`)){for(const r of j)await T.suspend(r);_(new Set),f()}},ne=async()=>{if(confirm(`Activate ${j.size} agents?`)){for(const r of j)await T.activate(r);_(new Set),f()}};return S.trendData.map(r=>r.count),e.jsxs("div",{style:{maxWidth:1400,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:16},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:18,fontWeight:700,color:t.textPrimary,margin:0,letterSpacing:"-0.01em"},children:"Agent Fleet"}),e.jsxs("div",{style:{...x,fontSize:11,color:t.textMuted,marginTop:2},children:["Governance Dashboard — ",S.totalAgents," agents registered"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("div",{style:{display:"flex",gap:2,background:"rgba(255,255,255,0.03)",borderRadius:4,padding:2},children:[e.jsx("button",{onClick:()=>N("cards"),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:A==="cards"?600:400,background:A==="cards"?"rgba(255,255,255,0.08)":"transparent",color:A==="cards"?t.textPrimary:t.textMuted},children:"⊞ Cards"}),e.jsx("button",{onClick:()=>N("table"),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:A==="table"?600:400,background:A==="table"?"rgba(255,255,255,0.08)":"transparent",color:A==="table"?t.textPrimary:t.textMuted},children:"▦ Table"})]}),e.jsxs("div",{style:{...x,fontSize:10,color:t.textMuted},children:["Updated ",K.toLocaleTimeString()]}),e.jsx("button",{onClick:f,style:{background:"none",border:`1px solid ${t.border}`,borderRadius:4,color:t.textSecondary,padding:"4px 10px",fontSize:11,cursor:"pointer"},onMouseEnter:r=>{r.currentTarget.style.borderColor=t.blue},onMouseLeave:r=>{r.currentTarget.style.borderColor=t.border},children:"↻ Refresh"})]})]}),e.jsx(he,{totalAgents:S.totalAgents,activeAgents:S.activeAgents,idleAgents:b.filter(r=>r.status==="idle").length,suspendedAgents:b.filter(r=>r.status==="suspended").length,avgTrustScore:b.length>0?b.reduce((r,y)=>r+y.trust_score,0)/b.length:0,t0Count:b.filter(r=>B(r.trust_score)==="T0").length,t1Count:b.filter(r=>B(r.trust_score)==="T1").length,t2Count:b.filter(r=>B(r.trust_score)==="T2").length,t3Count:b.filter(r=>B(r.trust_score)==="T3").length,pendingApprovals:0,actionsToday:S.actionsToday,avgLatencyMs:S.avgLatencyMs,unresolvedAlerts:S.unresolvedAlerts}),e.jsxs("div",{style:{display:"flex",gap:8,marginBottom:12,alignItems:"center",flexWrap:"wrap"},children:[e.jsx("input",{type:"text",placeholder:"Search agents...",value:L,onChange:r=>X(r.target.value),style:{padding:"6px 12px",fontSize:12,borderRadius:4,border:`1px solid ${t.border}`,background:"rgba(255,255,255,0.04)",color:t.textPrimary,width:200,fontFamily:"inherit",outline:"none"}}),e.jsx("div",{style:{display:"flex",gap:2,background:"rgba(255,255,255,0.03)",borderRadius:4,padding:2},children:[{key:"all",label:"All"},{key:"active",label:"🟢 Active"},{key:"idle",label:"🟡 Idle"},{key:"suspended",label:"🔴 Suspended"}].map(r=>e.jsx("button",{onClick:()=>q(r.key),style:{padding:"4px 10px",fontSize:11,borderRadius:3,border:"none",cursor:"pointer",fontWeight:R===r.key?600:400,background:R===r.key?"rgba(255,255,255,0.08)":"transparent",color:R===r.key?t.textPrimary:t.textMuted},children:r.label},r.key))}),(L||R!=="all")&&e.jsxs("span",{style:{...x,fontSize:10,color:t.textMuted},children:[w.length," of ",b.length]})]}),j.size>0&&e.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginBottom:12,padding:"8px 12px",background:"rgba(59,130,246,0.08)",borderRadius:6,border:"1px solid rgba(59,130,246,0.15)"},children:[e.jsxs("span",{style:{fontSize:12,color:t.blue,fontWeight:600},children:[j.size," selected"]}),e.jsx("button",{onClick:ne,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid rgba(16,185,129,0.3)",background:"rgba(16,185,129,0.1)",color:t.green,cursor:"pointer",fontWeight:500},children:"⚡ Activate All"}),e.jsx("button",{onClick:re,style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:"1px solid rgba(239,68,68,0.3)",background:"rgba(239,68,68,0.1)",color:t.red,cursor:"pointer",fontWeight:500},children:"⏸ Suspend All"}),e.jsx("button",{onClick:()=>_(new Set),style:{padding:"4px 10px",fontSize:11,borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.textMuted,cursor:"pointer"},children:"Clear"})]}),A==="cards"?e.jsxs("div",{style:{display:"grid",gridTemplateColumns:window.innerWidth>768?"1fr 340px":"1fr",gap:16},children:[e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:w.length===0?e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",alignItems:"center",justifyContent:"center",minHeight:300,color:t.textMuted,flexDirection:"column",gap:12},children:[e.jsx("div",{style:{fontSize:16},children:"📭"}),e.jsx("div",{style:{fontSize:14,fontWeight:600},children:"No agents registered yet"}),e.jsx("div",{style:{fontSize:11,color:t.textMuted},children:'Connect your first agent to get started. Click "Connect Agent" in settings.'})]}):w.map(r=>e.jsx(ge,{agent:r,riskTier:B(r.trust_score),warrantStatus:Se(r),onClick:()=>C(r.agent_id===v?null:r.agent_id),onAdjustTrust:()=>k({agentId:r.agent_id,score:r.trust_score}),onSuspend:()=>V(r.agent_id),onActivate:()=>U(r.agent_id)},r.agent_id))}),e.jsx(J,{alerts:s,onResolve:Y})]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:window.innerWidth>768?"1fr 340px":"1fr",gap:16},children:[e.jsx("div",{style:{background:t.card,border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden"},children:e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",minWidth:"800px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:`1px solid ${t.border}`},children:[e.jsx("th",{style:{padding:"10px 10px",width:28},children:e.jsx("input",{type:"checkbox",checked:w.length>0&&j.size===w.length,onChange:te,style:{cursor:"pointer",accentColor:t.blue}})}),["","Agent","Type","Trust","Actions","Latency","Errors","Alerts","Last Seen",""].map((r,y)=>e.jsx("th",{style:{textAlign:"left",padding:"10px 10px",fontSize:10,fontWeight:600,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.06em",whiteSpace:"nowrap",...y===0?{width:24}:{}},children:r},y))]})}),e.jsx("tbody",{children:w.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:11,style:{padding:"40px 20px",textAlign:"center",color:t.textMuted},children:[e.jsx("div",{style:{fontSize:14,marginBottom:8},children:"No agents registered"}),e.jsx("div",{style:{fontSize:11,color:t.textMuted},children:"Agents will appear here once they connect to Vienna OS"})]})}):w.map(r=>{const y=v===r.agent_id,$=je(r.last_heartbeat);return e.jsxs(oe.Fragment,{children:[e.jsxs("tr",{onClick:()=>C(y?null:r.agent_id),style:{borderBottom:`1px solid ${t.border}`,cursor:"pointer",background:y?"#161f2e":"transparent",transition:"background 150ms"},onMouseEnter:z=>{y||(z.currentTarget.style.background=t.cardHover)},onMouseLeave:z=>{y||(z.currentTarget.style.background="transparent")},children:[e.jsx("td",{style:{padding:"8px 10px",textAlign:"center"},onClick:z=>z.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:j.has(r.agent_id),onChange:()=>ee(r.agent_id),style:{cursor:"pointer",accentColor:t.blue}})}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"center"},children:e.jsx(Te,{status:r.status})}),e.jsxs("td",{style:{padding:"8px 10px"},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:t.textPrimary,lineHeight:1.2},children:r.display_name}),e.jsx("div",{style:{...x,fontSize:10,color:t.textMuted},children:r.agent_id})]}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx(O,{text:r.agent_type,color:me[r.agent_type]||t.textMuted})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx(we,{score:r.trust_score})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx("span",{style:{...x,fontSize:12,color:t.textPrimary},children:r.actions_today})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsxs("span",{style:{...x,fontSize:12,color:r.avg_latency_ms>1e3?t.yellow:t.textSecondary},children:[r.avg_latency_ms,"ms"]})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsxs("span",{style:{...x,fontSize:12,color:r.error_rate>10?t.red:t.textSecondary},children:[r.error_rate,"%"]})}),e.jsx("td",{style:{padding:"8px 10px"},children:r.unresolved_alerts>0?e.jsx("span",{style:{...x,fontSize:12,color:t.yellow,fontWeight:700},children:r.unresolved_alerts}):e.jsx("span",{style:{...x,fontSize:12,color:t.textMuted},children:"0"})}),e.jsx("td",{style:{padding:"8px 10px"},children:e.jsx("span",{style:{...x,fontSize:11,color:$?t.red:t.textMuted},children:H(r.last_heartbeat)})}),e.jsx("td",{style:{padding:"8px 10px",textAlign:"right"},children:e.jsx(Ce,{agent:r,onSuspend:V,onActivate:U,onAdjustTrust:z=>k({agentId:z,score:r.trust_score})})})]}),y&&c&&e.jsx(ke,{detail:c})]},r.agent_id)})})]})})}),e.jsx(J,{alerts:s,onResolve:Y})]}),S.agentsNeedingAttention.length>0&&e.jsxs("div",{style:{marginTop:16,background:t.card,border:`1px solid ${t.red}33`,borderRadius:6,padding:16},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:t.red,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"⚠ Agents Needing Attention"}),e.jsx("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:S.agentsNeedingAttention.map(r=>e.jsxs("div",{style:{background:"rgba(248,113,113,0.06)",border:`1px solid ${t.red}22`,borderRadius:4,padding:"6px 12px",display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{...x,fontSize:12,color:t.textPrimary,fontWeight:600},children:r.display_name}),e.jsx("span",{style:{fontSize:11,color:t.red},children:r.reason})]},r.agent_id))})]}),m&&e.jsx(Me,{agentId:m.agentId,currentScore:m.score,onSubmit:Z,onClose:()=>k(null)})]})}export{Re as FleetDashboardPage}; +//# sourceMappingURL=FleetDashboardPage-nC3mT2F1.js.map diff --git a/apps/console-proxy/public/assets/FleetPremium-DwUXznBp.js b/apps/console-proxy/public/assets/FleetPremium-DwUXznBp.js deleted file mode 100644 index d121ca53..00000000 --- a/apps/console-proxy/public/assets/FleetPremium-DwUXznBp.js +++ /dev/null @@ -1,2 +0,0 @@ -import{u as k,r as o,j as e,w as A}from"./index-D_7YXFSJ.js";import{f as L}from"./fleet-Bmy_93a8.js";function D(){var v;const a=k(),[s,d]=o.useState([]),[r,x]=o.useState(null),[g,j]=o.useState(!0),[h,f]=o.useState(!1),c=o.useCallback(async(t=!1)=>{t&&f(!0);try{const l=await L.getOverview();d(l.agents||[]),x(l.summary||null)}catch(l){console.error("Fleet load failed:",l)}finally{j(!1),f(!1)}},[]);o.useEffect(()=>{c()},[c]),o.useEffect(()=>{const t=setInterval(()=>c(),3e4);return()=>clearInterval(t)},[c]);const n=s.length,m=s.filter(t=>t.status==="active").length,u=s.filter(t=>t.status==="idle").length,p=s.filter(t=>t.status==="suspended").length,N=n>0?(s.reduce((t,l)=>t+(l.trust_score||0),0)/n).toFixed(1):"0.0",w=(r==null?void 0:r.actionsToday)??s.reduce((t,l)=>t+(l.actions_today||0),0),C=((v=r==null?void 0:r.avgLatencyMs)==null?void 0:v.toFixed(1))??"—";return g?e.jsx("div",{className:"flex items-center justify-center py-24",children:e.jsx("div",{className:"w-8 h-8 border-2 rounded-full animate-spin",style:{borderColor:"var(--border-subtle)",borderTopColor:"var(--accent-primary)"}})}):e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs("div",{className:"space-y-6 max-w-[1440px] mx-auto",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-bold tracking-tight",style:{color:"var(--text-primary)"},children:"Fleet Console"}),e.jsxs("p",{className:"text-[11px] uppercase tracking-widest mt-0.5",style:{color:"var(--text-muted)"},children:[n," agents registered"]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"px-3 py-1.5 rounded flex items-center gap-2",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse"}),e.jsx("span",{className:"text-xs font-mono text-emerald-500 uppercase tracking-wider",children:"Live"})]}),e.jsx("button",{onClick:()=>c(!0),disabled:h,className:"p-2 rounded-lg transition-colors hover:opacity-80",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:e.jsx(A,{size:16,className:h?"animate-spin":"",style:{color:"var(--text-tertiary)"}})}),e.jsx("button",{onClick:()=>a("/connect"),className:"px-3 py-1.5 text-xs font-semibold rounded-md transition-colors",style:{background:"var(--accent-primary)",color:"#000"},children:"+ Connect Agent"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-2.5",children:[e.jsxs(i,{label:"Total Agents",value:`${n}`,children:[e.jsxs("div",{className:"flex h-1 rounded-full overflow-hidden mt-2",style:{background:"var(--border-subtle)"},children:[m>0&&e.jsx("div",{className:"bg-emerald-500",style:{width:`${m/Math.max(n,1)*100}%`}}),u>0&&e.jsx("div",{className:"bg-amber-500",style:{width:`${u/Math.max(n,1)*100}%`}}),p>0&&e.jsx("div",{className:"bg-red-500",style:{width:`${p/Math.max(n,1)*100}%`}})]}),e.jsxs("div",{className:"flex gap-3 text-[9px] font-mono mt-1.5",style:{color:"var(--text-muted)"},children:[e.jsxs("span",{className:"text-emerald-500",children:["● ",m," ACT"]}),e.jsxs("span",{className:"text-amber-500",children:["● ",u," IDL"]}),e.jsxs("span",{className:"text-red-500",children:["● ",p," SUS"]})]})]}),e.jsx(i,{label:"Avg Trust",value:`${N}`,suffix:"%",valueColor:"text-emerald-500"}),e.jsx(i,{label:"Actions (24h)",value:w.toLocaleString(),valueColor:"text-blue-500"}),e.jsx(i,{label:"Fleet Latency",value:C,suffix:"ms"}),e.jsx(i,{label:"Total Warrants",value:((r==null?void 0:r.actionsToday)??0).toLocaleString(),valueColor:"text-amber-500"})]}),e.jsx("div",{className:"rounded-lg overflow-hidden",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:s.length===0?e.jsxs("div",{className:"p-12 text-center",children:[e.jsx("p",{className:"text-sm mb-2",style:{color:"var(--text-tertiary)"},children:"No agents registered yet"}),e.jsx("button",{onClick:()=>a("/connect"),className:"text-sm underline",style:{color:"var(--accent-primary)"},children:"Connect your first agent →"})]}):e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:["Status","Agent ID","Name","Trust","Actions (24h)","Last Heartbeat","Latency",""].map(t=>e.jsx("th",{className:`py-3 px-4 text-[11px] font-semibold uppercase tracking-wider ${t==="Trust"||t==="Actions (24h)"||t==="Latency"?"text-right":"text-left"}`,style:{color:"var(--text-muted)"},children:t},t))})}),e.jsx("tbody",{children:s.map((t,l)=>{var y,b;return e.jsxs("tr",{className:"transition-colors hover:opacity-90 cursor-pointer",style:{borderBottom:"1px solid var(--border-subtle)",background:l%2===0?"transparent":"rgba(255, 255, 255, 0.02)"},onClick:()=>a(`/fleet/${t.agent_id}`),children:[e.jsx("td",{className:"py-2 px-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${S(t.status)}`}),e.jsx("span",{className:"text-[10px] font-mono font-semibold uppercase",style:{color:"var(--text-tertiary)"},children:_(t.status)})]})}),e.jsx("td",{className:"py-2 px-4",children:e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--accent-primary)"},children:t.agent_id})}),e.jsx("td",{className:"py-2 px-4",children:e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-primary)"},children:t.display_name||t.agent_id})}),e.jsx("td",{className:"py-2 px-4 text-right",children:e.jsxs("span",{className:`font-mono text-xs font-medium ${$(t.trust_score)}`,children:[((y=t.trust_score)==null?void 0:y.toFixed(1))??"—","%"]})}),e.jsx("td",{className:"py-2 px-4 text-right",children:e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-secondary)"},children:(t.actions_today??0).toLocaleString()})}),e.jsx("td",{className:"py-2 px-4",children:e.jsx("span",{className:"font-mono text-xs",style:{color:"var(--text-muted)"},children:t.last_heartbeat?T(t.last_heartbeat):"—"})}),e.jsx("td",{className:"py-2 px-4 text-right",children:e.jsxs("span",{className:"font-mono text-xs",style:{color:"var(--text-tertiary)"},children:[((b=t.avg_latency_ms)==null?void 0:b.toFixed(0))??"—","ms"]})}),e.jsx("td",{className:"py-2 px-4 text-right",children:e.jsx("button",{className:"text-xs font-medium",style:{color:"var(--accent-primary)"},children:"Details →"})})]},t.id||t.agent_id)})})]})})]})})})}function i({label:a,value:s,suffix:d,valueColor:r,children:x}){return e.jsxs("div",{className:"rounded-md p-3.5 flex flex-col",style:{background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)"},children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-wider mb-2",style:{color:"var(--text-muted)"},children:a}),e.jsxs("div",{className:"flex items-baseline gap-1",children:[e.jsx("span",{className:`font-mono text-2xl font-bold ${r||""}`,style:r?{}:{color:"var(--text-primary)"},children:s}),d&&e.jsx("span",{className:"font-mono text-[11px]",style:{color:"var(--text-tertiary)"},children:d})]}),x]})}function S(a){switch(a){case"active":return"bg-emerald-500";case"idle":return"bg-amber-500";case"suspended":return"bg-red-500";default:return"bg-gray-500"}}function _(a){switch(a){case"active":return"ACT";case"idle":return"IDL";case"suspended":return"SUS";default:return"UNK"}}function $(a){return a?a>=95?"text-emerald-500":a>=85?"text-amber-500":"text-red-500":""}function T(a){const s=Date.now()-new Date(a).getTime();return s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:s<864e5?`${Math.floor(s/36e5)}h ago`:`${Math.floor(s/864e5)}d ago`}export{D as default}; -//# sourceMappingURL=FleetPremium-DwUXznBp.js.map diff --git a/apps/console-proxy/public/assets/GovernanceChainPage-BrCtXDQy.js b/apps/console-proxy/public/assets/GovernanceChainPage-BrCtXDQy.js deleted file mode 100644 index f81a41e2..00000000 --- a/apps/console-proxy/public/assets/GovernanceChainPage-BrCtXDQy.js +++ /dev/null @@ -1,2 +0,0 @@ -import{a as _,r as m,j as e,S as y,v as j,w as E,C as f,T as I,Z as N,F as A,x as $}from"./index-D_7YXFSJ.js";import{E as O}from"./eye-46CiQ26c.js";import{L as R}from"./lock-BIMZjRC7.js";import{C as D}from"./circle-x-DJXSWLrE.js";import{C as F}from"./clock-DwbEOyPD.js";async function G(a="24h"){return _.get("/governance",{range:a})}async function L(a,o){const s={};return _.get(`/governance/chain/${a}`,s)}const w={intent:{icon:N,label:"Intent Submitted",color:"text-blue-400",bgColor:"bg-blue-500/10"},policy:{icon:A,label:"Policy Evaluated",color:"text-amber-400",bgColor:"bg-amber-500/10"},approval:{icon:f,label:"Approval",color:"text-amber-400",bgColor:"bg-amber-500/10"},warrant:{icon:R,label:"Warrant Issued",color:"text-green-400",bgColor:"bg-green-500/10"},execution:{icon:N,label:"Executed",color:"text-cyan-400",bgColor:"bg-cyan-500/10"},verification:{icon:O,label:"Verified",color:"text-amber-400",bgColor:"bg-amber-500/10"},attestation:{icon:y,label:"Attested",color:"text-emerald-400",bgColor:"bg-emerald-500/10"}},u={T0:"text-green-400 bg-green-500/10 border-green-500/30",T1:"text-amber-400 bg-amber-500/10 border-amber-500/30",T2:"text-red-400 bg-red-500/10 border-red-500/30",T3:"text-amber-400 bg-amber-500/10 border-amber-500/30"};function P({step:a}){const[o,s]=m.useState(!1),l=w[a.type]||w.intent,x=l.icon,p=a.status==="completed"?e.jsx(f,{className:"w-4 h-4 text-green-400"}):a.status==="failed"?e.jsx(D,{className:"w-4 h-4 text-red-400"}):a.status==="pending"?e.jsx(F,{className:"w-4 h-4 text-amber-400 animate-pulse"}):e.jsx("div",{className:"w-4 h-4 rounded-full bg-[var(--bg-tertiary)]"});return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-6 top-12 bottom-0 w-px bg-[var(--border-subtle)]"}),e.jsxs("div",{className:`p-4 rounded-lg border cursor-pointer transition-all ${a.status==="completed"?"border-[var(--border-default)] bg-[var(--bg-secondary)]":a.status==="failed"?"border-red-500/30 bg-red-500/5":a.status==="pending"?"border-amber-500/30 bg-amber-500/5":"border-[var(--border-subtle)] bg-[var(--bg-primary)] opacity-50"}`,onClick:()=>s(!o),children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`p-2 rounded-lg ${l.bgColor}`,children:e.jsx(x,{className:`w-5 h-5 ${l.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-[var(--text-primary)]",children:l.label}),p,a.duration_ms!==void 0&&e.jsx("span",{className:"text-xs text-[var(--text-tertiary)]",children:a.duration_ms<1e3?`${a.duration_ms}ms`:`${(a.duration_ms/1e3).toFixed(1)}s`})]}),e.jsx("div",{className:"text-sm text-[var(--text-secondary)] truncate",children:a.id})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)]",children:new Date(a.timestamp).toLocaleTimeString()}),e.jsx($,{className:`w-4 h-4 text-[var(--text-tertiary)] transition-transform ${o?"rotate-90":""}`})]}),o&&e.jsx("div",{className:"mt-3 pt-3 border-t border-[var(--border-subtle)]",children:e.jsx("pre",{className:"text-xs text-[var(--text-secondary)] bg-[var(--bg-primary)] p-3 rounded overflow-x-auto",children:JSON.stringify(a.data,null,2)})})]})]})}function X(){const[a,o]=m.useState(""),[s,l]=m.useState(null),[x,p]=m.useState(!1),[v,C]=m.useState([]);m.useEffect(()=>{S()},[]);async function S(){try{const t=(await G("24h")).recentChains.map(n=>{var c,g,b;return{intent_id:n.intent_id,agent_id:n.agent_id,action:n.action_type,risk_tier:((b=(g=(c=n.warrants)==null?void 0:c[0])==null?void 0:g.risk_tier)==null?void 0:b.toString())||"T0",steps:[],total_duration_ms:0,chain_valid:!0}});C(t)}catch{}}async function h(i){p(!0);try{const t=await L(i);if(!t){l(null);return}const n=[];let c="T0",g=(t==null?void 0:t.agent_id)||"unknown",b=(t==null?void 0:t.action_type)||"unknown";if(t!=null&&t.intent){const r=t.intent;n.push({id:r.id||"intent-"+Date.now(),type:"intent",status:"completed",timestamp:r.created_at||new Date().toISOString(),data:r})}(Array.isArray(t==null?void 0:t.evaluations)?t.evaluations:[]).forEach(r=>{n.push({id:r.id||"eval-"+Date.now(),type:"policy",status:r.result==="deny"?"failed":"completed",timestamp:r.evaluated_at||new Date().toISOString(),data:r})}),(Array.isArray(t==null?void 0:t.warrants)?t.warrants:[]).forEach(r=>{var d;c=((d=r.risk_tier)==null?void 0:d.toString())||c,n.push({id:r.id||"warrant-"+Date.now(),type:"warrant",status:r.status==="active"?"completed":"failed",timestamp:r.created_at||new Date().toISOString(),data:r})}),(Array.isArray(t==null?void 0:t.executions)?t.executions:[]).forEach(r=>{const d=String(r.event_type||"");n.push({id:r.execution_id||"exec-"+Date.now(),type:"execution",status:d.includes("failed")?"failed":"completed",timestamp:r.timestamp||new Date().toISOString(),data:r})}),n.sort((r,d)=>new Date(r.timestamp).getTime()-new Date(d.timestamp).getTime());const T=n[0]?new Date(n[0].timestamp).getTime():0,k=n[n.length-1]?new Date(n[n.length-1].timestamp).getTime():0;l({intent_id:i,agent_id:g,action:b,risk_tier:c,steps:n,total_duration_ms:k-T,chain_valid:n.every(r=>r.status!=="failed")})}catch(t){console.error("Failed to load governance chain:",t)}finally{p(!1)}}return e.jsxs("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-[var(--text-primary)] flex items-center gap-3",children:[e.jsx(y,{className:"w-7 h-7 text-amber-400"}),"Governance Chain"]}),e.jsx("p",{className:"text-[var(--text-secondary)] mt-1",children:"Trace any action through the complete authorization chain — from intent to attestation."})]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"flex-1 relative",children:[e.jsx(j,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-tertiary)]"}),e.jsx("input",{type:"text",placeholder:"Enter intent ID (e.g., int_1711900000_abc123)",value:a,onChange:i=>o(i.target.value),onKeyDown:i=>i.key==="Enter"&&a&&h(a),className:"w-full pl-10 pr-4 py-2.5 bg-[var(--bg-secondary)] border border-[var(--border-default)] rounded-lg text-[var(--text-primary)] placeholder:text-[var(--text-tertiary)] focus:outline-none focus:ring-2 focus:ring-[var(--accent-primary)]/50"})]}),e.jsxs("button",{onClick:()=>a&&h(a),disabled:x||!a,className:"px-4 py-2.5 bg-[var(--accent-primary)] text-white rounded-lg font-medium disabled:opacity-50 transition-colors hover:bg-[var(--accent-secondary)] flex items-center gap-2",children:[x?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(j,{className:"w-4 h-4"}),"Trace"]})]}),s&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 bg-[var(--bg-secondary)] border border-[var(--border-default)] rounded-lg",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`px-3 py-1 rounded-full border text-sm font-mono ${u[s.risk_tier]||u.T0}`,children:s.risk_tier}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-[var(--text-primary)]",children:s.action}),e.jsxs("div",{className:"text-sm text-[var(--text-secondary)]",children:["Agent: ",s.agent_id," · ",s.steps.length," steps · ",s.total_duration_ms,"ms total"]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:s.chain_valid?e.jsxs("div",{className:"flex items-center gap-1.5 text-green-400 text-sm",children:[e.jsx(f,{className:"w-4 h-4"}),"Chain Valid"]}):e.jsxs("div",{className:"flex items-center gap-1.5 text-red-400 text-sm",children:[e.jsx(I,{className:"w-4 h-4"}),"Chain Broken"]})})]}),e.jsx("div",{className:"space-y-3 pl-2",children:s.steps.map((i,t)=>e.jsx(P,{step:i},`${i.type}-${t}`))}),s.steps.length>0&&s.steps.length<7&&e.jsxs("div",{className:"p-3 bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg text-sm text-[var(--text-tertiary)]",children:[7-s.steps.length," step(s) not yet recorded in audit trail. The full chain is: Intent → Policy → Approval → Warrant → Execution → Verification → Attestation"]})]}),!s&&v.length>0&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:"Recent Intents"}),v.map((i,t)=>e.jsx("button",{onClick:()=>{o(i.intent_id),h(i.intent_id)},className:"w-full p-3 bg-[var(--bg-secondary)] border border-[var(--border-default)] rounded-lg text-left hover:bg-[var(--bg-hover)] transition-colors",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:`px-2 py-0.5 rounded text-xs font-mono ${u[i.risk_tier]||u.T0}`,children:i.risk_tier}),e.jsx("span",{className:"font-mono text-sm text-[var(--text-primary)]",children:i.intent_id}),e.jsx("span",{className:"text-sm text-[var(--text-secondary)]",children:i.action})]})},t))]}),!s&&v.length===0&&!x&&e.jsxs("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[e.jsx(y,{className:"w-12 h-12 mx-auto mb-4 opacity-30"}),e.jsx("p",{className:"text-lg",children:"Enter an intent ID to trace its governance chain"}),e.jsx("p",{className:"text-sm mt-2",children:"Every action in Vienna OS has a complete, cryptographically verifiable authorization chain."})]})]})}export{X as GovernanceChainPage,X as default}; -//# sourceMappingURL=GovernanceChainPage-BrCtXDQy.js.map diff --git a/apps/console-proxy/public/assets/GovernanceLivePage-BuoY7Y-J.js b/apps/console-proxy/public/assets/GovernanceLivePage-BuoY7Y-J.js deleted file mode 100644 index 0e342c55..00000000 --- a/apps/console-proxy/public/assets/GovernanceLivePage-BuoY7Y-J.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as x,j as e,Z as C,U as S,S as I,T as v,C as j}from"./index-D_7YXFSJ.js";import{A as h}from"./activity-C-iTiNlh.js";import{L as E}from"./lock-BIMZjRC7.js";import{E as T}from"./eye-46CiQ26c.js";import{T as N}from"./trending-up-xPmnKzgu.js";import{C as R}from"./clock-DwbEOyPD.js";import{C as D}from"./circle-x-DJXSWLrE.js";const $={"intent.submitted":{icon:C,label:"Intent Submitted",color:"text-blue-400",bgColor:"bg-blue-500/10"},"intent.approved":{icon:j,label:"Intent Approved",color:"text-green-400",bgColor:"bg-green-500/10"},"intent.denied":{icon:D,label:"Intent Denied",color:"text-red-400",bgColor:"bg-red-500/10"},"warrant.issued":{icon:E,label:"Warrant Issued",color:"text-amber-400",bgColor:"bg-amber-500/10"},"warrant.expired":{icon:R,label:"Warrant Expired",color:"text-amber-400",bgColor:"bg-amber-500/10"},"warrant.tampered":{icon:v,label:"TAMPER DETECTED",color:"text-red-500",bgColor:"bg-red-500/20"},"approval.required":{icon:T,label:"Approval Required",color:"text-amber-400",bgColor:"bg-amber-500/10"},"approval.resolved":{icon:j,label:"Approval Resolved",color:"text-green-400",bgColor:"bg-green-500/10"},"agent.registered":{icon:S,label:"Agent Registered",color:"text-cyan-400",bgColor:"bg-cyan-500/10"},"execution.started":{icon:h,label:"Execution Started",color:"text-amber-400",bgColor:"bg-amber-500/10"},"execution.completed":{icon:j,label:"Execution Completed",color:"text-green-400",bgColor:"bg-green-500/10"},"execution.scope_drift":{icon:v,label:"Scope Drift!",color:"text-red-400",bgColor:"bg-red-500/10"},"anomaly.detected":{icon:v,label:"Anomaly Detected",color:"text-orange-400",bgColor:"bg-orange-500/10"}},k={T0:"bg-green-500/20 text-green-400 border-green-500/30",T1:"bg-amber-500/20 text-amber-400 border-amber-500/30",T2:"bg-red-500/20 text-red-400 border-red-500/30",T3:"bg-amber-500/20 text-amber-400 border-amber-500/30"};function g({icon:i,label:o,value:c,trend:n,color:l}){return e.jsxs("div",{className:"bg-[var(--bg-secondary)] border border-[var(--border-default)] rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx(i,{className:`w-5 h-5 ${l}`}),n==="up"&&e.jsx(N,{className:"w-4 h-4 text-green-400"}),n==="down"&&e.jsx(N,{className:"w-4 h-4 text-red-400 rotate-180"})]}),e.jsx("div",{className:"text-2xl font-bold text-[var(--text-primary)]",children:c}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] mt-1",children:o})]})}function L({event:i}){const o=$[i.type]||{icon:h,label:i.type,color:"text-slate-400",bgColor:"bg-slate-500/10"},c=o.icon,n=i.data||{},l=n.risk_tier||"",b=n.agent_id||"",d=n.warrant_id||"",u=n.action||"";return e.jsxs("div",{className:"flex items-center gap-3 p-3 bg-[var(--bg-secondary)] border border-[var(--border-subtle)] rounded-lg animate-in fade-in slide-in-from-top-2 duration-300",children:[e.jsx("div",{className:`p-1.5 rounded ${o.bgColor}`,children:e.jsx(c,{className:`w-4 h-4 ${o.color}`})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`font-medium text-sm ${o.color}`,children:o.label}),l&&e.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded border ${k[l]||""}`,children:l})]}),e.jsxs("div",{className:"text-xs text-[var(--text-tertiary)] truncate",children:[b&&e.jsxs("span",{children:["Agent: ",b]}),u&&e.jsxs("span",{children:[" · ",u]}),d&&e.jsxs("span",{children:[" · ",d.slice(0,16)]})]})]}),e.jsx("div",{className:"text-xs text-[var(--text-tertiary)] whitespace-nowrap",children:new Date(i.timestamp).toLocaleTimeString()})]})}function J(){const[i,o]=x.useState([]),[c,n]=x.useState({intents_per_minute:0,warrants_active:0,approvals_pending:0,agents_active:0,chain_length:0,anomalies_24h:0}),[l,b]=x.useState(!1),[d,u]=x.useState(!1),A=x.useRef(null),y=100;x.useEffect(()=>{const t=new EventSource("/api/v1/stream");A.current=t,t.onopen=()=>b(!0),t.onerror=()=>b(!1),t.onmessage=a=>{try{const r=JSON.parse(a.data);if(r.type==="heartbeat")return;const m={id:r.id||`evt_${Date.now()}`,type:r.type||r.event||"unknown",timestamp:r.timestamp||new Date().toISOString(),data:r.data||r};d||(o(p=>[m,...p].slice(0,y)),w(m))}catch{}};const s=["intent.submitted","intent.approved","intent.denied","warrant.issued","warrant.expired","approval.required","approval.resolved","agent.registered","execution.started","execution.completed"];for(const a of s)t.addEventListener(a,r=>{try{const m=JSON.parse(r.data),p={id:`${a}_${Date.now()}`,type:a,timestamp:new Date().toISOString(),data:m};d||(o(f=>[p,...f].slice(0,y)),w(p))}catch{}});return()=>t.close()},[d]),x.useEffect(()=>{fetch("/api/v1/governance?range=24h",{credentials:"include"}).then(t=>t.json()).then(t=>{if(t.success&&t.data){const s=t.data;n(a=>{var r,m,p;return{...a,warrants_active:((r=s.warrantStatus)==null?void 0:r.reduce((f,_)=>f+(_.status==="active"?parseInt(_.count,10):0),0))||0,approvals_pending:(m=s.chainStats)!=null&&m.pending_chains?parseInt(s.chainStats.pending_chains,10):0,chain_length:(p=s.chainStats)!=null&&p.completed_chains?parseInt(s.chainStats.completed_chains,10):0}})}}).catch(()=>{}),fetch("/api/v1/fleet/agents",{credentials:"include"}).then(t=>t.json()).then(t=>{t.success&&t.data&&n(s=>({...s,agents_active:t.data.length||0}))}).catch(()=>{})},[]);const w=x.useCallback(t=>{n(s=>{const a={...s};return t.type.includes("intent.submitted")&&a.intents_per_minute++,t.type.includes("warrant.issued")&&a.warrants_active++,t.type.includes("warrant.expired")&&(a.warrants_active=Math.max(0,a.warrants_active-1)),t.type.includes("approval.required")&&a.approvals_pending++,t.type.includes("approval.resolved")&&(a.approvals_pending=Math.max(0,a.approvals_pending-1)),t.type.includes("anomaly")&&a.anomalies_24h++,t.type.includes("warrant")&&t.type.includes("chained")&&a.chain_length++,a})},[]);return e.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-[var(--text-primary)] flex items-center gap-3",children:[e.jsx(h,{className:"w-7 h-7 text-amber-400"}),"Governance Live"]}),e.jsx("p",{className:"text-[var(--text-secondary)] mt-1",children:"Real-time governance pipeline activity"})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:`flex items-center gap-2 text-sm ${l?"text-green-400":"text-red-400"}`,children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${l?"bg-green-400 animate-pulse":"bg-red-400"}`}),l?"Connected":"Disconnected"]}),e.jsx("button",{onClick:()=>u(!d),className:`px-3 py-1.5 rounded-lg text-sm font-medium transition ${d?"bg-green-500/20 text-green-400 hover:bg-green-500/30":"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30"}`,children:d?"▶ Resume":"⏸ Pause"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-3",children:[e.jsx(g,{icon:C,label:"Intents / min",value:c.intents_per_minute,color:"text-blue-400"}),e.jsx(g,{icon:E,label:"Active Warrants",value:c.warrants_active,color:"text-amber-400"}),e.jsx(g,{icon:T,label:"Pending Approvals",value:c.approvals_pending,color:"text-amber-400"}),e.jsx(g,{icon:S,label:"Active Agents",value:c.agents_active,color:"text-cyan-400"}),e.jsx(g,{icon:I,label:"Chain Length",value:c.chain_length,color:"text-green-400"}),e.jsx(g,{icon:v,label:"Anomalies (24h)",value:c.anomalies_24h,color:"text-orange-400"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h2",{className:"text-lg font-semibold text-[var(--text-primary)]",children:"Event Stream"}),e.jsxs("span",{className:"text-xs text-[var(--text-tertiary)]",children:[i.length," events"]})]}),e.jsx("div",{className:"space-y-2 max-h-[600px] overflow-y-auto",children:i.length===0?e.jsxs("div",{className:"text-center py-16 text-[var(--text-tertiary)]",children:[e.jsx(h,{className:"w-12 h-12 mx-auto mb-4 opacity-30 animate-pulse"}),e.jsx("p",{children:"Waiting for governance events..."}),e.jsx("p",{className:"text-sm mt-2",children:"Events will appear here in real-time as agents submit intents."})]}):i.map(t=>e.jsx(L,{event:t},t.id))})]})]})}export{J as GovernanceLivePage,J as default}; -//# sourceMappingURL=GovernanceLivePage-BuoY7Y-J.js.map diff --git a/apps/console-proxy/public/assets/HistoryPage-C1gCvivw.js b/apps/console-proxy/public/assets/HistoryPage-Ck44Svwk.js similarity index 98% rename from apps/console-proxy/public/assets/HistoryPage-C1gCvivw.js rename to apps/console-proxy/public/assets/HistoryPage-Ck44Svwk.js index e02a756d..90c1deaa 100644 --- a/apps/console-proxy/public/assets/HistoryPage-C1gCvivw.js +++ b/apps/console-proxy/public/assets/HistoryPage-Ck44Svwk.js @@ -1,4 +1,4 @@ -import{r as c,j as t,b as x}from"./index-D_7YXFSJ.js";import{P as h}from"./PageLayout-CTYKc2go.js";function v(a,r){const o=[];r.forEach((n,l)=>{l>0&&o.push(""),o.push(`# ${n.title}`),n.headers&&o.push(n.headers.join(",")),n.rows.forEach(d=>{o.push(d.map(p=>{const s=String(p).replace(/"/g,'""');return s.includes(",")||s.includes('"')||s.includes(` +import{r as c,j as t,g as x}from"./index-C0nK3ekl.js";import{P as h}from"./PageLayout-D94mSHCV.js";function v(a,r){const o=[];r.forEach((n,l)=>{l>0&&o.push(""),o.push(`# ${n.title}`),n.headers&&o.push(n.headers.join(",")),n.rows.forEach(d=>{o.push(d.map(p=>{const s=String(p).replace(/"/g,'""');return s.includes(",")||s.includes('"')||s.includes(` `)?`"${s}"`:s}).join(","))})});const e=new Blob([o.join(` `)],{type:"text/csv;charset=utf-8;"});j(e,a)}function y(a,r){const o=window.open("","_blank");if(!o)return;const e=` @@ -51,4 +51,4 @@ import{r as c,j as t,b as x}from"./index-D_7YXFSJ.js";import{P as h}from"./PageL <\/script> `;o.document.write(e),o.document.close()}function j(a,r){const o=URL.createObjectURL(a),e=document.createElement("a");e.href=o,e.download=r,document.body.appendChild(e),e.click(),document.body.removeChild(e),URL.revokeObjectURL(o)}const b={intent:{icon:"🎯",color:"#f59e0b",bg:"rgba(167, 139, 250, 0.08)",label:"Intent"},warrant:{icon:"🔐",color:"#f59e0b",bg:"rgba(245, 158, 11, 0.08)",label:"Warrant"},execution:{icon:"⚡",color:"#10b981",bg:"rgba(16, 185, 129, 0.08)",label:"Execution"},verification:{icon:"🔍",color:"#60a5fa",bg:"rgba(96, 165, 250, 0.08)",label:"Verification"},policy:{icon:"📋",color:"#34d399",bg:"rgba(52, 211, 153, 0.08)",label:"Policy"},anomaly:{icon:"⚠️",color:"#ef4444",bg:"rgba(239, 68, 68, 0.08)",label:"Anomaly"}},u={success:{color:"#10b981",bg:"rgba(16, 185, 129, 0.1)"},failed:{color:"#ef4444",bg:"rgba(239, 68, 68, 0.1)"},pending:{color:"#f59e0b",bg:"rgba(245, 158, 11, 0.1)"},rejected:{color:"#ef4444",bg:"rgba(239, 68, 68, 0.1)"}};function $(){const[a,r]=c.useState("24h"),[o,e]=c.useState("all"),[n,l]=c.useState([]),[d,p]=c.useState(!0);c.useEffect(()=>{s()},[a,o]);const s=async()=>{var i;p(!0);try{const g=await fetch("/api/v1/audit/recent?limit=50",{credentials:"include"});if(g.ok){const m=await g.json();l(((i=m.data)==null?void 0:i.entries)||[])}}catch{}p(!1)};return t.jsx(h,{title:"History",description:"Execution ledger — every action, warrant, and verification",actions:t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx(f,{value:a,onChange:r,options:[{value:"1h",label:"Last hour"},{value:"6h",label:"Last 6 hours"},{value:"24h",label:"Last 24 hours"},{value:"7d",label:"Last 7 days"}]}),t.jsx(f,{value:o,onChange:e,options:[{value:"all",label:"All types"},{value:"intent",label:"Intents"},{value:"execution",label:"Executions"},{value:"warrant",label:"Warrants"},{value:"verification",label:"Verifications"},{value:"policy",label:"Policy decisions"}]}),t.jsx("button",{onClick:()=>{if(n.length===0){x("No entries to export","warning");return}v(`vienna-audit-${new Date().toISOString().slice(0,10)}.csv`,[{title:"Audit Trail",headers:["ID","Type","Action","Status","Details","Timestamp"],rows:n.map(i=>[i.id,i.type,i.action,i.status,i.details||"",i.timestamp])}]),x(`Exported ${n.length} audit entries`,"success")},style:{padding:"6px 12px",fontSize:"12px",borderRadius:"6px",border:"1px solid rgba(16,185,129,0.2)",background:"rgba(16,185,129,0.08)",color:"#10b981",cursor:"pointer",fontWeight:500,fontFamily:"var(--font-mono)"},children:"📥 CSV"}),t.jsx("button",{onClick:()=>{if(n.length===0){x("No entries to export","warning");return}y("Vienna OS Governance Audit Report",[{title:`Audit Trail — ${a} · ${o==="all"?"All Types":o}`,headers:["ID","Type","Action","Status","Details","Timestamp"],rows:n.map(i=>[i.id.slice(0,12),i.type,i.action,i.status,i.details||"",new Date(i.timestamp).toLocaleString()])}])},style:{padding:"6px 12px",fontSize:"12px",borderRadius:"6px",border:"1px solid rgba(245,158,11,0.2)",background:"rgba(245,158,11,0.08)",color:"#f59e0b",cursor:"pointer",fontWeight:500,fontFamily:"var(--font-mono)"},children:"📄 PDF"})]}),children:n.length>0?t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:n.map(i=>t.jsx(S,{entry:i},i.id))}):t.jsxs("div",{className:"empty-state",children:[t.jsx("div",{className:"empty-state-icon",children:"📋"}),t.jsx("h3",{className:"empty-state-title",children:d?"Loading audit trail…":"Audit trail is empty"}),t.jsx("p",{className:"empty-state-description",children:"Every governance action will appear here."})]})})}function S({entry:a}){const r=b[a.type]||b.intent,o=u[a.status]||u.success;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 20px 14px 16px",background:"var(--bg-primary)",borderRadius:"8px",border:"1px solid var(--border-subtle)",borderLeft:`4px solid ${r.color}`,transition:"all 200ms ease",cursor:"pointer",position:"relative",backdropFilter:"blur(8px)",backgroundImage:"linear-gradient(90deg, transparent 0%, rgba(124, 58, 237, 0.02) 50%, transparent 100%)"},onMouseEnter:e=>{e.currentTarget.style.transform="translateX(4px)",e.currentTarget.style.boxShadow=`0 4px 12px rgba(0, 0, 0, 0.15), 0 0 20px ${r.color}15`,e.currentTarget.style.borderLeftColor=r.color,e.currentTarget.style.borderLeftWidth="6px"},onMouseLeave:e=>{e.currentTarget.style.transform="translateX(0)",e.currentTarget.style.boxShadow="none",e.currentTarget.style.borderLeftWidth="4px"},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",borderRadius:"50%",background:`linear-gradient(135deg, ${r.color}20, ${r.color}10)`,border:`1px solid ${r.color}30`,fontSize:"14px",flexShrink:0},children:r.icon}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"2px"},children:[t.jsx("div",{style:{padding:"2px 8px",borderRadius:"4px",background:r.bg,fontSize:"10px",fontWeight:700,color:r.color,textTransform:"uppercase",letterSpacing:"0.5px",border:`1px solid ${r.color}25`},children:r.label}),t.jsx("div",{style:{padding:"2px 8px",borderRadius:"4px",background:o.bg,fontSize:"10px",fontWeight:600,color:o.color,textTransform:"uppercase",letterSpacing:"0.5px",border:`1px solid ${o.color}25`},children:a.status}),a.execution_id&&t.jsx("div",{style:{fontSize:"9px",color:"var(--text-muted)",fontFamily:"var(--font-mono)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"3px",border:"1px solid var(--border-subtle)"},children:a.execution_id.slice(0,12)})]}),t.jsx("div",{style:{fontSize:"13px",fontWeight:500,color:"var(--text-primary)",fontFamily:"var(--font-mono)",lineHeight:1.4},children:a.action})]}),t.jsxs("div",{style:{textAlign:"right",flexShrink:0},children:[t.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontFamily:"var(--font-mono)",fontWeight:600},children:new Date(a.timestamp).toLocaleTimeString()}),t.jsx("div",{style:{fontSize:"9px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",marginTop:"1px"},children:new Date(a.timestamp).toLocaleDateString()})]})]})}function f({value:a,onChange:r,options:o}){return t.jsx("select",{value:a,onChange:e=>r(e.target.value),style:{background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"8px",padding:"6px 12px",fontSize:"12px",color:"var(--text-secondary)",fontFamily:"var(--font-sans)",cursor:"pointer",outline:"none"},children:o.map(e=>t.jsx("option",{value:e.value,children:e.label},e.value))})}export{$ as HistoryPage}; -//# sourceMappingURL=HistoryPage-C1gCvivw.js.map +//# sourceMappingURL=HistoryPage-Ck44Svwk.js.map diff --git a/apps/console-proxy/public/assets/IntegrationsPage-DRbr7PRs.js b/apps/console-proxy/public/assets/IntegrationsPage-SbHmQPUH.js similarity index 99% rename from apps/console-proxy/public/assets/IntegrationsPage-DRbr7PRs.js rename to apps/console-proxy/public/assets/IntegrationsPage-SbHmQPUH.js index e659b52d..b6b26514 100644 --- a/apps/console-proxy/public/assets/IntegrationsPage-DRbr7PRs.js +++ b/apps/console-proxy/public/assets/IntegrationsPage-SbHmQPUH.js @@ -1,2 +1,2 @@ -import{a as S,r as c,e as w,j as e}from"./index-D_7YXFSJ.js";import{P as E}from"./PageLayout-CTYKc2go.js";async function B(){return S.get("/integrations")}async function D(t){return S.get(`/integrations/${t}`)}async function $(t){return S.post("/integrations",t)}async function L(t,i){return S.put(`/integrations/${t}`,i)}async function P(t){await S.delete(`/integrations/${t}`)}async function W(t){return S.post(`/integrations/${t}/test`,{})}async function M(t){return S.post(`/integrations/${t}/toggle`,{})}async function F(t,i=50,o=0){return await S.fetch(`/integrations/${t}/events?limit=${i}&offset=${o}`)}async function N(){return S.get("/integrations/types")}const A={slack:"💬",email:"📧",webhook:"🔗",github:"🐙"},q=[{value:"approval_required",label:"Approval Required"},{value:"approval_resolved",label:"Approval Resolved"},{value:"action_executed",label:"Action Executed"},{value:"action_failed",label:"Action Failed"},{value:"policy_violation",label:"Policy Violation"},{value:"alert",label:"Alert"}],s={card:{background:"var(--bg-primary)",borderRadius:"12px",padding:"20px",cursor:"pointer",transition:"all 150ms ease"},badge:t=>({display:"inline-block",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,background:`${t}22`,color:t}),button:t=>{const o={primary:{bg:"#f59e0b",text:"#fff",border:"#f59e0b"},danger:{bg:"#ef4444",text:"#fff",border:"#ef4444"},ghost:{bg:"transparent",text:"var(--text-secondary)",border:"var(--border-subtle)"},success:{bg:"#22c55e",text:"#fff",border:"#22c55e"}}[t];return{padding:"8px 16px",borderRadius:"8px",border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"opacity 150ms"}},input:{width:"100%",padding:"8px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box"},label:{display:"block",fontSize:"12px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"4px"},sectionTitle:{fontSize:"14px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"12px"}};function X(){const[t,i]=c.useState([]),[o,l]=c.useState([]),[n,a]=c.useState(!0),[y,d]=c.useState("list"),[x,u]=c.useState(null),[b,j]=c.useState(null),{isMobile:T}=w(),f=c.useCallback(async()=>{try{const[g,C]=await Promise.all([B(),N()]);i(g),l(C)}catch{}finally{a(!1)}},[]);return c.useEffect(()=>{f()},[f]),n?e.jsx(E,{title:"Integrations",description:"Loading...",children:e.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading integrations..."})}):e.jsxs(E,{title:"Integrations",description:"Connect Vienna governance events to external services",children:[y==="list"&&e.jsx(O,{integrations:t,schemas:o,onSelect:g=>{u(g),d("detail")},onAdd:()=>d("create"),onToggle:async g=>{await M(g),f()}}),y==="create"&&(b?e.jsx(R,{schema:o.find(g=>g.type===b),onSave:async g=>{await $({...g,type:b}),j(null),d("list"),f()},onCancel:()=>{j(null),d("list")}}):e.jsx(Y,{schemas:o,onSelect:g=>j(g),onCancel:()=>d("list")})),y==="detail"&&x&&e.jsx(J,{id:x,schemas:o,onBack:()=>{u(null),d("list"),f()},onEdit:()=>d("edit"),onDelete:async()=>{await P(x),u(null),d("list"),f()}}),y==="edit"&&x&&e.jsx(U,{id:x,schemas:o,onSave:async()=>{d("detail")},onCancel:()=>d("detail")})]})}function O({integrations:t,schemas:i,onSelect:o,onAdd:l,onToggle:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h2",{style:s.sectionTitle,children:"Configured Integrations"}),e.jsx("button",{style:s.button("primary"),onClick:l,children:"+ Add Integration"})]}),t.length===0?e.jsxs("div",{style:{...s.card,textAlign:"center",padding:"48px",cursor:"default",color:"var(--text-tertiary)"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"🔌"}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:"No integrations configured"}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:"Add a Slack, Email, Webhook, or GitHub integration to get started."})]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"12px"},children:t.map(a=>e.jsx(H,{integration:a,onClick:()=>o(a.id),onToggle:y=>{y.stopPropagation(),n(a.id)}},a.id))})]})}function H({integration:t,onClick:i,onToggle:o}){const l=A[t.type]||"🔌";t.consecutive_failures===0&&t.enabled;const n=t.consecutive_failures>0&&t.consecutive_failures<5&&t.enabled,a=t.consecutive_failures>=5||!t.enabled,y=a?"#ef4444":n?"#f59e0b":"#22c55e",d=t.enabled?a?"Failing":n?"Degraded":"Healthy":"Disabled";return e.jsxs("div",{style:s.card,onClick:i,onMouseEnter:x=>{x.currentTarget.style.borderColor="#f59e0b44"},onMouseLeave:x=>{x.currentTarget.style.borderColor="var(--border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"24px"},children:l}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:t.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.type})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:s.badge(y),children:d}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",cursor:"pointer",fontSize:"16px",padding:"4px",opacity:.6},title:t.enabled?"Disable":"Enable",children:t.enabled?"⏸":"▶️"})]})]}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"8px"},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"11px",color:"var(--text-tertiary)"},children:[t.event_count!==void 0&&e.jsxs("span",{children:["📊 ",t.event_count," events"]}),t.last_success&&e.jsxs("span",{children:["✅ ",_(t.last_success)]}),t.last_failure&&e.jsxs("span",{children:["❌ ",_(t.last_failure)]})]})]})}function Y({schemas:t,onSelect:i,onCancel:o}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h2",{style:s.sectionTitle,children:"Choose Integration Type"}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"← Back"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:t.map(l=>e.jsxs("div",{style:{...s.card,display:"flex",gap:"16px",alignItems:"center"},onClick:()=>i(l.type),onMouseEnter:n=>{n.currentTarget.style.borderColor="#f59e0b44"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"32px"},children:l.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)"},children:l.label}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"4px"},children:l.description})]})]},l.type))})]})}function R({schema:t,onSave:i,onCancel:o,initialValues:l}){const[n,a]=c.useState((l==null?void 0:l.name)||""),[y,d]=c.useState((l==null?void 0:l.description)||""),[x,u]=c.useState((l==null?void 0:l.config)||{}),[b,j]=c.useState((l==null?void 0:l.event_types)||["approval_required"]),[T,f]=c.useState((l==null?void 0:l.filters)||{}),[g,C]=c.useState(!1),[I,k]=c.useState(null),z=async()=>{if(!n.trim()){k("Name is required");return}C(!0),k(null);try{await i({name:n,description:y||void 0,config:x,event_types:b,filters:T})}catch(p){k(p instanceof Error?p.message:"Save failed")}finally{C(!1)}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px",maxWidth:"640px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("h2",{style:s.sectionTitle,children:[t.icon," Configure ",t.label]}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"← Back"})]}),I&&e.jsx("div",{style:{padding:"10px 14px",background:"#ef444422",border:"1px solid #ef4444",borderRadius:"8px",color:"#ef4444",fontSize:"13px"},children:I}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Name *"}),e.jsx("input",{style:s.input,value:n,onChange:p=>a(p.target.value),placeholder:`My ${t.label} Integration`})]}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Description"}),e.jsx("input",{style:s.input,value:y,onChange:p=>d(p.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Connection"}),t.fields.map(p=>e.jsx(G,{field:p,value:x[p.key],onChange:m=>u(h=>({...h,[p.key]:m}))},p.key))]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Event Types"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:q.map(p=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:b.includes(p.value),onChange:m=>{m.target.checked?j(h=>[...h,p.value]):j(h=>h.filter(r=>r!==p.value))}}),p.label]},p.value))})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Filters (optional)"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Risk Tiers (comma-separated)"}),e.jsx("input",{style:s.input,value:(T.risk_tiers||[]).join(", "),onChange:p=>f(m=>({...m,risk_tiers:p.target.value.split(",").map(h=>h.trim()).filter(Boolean)})),placeholder:"T1, T2"})]}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Agent IDs (comma-separated)"}),e.jsx("input",{style:s.input,value:(T.agents||[]).join(", "),onChange:p=>f(m=>({...m,agents:p.target.value.split(",").map(h=>h.trim()).filter(Boolean)})),placeholder:"agent-1, agent-2"})]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("button",{style:s.button("primary"),onClick:z,disabled:g,children:g?"Saving...":"Save Integration"}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"Cancel"})]})]})}function G({field:t,value:i,onChange:o}){var l;if(t.type==="select")return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),e.jsxs("select",{style:{...s.input,cursor:"pointer"},value:i||"",onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"Select..."}),(l=t.options)==null?void 0:l.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))]}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]});if(t.type==="multi-text"){const n=Array.isArray(i)?i:i?[i]:[];return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),n.map((a,y)=>e.jsxs("div",{style:{display:"flex",gap:"4px",marginBottom:"4px"},children:[e.jsx("input",{style:s.input,value:a,onChange:d=>{const x=[...n];x[y]=d.target.value,o(x)},placeholder:t.placeholder}),e.jsx("button",{style:{...s.button("ghost"),padding:"4px 8px",fontSize:"12px"},onClick:()=>o(n.filter((d,x)=>x!==y)),children:"×"})]},y)),e.jsx("button",{style:{...s.button("ghost"),padding:"4px 8px",fontSize:"11px"},onClick:()=>o([...n,""]),children:"+ Add"}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]})}return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),e.jsx("input",{style:s.input,type:t.type==="password"?"password":t.type==="number"?"number":"text",value:i||"",onChange:n=>o(t.type==="number"?n.target.value?parseInt(n.target.value):void 0:n.target.value),placeholder:t.placeholder}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]})}function J({id:t,schemas:i,onBack:o,onEdit:l,onDelete:n}){const[a,y]=c.useState(null),[d,x]=c.useState([]),[u,b]=c.useState(null),[j,T]=c.useState(!1),[f,g]=c.useState(null),[C,I]=c.useState(!1),[k,z]=c.useState(!0),{isMobile:p}=w();c.useEffect(()=>{(async()=>{try{const[r,v]=await Promise.all([D(t),F(t).catch(()=>({data:[],total:0}))]);y(r),x(Array.isArray(v)?v:(v==null?void 0:v.data)||v||[])}catch{}finally{z(!1)}})()},[t]);const m=async()=>{T(!0),b(null);try{const r=await W(t);b(r)}catch(r){b({success:!1,message:r instanceof Error?r.message:"Test failed"})}finally{T(!1)}};if(k||!a)return e.jsx("div",{style:{padding:"24px",color:"var(--text-tertiary)"},children:"Loading..."});const h=A[a.type]||"🔌";return i.find(r=>r.type===a.type),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{style:s.button("ghost"),onClick:o,children:"←"}),e.jsx("span",{style:{fontSize:"28px"},children:h}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:a.name}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:[a.type," • ",a.enabled?"Enabled":"Disabled"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{style:s.button("primary"),onClick:m,disabled:j,children:j?"Testing...":"🔌 Test Connection"}),e.jsx("button",{style:s.button("ghost"),onClick:l,children:"Edit"}),C?e.jsx("button",{style:s.button("danger"),onClick:n,children:"Confirm Delete"}):e.jsx("button",{style:s.button("danger"),onClick:()=>I(!0),children:"Delete"})]})]}),u&&e.jsxs("div",{style:{padding:"12px 16px",background:u.success?"#22c55e22":"#ef444422",border:`1px solid ${u.success?"#22c55e":"#ef4444"}`,borderRadius:"8px",color:u.success?"#22c55e":"#ef4444",fontSize:"13px"},children:[u.success?"✅":"❌"," ",u.message]}),a.stats&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[{label:"Total Events",value:a.stats.total_events,icon:"📊"},{label:"Successes",value:a.stats.success_count,icon:"✅"},{label:"Failures",value:a.stats.failure_count,icon:"❌"},{label:"Avg Latency",value:`${a.stats.avg_latency_ms}ms`,icon:"⏱"}].map(r=>e.jsxs("div",{style:{...s.card,cursor:"default",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"20px"},children:r.icon}),e.jsx("div",{style:{fontSize:"20px",fontWeight:700,color:"var(--text-primary)",marginTop:"4px"},children:r.value}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:r.label})]},r.label))}),e.jsxs("div",{style:s.card,children:[e.jsx("h3",{style:{...s.sectionTitle,marginBottom:"8px"},children:"Configuration"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:p?"1fr":"1fr 1fr",gap:"8px"},children:Object.entries(a.config).map(([r,v])=>e.jsxs("div",{style:{fontSize:"12px"},children:[e.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[r,": "]}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:typeof v=="string"&&v.includes("•")?v:String(v)})]},r))}),e.jsxs("div",{style:{marginTop:"12px",fontSize:"12px"},children:[e.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Events: "}),(a.event_types||[]).map(r=>e.jsx("span",{style:{...s.badge("#f59e0b"),marginRight:"4px"},children:r},r))]})]}),e.jsxs("div",{children:[e.jsx("h3",{style:s.sectionTitle,children:"Event Log"}),d.length===0?e.jsx("div",{style:{...s.card,cursor:"default",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No events yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:d.map(r=>e.jsxs("div",{children:[e.jsxs("div",{style:{...s.card,padding:"10px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",borderRadius:f===r.id?"8px 8px 0 0":"8px"},onClick:()=>g(f===r.id?null:r.id),children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"14px"},children:r.success?"✅":"❌"}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:r.event_type})]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"11px",color:"var(--text-tertiary)"},children:[r.latency_ms!=null&&e.jsxs("span",{children:[r.latency_ms,"ms"]}),r.response_status&&e.jsxs("span",{children:["HTTP ",r.response_status]}),e.jsx("span",{children:_(r.created_at)})]})]}),f===r.id&&e.jsxs("div",{style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderTop:"none",borderRadius:"0 0 8px 8px",padding:"12px 16px",fontSize:"11px",fontFamily:"monospace"},children:[r.error_message&&e.jsxs("div",{style:{color:"#ef4444",marginBottom:"8px"},children:["Error: ",r.error_message]}),e.jsx("div",{style:{color:"var(--text-tertiary)",marginBottom:"4px"},children:"Payload:"}),e.jsx("pre",{style:{color:"var(--text-secondary)",whiteSpace:"pre-wrap",margin:0},children:JSON.stringify(r.payload,null,2)}),r.response_body&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{color:"var(--text-tertiary)",marginTop:"8px",marginBottom:"4px"},children:"Response:"}),e.jsx("pre",{style:{color:"var(--text-secondary)",whiteSpace:"pre-wrap",margin:0},children:r.response_body.slice(0,1e3)})]})]})]},r.id))})]})]})}function U({id:t,schemas:i,onSave:o,onCancel:l}){const[n,a]=c.useState(null),[y,d]=c.useState(!0);if(c.useEffect(()=>{D(t).then(u=>{a(u),d(!1)}).catch(()=>d(!1))},[t]),y||!n)return e.jsx("div",{style:{padding:"24px",color:"var(--text-tertiary)"},children:"Loading..."});const x=i.find(u=>u.type===n.type);return x?e.jsx(R,{schema:x,initialValues:{name:n.name,description:n.description||"",config:n.config,event_types:n.event_types,filters:n.filters},onSave:async u=>{await L(t,u),o()},onCancel:l}):e.jsxs("div",{style:{padding:"24px",color:"#ef4444"},children:["Unknown type: ",n.type]})}function _(t){const i=Math.floor((Date.now()-new Date(t).getTime())/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}export{X as IntegrationsPage}; -//# sourceMappingURL=IntegrationsPage-DRbr7PRs.js.map +import{e as S,r as c,h as w,j as e}from"./index-C0nK3ekl.js";import{P as E}from"./PageLayout-D94mSHCV.js";async function B(){return S.get("/integrations")}async function D(t){return S.get(`/integrations/${t}`)}async function $(t){return S.post("/integrations",t)}async function L(t,i){return S.put(`/integrations/${t}`,i)}async function P(t){await S.delete(`/integrations/${t}`)}async function W(t){return S.post(`/integrations/${t}/test`,{})}async function M(t){return S.post(`/integrations/${t}/toggle`,{})}async function F(t,i=50,o=0){return await S.fetch(`/integrations/${t}/events?limit=${i}&offset=${o}`)}async function N(){return S.get("/integrations/types")}const A={slack:"💬",email:"📧",webhook:"🔗",github:"🐙"},q=[{value:"approval_required",label:"Approval Required"},{value:"approval_resolved",label:"Approval Resolved"},{value:"action_executed",label:"Action Executed"},{value:"action_failed",label:"Action Failed"},{value:"policy_violation",label:"Policy Violation"},{value:"alert",label:"Alert"}],s={card:{background:"var(--bg-primary)",borderRadius:"12px",padding:"20px",cursor:"pointer",transition:"all 150ms ease"},badge:t=>({display:"inline-block",padding:"2px 8px",borderRadius:"4px",fontSize:"11px",fontWeight:600,background:`${t}22`,color:t}),button:t=>{const o={primary:{bg:"#f59e0b",text:"#fff",border:"#f59e0b"},danger:{bg:"#ef4444",text:"#fff",border:"#ef4444"},ghost:{bg:"transparent",text:"var(--text-secondary)",border:"var(--border-subtle)"},success:{bg:"#22c55e",text:"#fff",border:"#22c55e"}}[t];return{padding:"8px 16px",borderRadius:"8px",border:`1px solid ${o.border}`,background:o.bg,color:o.text,fontSize:"13px",fontWeight:500,cursor:"pointer",transition:"opacity 150ms"}},input:{width:"100%",padding:"8px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box"},label:{display:"block",fontSize:"12px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"4px"},sectionTitle:{fontSize:"14px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"12px"}};function X(){const[t,i]=c.useState([]),[o,l]=c.useState([]),[n,a]=c.useState(!0),[y,d]=c.useState("list"),[x,u]=c.useState(null),[b,j]=c.useState(null),{isMobile:T}=w(),f=c.useCallback(async()=>{try{const[g,C]=await Promise.all([B(),N()]);i(g),l(C)}catch{}finally{a(!1)}},[]);return c.useEffect(()=>{f()},[f]),n?e.jsx(E,{title:"Integrations",description:"Loading...",children:e.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading integrations..."})}):e.jsxs(E,{title:"Integrations",description:"Connect Vienna governance events to external services",children:[y==="list"&&e.jsx(O,{integrations:t,schemas:o,onSelect:g=>{u(g),d("detail")},onAdd:()=>d("create"),onToggle:async g=>{await M(g),f()}}),y==="create"&&(b?e.jsx(R,{schema:o.find(g=>g.type===b),onSave:async g=>{await $({...g,type:b}),j(null),d("list"),f()},onCancel:()=>{j(null),d("list")}}):e.jsx(Y,{schemas:o,onSelect:g=>j(g),onCancel:()=>d("list")})),y==="detail"&&x&&e.jsx(J,{id:x,schemas:o,onBack:()=>{u(null),d("list"),f()},onEdit:()=>d("edit"),onDelete:async()=>{await P(x),u(null),d("list"),f()}}),y==="edit"&&x&&e.jsx(U,{id:x,schemas:o,onSave:async()=>{d("detail")},onCancel:()=>d("detail")})]})}function O({integrations:t,schemas:i,onSelect:o,onAdd:l,onToggle:n}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h2",{style:s.sectionTitle,children:"Configured Integrations"}),e.jsx("button",{style:s.button("primary"),onClick:l,children:"+ Add Integration"})]}),t.length===0?e.jsxs("div",{style:{...s.card,textAlign:"center",padding:"48px",cursor:"default",color:"var(--text-tertiary)"},children:[e.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"🔌"}),e.jsx("div",{style:{fontSize:"14px",fontWeight:600},children:"No integrations configured"}),e.jsx("div",{style:{fontSize:"12px",marginTop:"4px"},children:"Add a Slack, Email, Webhook, or GitHub integration to get started."})]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(320px, 1fr))",gap:"12px"},children:t.map(a=>e.jsx(H,{integration:a,onClick:()=>o(a.id),onToggle:y=>{y.stopPropagation(),n(a.id)}},a.id))})]})}function H({integration:t,onClick:i,onToggle:o}){const l=A[t.type]||"🔌";t.consecutive_failures===0&&t.enabled;const n=t.consecutive_failures>0&&t.consecutive_failures<5&&t.enabled,a=t.consecutive_failures>=5||!t.enabled,y=a?"#ef4444":n?"#f59e0b":"#22c55e",d=t.enabled?a?"Failing":n?"Degraded":"Healthy":"Disabled";return e.jsxs("div",{style:s.card,onClick:i,onMouseEnter:x=>{x.currentTarget.style.borderColor="#f59e0b44"},onMouseLeave:x=>{x.currentTarget.style.borderColor="var(--border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"24px"},children:l}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:t.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.type})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:s.badge(y),children:d}),e.jsx("button",{onClick:o,style:{background:"none",border:"none",cursor:"pointer",fontSize:"16px",padding:"4px",opacity:.6},title:t.enabled?"Disable":"Enable",children:t.enabled?"⏸":"▶️"})]})]}),t.description&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"8px"},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:"16px",marginTop:"12px",fontSize:"11px",color:"var(--text-tertiary)"},children:[t.event_count!==void 0&&e.jsxs("span",{children:["📊 ",t.event_count," events"]}),t.last_success&&e.jsxs("span",{children:["✅ ",_(t.last_success)]}),t.last_failure&&e.jsxs("span",{children:["❌ ",_(t.last_failure)]})]})]})}function Y({schemas:t,onSelect:i,onCancel:o}){return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h2",{style:s.sectionTitle,children:"Choose Integration Type"}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"← Back"})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:"12px"},children:t.map(l=>e.jsxs("div",{style:{...s.card,display:"flex",gap:"16px",alignItems:"center"},onClick:()=>i(l.type),onMouseEnter:n=>{n.currentTarget.style.borderColor="#f59e0b44"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"32px"},children:l.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)"},children:l.label}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"4px"},children:l.description})]})]},l.type))})]})}function R({schema:t,onSave:i,onCancel:o,initialValues:l}){const[n,a]=c.useState((l==null?void 0:l.name)||""),[y,d]=c.useState((l==null?void 0:l.description)||""),[x,u]=c.useState((l==null?void 0:l.config)||{}),[b,j]=c.useState((l==null?void 0:l.event_types)||["approval_required"]),[T,f]=c.useState((l==null?void 0:l.filters)||{}),[g,C]=c.useState(!1),[I,k]=c.useState(null),z=async()=>{if(!n.trim()){k("Name is required");return}C(!0),k(null);try{await i({name:n,description:y||void 0,config:x,event_types:b,filters:T})}catch(p){k(p instanceof Error?p.message:"Save failed")}finally{C(!1)}};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px",maxWidth:"640px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("h2",{style:s.sectionTitle,children:[t.icon," Configure ",t.label]}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"← Back"})]}),I&&e.jsx("div",{style:{padding:"10px 14px",background:"#ef444422",border:"1px solid #ef4444",borderRadius:"8px",color:"#ef4444",fontSize:"13px"},children:I}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Name *"}),e.jsx("input",{style:s.input,value:n,onChange:p=>a(p.target.value),placeholder:`My ${t.label} Integration`})]}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Description"}),e.jsx("input",{style:s.input,value:y,onChange:p=>d(p.target.value),placeholder:"Optional description"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Connection"}),t.fields.map(p=>e.jsx(G,{field:p,value:x[p.key],onChange:m=>u(h=>({...h,[p.key]:m}))},p.key))]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Event Types"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:q.map(p=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:b.includes(p.value),onChange:m=>{m.target.checked?j(h=>[...h,p.value]):j(h=>h.filter(r=>r!==p.value))}}),p.label]},p.value))})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("h3",{style:{...s.sectionTitle,fontSize:"12px"},children:"Filters (optional)"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Risk Tiers (comma-separated)"}),e.jsx("input",{style:s.input,value:(T.risk_tiers||[]).join(", "),onChange:p=>f(m=>({...m,risk_tiers:p.target.value.split(",").map(h=>h.trim()).filter(Boolean)})),placeholder:"T1, T2"})]}),e.jsxs("div",{children:[e.jsx("label",{style:s.label,children:"Agent IDs (comma-separated)"}),e.jsx("input",{style:s.input,value:(T.agents||[]).join(", "),onChange:p=>f(m=>({...m,agents:p.target.value.split(",").map(h=>h.trim()).filter(Boolean)})),placeholder:"agent-1, agent-2"})]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",borderTop:"1px solid var(--border-subtle)",paddingTop:"16px"},children:[e.jsx("button",{style:s.button("primary"),onClick:z,disabled:g,children:g?"Saving...":"Save Integration"}),e.jsx("button",{style:s.button("ghost"),onClick:o,children:"Cancel"})]})]})}function G({field:t,value:i,onChange:o}){var l;if(t.type==="select")return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),e.jsxs("select",{style:{...s.input,cursor:"pointer"},value:i||"",onChange:n=>o(n.target.value),children:[e.jsx("option",{value:"",children:"Select..."}),(l=t.options)==null?void 0:l.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))]}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]});if(t.type==="multi-text"){const n=Array.isArray(i)?i:i?[i]:[];return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),n.map((a,y)=>e.jsxs("div",{style:{display:"flex",gap:"4px",marginBottom:"4px"},children:[e.jsx("input",{style:s.input,value:a,onChange:d=>{const x=[...n];x[y]=d.target.value,o(x)},placeholder:t.placeholder}),e.jsx("button",{style:{...s.button("ghost"),padding:"4px 8px",fontSize:"12px"},onClick:()=>o(n.filter((d,x)=>x!==y)),children:"×"})]},y)),e.jsx("button",{style:{...s.button("ghost"),padding:"4px 8px",fontSize:"11px"},onClick:()=>o([...n,""]),children:"+ Add"}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]})}return e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsxs("label",{style:s.label,children:[t.label,t.required?" *":""]}),e.jsx("input",{style:s.input,type:t.type==="password"?"password":t.type==="number"?"number":"text",value:i||"",onChange:n=>o(t.type==="number"?n.target.value?parseInt(n.target.value):void 0:n.target.value),placeholder:t.placeholder}),t.help&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:t.help})]})}function J({id:t,schemas:i,onBack:o,onEdit:l,onDelete:n}){const[a,y]=c.useState(null),[d,x]=c.useState([]),[u,b]=c.useState(null),[j,T]=c.useState(!1),[f,g]=c.useState(null),[C,I]=c.useState(!1),[k,z]=c.useState(!0),{isMobile:p}=w();c.useEffect(()=>{(async()=>{try{const[r,v]=await Promise.all([D(t),F(t).catch(()=>({data:[],total:0}))]);y(r),x(Array.isArray(v)?v:(v==null?void 0:v.data)||v||[])}catch{}finally{z(!1)}})()},[t]);const m=async()=>{T(!0),b(null);try{const r=await W(t);b(r)}catch(r){b({success:!1,message:r instanceof Error?r.message:"Test failed"})}finally{T(!1)}};if(k||!a)return e.jsx("div",{style:{padding:"24px",color:"var(--text-tertiary)"},children:"Loading..."});const h=A[a.type]||"🔌";return i.find(r=>r.type===a.type),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"20px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("button",{style:s.button("ghost"),onClick:o,children:"←"}),e.jsx("span",{style:{fontSize:"28px"},children:h}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:a.name}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:[a.type," • ",a.enabled?"Enabled":"Disabled"]})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{style:s.button("primary"),onClick:m,disabled:j,children:j?"Testing...":"🔌 Test Connection"}),e.jsx("button",{style:s.button("ghost"),onClick:l,children:"Edit"}),C?e.jsx("button",{style:s.button("danger"),onClick:n,children:"Confirm Delete"}):e.jsx("button",{style:s.button("danger"),onClick:()=>I(!0),children:"Delete"})]})]}),u&&e.jsxs("div",{style:{padding:"12px 16px",background:u.success?"#22c55e22":"#ef444422",border:`1px solid ${u.success?"#22c55e":"#ef4444"}`,borderRadius:"8px",color:u.success?"#22c55e":"#ef4444",fontSize:"13px"},children:[u.success?"✅":"❌"," ",u.message]}),a.stats&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:"12px"},children:[{label:"Total Events",value:a.stats.total_events,icon:"📊"},{label:"Successes",value:a.stats.success_count,icon:"✅"},{label:"Failures",value:a.stats.failure_count,icon:"❌"},{label:"Avg Latency",value:`${a.stats.avg_latency_ms}ms`,icon:"⏱"}].map(r=>e.jsxs("div",{style:{...s.card,cursor:"default",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"20px"},children:r.icon}),e.jsx("div",{style:{fontSize:"20px",fontWeight:700,color:"var(--text-primary)",marginTop:"4px"},children:r.value}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:r.label})]},r.label))}),e.jsxs("div",{style:s.card,children:[e.jsx("h3",{style:{...s.sectionTitle,marginBottom:"8px"},children:"Configuration"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:p?"1fr":"1fr 1fr",gap:"8px"},children:Object.entries(a.config).map(([r,v])=>e.jsxs("div",{style:{fontSize:"12px"},children:[e.jsxs("span",{style:{color:"var(--text-tertiary)"},children:[r,": "]}),e.jsx("span",{style:{color:"var(--text-secondary)"},children:typeof v=="string"&&v.includes("•")?v:String(v)})]},r))}),e.jsxs("div",{style:{marginTop:"12px",fontSize:"12px"},children:[e.jsx("span",{style:{color:"var(--text-tertiary)"},children:"Events: "}),(a.event_types||[]).map(r=>e.jsx("span",{style:{...s.badge("#f59e0b"),marginRight:"4px"},children:r},r))]})]}),e.jsxs("div",{children:[e.jsx("h3",{style:s.sectionTitle,children:"Event Log"}),d.length===0?e.jsx("div",{style:{...s.card,cursor:"default",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No events yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:d.map(r=>e.jsxs("div",{children:[e.jsxs("div",{style:{...s.card,padding:"10px 16px",display:"flex",justifyContent:"space-between",alignItems:"center",borderRadius:f===r.id?"8px 8px 0 0":"8px"},onClick:()=>g(f===r.id?null:r.id),children:[e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[e.jsx("span",{style:{fontSize:"14px"},children:r.success?"✅":"❌"}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:r.event_type})]}),e.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"11px",color:"var(--text-tertiary)"},children:[r.latency_ms!=null&&e.jsxs("span",{children:[r.latency_ms,"ms"]}),r.response_status&&e.jsxs("span",{children:["HTTP ",r.response_status]}),e.jsx("span",{children:_(r.created_at)})]})]}),f===r.id&&e.jsxs("div",{style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderTop:"none",borderRadius:"0 0 8px 8px",padding:"12px 16px",fontSize:"11px",fontFamily:"monospace"},children:[r.error_message&&e.jsxs("div",{style:{color:"#ef4444",marginBottom:"8px"},children:["Error: ",r.error_message]}),e.jsx("div",{style:{color:"var(--text-tertiary)",marginBottom:"4px"},children:"Payload:"}),e.jsx("pre",{style:{color:"var(--text-secondary)",whiteSpace:"pre-wrap",margin:0},children:JSON.stringify(r.payload,null,2)}),r.response_body&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{color:"var(--text-tertiary)",marginTop:"8px",marginBottom:"4px"},children:"Response:"}),e.jsx("pre",{style:{color:"var(--text-secondary)",whiteSpace:"pre-wrap",margin:0},children:r.response_body.slice(0,1e3)})]})]})]},r.id))})]})]})}function U({id:t,schemas:i,onSave:o,onCancel:l}){const[n,a]=c.useState(null),[y,d]=c.useState(!0);if(c.useEffect(()=>{D(t).then(u=>{a(u),d(!1)}).catch(()=>d(!1))},[t]),y||!n)return e.jsx("div",{style:{padding:"24px",color:"var(--text-tertiary)"},children:"Loading..."});const x=i.find(u=>u.type===n.type);return x?e.jsx(R,{schema:x,initialValues:{name:n.name,description:n.description||"",config:n.config,event_types:n.event_types,filters:n.filters},onSave:async u=>{await L(t,u),o()},onCancel:l}):e.jsxs("div",{style:{padding:"24px",color:"#ef4444"},children:["Unknown type: ",n.type]})}function _(t){const i=Math.floor((Date.now()-new Date(t).getTime())/1e3);return i<60?"just now":i<3600?`${Math.floor(i/60)}m ago`:i<86400?`${Math.floor(i/3600)}h ago`:`${Math.floor(i/86400)}d ago`}export{X as IntegrationsPage}; +//# sourceMappingURL=IntegrationsPage-SbHmQPUH.js.map diff --git a/apps/console-proxy/public/assets/IntegrationsPremium-seB-nk74.js b/apps/console-proxy/public/assets/IntegrationsPremium-seB-nk74.js deleted file mode 100644 index 2abc7b20..00000000 --- a/apps/console-proxy/public/assets/IntegrationsPremium-seB-nk74.js +++ /dev/null @@ -1,131 +0,0 @@ -import{c as b,u as _,r as p,j as e,Z as h,w as I,b as d,C as v,S as z,M as E}from"./index-D_7YXFSJ.js";import{P as A}from"./PageLayout-CTYKc2go.js";import{C as j,a as N}from"./copy-DPJWkP7J.js";import{T as $}from"./terminal-ybst6913.js";import{B as D}from"./bot-CFwUaWgF.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const O=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],P=b("brain",O);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const W=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],F=b("cloud",W);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const R=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],M=b("database",R);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const B=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],L=b("settings",B),V=[{id:"python-sdk",name:"Python SDK",description:"Official Vienna OS Python client library",icon:"Code",status:"connected",category:"sdk",setupTime:"2 min",lastSync:"2 minutes ago",color:"#3b82f6"},{id:"nodejs-sdk",name:"Node.js SDK",description:"JavaScript/TypeScript client for Node.js",icon:"Code",status:"connected",category:"sdk",setupTime:"2 min",lastSync:"5 minutes ago",color:"#10b981"},{id:"rest-api",name:"REST API",description:"Direct HTTP API access for any language",icon:"Zap",status:"connected",category:"api",setupTime:"1 min",color:"#f59e0b"},{id:"openai",name:"OpenAI",description:"Govern GPT-4, o1, and other OpenAI models",icon:"Bot",status:"disconnected",category:"platform",setupTime:"5 min",color:"#06b6d4"},{id:"anthropic",name:"Anthropic",description:"Govern Claude models with Vienna warrants",icon:"Brain",status:"disconnected",category:"platform",setupTime:"5 min",color:"#8b5cf6"},{id:"postgres",name:"PostgreSQL",description:"Audit trail storage and policy evaluation",icon:"Database",status:"connected",category:"database",setupTime:"10 min",lastSync:"1 hour ago",color:"#3b82f6"},{id:"slack",name:"Slack",description:"Approval notifications and alerts",icon:"MessageSquare",status:"disconnected",category:"platform",setupTime:"3 min",color:"#e01e5a"},{id:"github",name:"GitHub Actions",description:"CI/CD governance for deployments",icon:"Settings",status:"disconnected",category:"platform",setupTime:"5 min",color:"#6b7280"}],q=(n,r)=>{const a={size:28,color:r,strokeWidth:1.5};switch(n){case"Bot":return e.jsx(D,{...a});case"Brain":return e.jsx(P,{...a});case"Database":return e.jsx(M,{...a});case"MessageSquare":return e.jsx(E,{...a});case"Settings":return e.jsx(L,{...a});case"Terminal":return e.jsx($,{...a});case"Code":return e.jsx(N,{...a});case"Cloud":return e.jsx(F,{...a});case"Shield":return e.jsx(z,{...a});default:return e.jsx(h,{...a})}};function H({integration:n,onConnect:r,onTest:a}){const[s,l]=p.useState(!1),c={connected:{color:"#10b981",glow:"rgba(16, 185, 129, 0.4)",label:"CONNECTED",pulse:!0},disconnected:{color:"#6b7280",glow:"rgba(107, 114, 128, 0.2)",label:"NOT CONNECTED",pulse:!1},error:{color:"#ef4444",glow:"rgba(239, 68, 68, 0.4)",label:"ERROR",pulse:!0}}[n.status];return e.jsxs("div",{onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{background:"rgba(10, 14, 20, 0.6)",border:`1px solid ${c.color}40`,padding:"20px",display:"flex",flexDirection:"column",gap:"12px",boxShadow:s?`0 0 20px ${c.glow}`:`0 0 8px ${c.glow}`,transform:s?"translateY(-4px)":"translateY(0)",transition:"all 250ms cubic-bezier(0.4, 0, 0.2, 1)",position:"relative",overflow:"hidden"},children:[e.jsxs("div",{style:{position:"absolute",top:"16px",right:"16px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:c.color,fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:c.label}),e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:c.color,boxShadow:`0 0 8px ${c.glow}`,animation:c.pulse?"pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite":"none"}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",display:"flex",alignItems:"center",justifyContent:"center",background:`${n.color}20`,border:`1px solid ${n.color}40`},children:q(n.icon,n.color)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#E6E1DC"},children:n.name}),e.jsxs("div",{style:{fontSize:"10px",color:"rgba(230, 225, 220, 0.5)",fontFamily:"var(--font-mono)"},children:["Setup: ",n.setupTime]})]})]}),e.jsx("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.7)",lineHeight:"1.4"},children:n.description}),n.lastSync&&e.jsxs("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",fontFamily:"var(--font-mono)",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(I,{size:10}),"Last sync: ",n.lastSync]}),e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px"},children:n.status==="connected"?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:a,style:{flex:1,padding:"8px 12px",background:`${n.color}20`,border:`1px solid ${n.color}40`,color:n.color,fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em"},children:"TEST CONNECTION"}),e.jsx("button",{onClick:()=>navigate("/integrations"),style:{padding:"8px 12px",background:"rgba(107, 114, 128, 0.2)",border:"1px solid rgba(107, 114, 128, 0.4)",color:"#6b7280",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em"},children:"CONFIGURE"})]}):e.jsx("button",{onClick:r,style:{flex:1,padding:"8px 12px",background:`${n.color}20`,border:`1px solid ${n.color}40`,color:n.color,fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em"},children:"CONNECT NOW →"})}),e.jsx("style",{children:` - @keyframes pulse { - 0%, 100% { opacity: 1; } - 50% { opacity: 0.3; } - } - `})]})}function G({apiKey:n,onRevoke:r}){const[a,s]=p.useState(!1),l=()=>{navigator.clipboard.writeText(n.key),s(!0),d("API key copied to clipboard","success"),setTimeout(()=>s(!1),2e3)};return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"#E6E1DC",marginBottom:"6px"},children:n.name}),e.jsxs("div",{style:{fontSize:"11px",fontFamily:"var(--font-mono)",color:"rgba(230, 225, 220, 0.5)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("span",{children:[n.key.slice(0,20),"..."]}),e.jsxs("button",{onClick:l,style:{padding:"4px 8px",background:a?"rgba(16, 185, 129, 0.2)":"rgba(251, 191, 36, 0.2)",border:`1px solid ${a?"rgba(16, 185, 129, 0.4)":"rgba(251, 191, 36, 0.4)"}`,color:a?"#10b981":"#fbbf24",fontSize:"9px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[a?e.jsx(v,{size:10}):e.jsx(j,{size:10}),a?"COPIED":"COPY"]})]}),e.jsxs("div",{style:{fontSize:"9px",color:"rgba(230, 225, 220, 0.4)",marginTop:"6px",fontFamily:"var(--font-mono)"},children:["Created: ",n.created," • Last used: ",n.lastUsed||"Never"]})]}),e.jsx("button",{onClick:r,style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",fontSize:"9px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em"},children:"REVOKE"})]})}function K({language:n,code:r}){const[a,s]=p.useState(!1),l=()=>{navigator.clipboard.writeText(r),s(!0),d(`${n} code copied`,"success"),setTimeout(()=>s(!1),2e3)};return e.jsxs("div",{style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid rgba(251, 191, 36, 0.15)",display:"flex",justifyContent:"space-between",alignItems:"center",background:"rgba(251, 191, 36, 0.05)"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:n.toUpperCase()}),e.jsxs("button",{onClick:l,style:{padding:"4px 10px",background:a?"rgba(16, 185, 129, 0.2)":"rgba(251, 191, 36, 0.2)",border:`1px solid ${a?"rgba(16, 185, 129, 0.4)":"rgba(251, 191, 36, 0.4)"}`,color:a?"#10b981":"#fbbf24",fontSize:"9px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[a?e.jsx(v,{size:10}):e.jsx(j,{size:10}),a?"COPIED":"COPY"]})]}),e.jsx("pre",{style:{padding:"14px",margin:0,fontSize:"11px",fontFamily:"var(--font-mono)",color:"#E6E1DC",lineHeight:"1.6",overflowX:"auto"},children:e.jsx("code",{children:r})})]})}function Q(){const n=_(),[r,a]=p.useState(V),[s,l]=p.useState([]),[g,c]=p.useState("python"),S={python:`from vienna_os import ViennaClient - -# Initialize client -client = ViennaClient(api_key="vienna_live_...") - -# Register an agent -agent = client.agents.create( - name="data-processor", - capabilities=["database_write", "api_call"], - trust_score=85 -) - -# Request a warrant -warrant = client.warrants.create( - agent_id=agent.id, - action_type="database_write", - resource="users_table", - environment="production" -) - -print(f"Warrant issued: {warrant.id}") -print(f"TTL: {warrant.ttl}s")`,nodejs:`import { ViennaClient } from 'vienna-os'; - -// Initialize client -const client = new ViennaClient({ - apiKey: 'vienna_live_...' -}); - -// Register an agent -const agent = await client.agents.create({ - name: 'data-processor', - capabilities: ['database_write', 'api_call'], - trustScore: 85 -}); - -// Request a warrant -const warrant = await client.warrants.create({ - agentId: agent.id, - actionType: 'database_write', - resource: 'users_table', - environment: 'production' -}); - -console.log(\`Warrant issued: \${warrant.id}\`); -console.log(\`TTL: \${warrant.ttl}s\`);`,go:`package main - -import ( - "fmt" - "github.com/vienna-os/vienna-go" -) - -func main() { - // Initialize client - client := vienna.NewClient("vienna_live_...") - - // Register an agent - agent, err := client.Agents.Create(&vienna.AgentCreate{ - Name: "data-processor", - Capabilities: []string{"database_write", "api_call"}, - TrustScore: 85, - }) - if err != nil { - panic(err) - } - - // Request a warrant - warrant, err := client.Warrants.Create(&vienna.WarrantCreate{ - AgentID: agent.ID, - ActionType: "database_write", - Resource: "users_table", - Environment: "production", - }) - if err != nil { - panic(err) - } - - fmt.Printf("Warrant issued: %s\\n", warrant.ID) - fmt.Printf("TTL: %ds\\n", warrant.TTL) -}`,rust:`use vienna_os::{ViennaClient, AgentCreate, WarrantCreate}; - -#[tokio::main] -async fn main() -> Result<(), Box> { - // Initialize client - let client = ViennaClient::new("vienna_live_..."); - - // Register an agent - let agent = client.agents.create(AgentCreate { - name: "data-processor".to_string(), - capabilities: vec!["database_write", "api_call"], - trust_score: 85, - }).await?; - - // Request a warrant - let warrant = client.warrants.create(WarrantCreate { - agent_id: agent.id.clone(), - action_type: "database_write".to_string(), - resource: "users_table".to_string(), - environment: "production".to_string(), - }).await?; - - println!("Warrant issued: {}", warrant.id); - println!("TTL: {}s", warrant.ttl); - - Ok(()) -}`},m=p.useCallback(()=>{const t=localStorage.getItem("vienna_access_token"),i={"Content-Type":"application/json"};return t&&(i.Authorization=`Bearer ${t}`),i},[]);p.useEffect(()=>{const t=m();Promise.all([fetch("/api/v1/integrations",{credentials:"include",headers:t}).then(i=>i.json()).catch(()=>({success:!1})),fetch("/api/v1/api-keys",{credentials:"include",headers:t}).then(i=>i.json()).catch(()=>({success:!1}))]).then(([i,x])=>{if(i.success&&i.data){const o=new Map(i.data.map(f=>[f.type,f]));a(f=>f.map(u=>{const y=o.get(u.id);return y?{...u,status:y.enabled?"connected":"disconnected",lastSync:y.updated_at?new Date(y.updated_at).toLocaleString():void 0}:u}))}x.success&&x.data&&l(x.data.map(o=>({id:o.id,name:o.name,key:o.key_prefix||"••••••••",created:new Date(o.created_at).toLocaleDateString(),lastUsed:o.last_used_at?new Date(o.last_used_at).toLocaleString():"Never",permissions:o.permissions||[]})))})},[m]);const C=async t=>{d(`Opening ${t} configuration...`,"info"),n("/integrations")},w=async t=>{d(`Testing ${t}...`,"info");const i=m();try{const o=await(await fetch(`/api/v1/integrations/${t}/test`,{method:"POST",credentials:"include",headers:i})).json();d(o.success?`${t} healthy`:`${t} test failed`,o.success?"success":"warning")}catch{d(`${t} test failed`,"error")}},k=async t=>{if(!confirm("Revoke this API key? This cannot be undone."))return;const i=m();try{const o=await(await fetch(`/api/v1/api-keys/${t}/revoke`,{method:"POST",credentials:"include",headers:i})).json();o.success?(l(f=>f.filter(u=>u.id!==t)),d("API key revoked","success")):d(`Failed: ${o.error}`,"error")}catch{d("Failed to revoke key","error")}},T=r.filter(t=>t.status==="connected").length;return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs(A,{title:"",description:"",children:[e.jsx("div",{style:{background:"linear-gradient(180deg, rgba(6, 182, 212, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:"24px",fontWeight:700,color:"#06b6d4",margin:0,fontFamily:"var(--font-mono)",letterSpacing:"0.02em"},children:"🔌 INTEGRATIONS"}),e.jsxs("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.5)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:[T," of ",r.length," integrations connected"]})]}),e.jsxs("button",{onClick:()=>n("/api-keys"),style:{padding:"8px 16px",background:"rgba(6, 182, 212, 0.2)",border:"1px solid rgba(6, 182, 212, 0.4)",color:"#06b6d4",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(h,{size:12}),"CREATE API KEY"]})]})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"14px",fontWeight:700,color:"#fbbf24",marginBottom:"12px",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"AVAILABLE INTEGRATIONS"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:r.map(t=>e.jsx(H,{integration:t,onConnect:()=>C(t.id),onTest:()=>w(t.id)},t.id))})]}),e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"14px",fontWeight:700,color:"#fbbf24",marginBottom:"12px",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"API KEYS"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:s.map(t=>e.jsx(G,{apiKey:t,onRevoke:()=>k(t.id)},t.id))})]}),e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"14px",fontWeight:700,color:"#fbbf24",marginBottom:"12px",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:"SDK CODE EXAMPLES"}),e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:["python","nodejs","go","rust"].map(t=>e.jsx("button",{onClick:()=>c(t),style:{padding:"8px 16px",background:g===t?"rgba(251, 191, 36, 0.2)":"rgba(107, 114, 128, 0.1)",border:`1px solid ${g===t?"rgba(251, 191, 36, 0.4)":"rgba(107, 114, 128, 0.2)"}`,color:g===t?"#fbbf24":"#6b7280",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",cursor:"pointer",letterSpacing:"0.05em"},children:t.toUpperCase()},t))}),e.jsx(K,{language:g,code:S[g]})]})]})]})})})}export{Q as IntegrationsPremium}; -//# sourceMappingURL=IntegrationsPremium-seB-nk74.js.map diff --git a/apps/console-proxy/public/assets/IntentPage-BgvuBxmu.js b/apps/console-proxy/public/assets/IntentPage-DxOSxxxH.js similarity index 98% rename from apps/console-proxy/public/assets/IntentPage-BgvuBxmu.js rename to apps/console-proxy/public/assets/IntentPage-DxOSxxxH.js index 70dfc2f2..83d50940 100644 --- a/apps/console-proxy/public/assets/IntentPage-BgvuBxmu.js +++ b/apps/console-proxy/public/assets/IntentPage-DxOSxxxH.js @@ -1,2 +1,2 @@ -import{r as a,e as _,R as z,j as e}from"./index-D_7YXFSJ.js";const v=[{id:"check_health",label:"Health Check",desc:"Verify system health through the governance pipeline",tier:"T0",tierColor:"#94a3b8"},{id:"list_objectives",label:"List Objectives",desc:"Query active governance objectives and their states",tier:"T0",tierColor:"#94a3b8"},{id:"check_system_status",label:"System Status",desc:"Full system posture check — runtime, providers, state graph",tier:"T0",tierColor:"#94a3b8"},{id:"list_recent_executions",label:"Recent Executions",desc:"View the execution audit trail with outcomes",tier:"T0",tierColor:"#94a3b8",params:[{key:"limit",label:"Limit",placeholder:"10"}]},{id:"run_diagnostic",label:"Run Diagnostic",desc:"Execute system diagnostics — checks all governance engines",tier:"T0",tierColor:"#94a3b8"},{id:"check_execution_status",label:"Check Execution Status",desc:"Query status of a specific execution by ID",tier:"T0",tierColor:"#94a3b8",params:[{key:"execution_id",label:"Execution ID",placeholder:"exec-xxxxx-xxxx-xxxx",required:!0}]},{id:"query_state_graph",label:"Query State Graph",desc:"Query the canonical state graph for entities",tier:"T0",tierColor:"#94a3b8",params:[{key:"entity_type",label:"Entity Type",placeholder:"execution | objective | proposal"}]},{id:"restart_service",label:"Restart Service",desc:"Restart a specific service — requires operator approval",tier:"T1",tierColor:"#f59e0b",params:[{key:"service",label:"Service Name",placeholder:"api-gateway",required:!0}]},{id:"trigger_backup",label:"Trigger Backup",desc:"Initiate a state graph backup",tier:"T1",tierColor:"#f59e0b"},{id:"update_configuration",label:"Update Configuration",desc:"Modify a runtime configuration value",tier:"T1",tierColor:"#f59e0b",params:[{key:"key",label:"Config Key",placeholder:"rate_limit.max_requests",required:!0},{key:"value",label:"New Value",placeholder:"100",required:!0}]},{id:"check_service_logs",label:"Check Service Logs",desc:"Retrieve recent logs for a specific service",tier:"T1",tierColor:"#f59e0b",params:[{key:"service",label:"Service Name",placeholder:"intent-gateway",required:!0}]}];function w(){const[n,S]=a.useState("check_health"),[d,u]=a.useState(""),[h,j]=a.useState([]),[s,m]=a.useState({}),[y,k]=a.useState(!1),[p,f]=a.useState(!1),[r,l]=a.useState(null),{isMobile:C}=_();z.useEffect(()=>{fetch("/api/v1/agents",{credentials:"include"}).then(t=>t.json()).then(t=>{const o=(t.data||t.agents||[]).filter(g=>g.status==="active");j(o),o.length>0&&!d&&u(o[0].id)}).catch(()=>{})},[]);const i=v.find(t=>t.id===n),T=async()=>{if(!d){l({success:!1,error:"Please select an agent"});return}f(!0),l(null);try{const t={agent_id:d,action:n,source:"openclaw",tenant_id:"system",simulation:y};if(i.params&&i.params.length>0){const b={};for(const c of i.params)s[c.key]&&(b[c.key]=s[c.key],t[c.key]=s[c.key]);t.context=b}const g=await(await fetch("/api/v1/agent/intent",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)})).json();l(g)}catch(t){l({success:!1,error:t instanceof Error?t.message:"Request failed"})}f(!1)},x=r&&r.success===!0;return e.jsxs("div",{style:{padding:"28px 32px",maxWidth:"1400px",margin:"0 auto",fontFamily:"var(--font-sans)"},children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",margin:0},children:"Intent Submission"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-tertiary)",marginTop:"4px"},children:"Submit agent intents through the governed execution pipeline. Every action flows through policy → risk tier → warrant → execute → verify."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:C?"1fr":"1fr 1fr",gap:"24px"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Acting Agent"}),e.jsxs("select",{value:d,onChange:t=>u(t.target.value),style:{width:"100%",background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"6px",padding:"8px 12px",fontSize:"13px",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",boxSizing:"border-box",cursor:"pointer"},children:[h.length===0&&e.jsx("option",{value:"",children:"Loading agents..."}),h.map(t=>e.jsxs("option",{value:t.id,children:[t.display_name," (",t.id.slice(0,8),"...)"]},t.id))]})]}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Select Action"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px",marginBottom:"20px",maxHeight:"400px",overflowY:"auto"},children:v.map(t=>e.jsxs("button",{onClick:()=>{S(t.id),m({}),l(null)},style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"8px",border:n===t.id?"1px solid rgba(212, 165, 32, 0.3)":"1px solid var(--border-subtle)",background:n===t.id?"rgba(212, 165, 32, 0.06)":"var(--bg-primary)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"all 150ms"},children:[e.jsx("div",{style:{padding:"2px 6px",borderRadius:"4px",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",color:t.tierColor,background:`${t.tierColor}12`,border:`1px solid ${t.tierColor}20`,flexShrink:0},children:t.tier}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:n===t.id?"#D4A520":"var(--text-primary)"},children:t.label}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"1px"},children:t.desc})]})]},t.id))}),i.params&&i.params.length>0&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Parameters"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.params.map(t=>e.jsxs("div",{children:[e.jsxs("label",{style:{display:"block",fontSize:"11px",color:"var(--text-tertiary)",marginBottom:"4px"},children:[t.label," ",t.required&&e.jsx("span",{style:{color:"#D4A520"},children:"*"})]}),e.jsx("input",{value:s[t.key]||"",onChange:o=>m({...s,[t.key]:o.target.value}),placeholder:t.placeholder,style:{width:"100%",background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"6px",padding:"8px 12px",fontSize:"13px",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",boxSizing:"border-box"}})]},t.key))})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"},children:[e.jsx("input",{type:"checkbox",id:"sim",checked:y,onChange:t=>k(t.target.checked),style:{accentColor:"#D4A520"}}),e.jsx("label",{htmlFor:"sim",style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Simulation mode (dry run — no side effects)"})]}),e.jsx("button",{onClick:T,disabled:p,style:{width:"100%",padding:"12px",borderRadius:"8px",border:"none",background:p?"var(--bg-tertiary)":"#B8860B",color:"#fff",fontSize:"13px",fontWeight:600,cursor:p?"default":"pointer",fontFamily:"inherit",transition:"all 150ms"},children:p?"Executing...":`Submit ${i.tier} Intent: ${i.label}`})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Governance Response"}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px",minHeight:"500px"},children:r?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"},children:[e.jsx("div",{style:{padding:"3px 10px",borderRadius:"4px",fontSize:"11px",fontWeight:700,fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.05em",color:x?"#10b981":"#ef4444",background:x?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${x?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)"}`},children:x?"✓ Executed":"✗ Failed"}),r.status&&e.jsx("span",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:String(r.status)})]}),r.explanation&&e.jsx("div",{style:{background:"var(--bg-secondary)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"12px",color:"var(--text-secondary)",lineHeight:1.6},children:String(r.explanation)}),e.jsx("div",{style:{background:"var(--bg-app)",borderRadius:"8px",padding:"12px",overflow:"auto",maxHeight:"360px"},children:e.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-secondary)",lineHeight:1.6,margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(r,null,2)})})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"12px"},children:"🎯"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"6px"},children:"Select an intent and execute"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",maxWidth:"300px",lineHeight:1.6},children:"Every submission flows through the full governance pipeline: policy check → risk tier → warrant → execution → verification → audit trail."})]})})]})]})]})}export{w as IntentPage}; -//# sourceMappingURL=IntentPage-BgvuBxmu.js.map +import{r as a,h as _,R as z,j as e}from"./index-C0nK3ekl.js";const v=[{id:"check_health",label:"Health Check",desc:"Verify system health through the governance pipeline",tier:"T0",tierColor:"#94a3b8"},{id:"list_objectives",label:"List Objectives",desc:"Query active governance objectives and their states",tier:"T0",tierColor:"#94a3b8"},{id:"check_system_status",label:"System Status",desc:"Full system posture check — runtime, providers, state graph",tier:"T0",tierColor:"#94a3b8"},{id:"list_recent_executions",label:"Recent Executions",desc:"View the execution audit trail with outcomes",tier:"T0",tierColor:"#94a3b8",params:[{key:"limit",label:"Limit",placeholder:"10"}]},{id:"run_diagnostic",label:"Run Diagnostic",desc:"Execute system diagnostics — checks all governance engines",tier:"T0",tierColor:"#94a3b8"},{id:"check_execution_status",label:"Check Execution Status",desc:"Query status of a specific execution by ID",tier:"T0",tierColor:"#94a3b8",params:[{key:"execution_id",label:"Execution ID",placeholder:"exec-xxxxx-xxxx-xxxx",required:!0}]},{id:"query_state_graph",label:"Query State Graph",desc:"Query the canonical state graph for entities",tier:"T0",tierColor:"#94a3b8",params:[{key:"entity_type",label:"Entity Type",placeholder:"execution | objective | proposal"}]},{id:"restart_service",label:"Restart Service",desc:"Restart a specific service — requires operator approval",tier:"T1",tierColor:"#f59e0b",params:[{key:"service",label:"Service Name",placeholder:"api-gateway",required:!0}]},{id:"trigger_backup",label:"Trigger Backup",desc:"Initiate a state graph backup",tier:"T1",tierColor:"#f59e0b"},{id:"update_configuration",label:"Update Configuration",desc:"Modify a runtime configuration value",tier:"T1",tierColor:"#f59e0b",params:[{key:"key",label:"Config Key",placeholder:"rate_limit.max_requests",required:!0},{key:"value",label:"New Value",placeholder:"100",required:!0}]},{id:"check_service_logs",label:"Check Service Logs",desc:"Retrieve recent logs for a specific service",tier:"T1",tierColor:"#f59e0b",params:[{key:"service",label:"Service Name",placeholder:"intent-gateway",required:!0}]}];function w(){const[n,S]=a.useState("check_health"),[d,u]=a.useState(""),[h,j]=a.useState([]),[s,m]=a.useState({}),[y,k]=a.useState(!1),[p,f]=a.useState(!1),[r,l]=a.useState(null),{isMobile:C}=_();z.useEffect(()=>{fetch("/api/v1/agents",{credentials:"include"}).then(t=>t.json()).then(t=>{const o=(t.data||t.agents||[]).filter(g=>g.status==="active");j(o),o.length>0&&!d&&u(o[0].id)}).catch(()=>{})},[]);const i=v.find(t=>t.id===n),T=async()=>{if(!d){l({success:!1,error:"Please select an agent"});return}f(!0),l(null);try{const t={agent_id:d,action:n,source:"openclaw",tenant_id:"system",simulation:y};if(i.params&&i.params.length>0){const b={};for(const c of i.params)s[c.key]&&(b[c.key]=s[c.key],t[c.key]=s[c.key]);t.context=b}const g=await(await fetch("/api/v1/agent/intent",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(t)})).json();l(g)}catch(t){l({success:!1,error:t instanceof Error?t.message:"Request failed"})}f(!1)},x=r&&r.success===!0;return e.jsxs("div",{style:{padding:"28px 32px",maxWidth:"1400px",margin:"0 auto",fontFamily:"var(--font-sans)"},children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h1",{style:{fontSize:"22px",fontWeight:700,color:"var(--text-primary)",letterSpacing:"-0.02em",margin:0},children:"Intent Submission"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-tertiary)",marginTop:"4px"},children:"Submit agent intents through the governed execution pipeline. Every action flows through policy → risk tier → warrant → execute → verify."})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:C?"1fr":"1fr 1fr",gap:"24px"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Acting Agent"}),e.jsxs("select",{value:d,onChange:t=>u(t.target.value),style:{width:"100%",background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"6px",padding:"8px 12px",fontSize:"13px",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",boxSizing:"border-box",cursor:"pointer"},children:[h.length===0&&e.jsx("option",{value:"",children:"Loading agents..."}),h.map(t=>e.jsxs("option",{value:t.id,children:[t.display_name," (",t.id.slice(0,8),"...)"]},t.id))]})]}),e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Select Action"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"4px",marginBottom:"20px",maxHeight:"400px",overflowY:"auto"},children:v.map(t=>e.jsxs("button",{onClick:()=>{S(t.id),m({}),l(null)},style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderRadius:"8px",border:n===t.id?"1px solid rgba(212, 165, 32, 0.3)":"1px solid var(--border-subtle)",background:n===t.id?"rgba(212, 165, 32, 0.06)":"var(--bg-primary)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"all 150ms"},children:[e.jsx("div",{style:{padding:"2px 6px",borderRadius:"4px",fontSize:"10px",fontWeight:700,fontFamily:"var(--font-mono)",color:t.tierColor,background:`${t.tierColor}12`,border:`1px solid ${t.tierColor}20`,flexShrink:0},children:t.tier}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:n===t.id?"#D4A520":"var(--text-primary)"},children:t.label}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"1px"},children:t.desc})]})]},t.id))}),i.params&&i.params.length>0&&e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Parameters"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:i.params.map(t=>e.jsxs("div",{children:[e.jsxs("label",{style:{display:"block",fontSize:"11px",color:"var(--text-tertiary)",marginBottom:"4px"},children:[t.label," ",t.required&&e.jsx("span",{style:{color:"#D4A520"},children:"*"})]}),e.jsx("input",{value:s[t.key]||"",onChange:o=>m({...s,[t.key]:o.target.value}),placeholder:t.placeholder,style:{width:"100%",background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"6px",padding:"8px 12px",fontSize:"13px",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",boxSizing:"border-box"}})]},t.key))})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"},children:[e.jsx("input",{type:"checkbox",id:"sim",checked:y,onChange:t=>k(t.target.checked),style:{accentColor:"#D4A520"}}),e.jsx("label",{htmlFor:"sim",style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Simulation mode (dry run — no side effects)"})]}),e.jsx("button",{onClick:T,disabled:p,style:{width:"100%",padding:"12px",borderRadius:"8px",border:"none",background:p?"var(--bg-tertiary)":"#B8860B",color:"#fff",fontSize:"13px",fontWeight:600,cursor:p?"default":"pointer",fontFamily:"inherit",transition:"all 150ms"},children:p?"Executing...":`Submit ${i.tier} Intent: ${i.label}`})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Governance Response"}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px",minHeight:"500px"},children:r?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"16px"},children:[e.jsx("div",{style:{padding:"3px 10px",borderRadius:"4px",fontSize:"11px",fontWeight:700,fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.05em",color:x?"#10b981":"#ef4444",background:x?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${x?"rgba(16, 185, 129, 0.2)":"rgba(239, 68, 68, 0.2)"}`},children:x?"✓ Executed":"✗ Failed"}),r.status&&e.jsx("span",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:String(r.status)})]}),r.explanation&&e.jsx("div",{style:{background:"var(--bg-secondary)",borderRadius:"8px",padding:"12px",marginBottom:"16px",fontSize:"12px",color:"var(--text-secondary)",lineHeight:1.6},children:String(r.explanation)}),e.jsx("div",{style:{background:"var(--bg-app)",borderRadius:"8px",padding:"12px",overflow:"auto",maxHeight:"360px"},children:e.jsx("pre",{style:{fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-secondary)",lineHeight:1.6,margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(r,null,2)})})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",minHeight:"300px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"12px"},children:"🎯"}),e.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"6px"},children:"Select an intent and execute"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",maxWidth:"300px",lineHeight:1.6},children:"Every submission flows through the full governance pipeline: policy check → risk tier → warrant → execution → verification → audit trail."})]})})]})]})]})}export{w as IntentPage}; +//# sourceMappingURL=IntentPage-DxOSxxxH.js.map diff --git a/apps/console-proxy/public/assets/NowPage-C77cUF1w.js b/apps/console-proxy/public/assets/NowPage-C77cUF1w.js new file mode 100644 index 00000000..3ef50a04 --- /dev/null +++ b/apps/console-proxy/public/assets/NowPage-C77cUF1w.js @@ -0,0 +1,2 @@ +import{r as l,u as M,j as e}from"./index-C0nK3ekl.js";function $(t={}){const{enabled:n=!0,maxEvents:d=50,onEvent:a}=t,[o,c]=l.useState(!1),[h,b]=l.useState([]),[v,u]=l.useState(null),p=l.useRef(null),f=l.useRef(),g=l.useCallback(()=>{if(n){p.current&&p.current.close();try{const s=new EventSource("/api/v1/stream/events");p.current=s,s.onopen=()=>{c(!0),u(null)},s.onmessage=x=>{try{const m=JSON.parse(x.data);if(m.type==="connected"){c(!0);return}m.type==="pipeline_event"&&(b(S=>[m,...S].slice(0,d)),a==null||a(m))}catch{}},s.onerror=()=>{c(!1),u("Stream disconnected"),s.close(),f.current=setTimeout(g,5e3)}}catch{u("Failed to connect to event stream")}}},[n,d,a]);l.useEffect(()=>(g(),()=>{var s;(s=p.current)==null||s.close(),f.current&&clearTimeout(f.current)}),[g]);const r=l.useCallback(()=>b([]),[]);return{connected:o,events:h,error:v,clearEvents:r}}async function y(t){return(await fetch(t,{credentials:"include"})).json()}function Q(){const[t,n]=l.useState(null),[d,a]=l.useState(!0),[o,c]=l.useState(null),[h,b]=l.useState(new Date),{connected:v,events:u}=$({enabled:!0,maxEvents:20}),p=l.useCallback(async()=>{var r,s;try{c(null);const[x,m,S,E,B,F,A,D]=await Promise.all([y("/api/v1/agents"),y("/api/v1/proposals"),y("/api/v1/warrants"),y("/api/v1/audit/recent?limit=10"),y("/api/v1/policies"),y("/api/v1/policy-rules"),y("/api/v1/anomalies?limit=5"),y("/api/v1/analytics/value-summary").catch(()=>({data:null}))]),R=x.data||[],w=m.data||[],T=S.data||[],C=((r=E.data)==null?void 0:r.entries)||[],L=((s=E.data)==null?void 0:s.total)||C.length,W=B.data||[],I=F.data||[],_=A.data||[],V=D.data;n({agents:{total:R.length,active:R.filter(i=>i.status==="active").length,suspended:R.filter(i=>i.status==="suspended").length},proposals:{total:w.length,pending:w.filter(i=>i.state==="pending").length,approved:w.filter(i=>i.state==="approved"||i.state==="warranted").length,denied:w.filter(i=>i.state==="denied").length},warrants:{total:T.length,active:T.filter(i=>!i.revoked&&new Date(i.expires_at)>new Date).length,revoked:T.filter(i=>i.revoked).length,expired:T.filter(i=>!i.revoked&&new Date(i.expires_at)<=new Date).length},audit:{total:L,recent:C},policies:{total:W.length,enabled:W.filter(i=>i.enabled).length},policyRules:{total:I.length,enabled:I.filter(i=>i.enabled).length},anomalies:{total:_.length,critical:_.filter(i=>i.severity==="critical").length,high:_.filter(i=>i.severity==="high").length,recent:_.slice(0,5)},valueSummary:V}),b(new Date)}catch(x){c(x instanceof Error?x.message:"Failed to load")}finally{a(!1)}},[]);l.useEffect(()=>{p();const r=setInterval(p,3e4);return()=>clearInterval(r)},[p]),l.useEffect(()=>{u.length>0&&p()},[u.length]);const f=M(),g=r=>{f(`/${r}`)};return!t&&d?e.jsxs("div",{style:{maxWidth:960,margin:"0 auto",padding:"48px 24px"},children:[e.jsx("div",{style:{height:24,width:200,background:"var(--bg-secondary)",borderRadius:6,marginBottom:8}}),e.jsx("div",{style:{height:14,width:140,background:"var(--bg-secondary)",borderRadius:4,marginBottom:40}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:1},children:[...Array(6)].map((r,s)=>e.jsx("div",{style:{height:80,background:"var(--bg-secondary)",borderRadius:s===0?"8px 0 0 8px":s===5?"0 8px 8px 0":0}},s))})]}):e.jsxs("div",{style:{maxWidth:960,margin:"0 auto",padding:"40px 24px"},children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:22,fontWeight:600,color:"var(--text-primary)",margin:0,letterSpacing:"-0.02em"},children:"System Posture"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-tertiary)",margin:"4px 0 0"},children:"Operational overview"})]}),e.jsxs("button",{onClick:()=>{a(!0),p()},style:{padding:"6px 12px",fontSize:12,color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer",fontFamily:"var(--font-mono)",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:["↻ ",h.toLocaleTimeString()]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:v?"#10b981":o?"#ef4444":"#f59e0b"}}),e.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.05em"},children:v?"Streaming":"Polling"})]}),v&&e.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,background:"rgba(16, 185, 129, 0.1)",color:"#10b981",fontFamily:"var(--font-mono)",fontWeight:500,letterSpacing:"0.05em"},children:"SSE LIVE"})]})]}),o&&e.jsx("div",{style:{padding:"10px 14px",marginBottom:24,fontSize:13,color:"#ef4444",background:"rgba(239,68,68,0.06)",borderRadius:6},children:o}),t&&e.jsxs(e.Fragment,{children:[t.proposals.pending>0&&e.jsxs("div",{onClick:()=>g("approvals"),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",marginBottom:20,background:"rgba(245, 158, 11, 0.04)",borderRadius:6,cursor:"pointer",transition:"background 150ms"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(245, 158, 11, 0.08)"},onMouseLeave:r=>{r.currentTarget.style.background="rgba(245, 158, 11, 0.04)"},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#f59e0b",flexShrink:0}}),e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"#f59e0b"},children:[t.proposals.pending," proposal",t.proposals.pending!==1?"s":""," awaiting approval"]}),e.jsx("span",{style:{fontSize:12,color:"var(--text-tertiary)",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{className:"dashboard-grid",style:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:1,background:"var(--border-subtle)",borderRadius:8,overflow:"hidden",marginBottom:24},children:[e.jsx(j,{label:"Agents",value:t.agents.active,detail:`/${t.agents.total}`,onClick:()=>g("fleet")}),e.jsx(j,{label:"Proposals",value:t.proposals.total,detail:t.proposals.pending>0?`${t.proposals.pending} pending`:void 0,onClick:()=>g("intent")}),e.jsx(j,{label:"Warrants",value:t.warrants.total,detail:t.warrants.active>0?`${t.warrants.active} active`:void 0,onClick:()=>g("approvals")}),e.jsx(j,{label:"Policies",value:t.policies.enabled,detail:`/${t.policies.total}`,onClick:()=>g("policies")}),e.jsx(j,{label:"Rules",value:t.policyRules.enabled,detail:`/${t.policyRules.total}`,onClick:()=>g("policy-templates")}),e.jsx(j,{label:"Audit Events",value:t.audit.total,onClick:()=>g("history")})]}),e.jsx(O,{snapshot:t}),e.jsxs("div",{className:"dashboard-grid",style:{display:"grid",gridTemplateColumns:"3fr 2fr",gap:24,alignItems:"start"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:v?"#10b981":"var(--text-tertiary)"}}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Live Governance"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:8,overflow:"hidden"},children:u.length>0?u.slice(0,8).map((r,s)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",borderBottom:sg("history"),style:{fontSize:11,color:"var(--text-tertiary)",cursor:"pointer",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:"View all →"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:8,overflow:"hidden"},children:t.audit.recent.length===0&&t.agents.total===0&&t.proposals.total===0&&t.warrants.total===0?e.jsx(P,{}):t.audit.recent.length===0?e.jsxs("div",{style:{padding:"24px 16px"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-secondary)",marginBottom:6},children:"No recent events"}),e.jsx("span",{onClick:()=>g("intent"),style:{fontSize:12,color:"var(--text-tertiary)",cursor:"pointer",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:"Submit intent →"})]}):t.audit.recent.slice(0,6).map((r,s)=>{const x=r.event||r.action||"unknown",S={warrant_issued:"#f59e0b",execution_verified:"#10b981",execution_denied:"#ef4444",proposal_pending:"#3b82f6",proposal_denied:"#ef4444",warrant_revoked:"#f59e0b"}[x]||"var(--text-tertiary)";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 16px",borderBottom:se.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 16px",borderBottom:dwindow.open("https://regulator.ai/try","_blank")})]})]})]})}function z({icon:t,label:n,href:d}){const a=M();return e.jsxs("button",{onClick:()=>a(d),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",cursor:"pointer",transition:"all var(--transition-fast)",fontSize:"var(--text-body)",color:"var(--text-secondary)",fontWeight:500,width:"100%",textAlign:"left",fontFamily:"var(--font-sans)"},onMouseEnter:o=>{o.currentTarget.style.background="var(--bg-tertiary)",o.currentTarget.style.borderColor="var(--border-strong)",o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.background="var(--bg-primary)",o.currentTarget.style.borderColor="var(--border-subtle)",o.currentTarget.style.color="var(--text-secondary)"},children:[e.jsx("span",{style:{fontSize:14},children:t}),e.jsx("span",{children:n})]})}function N({icon:t,label:n,onClick:d}){return e.jsxs("button",{onClick:d,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",cursor:"pointer",transition:"all var(--transition-fast)",fontSize:"var(--text-body)",color:"var(--text-secondary)",fontWeight:500,width:"100%",textAlign:"left",fontFamily:"var(--font-sans)"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-tertiary)",a.currentTarget.style.borderColor="var(--border-strong)",a.currentTarget.style.color="var(--text-primary)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-primary)",a.currentTarget.style.borderColor="var(--border-subtle)",a.currentTarget.style.color="var(--text-secondary)"},children:[e.jsx("span",{style:{fontSize:14},children:t}),e.jsx("span",{children:n})]})}function O({snapshot:t}){const[n,d]=l.useState(!1);l.useEffect(()=>{const c=setTimeout(()=>d(!0),200);return()=>clearTimeout(c)},[]);const a=t.valueSummary||{actions_governed:0,violations_caught:0,approvals_processed:0,estimated_risk_avoided:0,audit_events:0,demo:!0},o=c=>c>=1e6?`$${(c/1e6).toFixed(1)}M`:c>=1e3?`$${(c/1e3).toFixed(0)}K`:`$${c}`;return e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:12,padding:"20px 24px",marginBottom:32,position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:"🛡️"}),e.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:"Value Delivered"})]}),a.demo&&e.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:4,background:"rgba(139, 92, 246, 0.1)",color:"#8b5cf6",fontWeight:500,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Demo Data"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"16px"},children:[e.jsx(k,{label:"Actions Governed",value:a.actions_governed,color:"#10b981",animate:n}),e.jsx(k,{label:"Violations Caught",value:a.violations_caught,color:"#ef4444",animate:n}),e.jsx(k,{label:"Approvals Processed",value:a.approvals_processed,color:"#3b82f6",animate:n}),e.jsx(k,{label:"Estimated Risk Avoided",value:a.estimated_risk_avoided,color:"#10b981",formatter:o,animate:n}),e.jsx(k,{label:"Audit Events",value:a.audit_events,color:"#8b5cf6",animate:n})]})]})}function k({label:t,value:n,color:d,formatter:a,animate:o=!1}){const[c,h]=l.useState(0);return l.useEffect(()=>{if(!o){h(n);return}const b=1500,v=60,u=n/v;let p=0;const f=setInterval(()=>{p+=u,p>=n&&(p=n,clearInterval(f)),h(Math.round(p))},b/v);return()=>clearInterval(f)},[n,o]),e.jsxs("div",{style:{textAlign:"left"},children:[e.jsx("div",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:d,fontVariantNumeric:"tabular-nums",lineHeight:1},children:a?a(c):c.toLocaleString()})]})}function j({label:t,value:n,detail:d,onClick:a}){return e.jsxs("div",{onClick:a,style:{background:"var(--bg-primary)",padding:"16px 20px",cursor:a?"pointer":"default",transition:"background 150ms"},onMouseEnter:o=>{a&&(o.currentTarget.style.background="var(--bg-secondary)")},onMouseLeave:o=>{a&&(o.currentTarget.style.background="var(--bg-primary)")},children:[e.jsx("div",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:4},children:[e.jsx("span",{style:{fontSize:26,fontWeight:600,color:"var(--text-primary)",fontVariantNumeric:"tabular-nums",lineHeight:1},children:n}),d&&e.jsx("span",{style:{fontSize:12,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:d})]})]})}export{Q as NowPage}; +//# sourceMappingURL=NowPage-C77cUF1w.js.map diff --git a/apps/console-proxy/public/assets/NowPage-CsxHNsT_.js b/apps/console-proxy/public/assets/NowPage-CsxHNsT_.js deleted file mode 100644 index 2060d664..00000000 --- a/apps/console-proxy/public/assets/NowPage-CsxHNsT_.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as c,u as M,j as e}from"./index-D_7YXFSJ.js";import{u as $}from"./useEventStream-VJ5QEnuI.js";async function u(t){return(await fetch(t,{credentials:"include"})).json()}function H(){const[t,i]=c.useState(null),[s,a]=c.useState(!0),[o,l]=c.useState(null),[h,w]=c.useState(new Date),{connected:x,events:v}=$({enabled:!0,maxEvents:20}),p=c.useCallback(async()=>{var r,d;try{l(null);const[y,z,T,W,B,A,F,D]=await Promise.all([u("/api/v1/agents"),u("/api/v1/proposals"),u("/api/v1/warrants"),u("/api/v1/audit/recent?limit=10"),u("/api/v1/policies"),u("/api/v1/policy-rules"),u("/api/v1/anomalies?limit=5"),u("/api/v1/analytics/value-summary").catch(()=>({data:null}))]),_=y.data||[],j=z.data||[],S=T.data||[],C=((r=W.data)==null?void 0:r.entries)||[],L=((d=W.data)==null?void 0:d.total)||C.length,E=B.data||[],I=A.data||[],k=F.data||[],V=D.data;i({agents:{total:_.length,active:_.filter(n=>n.status==="active").length,suspended:_.filter(n=>n.status==="suspended").length},proposals:{total:j.length,pending:j.filter(n=>n.state==="pending").length,approved:j.filter(n=>n.state==="approved"||n.state==="warranted").length,denied:j.filter(n=>n.state==="denied").length},warrants:{total:S.length,active:S.filter(n=>!n.revoked&&new Date(n.expires_at)>new Date).length,revoked:S.filter(n=>n.revoked).length,expired:S.filter(n=>!n.revoked&&new Date(n.expires_at)<=new Date).length},audit:{total:L,recent:C},policies:{total:E.length,enabled:E.filter(n=>n.enabled).length},policyRules:{total:I.length,enabled:I.filter(n=>n.enabled).length},anomalies:{total:k.length,critical:k.filter(n=>n.severity==="critical").length,high:k.filter(n=>n.severity==="high").length,recent:k.slice(0,5)},valueSummary:V}),w(new Date)}catch(y){l(y instanceof Error?y.message:"Failed to load")}finally{a(!1)}},[]);c.useEffect(()=>{p();const r=setInterval(p,3e4);return()=>clearInterval(r)},[p]),c.useEffect(()=>{v.length>0&&p()},[v.length]);const b=M(),g=r=>{b(`/${r}`)};return!t&&s?e.jsxs("div",{style:{maxWidth:960,margin:"0 auto",padding:"48px 24px"},children:[e.jsx("div",{style:{height:24,width:200,background:"var(--bg-secondary)",borderRadius:6,marginBottom:8}}),e.jsx("div",{style:{height:14,width:140,background:"var(--bg-secondary)",borderRadius:4,marginBottom:40}}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:1},children:[...Array(6)].map((r,d)=>e.jsx("div",{style:{height:80,background:"var(--bg-secondary)",borderRadius:d===0?"8px 0 0 8px":d===5?"0 8px 8px 0":0}},d))})]}):e.jsxs("div",{style:{maxWidth:960,margin:"0 auto",padding:"40px 24px"},children:[e.jsxs("div",{style:{marginBottom:32},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h1",{style:{fontSize:22,fontWeight:600,color:"var(--text-primary)",margin:0,letterSpacing:"-0.02em"},children:"System Posture"}),e.jsx("p",{style:{fontSize:13,color:"var(--text-tertiary)",margin:"4px 0 0"},children:"Operational overview"})]}),e.jsxs("button",{onClick:()=>{a(!0),p()},style:{padding:"6px 12px",fontSize:12,color:"var(--text-tertiary)",background:"none",border:"none",cursor:"pointer",fontFamily:"var(--font-mono)",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:["↻ ",h.toLocaleTimeString()]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:x?"#10b981":o?"#ef4444":"#f59e0b"}}),e.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",textTransform:"uppercase",letterSpacing:"0.05em"},children:x?"Streaming":"Polling"})]}),x&&e.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:3,background:"rgba(16, 185, 129, 0.1)",color:"#10b981",fontFamily:"var(--font-mono)",fontWeight:500,letterSpacing:"0.05em"},children:"SSE LIVE"})]})]}),o&&e.jsx("div",{style:{padding:"10px 14px",marginBottom:24,fontSize:13,color:"#ef4444",background:"rgba(239,68,68,0.06)",borderRadius:6},children:o}),t&&e.jsxs(e.Fragment,{children:[t.proposals.pending>0&&e.jsxs("div",{onClick:()=>g("approvals"),style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px",marginBottom:20,background:"rgba(245, 158, 11, 0.04)",borderRadius:6,cursor:"pointer",transition:"background 150ms"},onMouseEnter:r=>{r.currentTarget.style.background="rgba(245, 158, 11, 0.08)"},onMouseLeave:r=>{r.currentTarget.style.background="rgba(245, 158, 11, 0.04)"},children:[e.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#f59e0b",flexShrink:0}}),e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"#f59e0b"},children:[t.proposals.pending," proposal",t.proposals.pending!==1?"s":""," awaiting approval"]}),e.jsx("span",{style:{fontSize:12,color:"var(--text-tertiary)",marginLeft:"auto"},children:"→"})]}),e.jsxs("div",{className:"dashboard-grid",style:{display:"grid",gridTemplateColumns:"repeat(6, 1fr)",gap:1,background:"var(--border-subtle)",borderRadius:8,overflow:"hidden",marginBottom:24},children:[e.jsx(m,{label:"Agents",value:t.agents.active,detail:`/${t.agents.total}`,onClick:()=>g("fleet")}),e.jsx(m,{label:"Proposals",value:t.proposals.total,detail:t.proposals.pending>0?`${t.proposals.pending} pending`:void 0,onClick:()=>g("intent")}),e.jsx(m,{label:"Warrants",value:t.warrants.total,detail:t.warrants.active>0?`${t.warrants.active} active`:void 0,onClick:()=>g("approvals")}),e.jsx(m,{label:"Policies",value:t.policies.enabled,detail:`/${t.policies.total}`,onClick:()=>g("policies")}),e.jsx(m,{label:"Rules",value:t.policyRules.enabled,detail:`/${t.policyRules.total}`,onClick:()=>g("policy-templates")}),e.jsx(m,{label:"Audit Events",value:t.audit.total,onClick:()=>g("history")})]}),e.jsx(G,{snapshot:t}),e.jsxs("div",{className:"dashboard-grid",style:{display:"grid",gridTemplateColumns:"3fr 2fr",gap:24,alignItems:"start"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:16},children:[e.jsx("div",{style:{width:5,height:5,borderRadius:"50%",background:x?"#10b981":"var(--text-tertiary)"}}),e.jsx("span",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Live Governance"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:8,overflow:"hidden"},children:v.length>0?v.slice(0,8).map((r,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",borderBottom:dg("history"),style:{fontSize:11,color:"var(--text-tertiary)",cursor:"pointer",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:"View all →"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",borderRadius:8,overflow:"hidden"},children:t.audit.recent.length===0&&t.agents.total===0&&t.proposals.total===0&&t.warrants.total===0?e.jsx(P,{}):t.audit.recent.length===0?e.jsxs("div",{style:{padding:"24px 16px"},children:[e.jsx("div",{style:{fontSize:14,fontWeight:500,color:"var(--text-secondary)",marginBottom:6},children:"No recent events"}),e.jsx("span",{onClick:()=>g("intent"),style:{fontSize:12,color:"var(--text-tertiary)",cursor:"pointer",transition:"color 150ms"},onMouseEnter:r=>{r.currentTarget.style.color="var(--text-primary)"},onMouseLeave:r=>{r.currentTarget.style.color="var(--text-tertiary)"},children:"Submit intent →"})]}):t.audit.recent.slice(0,6).map((r,d)=>{const y=r.event||r.action||"unknown",T={warrant_issued:"#f59e0b",execution_verified:"#10b981",execution_denied:"#ef4444",proposal_pending:"#3b82f6",proposal_denied:"#ef4444",warrant_revoked:"#f59e0b"}[y]||"var(--text-tertiary)";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"9px 16px",borderBottom:de.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"8px 16px",borderBottom:swindow.open("https://regulator.ai/try","_blank")})]})]})]})}function R({icon:t,label:i,href:s}){const a=M();return e.jsxs("button",{onClick:()=>a(s),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",cursor:"pointer",transition:"all var(--transition-fast)",fontSize:"var(--text-body)",color:"var(--text-secondary)",fontWeight:500,width:"100%",textAlign:"left",fontFamily:"var(--font-sans)"},onMouseEnter:o=>{o.currentTarget.style.background="var(--bg-tertiary)",o.currentTarget.style.borderColor="var(--border-strong)",o.currentTarget.style.color="var(--text-primary)"},onMouseLeave:o=>{o.currentTarget.style.background="var(--bg-primary)",o.currentTarget.style.borderColor="var(--border-subtle)",o.currentTarget.style.color="var(--text-secondary)"},children:[e.jsx("span",{style:{fontSize:14},children:t}),e.jsx("span",{children:i})]})}function N({icon:t,label:i,onClick:s}){return e.jsxs("button",{onClick:s,style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"var(--radius-md)",cursor:"pointer",transition:"all var(--transition-fast)",fontSize:"var(--text-body)",color:"var(--text-secondary)",fontWeight:500,width:"100%",textAlign:"left",fontFamily:"var(--font-sans)"},onMouseEnter:a=>{a.currentTarget.style.background="var(--bg-tertiary)",a.currentTarget.style.borderColor="var(--border-strong)",a.currentTarget.style.color="var(--text-primary)"},onMouseLeave:a=>{a.currentTarget.style.background="var(--bg-primary)",a.currentTarget.style.borderColor="var(--border-subtle)",a.currentTarget.style.color="var(--text-secondary)"},children:[e.jsx("span",{style:{fontSize:14},children:t}),e.jsx("span",{children:i})]})}function G({snapshot:t}){const[i,s]=c.useState(!1);c.useEffect(()=>{const l=setTimeout(()=>s(!0),200);return()=>clearTimeout(l)},[]);const a=t.valueSummary||{actions_governed:0,violations_caught:0,approvals_processed:0,estimated_risk_avoided:0,audit_events:0,demo:!0},o=l=>l>=1e6?`$${(l/1e6).toFixed(1)}M`:l>=1e3?`$${(l/1e3).toFixed(0)}K`:`$${l}`;return e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:12,padding:"20px 24px",marginBottom:32,position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:"🛡️"}),e.jsx("h3",{style:{margin:0,fontSize:16,fontWeight:600,color:"var(--text-primary)"},children:"Value Delivered"})]}),a.demo&&e.jsx("span",{style:{fontSize:10,padding:"2px 8px",borderRadius:4,background:"rgba(139, 92, 246, 0.1)",color:"#8b5cf6",fontWeight:500,textTransform:"uppercase",letterSpacing:"0.05em"},children:"Demo Data"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"16px"},children:[e.jsx(f,{label:"Actions Governed",value:a.actions_governed,color:"#10b981",animate:i}),e.jsx(f,{label:"Violations Caught",value:a.violations_caught,color:"#ef4444",animate:i}),e.jsx(f,{label:"Approvals Processed",value:a.approvals_processed,color:"#3b82f6",animate:i}),e.jsx(f,{label:"Estimated Risk Avoided",value:a.estimated_risk_avoided,color:"#10b981",formatter:o,animate:i}),e.jsx(f,{label:"Audit Events",value:a.audit_events,color:"#8b5cf6",animate:i})]})]})}function f({label:t,value:i,color:s,formatter:a,animate:o=!1}){const[l,h]=c.useState(0);return c.useEffect(()=>{if(!o){h(i);return}const w=1500,x=60,v=i/x;let p=0;const b=setInterval(()=>{p+=v,p>=i&&(p=i,clearInterval(b)),h(Math.round(p))},w/x);return()=>clearInterval(b)},[i,o]),e.jsxs("div",{style:{textAlign:"left"},children:[e.jsx("div",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:4},children:t}),e.jsx("div",{style:{fontSize:20,fontWeight:700,color:s,fontVariantNumeric:"tabular-nums",lineHeight:1},children:a?a(l):l.toLocaleString()})]})}function m({label:t,value:i,detail:s,onClick:a}){return e.jsxs("div",{onClick:a,style:{background:"var(--bg-primary)",padding:"16px 20px",cursor:a?"pointer":"default",transition:"background 150ms"},onMouseEnter:o=>{a&&(o.currentTarget.style.background="var(--bg-secondary)")},onMouseLeave:o=>{a&&(o.currentTarget.style.background="var(--bg-primary)")},children:[e.jsx("div",{style:{fontSize:11,fontWeight:500,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:4},children:[e.jsx("span",{style:{fontSize:26,fontWeight:600,color:"var(--text-primary)",fontVariantNumeric:"tabular-nums",lineHeight:1},children:i}),s&&e.jsx("span",{style:{fontSize:12,color:"var(--text-tertiary)",fontFamily:"var(--font-mono)"},children:s})]})]})}export{H as NowPage}; -//# sourceMappingURL=NowPage-CsxHNsT_.js.map diff --git a/apps/console-proxy/public/assets/PageLayout-CTYKc2go.js b/apps/console-proxy/public/assets/PageLayout-D94mSHCV.js similarity index 85% rename from apps/console-proxy/public/assets/PageLayout-CTYKc2go.js rename to apps/console-proxy/public/assets/PageLayout-D94mSHCV.js index f61474af..43a09a33 100644 --- a/apps/console-proxy/public/assets/PageLayout-CTYKc2go.js +++ b/apps/console-proxy/public/assets/PageLayout-D94mSHCV.js @@ -1,2 +1,2 @@ -import{j as e}from"./index-D_7YXFSJ.js";function l({title:t,description:s,children:i,actions:a}){return e.jsxs("div",{style:{padding:"var(--space-6) var(--space-8)",maxWidth:"1400px",margin:"0 auto",fontFamily:"var(--font-sans)",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"var(--space-6)",position:"relative"},children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-title",style:{margin:0},children:t}),s&&e.jsx("p",{className:"text-body",style:{margin:"var(--space-2) 0 0 0"},children:s})]}),a&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:a})]}),e.jsx("div",{children:i})]})}export{l as P}; -//# sourceMappingURL=PageLayout-CTYKc2go.js.map +import{j as e}from"./index-C0nK3ekl.js";function l({title:t,description:s,children:i,actions:a}){return e.jsxs("div",{style:{padding:"var(--space-6) var(--space-8)",maxWidth:"1400px",margin:"0 auto",fontFamily:"var(--font-sans)",position:"relative"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"var(--space-6)",position:"relative"},children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-title",style:{margin:0},children:t}),s&&e.jsx("p",{className:"text-body",style:{margin:"var(--space-2) 0 0 0"},children:s})]}),a&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"var(--space-2)"},children:a})]}),e.jsx("div",{children:i})]})}export{l as P}; +//# sourceMappingURL=PageLayout-D94mSHCV.js.map diff --git a/apps/console-proxy/public/assets/PolicyBuilderPage-emZlR9y7.js b/apps/console-proxy/public/assets/PolicyBuilderPage-Bg5susqy.js similarity index 96% rename from apps/console-proxy/public/assets/PolicyBuilderPage-emZlR9y7.js rename to apps/console-proxy/public/assets/PolicyBuilderPage-Bg5susqy.js index 749e42a8..6a87441b 100644 --- a/apps/console-proxy/public/assets/PolicyBuilderPage-emZlR9y7.js +++ b/apps/console-proxy/public/assets/PolicyBuilderPage-Bg5susqy.js @@ -1,4 +1,4 @@ -import{r as l,l as Q,j as e,g as X,h as Z,i as ee,t as te,k as ae,m as ne,n as re,o as ie,p as Y,q as le,s as oe}from"./index-D_7YXFSJ.js";import{P as se}from"./PageLayout-CTYKc2go.js";const N=[{value:"action_type",label:"Action Type",type:"string"},{value:"agent_id",label:"Agent ID",type:"string"},{value:"amount",label:"Amount",type:"number"},{value:"environment",label:"Environment",type:"string"},{value:"time_of_day",label:"Time of Day",type:"time"},{value:"day_of_week",label:"Day of Week",type:"string"},{value:"source_ip",label:"Source IP",type:"string"},{value:"risk_score",label:"Risk Score",type:"number"},{value:"resource_type",label:"Resource Type",type:"string"},{value:"custom",label:"Custom Field…",type:"custom"}],U={string:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"contains",label:"contains"},{value:"not_contains",label:"not contains"},{value:"in",label:"in list"},{value:"not_in",label:"not in list"},{value:"matches",label:"regex"},{value:"exists",label:"exists"},{value:"not_exists",label:"not exists"}],number:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"gt",label:">"},{value:"gte",label:"≥"},{value:"lt",label:"<"},{value:"lte",label:"≤"},{value:"between",label:"between"},{value:"exists",label:"exists"}],time:[{value:"time_between",label:"between"},{value:"equals",label:"="}],custom:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"contains",label:"contains"},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"in",label:"in list"},{value:"exists",label:"exists"}]},L=[{value:"allow",label:"Allow",color:"#10b981",icon:"✅"},{value:"deny",label:"Deny",color:"#ef4444",icon:"🚫"},{value:"require_approval",label:"Require Approval",color:"#f59e0b",icon:"⏳"},{value:"flag_for_review",label:"Flag for Review",color:"#f59e0b",icon:"🔍"},{value:"rate_limit",label:"Rate Limit",color:"#f59e0b",icon:"⏱️"},{value:"escalate",label:"Escalate",color:"#f59e0b",icon:"🔺"}],de=[{value:"T0",label:"T0 — Auto-approved"},{value:"T1",label:"T1 — Single approver"},{value:"T2",label:"T2 — Multi-party"}],pe=`{ +import{r as l,l as Q,j as e,i as X,k as Z,m as ee,t as te,n as ae,o as ne,p as re,q as ie,s as Y,v as le,w as oe}from"./index-C0nK3ekl.js";import{P as se}from"./PageLayout-D94mSHCV.js";const N=[{value:"action_type",label:"Action Type",type:"string"},{value:"agent_id",label:"Agent ID",type:"string"},{value:"amount",label:"Amount",type:"number"},{value:"environment",label:"Environment",type:"string"},{value:"time_of_day",label:"Time of Day",type:"time"},{value:"day_of_week",label:"Day of Week",type:"string"},{value:"source_ip",label:"Source IP",type:"string"},{value:"risk_score",label:"Risk Score",type:"number"},{value:"resource_type",label:"Resource Type",type:"string"},{value:"custom",label:"Custom Field…",type:"custom"}],U={string:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"contains",label:"contains"},{value:"not_contains",label:"not contains"},{value:"in",label:"in list"},{value:"not_in",label:"not in list"},{value:"matches",label:"regex"},{value:"exists",label:"exists"},{value:"not_exists",label:"not exists"}],number:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"gt",label:">"},{value:"gte",label:"≥"},{value:"lt",label:"<"},{value:"lte",label:"≤"},{value:"between",label:"between"},{value:"exists",label:"exists"}],time:[{value:"time_between",label:"between"},{value:"equals",label:"="}],custom:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"contains",label:"contains"},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"in",label:"in list"},{value:"exists",label:"exists"}]},L=[{value:"allow",label:"Allow",color:"#10b981",icon:"✅"},{value:"deny",label:"Deny",color:"#ef4444",icon:"🚫"},{value:"require_approval",label:"Require Approval",color:"#f59e0b",icon:"⏳"},{value:"flag_for_review",label:"Flag for Review",color:"#f59e0b",icon:"🔍"},{value:"rate_limit",label:"Rate Limit",color:"#f59e0b",icon:"⏱️"},{value:"escalate",label:"Escalate",color:"#f59e0b",icon:"🔺"}],de=[{value:"T0",label:"T0 — Auto-approved"},{value:"T1",label:"T1 — Single approver"},{value:"T2",label:"T2 — Multi-party"}],pe=`{ "action_type": "wire_transfer", "agent_id": "agent-001", "amount": 15000, @@ -6,5 +6,5 @@ import{r as l,l as Q,j as e,g as X,h as Z,i as ee,t as te,k as ae,m as ne,n as r "risk_score": 65, "resource_type": "financial", "source_ip": "10.0.1.50" -}`,r={card:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",padding:"20px"},input:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"8px 12px",color:"#E6E1DC",fontSize:"13px",fontFamily:"var(--font-mono, monospace)",outline:"none",width:"100%"},select:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"8px 12px",color:"#E6E1DC",fontSize:"13px",fontFamily:"var(--font-mono, monospace)",outline:"none",cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",paddingRight:"30px"},btn:{padding:"8px 16px",borderRadius:"6px",border:"none",fontSize:"13px",fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms",display:"inline-flex",alignItems:"center",gap:"6px"},btnPrimary:{background:"#f59e0b",color:"#0A0E14",fontWeight:600},btnSecondary:{background:"transparent",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24"},btnGhost:{background:"transparent",color:"var(--text-secondary)",padding:"6px 10px"},label:{fontSize:"12px",fontWeight:500,color:"var(--text-secondary)",marginBottom:"4px",display:"block"},chip:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"0",fontSize:"11px",fontFamily:"var(--font-mono, monospace)",background:"rgba(251, 191, 36, 0.1)",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24",gap:"4px"},textarea:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"12px",color:"#E6E1DC",fontSize:"12px",fontFamily:"var(--font-mono, monospace)",outline:"none",width:"100%",resize:"vertical",minHeight:"120px",lineHeight:"1.5"}};function ce({checked:t,onChange:o,disabled:s}){return e.jsx("button",{onClick:o,disabled:s,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",background:t?"#10b981":"rgba(251, 191, 36, 0.1)",position:"relative",cursor:s?"default":"pointer",transition:"background 150ms",opacity:s?.5:1,flexShrink:0},children:e.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"50%",background:"#fff",position:"absolute",top:"2px",left:t?"18px":"2px",transition:"left 150ms"}})})}function q({action:t}){const o=L.find(s=>s.value===t);return o?e.jsxs("span",{style:{...r.chip,background:`${o.color}15`,color:o.color,fontFamily:"var(--font-sans)",fontWeight:500},children:[o.icon," ",o.label]}):e.jsx("span",{style:r.chip,children:t})}function xe({conditions:t}){return!t||t.length===0?e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)"},children:"No conditions (catch-all)"}):e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:[t.slice(0,3).map((o,s)=>e.jsxs("span",{style:r.chip,children:[o.field," ",o.operator," ",JSON.stringify(o.value)]},s)),t.length>3&&e.jsxs("span",{style:{...r.chip,color:"#fbbf24"},children:["+",t.length-3," more"]})]})}function K({icon:t,title:o,description:s,action:g}){return e.jsxs("div",{style:{...r.card,textAlign:"center",padding:"48px 32px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"12px"},children:t}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px 0"},children:o}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-secondary)",margin:"0 0 16px 0"},children:s}),g]})}function ue({condition:t,index:o,onChange:s,onRemove:g}){const h=(N.find(i=>i.value===t.field)||(t.field?{value:t.field,label:t.field,type:"custom"}:N[0])).type,x=U[h]||U.string,p=!N.find(i=>i.value===t.field);return e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)",width:"24px",textAlign:"center",flexShrink:0},children:o>0?"AND":"IF"}),e.jsx("div",{style:{flex:"0 0 160px"},children:p?e.jsx("input",{style:{...r.input,width:"100%"},value:t.field,onChange:i=>s(o,{...t,field:i.target.value}),placeholder:"custom.field"}):e.jsxs("select",{style:{...r.select,width:"100%"},value:t.field||"",onChange:i=>{const d=i.target.value;d==="custom"?s(o,{...t,field:"custom."}):s(o,{...t,field:d})},children:[e.jsx("option",{value:"",children:"Select field…"}),N.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})}),e.jsx("div",{style:{flex:"0 0 130px"},children:e.jsxs("select",{style:{...r.select,width:"100%"},value:t.operator||"",onChange:i=>s(o,{...t,operator:i.target.value}),children:[e.jsx("option",{value:"",children:"Operator…"}),x.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})}),e.jsx("div",{style:{flex:1,minWidth:"120px"},children:t.operator==="exists"||t.operator==="not_exists"?e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)",padding:"8px"},children:"—"}):t.operator==="between"||t.operator==="time_between"?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsx("input",{style:{...r.input,width:"45%"},value:Array.isArray(t.value)?String(t.value[0]??""):"",onChange:i=>{const d=Array.isArray(t.value)?[...t.value]:["",""];d[0]=i.target.value,s(o,{...t,value:d})},placeholder:t.operator==="time_between"?"HH:MM":"min"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"12px"},children:"—"}),e.jsx("input",{style:{...r.input,width:"45%"},value:Array.isArray(t.value)?String(t.value[1]??""):"",onChange:i=>{const d=Array.isArray(t.value)?[...t.value]:["",""];d[1]=i.target.value,s(o,{...t,value:d})},placeholder:t.operator==="time_between"?"HH:MM":"max"})]}):e.jsx("input",{style:r.input,value:typeof t.value=="string"||typeof t.value=="number"?String(t.value):Array.isArray(t.value)?t.value.join(", "):"",onChange:i=>{let d=i.target.value;["gt","gte","lt","lte"].includes(t.operator)&&!isNaN(Number(d))&&(d=Number(d)),["in","not_in"].includes(t.operator)&&(d=String(d).split(",").map(C=>C.trim())),s(o,{...t,value:d})},placeholder:["in","not_in"].includes(t.operator)?"val1, val2, val3":h==="number"?"0":h==="time"?"HH:MM":"value"})}),e.jsx("button",{onClick:()=>g(o),style:{...r.btn,...r.btnGhost,color:"#ef4444",padding:"4px 8px",fontSize:"16px",flexShrink:0},title:"Remove condition",children:"×"})]})}function ge({rule:t,onSave:o,onClose:s}){var W,w,F,n;const[g,c]=l.useState((t==null?void 0:t.name)||""),[h,x]=l.useState((t==null?void 0:t.description)||""),[p,i]=l.useState((t==null?void 0:t.conditions)||[{field:"",operator:"",value:""}]),[d,C]=l.useState((t==null?void 0:t.action_on_match)||"require_approval"),[m,O]=l.useState((t==null?void 0:t.approval_tier)||"T1"),[v,H]=l.useState(((t==null?void 0:t.required_approvers)||[]).join(", ")),[j,M]=l.useState((t==null?void 0:t.priority)??100),[R,E]=l.useState(!1),[T,S]=l.useState(""),[k,_]=l.useState(pe),[y,b]=l.useState(null),[z,I]=l.useState(!1),[B,D]=l.useState(""),$=(a,u)=>{const f=[...p];f[a]=u,i(f)},G=a=>{i(p.filter((u,f)=>f!==a))},P=()=>{i([...p,{field:"",operator:"",value:""}])},V=async()=>{if(S(""),!g.trim()){S("Rule name is required");return}const a=p.filter(u=>u.field&&u.operator);E(!0);try{await o({name:g.trim(),description:h.trim()||void 0,conditions:a,action_on_match:d,approval_tier:d==="require_approval"?m:void 0,required_approvers:v?v.split(",").map(u=>u.trim()).filter(Boolean):[],priority:j},t==null?void 0:t.id)}catch(u){S(u instanceof Error?u.message:"Failed to save")}finally{E(!1)}},J=async()=>{D(""),b(null),I(!0);try{const a=JSON.parse(k),u=await oe(a);b(u)}catch(a){D(a instanceof Error?a.message:"Test failed")}finally{I(!1)}};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(10, 14, 20, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px"},onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"0",width:"100%",maxWidth:"1100px",maxHeight:"90vh",overflow:"auto",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:t!=null&&t.id?"Edit Policy Rule":"New Policy Rule"}),e.jsx("button",{onClick:s,style:{...r.btn,...r.btnGhost,fontSize:"18px"},children:"×"})]}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"auto"},children:[e.jsxs("div",{style:{flex:"1 1 60%",padding:"24px",overflowY:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:r.label,children:"Rule Name *"}),e.jsx("input",{style:r.input,value:g,onChange:a=>c(a.target.value),placeholder:"e.g., Wire Transfers > $10K Require Multi-Party Approval",autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Description"}),e.jsx("input",{style:r.input,value:h,onChange:a=>x(a.target.value),placeholder:"Optional description of what this rule governs"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("label",{style:{...r.label,marginBottom:0},children:"Conditions"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"All conditions must match (AND)"})]}),e.jsxs("div",{style:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:"8px",padding:"12px"},children:[p.length===0?e.jsx("p",{style:{fontSize:"12px",color:"var(--text-muted)",textAlign:"center",margin:"8px 0"},children:"No conditions — this rule will match all intents (catch-all)"}):p.map((a,u)=>e.jsx(ue,{condition:a,index:u,onChange:$,onRemove:G},u)),e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary,marginTop:"8px",fontSize:"12px"},children:"+ Add Condition"})]})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Action When Matched"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:L.map(a=>e.jsxs("button",{onClick:()=>C(a.value),style:{...r.btn,background:d===a.value?`${a.color}20`:"rgba(255,255,255,0.04)",color:d===a.value?a.color:"#9ca3af",border:`1px solid ${d===a.value?`${a.color}40`:"rgba(255,255,255,0.06)"}`},children:[a.icon," ",a.label]},a.value))})]}),d==="require_approval"&&e.jsxs("div",{style:{marginBottom:"24px",display:"flex",gap:"16px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:r.label,children:"Approval Tier"}),e.jsx("select",{style:{...r.select,width:"100%"},value:m,onChange:a=>O(a.target.value),children:de.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:r.label,children:"Required Approvers (optional)"}),e.jsx("input",{style:r.input,value:v,onChange:a=>H(a.target.value),placeholder:"operator-1, operator-2"})]})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Priority (higher = evaluated first)"}),e.jsx("input",{style:{...r.input,width:"120px"},type:"number",value:j,onChange:a=>M(parseInt(a.target.value)||0),min:0,max:9999})]}),T&&e.jsx("div",{style:{padding:"10px 14px",background:"rgba(248,113,113,0.1)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"6px",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:T}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:s,style:{...r.btn,...r.btnSecondary},children:"Cancel"}),e.jsx("button",{onClick:V,disabled:R,style:{...r.btn,...r.btnPrimary,opacity:R?.6:1},children:R?"Saving…":t!=null&&t.id?"Update Rule":"Create Rule"})]})]}),e.jsxs("div",{style:{flex:"0 0 40%",padding:"24px",overflowY:"auto",background:"var(--bg-app, #0A0E14)"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 12px 0"},children:"🧪 Test Policy Rules"}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--text-secondary)",margin:"0 0 12px 0"},children:["Enter a mock intent to test against ",e.jsx("strong",{children:"all active rules"}),":"]}),e.jsx("textarea",{style:r.textarea,value:k,onChange:a=>_(a.target.value),spellCheck:!1}),e.jsx("button",{onClick:J,disabled:z,style:{...r.btn,...r.btnPrimary,width:"100%",justifyContent:"center",marginTop:"12px",opacity:z?.6:1},children:z?"Evaluating…":"▶ Run Test"}),B&&e.jsx("div",{style:{marginTop:"12px",padding:"10px",background:"rgba(248,113,113,0.1)",borderRadius:"6px",color:"#ef4444",fontSize:"12px"},children:B}),y&&e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsxs("div",{style:{padding:"12px",background:y.matched_rule?`${((W=L.find(a=>a.value===y.matched_rule.action))==null?void 0:W.color)||"#fbbf24"}15`:"rgba(74,222,128,0.1)",border:`1px solid ${y.matched_rule?`${((w=L.find(a=>a.value===y.matched_rule.action))==null?void 0:w.color)||"#fbbf24"}30`:"rgba(74,222,128,0.2)"}`,borderRadius:"8px",marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",marginBottom:"4px"},children:y.matched_rule?`⚡ Rule Matched: ${y.matched_rule.rule_name}`:"✅ No Rule Matched — Default Action Applied"}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:["Action: ",e.jsx(q,{action:((F=y.matched_rule)==null?void 0:F.action)||y.default_action}),((n=y.matched_rule)==null?void 0:n.approval_tier)&&e.jsxs("span",{style:{marginLeft:"8px"},children:["Tier: ",y.matched_rule.approval_tier]})]})]}),y.all_results.map((a,u)=>e.jsxs("div",{style:{padding:"10px 12px",background:"var(--bg-panel, #0F1419)",borderRadius:"6px",marginBottom:"6px",border:`1px solid ${a.matched?"rgba(74,222,128,0.2)":"rgba(255,255,255,0.04)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.conditions_detail.length>0?"6px":0},children:[e.jsxs("span",{style:{fontSize:"12px",fontWeight:500,color:a.matched?"#10b981":"#9ca3af"},children:[a.matched?"✅":"○"," ",a.rule_name]}),e.jsx(q,{action:a.action})]}),a.conditions_detail.length>0&&e.jsx("div",{style:{paddingLeft:"20px"},children:a.conditions_detail.map((f,A)=>e.jsxs("div",{style:{fontSize:"11px",color:f.passed?"#10b981":"#f87171",fontFamily:"var(--font-mono, monospace)",padding:"2px 0"},children:[f.passed?"✓":"✗"," ",f.field," ",f.operator," ",JSON.stringify(f.expected),e.jsxs("span",{style:{color:"var(--text-muted)"},children:[" (actual: ",JSON.stringify(f.actual),")"]})]},A))})]},u))]})]})]})]})})}function ye({templates:t,onImport:o,onClose:s}){const[g,c]=l.useState(null),h=async x=>{c(x.id);try{await o(x)}finally{c(null)}};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(10, 14, 20, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px"},onClick:x=>{x.target===x.currentTarget&&s()},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"0",width:"100%",maxWidth:"700px",maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:"📋 Industry Templates"}),e.jsx("button",{onClick:s,style:{...r.btn,...r.btnGhost,fontSize:"18px"},children:"×"})]}),e.jsxs("div",{style:{padding:"24px"},children:[e.jsx("p",{style:{fontSize:"13px",color:"var(--text-secondary)",margin:"0 0 20px 0"},children:"Import pre-built governance rules for common industries. Rules are created as disabled for review before activation."}),t.map(x=>e.jsxs("div",{style:{...r.card,marginBottom:"12px",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 4px 0"},children:x.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-secondary)",margin:"0 0 8px 0"},children:x.description}),e.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:x.rules.map((p,i)=>e.jsx("span",{style:r.chip,children:p.name},i))})]}),e.jsx("button",{onClick:()=>h(x),disabled:g===x.id,style:{...r.btn,...r.btnPrimary,marginLeft:"16px",flexShrink:0,opacity:g===x.id?.6:1},children:g===x.id?"Importing…":`Import ${x.rules.length} rules`})]},x.id))]})]})})}function he(){const[t,o]=l.useState([]),[s,g]=l.useState(!0);return l.useEffect(()=>{(async()=>{try{const c=await re({limit:50});o(c)}catch{}finally{g(!1)}})()},[]),s?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading evaluations…"}):t.length===0?e.jsx(K,{icon:"📊",title:"No Evaluations Yet",description:"Policy evaluations will appear here as rules are tested or triggered."}):e.jsx("div",{style:{...r.card,padding:0,overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:["Time","Rule","Agent","Action Type","Result","Action Taken"].map(c=>e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:c},c))})}),e.jsx("tbody",{children:t.map(c=>{var h;return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.03)"},children:[e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-mono, monospace)"},children:new Date(c.evaluated_at).toLocaleString()}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-primary)"},children:c.rule_name||((h=c.rule_id)==null?void 0:h.slice(0,8))||"—"}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-mono, monospace)"},children:c.agent_id||"—"}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)"},children:c.action_type||"—"}),e.jsx("td",{style:{padding:"8px 14px"},children:e.jsx("span",{style:{...r.chip,background:c.result==="matched"?"rgba(74,222,128,0.1)":"rgba(255,255,255,0.04)",color:c.result==="matched"?"#10b981":"#9ca3af"},children:c.result})}),e.jsx("td",{style:{padding:"8px 14px"},children:c.action_taken?e.jsx(q,{action:c.action_taken}):"—"})]},c.id)})})]})})}function fe({rule:t,onRevert:o,onClose:s}){const[g,c]=l.useState([]),[h,x]=l.useState(!0);return l.useEffect(()=>{le(t.id).then(p=>c(p)).catch(()=>{c([{version:t.version||1,name:t.name,conditions:t.conditions,action_on_match:t.action_on_match,approval_tier:t.approval_tier,enabled:t.enabled,updated_at:t.updated_at,updated_by:t.created_by}])}).finally(()=>x(!1))},[t.id]),e.jsx("div",{onClick:p=>{p.target===p.currentTarget&&s()},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 14, 20, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",border:"1px solid var(--border-subtle)",width:"500px",maxWidth:"90vw",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 16px 48px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:0},children:"🕐 Version History"}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:[t.name," — v",t.version||1]})]}),e.jsx("button",{onClick:s,style:{background:"rgba(255,255,255,0.06)",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"6px 10px",borderRadius:"6px",fontSize:"14px"},children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px",overflowY:"auto",flex:1},children:h?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"12px"},children:"Loading version history..."}):g.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"12px"},children:"No version history available. Changes will be tracked from now on."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:g.map((p,i)=>{const d=p.version===(t.version||1);return e.jsxs("div",{style:{padding:"12px 14px",borderRadius:"8px",background:d?"rgba(245,158,11,0.08)":"rgba(255,255,255,0.02)",border:`1px solid ${d?"rgba(245,158,11,0.2)":"var(--border-subtle)"}`},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("span",{style:{fontSize:"11px",fontWeight:700,fontFamily:"var(--font-mono)",color:d?"#f59e0b":"var(--text-secondary)"},children:["v",p.version]}),d&&e.jsx("span",{style:{fontSize:"9px",fontWeight:600,padding:"1px 6px",borderRadius:"3px",background:"rgba(245,158,11,0.15)",color:"#f59e0b"},children:"CURRENT"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:p.name})]}),!d&&e.jsx("button",{onClick:()=>{confirm(`Revert to v${p.version}?`)&&o(p.version)},style:{padding:"3px 8px",fontSize:"10px",borderRadius:"4px",border:"1px solid rgba(245,158,11,0.3)",background:"rgba(245,158,11,0.08)",color:"#f59e0b",cursor:"pointer",fontWeight:500},children:"Revert"})]}),e.jsxs("div",{style:{fontSize:"10px",color:"var(--text-tertiary)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:[new Date(p.updated_at).toLocaleString()," · ",p.updated_by," · ",p.conditions.length," condition",p.conditions.length!==1?"s":""," · ",p.enabled?"✅ enabled":"⏸ disabled"]})]},p.version)})})})]})})}function me(){const[t,o]=l.useState([]),[s,g]=l.useState(!0),[c,h]=l.useState(""),[x,p]=l.useState("rules"),[i,d]=l.useState(""),[C,m]=l.useState(!1),[O,v]=l.useState(null),[H,j]=l.useState(!1),[M,R]=l.useState([]),[E,T]=l.useState(null),[S,k]=l.useState(null),_=l.useRef(null),y=l.useRef(null),b=l.useCallback(async()=>{try{const n=await Q(i?{search:i}:void 0);o(n),h("")}catch(n){h(n instanceof Error?n.message:"Failed to load policies")}finally{g(!1)}},[i]);l.useEffect(()=>{b()},[b]);const z=async(n,a)=>{a?await ie(a,n):await Y(n),m(!1),v(null),await b()},I=async n=>{T(n.id);try{await te(n.id),await b()}finally{T(null)}},B=async n=>{confirm(`Disable rule "${n.name}"?`)&&(await ne(n.id),await b())},D=async n=>{await ae(n.id),await b()},$=n=>{v(n),m(!0)},G=async n=>{for(const a of n.rules)await Y({name:a.name,conditions:a.conditions,action_on_match:a.action_on_match,approval_tier:a.approval_tier,required_approvers:a.required_approvers,priority:a.priority,enabled:!1,tenant_scope:a.tenant_scope});j(!1),await b()},P=async()=>{try{const n=await Z();R(n),j(!0)}catch{j(!0)}},V=n=>{_.current=n},J=n=>{y.current=n},W=async()=>{if(_.current===null||y.current===null||_.current===y.current)return;const n=[...t],[a]=n.splice(_.current,1);n.splice(y.current,0,a);const u=n.map((f,A)=>({id:f.id,priority:(n.length-A)*10}));o(n.map((f,A)=>({...f,priority:u[A].priority}))),_.current=null,y.current=null;try{await ee(u)}catch{await b()}},w=t,F=e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary},children:"📋 Templates"}),e.jsx("button",{onClick:()=>{v(null),m(!0)},style:{...r.btn,...r.btnPrimary},children:"+ New Rule"})]});return e.jsxs(se,{title:"Policy Builder",description:"Define governance rules that control what agents can do",actions:F,children:[e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"20px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[{id:"rules",label:"🛡️ Rules",count:t.length},{id:"audit",label:"📊 Audit Trail"}].map(n=>e.jsxs("button",{onClick:()=>p(n.id),style:{padding:"8px 16px",fontSize:"13px",fontWeight:x===n.id?600:400,color:x===n.id?"#f59e0b":"#9ca3af",background:x===n.id?"rgba(245,158,11,0.08)":"transparent",border:"none",borderBottom:x===n.id?"2px solid #f59e0b":"2px solid transparent",borderRadius:"8px 8px 0 0",cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms"},children:[n.label,n.count!==void 0&&e.jsx("span",{style:{marginLeft:"6px",padding:"1px 6px",borderRadius:"8px",background:"rgba(255,255,255,0.06)",fontSize:"11px",fontWeight:400},children:n.count})]},n.id))}),x==="rules"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("input",{style:{...r.input,maxWidth:"400px"},value:i,onChange:n=>d(n.target.value),placeholder:"Search rules by name or description…"})}),c&&e.jsx("div",{style:{padding:"10px 14px",background:"rgba(248,113,113,0.1)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"6px",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:c}),s?e.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading policy rules…"}):w.length===0?e.jsx(K,{icon:"🛡️",title:"No Policy Rules",description:"Create your first governance rule or import from an industry template.",action:e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"center"},children:[e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary},children:"📋 Import Template"}),e.jsx("button",{onClick:()=>{v(null),m(!0)},style:{...r.btn,...r.btnPrimary},children:"+ New Rule"})]})}):e.jsxs("div",{style:{...r.card,padding:0,overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em",width:"30px"}}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Name"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Conditions"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Action"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"center",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Status"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Last Triggered"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"right",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Actions"})]})}),e.jsx("tbody",{children:w.map((n,a)=>e.jsxs("tr",{draggable:!0,onDragStart:()=>V(a),onDragEnter:()=>J(a),onDragEnd:W,onDragOver:u=>u.preventDefault(),style:{borderBottom:"1px solid rgba(255,255,255,0.03)",opacity:n.enabled?1:.5,cursor:"grab",transition:"background 150ms"},onMouseEnter:u=>{u.currentTarget.style.background="rgba(255,255,255,0.02)"},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[e.jsx("td",{style:{padding:"10px 14px",color:"var(--text-muted)",fontSize:"11px",fontFamily:"var(--font-mono, monospace)",textAlign:"center"},children:e.jsx("span",{title:`Priority: ${n.priority}`,children:"⠿"})}),e.jsxs("td",{style:{padding:"10px 14px"},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:"2px"},children:n.name}),n.description&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:n.description})]}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsx(xe,{conditions:n.conditions})}),e.jsxs("td",{style:{padding:"10px 14px"},children:[e.jsx(q,{action:n.action_on_match}),n.approval_tier&&e.jsx("span",{style:{...r.chip,marginLeft:"6px"},children:n.approval_tier})]}),e.jsx("td",{style:{padding:"10px 14px",textAlign:"center"},children:e.jsx(ce,{checked:n.enabled,onChange:()=>I(n),disabled:E===n.id})}),e.jsx("td",{style:{padding:"10px 14px",fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-mono, monospace)"},children:n.last_triggered?new Date(n.last_triggered).toLocaleDateString():"—"}),e.jsx("td",{style:{padding:"10px 14px",textAlign:"right"},children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>$(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Edit",children:"✏️"}),e.jsx("button",{onClick:()=>D(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Duplicate",children:"📋"}),e.jsx("button",{onClick:()=>k(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Version History",children:"🕐"}),e.jsx("button",{onClick:()=>B(n),style:{...r.btn,...r.btnGhost,fontSize:"12px",color:"#ef4444"},title:"Delete",children:"🗑️"})]})})]},n.id))})]}),e.jsxs("div",{style:{padding:"10px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"11px",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[w.length," rules · ",w.filter(n=>n.enabled).length," active"]}),e.jsx("span",{children:"Rules evaluated highest priority first"})]})]})]}),x==="audit"&&e.jsx(he,{}),C&&e.jsx(ge,{rule:O,onSave:z,onClose:()=>{m(!1),v(null)}}),H&&e.jsx(ye,{templates:M,onImport:G,onClose:()=>j(!1)}),S&&e.jsx(fe,{rule:S,onRevert:async n=>{try{await X(S.id,n),k(null),await b()}catch{}},onClose:()=>k(null)})]})}export{me as PolicyBuilderPage}; -//# sourceMappingURL=PolicyBuilderPage-emZlR9y7.js.map +}`,r={card:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(251, 191, 36, 0.2)",borderRadius:"0",padding:"20px"},input:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"8px 12px",color:"#E6E1DC",fontSize:"13px",fontFamily:"var(--font-mono, monospace)",outline:"none",width:"100%"},select:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"8px 12px",color:"#E6E1DC",fontSize:"13px",fontFamily:"var(--font-mono, monospace)",outline:"none",cursor:"pointer",appearance:"none",backgroundImage:`url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23fbbf24' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")`,backgroundRepeat:"no-repeat",backgroundPosition:"right 10px center",paddingRight:"30px"},btn:{padding:"8px 16px",borderRadius:"6px",border:"none",fontSize:"13px",fontWeight:500,cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms",display:"inline-flex",alignItems:"center",gap:"6px"},btnPrimary:{background:"#f59e0b",color:"#0A0E14",fontWeight:600},btnSecondary:{background:"transparent",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24"},btnGhost:{background:"transparent",color:"var(--text-secondary)",padding:"6px 10px"},label:{fontSize:"12px",fontWeight:500,color:"var(--text-secondary)",marginBottom:"4px",display:"block"},chip:{display:"inline-flex",alignItems:"center",padding:"2px 8px",borderRadius:"0",fontSize:"11px",fontFamily:"var(--font-mono, monospace)",background:"rgba(251, 191, 36, 0.1)",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24",gap:"4px"},textarea:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(251, 191, 36, 0.3)",borderRadius:"0",padding:"12px",color:"#E6E1DC",fontSize:"12px",fontFamily:"var(--font-mono, monospace)",outline:"none",width:"100%",resize:"vertical",minHeight:"120px",lineHeight:"1.5"}};function ce({checked:t,onChange:o,disabled:s}){return e.jsx("button",{onClick:o,disabled:s,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",background:t?"#10b981":"rgba(251, 191, 36, 0.1)",position:"relative",cursor:s?"default":"pointer",transition:"background 150ms",opacity:s?.5:1,flexShrink:0},children:e.jsx("div",{style:{width:"16px",height:"16px",borderRadius:"50%",background:"#fff",position:"absolute",top:"2px",left:t?"18px":"2px",transition:"left 150ms"}})})}function q({action:t}){const o=L.find(s=>s.value===t);return o?e.jsxs("span",{style:{...r.chip,background:`${o.color}15`,color:o.color,fontFamily:"var(--font-sans)",fontWeight:500},children:[o.icon," ",o.label]}):e.jsx("span",{style:r.chip,children:t})}function xe({conditions:t}){return!t||t.length===0?e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)"},children:"No conditions (catch-all)"}):e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:[t.slice(0,3).map((o,s)=>e.jsxs("span",{style:r.chip,children:[o.field," ",o.operator," ",JSON.stringify(o.value)]},s)),t.length>3&&e.jsxs("span",{style:{...r.chip,color:"#fbbf24"},children:["+",t.length-3," more"]})]})}function K({icon:t,title:o,description:s,action:g}){return e.jsxs("div",{style:{...r.card,textAlign:"center",padding:"48px 32px"},children:[e.jsx("div",{style:{fontSize:"40px",marginBottom:"12px"},children:t}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 8px 0"},children:o}),e.jsx("p",{style:{fontSize:"13px",color:"var(--text-secondary)",margin:"0 0 16px 0"},children:s}),g]})}function ue({condition:t,index:o,onChange:s,onRemove:g}){const h=(N.find(i=>i.value===t.field)||(t.field?{value:t.field,label:t.field,type:"custom"}:N[0])).type,x=U[h]||U.string,p=!N.find(i=>i.value===t.field);return e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)",width:"24px",textAlign:"center",flexShrink:0},children:o>0?"AND":"IF"}),e.jsx("div",{style:{flex:"0 0 160px"},children:p?e.jsx("input",{style:{...r.input,width:"100%"},value:t.field,onChange:i=>s(o,{...t,field:i.target.value}),placeholder:"custom.field"}):e.jsxs("select",{style:{...r.select,width:"100%"},value:t.field||"",onChange:i=>{const d=i.target.value;d==="custom"?s(o,{...t,field:"custom."}):s(o,{...t,field:d})},children:[e.jsx("option",{value:"",children:"Select field…"}),N.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})}),e.jsx("div",{style:{flex:"0 0 130px"},children:e.jsxs("select",{style:{...r.select,width:"100%"},value:t.operator||"",onChange:i=>s(o,{...t,operator:i.target.value}),children:[e.jsx("option",{value:"",children:"Operator…"}),x.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))]})}),e.jsx("div",{style:{flex:1,minWidth:"120px"},children:t.operator==="exists"||t.operator==="not_exists"?e.jsx("span",{style:{fontSize:"12px",color:"var(--text-muted)",padding:"8px"},children:"—"}):t.operator==="between"||t.operator==="time_between"?e.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[e.jsx("input",{style:{...r.input,width:"45%"},value:Array.isArray(t.value)?String(t.value[0]??""):"",onChange:i=>{const d=Array.isArray(t.value)?[...t.value]:["",""];d[0]=i.target.value,s(o,{...t,value:d})},placeholder:t.operator==="time_between"?"HH:MM":"min"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"12px"},children:"—"}),e.jsx("input",{style:{...r.input,width:"45%"},value:Array.isArray(t.value)?String(t.value[1]??""):"",onChange:i=>{const d=Array.isArray(t.value)?[...t.value]:["",""];d[1]=i.target.value,s(o,{...t,value:d})},placeholder:t.operator==="time_between"?"HH:MM":"max"})]}):e.jsx("input",{style:r.input,value:typeof t.value=="string"||typeof t.value=="number"?String(t.value):Array.isArray(t.value)?t.value.join(", "):"",onChange:i=>{let d=i.target.value;["gt","gte","lt","lte"].includes(t.operator)&&!isNaN(Number(d))&&(d=Number(d)),["in","not_in"].includes(t.operator)&&(d=String(d).split(",").map(C=>C.trim())),s(o,{...t,value:d})},placeholder:["in","not_in"].includes(t.operator)?"val1, val2, val3":h==="number"?"0":h==="time"?"HH:MM":"value"})}),e.jsx("button",{onClick:()=>g(o),style:{...r.btn,...r.btnGhost,color:"#ef4444",padding:"4px 8px",fontSize:"16px",flexShrink:0},title:"Remove condition",children:"×"})]})}function ge({rule:t,onSave:o,onClose:s}){var W,_,F,n;const[g,c]=l.useState((t==null?void 0:t.name)||""),[h,x]=l.useState((t==null?void 0:t.description)||""),[p,i]=l.useState((t==null?void 0:t.conditions)||[{field:"",operator:"",value:""}]),[d,C]=l.useState((t==null?void 0:t.action_on_match)||"require_approval"),[m,O]=l.useState((t==null?void 0:t.approval_tier)||"T1"),[v,H]=l.useState(((t==null?void 0:t.required_approvers)||[]).join(", ")),[j,M]=l.useState((t==null?void 0:t.priority)??100),[R,E]=l.useState(!1),[T,S]=l.useState(""),[k,w]=l.useState(pe),[y,b]=l.useState(null),[z,I]=l.useState(!1),[B,D]=l.useState(""),$=(a,u)=>{const f=[...p];f[a]=u,i(f)},G=a=>{i(p.filter((u,f)=>f!==a))},P=()=>{i([...p,{field:"",operator:"",value:""}])},V=async()=>{if(S(""),!g.trim()){S("Rule name is required");return}const a=p.filter(u=>u.field&&u.operator);E(!0);try{await o({name:g.trim(),description:h.trim()||void 0,conditions:a,action_on_match:d,approval_tier:d==="require_approval"?m:void 0,required_approvers:v?v.split(",").map(u=>u.trim()).filter(Boolean):[],priority:j},t==null?void 0:t.id)}catch(u){S(u instanceof Error?u.message:"Failed to save")}finally{E(!1)}},J=async()=>{D(""),b(null),I(!0);try{const a=JSON.parse(k),u=await oe(a);b(u)}catch(a){D(a instanceof Error?a.message:"Test failed")}finally{I(!1)}};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(10, 14, 20, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px"},onClick:a=>{a.target===a.currentTarget&&s()},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"0",width:"100%",maxWidth:"1100px",maxHeight:"90vh",overflow:"auto",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:t!=null&&t.id?"Edit Policy Rule":"New Policy Rule"}),e.jsx("button",{onClick:s,style:{...r.btn,...r.btnGhost,fontSize:"18px"},children:"×"})]}),e.jsxs("div",{style:{display:"flex",flex:1,overflow:"auto"},children:[e.jsxs("div",{style:{flex:"1 1 60%",padding:"24px",overflowY:"auto",borderRight:"1px solid rgba(255,255,255,0.06)"},children:[e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:r.label,children:"Rule Name *"}),e.jsx("input",{style:r.input,value:g,onChange:a=>c(a.target.value),placeholder:"e.g., Wire Transfers > $10K Require Multi-Party Approval",autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Description"}),e.jsx("input",{style:r.input,value:h,onChange:a=>x(a.target.value),placeholder:"Optional description of what this rule governs"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"8px"},children:[e.jsx("label",{style:{...r.label,marginBottom:0},children:"Conditions"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-muted)"},children:"All conditions must match (AND)"})]}),e.jsxs("div",{style:{background:"var(--bg-app, #0A0E14)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:"8px",padding:"12px"},children:[p.length===0?e.jsx("p",{style:{fontSize:"12px",color:"var(--text-muted)",textAlign:"center",margin:"8px 0"},children:"No conditions — this rule will match all intents (catch-all)"}):p.map((a,u)=>e.jsx(ue,{condition:a,index:u,onChange:$,onRemove:G},u)),e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary,marginTop:"8px",fontSize:"12px"},children:"+ Add Condition"})]})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Action When Matched"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:L.map(a=>e.jsxs("button",{onClick:()=>C(a.value),style:{...r.btn,background:d===a.value?`${a.color}20`:"rgba(255,255,255,0.04)",color:d===a.value?a.color:"#9ca3af",border:`1px solid ${d===a.value?`${a.color}40`:"rgba(255,255,255,0.06)"}`},children:[a.icon," ",a.label]},a.value))})]}),d==="require_approval"&&e.jsxs("div",{style:{marginBottom:"24px",display:"flex",gap:"16px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:r.label,children:"Approval Tier"}),e.jsx("select",{style:{...r.select,width:"100%"},value:m,onChange:a=>O(a.target.value),children:de.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]}),e.jsxs("div",{style:{flex:1},children:[e.jsx("label",{style:r.label,children:"Required Approvers (optional)"}),e.jsx("input",{style:r.input,value:v,onChange:a=>H(a.target.value),placeholder:"operator-1, operator-2"})]})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:r.label,children:"Priority (higher = evaluated first)"}),e.jsx("input",{style:{...r.input,width:"120px"},type:"number",value:j,onChange:a=>M(parseInt(a.target.value)||0),min:0,max:9999})]}),T&&e.jsx("div",{style:{padding:"10px 14px",background:"rgba(248,113,113,0.1)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"6px",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:T}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:s,style:{...r.btn,...r.btnSecondary},children:"Cancel"}),e.jsx("button",{onClick:V,disabled:R,style:{...r.btn,...r.btnPrimary,opacity:R?.6:1},children:R?"Saving…":t!=null&&t.id?"Update Rule":"Create Rule"})]})]}),e.jsxs("div",{style:{flex:"0 0 40%",padding:"24px",overflowY:"auto",background:"var(--bg-app, #0A0E14)"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 12px 0"},children:"🧪 Test Policy Rules"}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--text-secondary)",margin:"0 0 12px 0"},children:["Enter a mock intent to test against ",e.jsx("strong",{children:"all active rules"}),":"]}),e.jsx("textarea",{style:r.textarea,value:k,onChange:a=>w(a.target.value),spellCheck:!1}),e.jsx("button",{onClick:J,disabled:z,style:{...r.btn,...r.btnPrimary,width:"100%",justifyContent:"center",marginTop:"12px",opacity:z?.6:1},children:z?"Evaluating…":"▶ Run Test"}),B&&e.jsx("div",{style:{marginTop:"12px",padding:"10px",background:"rgba(248,113,113,0.1)",borderRadius:"6px",color:"#ef4444",fontSize:"12px"},children:B}),y&&e.jsxs("div",{style:{marginTop:"16px"},children:[e.jsxs("div",{style:{padding:"12px",background:y.matched_rule?`${((W=L.find(a=>a.value===y.matched_rule.action))==null?void 0:W.color)||"#fbbf24"}15`:"rgba(74,222,128,0.1)",border:`1px solid ${y.matched_rule?`${((_=L.find(a=>a.value===y.matched_rule.action))==null?void 0:_.color)||"#fbbf24"}30`:"rgba(74,222,128,0.2)"}`,borderRadius:"8px",marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",marginBottom:"4px"},children:y.matched_rule?`⚡ Rule Matched: ${y.matched_rule.rule_name}`:"✅ No Rule Matched — Default Action Applied"}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:["Action: ",e.jsx(q,{action:((F=y.matched_rule)==null?void 0:F.action)||y.default_action}),((n=y.matched_rule)==null?void 0:n.approval_tier)&&e.jsxs("span",{style:{marginLeft:"8px"},children:["Tier: ",y.matched_rule.approval_tier]})]})]}),y.all_results.map((a,u)=>e.jsxs("div",{style:{padding:"10px 12px",background:"var(--bg-panel, #0F1419)",borderRadius:"6px",marginBottom:"6px",border:`1px solid ${a.matched?"rgba(74,222,128,0.2)":"rgba(255,255,255,0.04)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a.conditions_detail.length>0?"6px":0},children:[e.jsxs("span",{style:{fontSize:"12px",fontWeight:500,color:a.matched?"#10b981":"#9ca3af"},children:[a.matched?"✅":"○"," ",a.rule_name]}),e.jsx(q,{action:a.action})]}),a.conditions_detail.length>0&&e.jsx("div",{style:{paddingLeft:"20px"},children:a.conditions_detail.map((f,A)=>e.jsxs("div",{style:{fontSize:"11px",color:f.passed?"#10b981":"#f87171",fontFamily:"var(--font-mono, monospace)",padding:"2px 0"},children:[f.passed?"✓":"✗"," ",f.field," ",f.operator," ",JSON.stringify(f.expected),e.jsxs("span",{style:{color:"var(--text-muted)"},children:[" (actual: ",JSON.stringify(f.actual),")"]})]},A))})]},u))]})]})]})]})})}function ye({templates:t,onImport:o,onClose:s}){const[g,c]=l.useState(null),h=async x=>{c(x.id);try{await o(x)}finally{c(null)}};return e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(10, 14, 20, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"24px"},onClick:x=>{x.target===x.currentTarget&&s()},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",border:"1px solid rgba(255,255,255,0.1)",borderRadius:"0",width:"100%",maxWidth:"700px",maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("div",{style:{padding:"20px 24px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:"var(--text-primary)"},children:"📋 Industry Templates"}),e.jsx("button",{onClick:s,style:{...r.btn,...r.btnGhost,fontSize:"18px"},children:"×"})]}),e.jsxs("div",{style:{padding:"24px"},children:[e.jsx("p",{style:{fontSize:"13px",color:"var(--text-secondary)",margin:"0 0 20px 0"},children:"Import pre-built governance rules for common industries. Rules are created as disabled for review before activation."}),t.map(x=>e.jsxs("div",{style:{...r.card,marginBottom:"12px",display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:"0 0 4px 0"},children:x.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-secondary)",margin:"0 0 8px 0"},children:x.description}),e.jsx("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap"},children:x.rules.map((p,i)=>e.jsx("span",{style:r.chip,children:p.name},i))})]}),e.jsx("button",{onClick:()=>h(x),disabled:g===x.id,style:{...r.btn,...r.btnPrimary,marginLeft:"16px",flexShrink:0,opacity:g===x.id?.6:1},children:g===x.id?"Importing…":`Import ${x.rules.length} rules`})]},x.id))]})]})})}function he(){const[t,o]=l.useState([]),[s,g]=l.useState(!0);return l.useEffect(()=>{(async()=>{try{const c=await re({limit:50});o(c)}catch{}finally{g(!1)}})()},[]),s?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading evaluations…"}):t.length===0?e.jsx(K,{icon:"📊",title:"No Evaluations Yet",description:"Policy evaluations will appear here as rules are tested or triggered."}):e.jsx("div",{style:{...r.card,padding:0,overflow:"hidden"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"12px"},children:[e.jsx("thead",{children:e.jsx("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:["Time","Rule","Agent","Action Type","Result","Action Taken"].map(c=>e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:c},c))})}),e.jsx("tbody",{children:t.map(c=>{var h;return e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.03)"},children:[e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-mono, monospace)"},children:new Date(c.evaluated_at).toLocaleString()}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-primary)"},children:c.rule_name||((h=c.rule_id)==null?void 0:h.slice(0,8))||"—"}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)",fontFamily:"var(--font-mono, monospace)"},children:c.agent_id||"—"}),e.jsx("td",{style:{padding:"8px 14px",color:"var(--text-secondary)"},children:c.action_type||"—"}),e.jsx("td",{style:{padding:"8px 14px"},children:e.jsx("span",{style:{...r.chip,background:c.result==="matched"?"rgba(74,222,128,0.1)":"rgba(255,255,255,0.04)",color:c.result==="matched"?"#10b981":"#9ca3af"},children:c.result})}),e.jsx("td",{style:{padding:"8px 14px"},children:c.action_taken?e.jsx(q,{action:c.action_taken}):"—"})]},c.id)})})]})})}function fe({rule:t,onRevert:o,onClose:s}){const[g,c]=l.useState([]),[h,x]=l.useState(!0);return l.useEffect(()=>{le(t.id).then(p=>c(p)).catch(()=>{c([{version:t.version||1,name:t.name,conditions:t.conditions,action_on_match:t.action_on_match,approval_tier:t.approval_tier,enabled:t.enabled,updated_at:t.updated_at,updated_by:t.created_by}])}).finally(()=>x(!1))},[t.id]),e.jsx("div",{onClick:p=>{p.target===p.currentTarget&&s()},style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(10, 14, 20, 0.85)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("div",{style:{background:"var(--bg-panel, #0F1419)",borderRadius:"0",border:"1px solid var(--border-subtle)",width:"500px",maxWidth:"90vw",maxHeight:"80vh",overflow:"hidden",display:"flex",flexDirection:"column",boxShadow:"0 16px 48px rgba(0,0,0,0.5)"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)",margin:0},children:"🕐 Version History"}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:[t.name," — v",t.version||1]})]}),e.jsx("button",{onClick:s,style:{background:"rgba(255,255,255,0.06)",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:"6px 10px",borderRadius:"6px",fontSize:"14px"},children:"✕"})]}),e.jsx("div",{style:{padding:"16px 20px",overflowY:"auto",flex:1},children:h?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"12px"},children:"Loading version history..."}):g.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"12px"},children:"No version history available. Changes will be tracked from now on."}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:g.map((p,i)=>{const d=p.version===(t.version||1);return e.jsxs("div",{style:{padding:"12px 14px",borderRadius:"8px",background:d?"rgba(245,158,11,0.08)":"rgba(255,255,255,0.02)",border:`1px solid ${d?"rgba(245,158,11,0.2)":"var(--border-subtle)"}`},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("span",{style:{fontSize:"11px",fontWeight:700,fontFamily:"var(--font-mono)",color:d?"#f59e0b":"var(--text-secondary)"},children:["v",p.version]}),d&&e.jsx("span",{style:{fontSize:"9px",fontWeight:600,padding:"1px 6px",borderRadius:"3px",background:"rgba(245,158,11,0.15)",color:"#f59e0b"},children:"CURRENT"}),e.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:p.name})]}),!d&&e.jsx("button",{onClick:()=>{confirm(`Revert to v${p.version}?`)&&o(p.version)},style:{padding:"3px 8px",fontSize:"10px",borderRadius:"4px",border:"1px solid rgba(245,158,11,0.3)",background:"rgba(245,158,11,0.08)",color:"#f59e0b",cursor:"pointer",fontWeight:500},children:"Revert"})]}),e.jsxs("div",{style:{fontSize:"10px",color:"var(--text-tertiary)",marginTop:"4px",fontFamily:"var(--font-mono)"},children:[new Date(p.updated_at).toLocaleString()," · ",p.updated_by," · ",p.conditions.length," condition",p.conditions.length!==1?"s":""," · ",p.enabled?"✅ enabled":"⏸ disabled"]})]},p.version)})})})]})})}function me(){const[t,o]=l.useState([]),[s,g]=l.useState(!0),[c,h]=l.useState(""),[x,p]=l.useState("rules"),[i,d]=l.useState(""),[C,m]=l.useState(!1),[O,v]=l.useState(null),[H,j]=l.useState(!1),[M,R]=l.useState([]),[E,T]=l.useState(null),[S,k]=l.useState(null),w=l.useRef(null),y=l.useRef(null),b=l.useCallback(async()=>{try{const n=await Q(i?{search:i}:void 0);o(n),h("")}catch(n){h(n instanceof Error?n.message:"Failed to load policies")}finally{g(!1)}},[i]);l.useEffect(()=>{b()},[b]);const z=async(n,a)=>{a?await ie(a,n):await Y(n),m(!1),v(null),await b()},I=async n=>{T(n.id);try{await te(n.id),await b()}finally{T(null)}},B=async n=>{confirm(`Disable rule "${n.name}"?`)&&(await ne(n.id),await b())},D=async n=>{await ae(n.id),await b()},$=n=>{v(n),m(!0)},G=async n=>{for(const a of n.rules)await Y({name:a.name,conditions:a.conditions,action_on_match:a.action_on_match,approval_tier:a.approval_tier,required_approvers:a.required_approvers,priority:a.priority,enabled:!1,tenant_scope:a.tenant_scope});j(!1),await b()},P=async()=>{try{const n=await Z();R(n),j(!0)}catch{j(!0)}},V=n=>{w.current=n},J=n=>{y.current=n},W=async()=>{if(w.current===null||y.current===null||w.current===y.current)return;const n=[...t],[a]=n.splice(w.current,1);n.splice(y.current,0,a);const u=n.map((f,A)=>({id:f.id,priority:(n.length-A)*10}));o(n.map((f,A)=>({...f,priority:u[A].priority}))),w.current=null,y.current=null;try{await ee(u)}catch{await b()}},_=t,F=e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary},children:"📋 Templates"}),e.jsx("button",{onClick:()=>{v(null),m(!0)},style:{...r.btn,...r.btnPrimary},children:"+ New Rule"})]});return e.jsxs(se,{title:"Policy Builder",description:"Define governance rules that control what agents can do",actions:F,children:[e.jsx("div",{style:{display:"flex",gap:"2px",marginBottom:"20px",borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[{id:"rules",label:"🛡️ Rules",count:t.length},{id:"audit",label:"📊 Audit Trail"}].map(n=>e.jsxs("button",{onClick:()=>p(n.id),style:{padding:"8px 16px",fontSize:"13px",fontWeight:x===n.id?600:400,color:x===n.id?"#f59e0b":"#9ca3af",background:x===n.id?"rgba(245,158,11,0.08)":"transparent",border:"none",borderBottom:x===n.id?"2px solid #f59e0b":"2px solid transparent",borderRadius:"8px 8px 0 0",cursor:"pointer",fontFamily:"var(--font-sans)",transition:"all 150ms"},children:[n.label,n.count!==void 0&&e.jsx("span",{style:{marginLeft:"6px",padding:"1px 6px",borderRadius:"8px",background:"rgba(255,255,255,0.06)",fontSize:"11px",fontWeight:400},children:n.count})]},n.id))}),x==="rules"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("input",{style:{...r.input,maxWidth:"400px"},value:i,onChange:n=>d(n.target.value),placeholder:"Search rules by name or description…"})}),c&&e.jsx("div",{style:{padding:"10px 14px",background:"rgba(248,113,113,0.1)",border:"1px solid rgba(248,113,113,0.2)",borderRadius:"6px",color:"#ef4444",fontSize:"13px",marginBottom:"16px"},children:c}),s?e.jsx("div",{style:{padding:"48px",textAlign:"center",color:"var(--text-secondary)",fontSize:"13px"},children:"Loading policy rules…"}):_.length===0?e.jsx(K,{icon:"🛡️",title:"No Policy Rules",description:"Create your first governance rule or import from an industry template.",action:e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"center"},children:[e.jsx("button",{onClick:P,style:{...r.btn,...r.btnSecondary},children:"📋 Import Template"}),e.jsx("button",{onClick:()=>{v(null),m(!0)},style:{...r.btn,...r.btnPrimary},children:"+ New Rule"})]})}):e.jsxs("div",{style:{...r.card,padding:0,overflow:"hidden"},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:"13px"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.06)"},children:[e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em",width:"30px"}}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Name"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Conditions"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Action"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"center",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Status"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"left",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Last Triggered"}),e.jsx("th",{style:{padding:"10px 14px",textAlign:"right",color:"var(--text-secondary)",fontWeight:500,fontSize:"11px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Actions"})]})}),e.jsx("tbody",{children:_.map((n,a)=>e.jsxs("tr",{draggable:!0,onDragStart:()=>V(a),onDragEnter:()=>J(a),onDragEnd:W,onDragOver:u=>u.preventDefault(),style:{borderBottom:"1px solid rgba(255,255,255,0.03)",opacity:n.enabled?1:.5,cursor:"grab",transition:"background 150ms"},onMouseEnter:u=>{u.currentTarget.style.background="rgba(255,255,255,0.02)"},onMouseLeave:u=>{u.currentTarget.style.background="transparent"},children:[e.jsx("td",{style:{padding:"10px 14px",color:"var(--text-muted)",fontSize:"11px",fontFamily:"var(--font-mono, monospace)",textAlign:"center"},children:e.jsx("span",{title:`Priority: ${n.priority}`,children:"⠿"})}),e.jsxs("td",{style:{padding:"10px 14px"},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--text-primary)",marginBottom:"2px"},children:n.name}),n.description&&e.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)"},children:n.description})]}),e.jsx("td",{style:{padding:"10px 14px"},children:e.jsx(xe,{conditions:n.conditions})}),e.jsxs("td",{style:{padding:"10px 14px"},children:[e.jsx(q,{action:n.action_on_match}),n.approval_tier&&e.jsx("span",{style:{...r.chip,marginLeft:"6px"},children:n.approval_tier})]}),e.jsx("td",{style:{padding:"10px 14px",textAlign:"center"},children:e.jsx(ce,{checked:n.enabled,onChange:()=>I(n),disabled:E===n.id})}),e.jsx("td",{style:{padding:"10px 14px",fontSize:"11px",color:"var(--text-muted)",fontFamily:"var(--font-mono, monospace)"},children:n.last_triggered?new Date(n.last_triggered).toLocaleDateString():"—"}),e.jsx("td",{style:{padding:"10px 14px",textAlign:"right"},children:e.jsxs("div",{style:{display:"flex",gap:"4px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>$(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Edit",children:"✏️"}),e.jsx("button",{onClick:()=>D(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Duplicate",children:"📋"}),e.jsx("button",{onClick:()=>k(n),style:{...r.btn,...r.btnGhost,fontSize:"12px"},title:"Version History",children:"🕐"}),e.jsx("button",{onClick:()=>B(n),style:{...r.btn,...r.btnGhost,fontSize:"12px",color:"#ef4444"},title:"Delete",children:"🗑️"})]})})]},n.id))})]}),e.jsxs("div",{style:{padding:"10px 14px",borderTop:"1px solid rgba(255,255,255,0.06)",display:"flex",justifyContent:"space-between",alignItems:"center",fontSize:"11px",color:"var(--text-muted)"},children:[e.jsxs("span",{children:[_.length," rules · ",_.filter(n=>n.enabled).length," active"]}),e.jsx("span",{children:"Rules evaluated highest priority first"})]})]})]}),x==="audit"&&e.jsx(he,{}),C&&e.jsx(ge,{rule:O,onSave:z,onClose:()=>{m(!1),v(null)}}),H&&e.jsx(ye,{templates:M,onImport:G,onClose:()=>j(!1)}),S&&e.jsx(fe,{rule:S,onRevert:async n=>{try{await X(S.id,n),k(null),await b()}catch{}},onClose:()=>k(null)})]})}export{me as PolicyBuilderPage}; +//# sourceMappingURL=PolicyBuilderPage-Bg5susqy.js.map diff --git a/apps/console-proxy/public/assets/PolicyBuilderPremium-5tI4E96l.js b/apps/console-proxy/public/assets/PolicyBuilderPremium-5tI4E96l.js deleted file mode 100644 index 4a2e3e13..00000000 --- a/apps/console-proxy/public/assets/PolicyBuilderPremium-5tI4E96l.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as d,l as _,j as e,Z as C,S as F,m as L,t as B,o as P,p as D}from"./index-D_7YXFSJ.js";import{P as O}from"./PageLayout-CTYKc2go.js";import{A as I}from"./activity-C-iTiNlh.js";const E={T0:{primary:"#10b981",glow:"rgba(16, 185, 129, 0.4)"},T1:{primary:"#f59e0b",glow:"rgba(245, 158, 11, 0.4)"},T2:{primary:"#ef4444",glow:"rgba(239, 68, 68, 0.4)"}},W=[{value:"allow",label:"ALLOW",color:"#10b981",icon:"Check"},{value:"deny",label:"DENY",color:"#ef4444",icon:"X"},{value:"require_approval",label:"APPROVAL",color:"#f59e0b",icon:"Clock"},{value:"flag_for_review",label:"REVIEW",color:"#8b5cf6",icon:"Search"},{value:"rate_limit",label:"LIMIT",color:"#06b6d4",icon:"Timer"},{value:"escalate",label:"ESCALATE",color:"#f97316",icon:"AlertTriangle"}],N=t=>{const i={size:14,strokeWidth:2,style:{display:"inline-block",marginRight:"6px",verticalAlign:"middle"}};switch(t){case"Shield":return e.jsx(F,{...i});case"Activity":return e.jsx(I,{...i});default:return e.jsx(C,{...i})}},w=[{field:"action_type",label:"Action Type",type:"string"},{field:"agent_id",label:"Agent",type:"string"},{field:"amount",label:"Amount ($)",type:"number"},{field:"environment",label:"Environment",type:"string"},{field:"risk_score",label:"Risk Score",type:"number"},{field:"resource_type",label:"Resource",type:"string"},{field:"time_of_day",label:"Time",type:"time"}],z={string:[{value:"equals",label:"="},{value:"not_equals",label:"≠"},{value:"contains",label:"⊃"},{value:"in",label:"∈"},{value:"matches",label:"~"}],number:[{value:"equals",label:"="},{value:"gt",label:">"},{value:"gte",label:"≥"},{value:"lt",label:"<"},{value:"lte",label:"≤"},{value:"between",label:"↔"}],time:[{value:"time_between",label:"between"},{value:"equals",label:"="}]};function y({label:t,value:i,trend:l,sparkline:a}){return e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"12px 16px",position:"relative",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"1px",background:"linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.6), transparent)"}}),e.jsxs("div",{style:{position:"relative",zIndex:1},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",letterSpacing:"0.1em",marginBottom:"4px",fontFamily:"var(--font-mono)"},children:t}),e.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",lineHeight:1},children:i}),l&&e.jsx("div",{style:{fontSize:"11px",color:l==="up"?"#10b981":l==="down"?"#ef4444":"#6b7280",marginTop:"4px",fontFamily:"var(--font-mono)"},children:l==="up"?"↗":l==="down"?"↘":"→"})]}),a&&a.length>0&&e.jsx("svg",{width:"100%",height:"24",style:{position:"absolute",bottom:0,left:0,right:0,opacity:.3},children:e.jsx("polyline",{points:a.map((s,c)=>`${c/(a.length-1)*100}%,${24-s/Math.max(...a)*20}`).join(" "),fill:"none",stroke:"#fbbf24",strokeWidth:"1.5"})})]})}function U({rule:t}){const i=W.find(a=>a.value===t.action_on_match),l=t.approval_tier?E[t.approval_tier]:null;return e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 10px",background:`${i==null?void 0:i.color}15`,border:`1px solid ${i==null?void 0:i.color}40`,fontSize:"11px",fontWeight:600,color:i==null?void 0:i.color,fontFamily:"var(--font-mono)",position:"relative",...l&&{boxShadow:`0 0 12px ${l.glow}`}},children:[i==null?void 0:i.icon," ",i==null?void 0:i.label,t.approval_tier&&e.jsx("span",{style:{marginLeft:"4px",padding:"2px 4px",background:l==null?void 0:l.primary,color:"#0A0E14",fontSize:"9px",fontWeight:700},children:t.approval_tier})]})}function $({condition:t,index:i,onChange:l,onRemove:a}){const s=w.find(r=>r.field===t.field),c=(s==null?void 0:s.type)||"string",g=z[c]||z.string;return e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"40px 1fr 100px 1fr 32px",gap:"8px",alignItems:"center",padding:"8px",background:"rgba(10, 14, 20, 0.4)",border:"1px solid rgba(251, 191, 36, 0.15)",marginBottom:"6px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:700,color:i===0?"#fbbf24":"rgba(251, 191, 36, 0.5)",fontFamily:"var(--font-mono)",textAlign:"center"},children:i===0?"IF":"AND"}),e.jsxs("select",{value:t.field,onChange:r=>l(i,{...t,field:r.target.value}),style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#E6E1DC",padding:"6px 10px",fontSize:"12px",fontFamily:"var(--font-mono)",outline:"none"},children:[e.jsx("option",{value:"",children:"Select field..."}),w.map(r=>e.jsx("option",{value:r.field,children:r.label},r.field))]}),e.jsxs("select",{value:t.operator,onChange:r=>l(i,{...t,operator:r.target.value}),style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24",padding:"6px 10px",fontSize:"13px",fontFamily:"var(--font-mono)",fontWeight:600,outline:"none",textAlign:"center"},children:[e.jsx("option",{value:"",children:"Op"}),g.map(r=>e.jsx("option",{value:r.value,children:r.label},r.value))]}),e.jsx("input",{type:c==="number"?"number":"text",value:typeof t.value=="string"||typeof t.value=="number"?String(t.value):"",onChange:r=>{let f=r.target.value;c==="number"&&!isNaN(Number(f))&&(f=Number(f)),l(i,{...t,value:f})},placeholder:c==="number"?"0":"value",style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#E6E1DC",padding:"6px 10px",fontSize:"12px",fontFamily:"var(--font-mono)",outline:"none"}}),e.jsx("button",{onClick:()=>a(i),style:{background:"transparent",border:"none",color:"#ef4444",fontSize:"16px",cursor:"pointer",padding:"4px"},children:"✕"})]})}function M({rule:t,onEdit:i,onToggle:l,onDelete:a}){const s=t.approval_tier?E[t.approval_tier]:null;return e.jsxs("div",{style:{background:t.enabled?"rgba(10, 14, 20, 0.8)":"rgba(10, 14, 20, 0.4)",border:`1px solid ${t.enabled?"rgba(251, 191, 36, 0.3)":"rgba(251, 191, 36, 0.1)"}`,padding:"16px",position:"relative",opacity:t.enabled?1:.6,transition:"all 200ms",...s&&t.enabled&&{boxShadow:`0 0 16px ${s.glow}, inset 0 0 60px ${s.glow}15`}},children:[t.enabled&&e.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,height:"2px",background:s?`linear-gradient(90deg, transparent, ${s.primary}, transparent)`:"linear-gradient(90deg, transparent, #fbbf24, transparent)"}}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",marginBottom:"12px"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:700,color:t.enabled?"#fbbf24":"#6b7280",marginBottom:"4px",fontFamily:"var(--font-mono)"},children:t.name}),t.description&&e.jsx("div",{style:{fontSize:"11px",color:"rgba(230, 225, 220, 0.6)",marginBottom:"8px"},children:t.description})]}),e.jsx("button",{onClick:l,style:{width:"32px",height:"18px",borderRadius:"9px",border:"none",background:t.enabled?"#10b981":"rgba(107, 114, 128, 0.3)",position:"relative",cursor:"pointer",transition:"background 150ms"},children:e.jsx("div",{style:{width:"14px",height:"14px",borderRadius:"50%",background:"#fff",position:"absolute",top:"2px",left:t.enabled?"16px":"2px",transition:"left 150ms"}})})]}),e.jsx("div",{style:{marginBottom:"12px"},children:e.jsx(U,{rule:t})}),e.jsx("div",{style:{fontSize:"10px",color:"rgba(251, 191, 36, 0.5)",marginBottom:"12px",fontFamily:"var(--font-mono)"},children:t.conditions.length===0?e.jsx("span",{children:"MATCH ALL (catch-all)"}):e.jsxs("span",{children:[t.conditions.length," condition",t.conditions.length!==1?"s":""]})}),e.jsxs("div",{style:{display:"flex",gap:"6px",fontSize:"11px"},children:[e.jsx("button",{onClick:i,style:{flex:1,padding:"6px",background:"rgba(251, 191, 36, 0.1)",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#fbbf24",cursor:"pointer",fontWeight:600,fontFamily:"var(--font-mono)"},children:"EDIT"}),e.jsx("button",{onClick:a,style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",cursor:"pointer",fontWeight:600},children:"✕"})]}),e.jsxs("div",{style:{position:"absolute",top:"8px",right:"48px",fontSize:"9px",fontWeight:700,color:"rgba(251, 191, 36, 0.4)",fontFamily:"var(--font-mono)"},children:["P",t.priority]})]})}function q({rule:t,onSave:i,onClose:l}){const[a,s]=d.useState((t==null?void 0:t.name)||""),[c,g]=d.useState((t==null?void 0:t.description)||""),[r,f]=d.useState((t==null?void 0:t.conditions)||[]),[p,T]=d.useState((t==null?void 0:t.action_on_match)||"require_approval"),[x,m]=d.useState((t==null?void 0:t.approval_tier)||"T1"),[j,A]=d.useState((t==null?void 0:t.priority)??100),[v,S]=d.useState(!1),h=async()=>{if(a.trim()){S(!0);try{await i({name:a.trim(),description:c.trim()||void 0,conditions:r.filter(n=>n.field&&n.operator),action_on_match:p,approval_tier:p==="require_approval"?x:void 0,priority:j,required_approvers:[]},t==null?void 0:t.id)}finally{S(!1)}}};return e.jsx("div",{onClick:n=>{n.target===n.currentTarget&&l()},style:{position:"fixed",inset:0,background:"rgba(10, 14, 20, 0.9)",backdropFilter:"blur(8px)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},children:e.jsxs("div",{style:{background:"#0F1419",border:"1px solid rgba(251, 191, 36, 0.3)",width:"90%",maxWidth:"800px",maxHeight:"90vh",overflow:"auto"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",display:"flex",justifyContent:"space-between",alignItems:"center",background:"linear-gradient(180deg, rgba(251, 191, 36, 0.08) 0%, transparent 100%)"},children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:700,color:"#fbbf24",fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:t!=null&&t.id?"⚙ EDIT RULE":"+ NEW RULE"}),e.jsx("button",{onClick:l,style:{background:"transparent",border:"none",color:"#fbbf24",fontSize:"18px",cursor:"pointer"},children:"✕"})]}),e.jsxs("div",{style:{padding:"20px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"6px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"RULE NAME"}),e.jsx("input",{value:a,onChange:n=>s(n.target.value),placeholder:"e.g. Wire Transfers > $10K Require Approval",style:{width:"100%",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#E6E1DC",padding:"10px 12px",fontSize:"13px",fontFamily:"var(--font-mono)",outline:"none"}})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"6px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"DESCRIPTION (optional)"}),e.jsx("input",{value:c,onChange:n=>g(n.target.value),placeholder:"What does this rule govern?",style:{width:"100%",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#E6E1DC",padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",outline:"none"}})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"8px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"CONDITIONS (all must match)"}),r.map((n,b)=>e.jsx($,{condition:n,index:b,onChange:(u,k)=>{const o=[...r];o[u]=k,f(o)},onRemove:u=>f(r.filter((k,o)=>o!==u))},b)),e.jsx("button",{onClick:()=>f([...r,{field:"",operator:"",value:""}]),style:{width:"100%",padding:"8px",background:"rgba(251, 191, 36, 0.1)",border:"1px dashed rgba(251, 191, 36, 0.3)",color:"#fbbf24",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-mono)"},children:"+ ADD CONDITION"})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"8px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"ACTION"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px"},children:W.map(n=>e.jsxs("button",{onClick:()=>T(n.value),style:{padding:"10px",background:p===n.value?`${n.color}20`:"rgba(10, 14, 20, 0.6)",border:`1px solid ${p===n.value?n.color:"rgba(251, 191, 36, 0.2)"}`,color:p===n.value?n.color:"#6b7280",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"var(--font-mono)",transition:"all 150ms"},children:[n.icon," ",n.label]},n.value))})]}),p==="require_approval"&&e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"8px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"APPROVAL TIER"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"8px"},children:Object.keys(E).map(n=>{const b=E[n];return e.jsx("button",{onClick:()=>m(n),style:{padding:"10px",background:x===n?`${b.primary}20`:"rgba(10, 14, 20, 0.6)",border:`1px solid ${x===n?b.primary:"rgba(251, 191, 36, 0.2)"}`,color:x===n?b.primary:"#6b7280",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"var(--font-mono)",...x===n&&{boxShadow:`0 0 12px ${b.glow}`}},children:n},n)})})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"rgba(251, 191, 36, 0.7)",marginBottom:"6px",letterSpacing:"0.1em",fontFamily:"var(--font-mono)"},children:"PRIORITY (higher = evaluated first)"}),e.jsx("input",{type:"number",value:j,onChange:n=>A(parseInt(n.target.value)||0),min:0,max:9999,style:{width:"120px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.3)",color:"#E6E1DC",padding:"10px 12px",fontSize:"13px",fontFamily:"var(--font-mono)",outline:"none"}})]}),e.jsxs("div",{style:{display:"flex",gap:"10px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:l,style:{padding:"10px 20px",background:"rgba(107, 114, 128, 0.2)",border:"1px solid rgba(107, 114, 128, 0.4)",color:"#9ca3af",cursor:"pointer",fontWeight:600,fontSize:"12px",fontFamily:"var(--font-mono)"},children:"CANCEL"}),e.jsx("button",{onClick:h,disabled:v||!a.trim(),style:{padding:"10px 20px",background:v||!a.trim()?"rgba(251, 191, 36, 0.2)":"#f59e0b",border:"1px solid #f59e0b",color:v||!a.trim()?"#6b7280":"#0A0E14",cursor:v||!a.trim()?"default":"pointer",fontWeight:700,fontSize:"12px",fontFamily:"var(--font-mono)"},children:v?"SAVING...":t!=null&&t.id?"UPDATE RULE":"CREATE RULE"})]})]})]})})}function H(){const[t,i]=d.useState([]),[l,a]=d.useState(!0),[s,c]=d.useState("builder"),[g,r]=d.useState("grid"),[f,p]=d.useState(!1),[T,x]=d.useState(null),m=d.useCallback(async()=>{try{const o=await _();i(o)}catch{}finally{a(!1)}},[]);d.useEffect(()=>{m()},[m]);const j=async(o,R)=>{R?await P(R,o):await D(o),p(!1),x(null),await m()},A=async o=>{await B(o.id),await m()},v=async o=>{confirm(`Delete rule "${o.name}"?`)&&(await L(o.id),await m())},S=o=>{x(o),p(!0)},h=t.length,n=t.filter(o=>o.enabled).length,b=t.filter(o=>o.approval_tier==="T0"&&o.enabled).length,u=t.filter(o=>o.approval_tier==="T1"&&o.enabled).length,k=t.filter(o=>o.approval_tier==="T2"&&o.enabled).length;return e.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:e.jsx("div",{style:{position:"relative",zIndex:1},children:e.jsxs(O,{title:"",description:"",children:[e.jsxs("div",{style:{background:"linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[e.jsxs("h1",{style:{fontSize:"24px",fontWeight:700,color:"#fbbf24",margin:0,fontFamily:"var(--font-mono)",letterSpacing:"0.02em"},children:[e.jsx(C,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"POLICY BUILDER"]}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(230, 225, 220, 0.6)",marginTop:"4px"},children:"Mission control for governance rules"})]}),e.jsx("button",{onClick:()=>{x(null),p(!0)},style:{padding:"10px 20px",background:"#f59e0b",border:"1px solid #f59e0b",color:"#0A0E14",cursor:"pointer",fontWeight:700,fontSize:"13px",fontFamily:"var(--font-mono)",boxShadow:"0 0 20px rgba(245, 158, 11, 0.4)"},children:"+ NEW RULE"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(5, 1fr)",gap:"12px",marginTop:"20px"},children:[e.jsx(y,{label:"TOTAL RULES",value:h,sparkline:[4,7,5,9,12,15,h]}),e.jsx(y,{label:"ACTIVE",value:n,trend:"up"}),e.jsx(y,{label:"T0 AUTO",value:b}),e.jsx(y,{label:"T1 SINGLE",value:u}),e.jsx(y,{label:"T2 MULTI",value:k})]})]}),e.jsx("div",{style:{display:"flex",gap:"4px",marginBottom:"20px",borderBottom:"1px solid rgba(251, 191, 36, 0.1)"},children:[{id:"builder",label:"RULES",count:h,icon:"Shield"},{id:"simulator",label:"SIMULATOR",icon:"Activity"},{id:"audit",label:"AUDIT",icon:"Activity"}].map(o=>e.jsxs("button",{onClick:()=>c(o.id),style:{padding:"10px 16px",background:s===o.id?"rgba(251, 191, 36, 0.15)":"transparent",border:"none",borderBottom:s===o.id?"2px solid #fbbf24":"2px solid transparent",color:s===o.id?"#fbbf24":"#6b7280",cursor:"pointer",fontSize:"12px",fontWeight:700,fontFamily:"var(--font-mono)",letterSpacing:"0.05em"},children:[N(o.icon),o.label,o.count!==void 0&&e.jsx("span",{style:{marginLeft:"6px",padding:"2px 6px",background:"rgba(251, 191, 36, 0.2)",borderRadius:"8px",fontSize:"10px"},children:o.count})]},o.id))}),s==="builder"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:"16px",gap:"8px"},children:[e.jsx("button",{onClick:()=>r("grid"),style:{padding:"6px 12px",background:g==="grid"?"rgba(251, 191, 36, 0.2)":"rgba(10, 14, 20, 0.6)",border:`1px solid ${g==="grid"?"#fbbf24":"rgba(251, 191, 36, 0.2)"}`,color:g==="grid"?"#fbbf24":"#6b7280",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-mono)"},children:"GRID"}),e.jsx("button",{onClick:()=>r("flow"),style:{padding:"6px 12px",background:g==="flow"?"rgba(251, 191, 36, 0.2)":"rgba(10, 14, 20, 0.6)",border:`1px solid ${g==="flow"?"#fbbf24":"rgba(251, 191, 36, 0.2)"}`,color:g==="flow"?"#fbbf24":"#6b7280",cursor:"pointer",fontSize:"11px",fontWeight:600,fontFamily:"var(--font-mono)"},children:"FLOW"})]}),l?e.jsxs("div",{style:{padding:"60px",textAlign:"center",color:"rgba(251, 191, 36, 0.5)",fontSize:"13px",fontFamily:"var(--font-mono)"},children:[e.jsx(C,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"LOADING RULES..."]}):t.length===0?e.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px dashed rgba(251, 191, 36, 0.3)",padding:"60px 40px",textAlign:"center"},children:[e.jsx("div",{style:{marginBottom:"12px"},children:e.jsx(F,{size:40,color:"rgba(251, 191, 36, 0.6)",strokeWidth:1.5})}),e.jsx("div",{style:{fontSize:"16px",fontWeight:700,color:"#fbbf24",marginBottom:"8px",fontFamily:"var(--font-mono)"},children:"NO RULES YET"}),e.jsx("div",{style:{fontSize:"12px",color:"rgba(230, 225, 220, 0.6)",marginBottom:"20px"},children:"Create your first governance rule to control what agents can do"}),e.jsx("button",{onClick:()=>{x(null),p(!0)},style:{padding:"12px 24px",background:"#f59e0b",border:"1px solid #f59e0b",color:"#0A0E14",cursor:"pointer",fontWeight:700,fontSize:"13px",fontFamily:"var(--font-mono)"},children:"+ CREATE FIRST RULE"})]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:g==="grid"?"repeat(auto-fill, minmax(300px, 1fr))":"1fr",gap:"12px"},children:t.map(o=>e.jsx(M,{rule:o,onEdit:()=>S(o),onToggle:()=>A(o),onDelete:()=>v(o)},o.id))})]}),s==="simulator"&&e.jsx("div",{style:{padding:"40px",textAlign:"center",color:"rgba(251, 191, 36, 0.5)",fontFamily:"var(--font-mono)"},children:"🧪 SIMULATOR — Coming soon"}),s==="audit"&&e.jsxs("div",{style:{padding:"40px",textAlign:"center",color:"rgba(251, 191, 36, 0.5)",fontFamily:"var(--font-mono)"},children:[e.jsx(I,{size:16,style:{display:"inline-block",marginRight:"8px",verticalAlign:"middle"},strokeWidth:2}),"AUDIT TRAIL — Coming soon"]}),f&&e.jsx(q,{rule:T,onSave:j,onClose:()=>{p(!1),x(null)}})]})})})}export{H as PolicyBuilderPremium}; -//# sourceMappingURL=PolicyBuilderPremium-5tI4E96l.js.map diff --git a/apps/console-proxy/public/assets/PolicyTemplatesPage-CLGwQrxS.js b/apps/console-proxy/public/assets/PolicyTemplatesPage-D4Vcprkl.js similarity index 97% rename from apps/console-proxy/public/assets/PolicyTemplatesPage-CLGwQrxS.js rename to apps/console-proxy/public/assets/PolicyTemplatesPage-D4Vcprkl.js index c68d83aa..57bd9157 100644 --- a/apps/console-proxy/public/assets/PolicyTemplatesPage-CLGwQrxS.js +++ b/apps/console-proxy/public/assets/PolicyTemplatesPage-D4Vcprkl.js @@ -1,2 +1,2 @@ -import{u,r,a as d,j as e}from"./index-D_7YXFSJ.js";function N(){const x=u(),[n,m]=r.useState([]),[b,c]=r.useState(!0),[l,p]=r.useState("all"),[t,i]=r.useState(null);r.useEffect(()=>{h()},[l]);const h=async()=>{try{c(!0);const s=l==="all"?"":`?category=${l}`,a=await d.get(`/api/v1/policy-templates${s}`);m(a.data||[])}catch(s){console.error("[PolicyTemplates] fetch error:",s)}finally{c(!1)}},o=async s=>{try{await d.post(`/api/v1/policy-templates/${s.id}/instantiate`,{name:s.name,customizations:{}}),x("/policies")}catch(a){console.error("[PolicyTemplates] instantiate error:",a)}},g=[{id:"all",name:"All Templates",icon:"📋"},{id:"regulatory",name:"Regulatory",icon:"⚖️"},{id:"financial",name:"Financial",icon:"💰"},{id:"privacy",name:"Privacy",icon:"🔒"},{id:"security",name:"Security",icon:"🛡️"},{id:"operations",name:"Operations",icon:"⚙️"}];return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-[#e2e8f0] mb-2",children:"Policy Templates"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)]",children:"Choose from pre-built governance templates to get started quickly"})]}),e.jsx("div",{className:"mb-6 flex space-x-2 border-b border-[rgba(255,255,255,0.08)]",children:g.map(s=>e.jsxs("button",{onClick:()=>p(s.id),className:`px-4 py-2 border-b-2 transition-colors ${l===s.id?"border-blue-500 text-blue-600":"border-transparent text-[rgba(255,255,255,0.6)] hover:text-[#e2e8f0]"}`,children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name]},s.id))}),b?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("p",{className:"mt-4 text-[rgba(255,255,255,0.6)]",children:"Loading templates..."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.length===0?e.jsxs("div",{className:"col-span-full text-center py-12",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📋"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)] text-lg mb-2",children:"No policy templates found"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.4)] text-sm",children:l==="all"?"Templates will appear here once they are created":`No templates in the "${l}" category`})]}):n.map(s=>e.jsxs("div",{className:"border border-[rgba(255,255,255,0.08)] rounded-lg p-6 hover:bg-[rgba(255,255,255,0.04)] transition-all cursor-pointer",onClick:()=>i(s),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("div",{className:"text-4xl",children:s.icon}),e.jsx("span",{className:"px-2 py-1 bg-[rgba(255,255,255,0.08)] text-[rgba(255,255,255,0.6)] text-xs rounded",children:s.category})]}),e.jsx("h3",{className:"text-lg font-semibold text-[#e2e8f0] mb-2",children:s.name}),e.jsx("p",{className:"text-sm text-[rgba(255,255,255,0.6)] mb-4 line-clamp-3",children:s.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.slice(0,3).map(a=>e.jsx("span",{className:"px-2 py-1 bg-blue-50 text-blue-600 text-xs rounded",children:a},a))}),e.jsxs("span",{className:"text-xs text-[rgba(255,255,255,0.4)]",children:["Used ",s.use_count,"x"]})]}),e.jsx("button",{onClick:a=>{a.stopPropagation(),o(s)},className:"mt-4 w-full bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 transition-colors",children:"Use Template"})]},s.id))}),t&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",onClick:()=>i(null),children:e.jsxs("div",{className:"bg-[#12131a] rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto p-6 border border-[rgba(255,255,255,0.08)]",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-5xl mb-3",children:t.icon}),e.jsx("h2",{className:"text-2xl font-bold text-[#e2e8f0] mb-2",children:t.name}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)]",children:t.description})]}),e.jsx("button",{onClick:()=>i(null),className:"text-[rgba(255,255,255,0.4)] hover:text-[rgba(255,255,255,0.6)]",children:"✕"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0] mb-3",children:"Policy Rules"}),e.jsx("div",{className:"bg-[rgba(255,255,255,0.03)] rounded p-4",children:e.jsx("pre",{className:"text-sm text-[rgba(255,255,255,0.6)] whitespace-pre-wrap",children:JSON.stringify(t.rules,null,2)})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0] mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.tags.map(s=>e.jsx("span",{className:"px-3 py-1 bg-[rgba(59,130,246,0.15)] text-blue-400 text-sm rounded",children:s},s))})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:()=>o(t),className:"flex-1 bg-blue-500 text-white py-3 px-6 rounded-lg hover:bg-blue-600 transition-colors font-medium",children:"Use This Template"}),e.jsx("button",{onClick:()=>i(null),className:"px-6 py-3 border border-[rgba(255,255,255,0.08)] rounded-lg hover:bg-[rgba(255,255,255,0.04)] transition-colors text-[rgba(255,255,255,0.6)]",children:"Cancel"})]})]})})]})}export{N as default}; -//# sourceMappingURL=PolicyTemplatesPage-CLGwQrxS.js.map +import{u,r,e as d,j as e}from"./index-C0nK3ekl.js";function N(){const x=u(),[n,m]=r.useState([]),[b,c]=r.useState(!0),[l,p]=r.useState("all"),[t,i]=r.useState(null);r.useEffect(()=>{h()},[l]);const h=async()=>{try{c(!0);const s=l==="all"?"":`?category=${l}`,a=await d.get(`/api/v1/policy-templates${s}`);m(a.data||[])}catch(s){console.error("[PolicyTemplates] fetch error:",s)}finally{c(!1)}},o=async s=>{try{await d.post(`/api/v1/policy-templates/${s.id}/instantiate`,{name:s.name,customizations:{}}),x("/policies")}catch(a){console.error("[PolicyTemplates] instantiate error:",a)}},g=[{id:"all",name:"All Templates",icon:"📋"},{id:"regulatory",name:"Regulatory",icon:"⚖️"},{id:"financial",name:"Financial",icon:"💰"},{id:"privacy",name:"Privacy",icon:"🔒"},{id:"security",name:"Security",icon:"🛡️"},{id:"operations",name:"Operations",icon:"⚙️"}];return e.jsxs("div",{className:"p-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold text-[#e2e8f0] mb-2",children:"Policy Templates"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)]",children:"Choose from pre-built governance templates to get started quickly"})]}),e.jsx("div",{className:"mb-6 flex space-x-2 border-b border-[rgba(255,255,255,0.08)]",children:g.map(s=>e.jsxs("button",{onClick:()=>p(s.id),className:`px-4 py-2 border-b-2 transition-colors ${l===s.id?"border-blue-500 text-blue-600":"border-transparent text-[rgba(255,255,255,0.6)] hover:text-[#e2e8f0]"}`,children:[e.jsx("span",{className:"mr-2",children:s.icon}),s.name]},s.id))}),b?e.jsxs("div",{className:"text-center py-12",children:[e.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500"}),e.jsx("p",{className:"mt-4 text-[rgba(255,255,255,0.6)]",children:"Loading templates..."})]}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:n.length===0?e.jsxs("div",{className:"col-span-full text-center py-12",children:[e.jsx("div",{className:"text-6xl mb-4",children:"📋"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)] text-lg mb-2",children:"No policy templates found"}),e.jsx("p",{className:"text-[rgba(255,255,255,0.4)] text-sm",children:l==="all"?"Templates will appear here once they are created":`No templates in the "${l}" category`})]}):n.map(s=>e.jsxs("div",{className:"border border-[rgba(255,255,255,0.08)] rounded-lg p-6 hover:bg-[rgba(255,255,255,0.04)] transition-all cursor-pointer",onClick:()=>i(s),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsx("div",{className:"text-4xl",children:s.icon}),e.jsx("span",{className:"px-2 py-1 bg-[rgba(255,255,255,0.08)] text-[rgba(255,255,255,0.6)] text-xs rounded",children:s.category})]}),e.jsx("h3",{className:"text-lg font-semibold text-[#e2e8f0] mb-2",children:s.name}),e.jsx("p",{className:"text-sm text-[rgba(255,255,255,0.6)] mb-4 line-clamp-3",children:s.description}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:s.tags.slice(0,3).map(a=>e.jsx("span",{className:"px-2 py-1 bg-blue-50 text-blue-600 text-xs rounded",children:a},a))}),e.jsxs("span",{className:"text-xs text-[rgba(255,255,255,0.4)]",children:["Used ",s.use_count,"x"]})]}),e.jsx("button",{onClick:a=>{a.stopPropagation(),o(s)},className:"mt-4 w-full bg-blue-500 text-white py-2 px-4 rounded hover:bg-blue-600 transition-colors",children:"Use Template"})]},s.id))}),t&&e.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50",onClick:()=>i(null),children:e.jsxs("div",{className:"bg-[#12131a] rounded-lg max-w-2xl w-full max-h-[90vh] overflow-y-auto p-6 border border-[rgba(255,255,255,0.08)]",onClick:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-5xl mb-3",children:t.icon}),e.jsx("h2",{className:"text-2xl font-bold text-[#e2e8f0] mb-2",children:t.name}),e.jsx("p",{className:"text-[rgba(255,255,255,0.6)]",children:t.description})]}),e.jsx("button",{onClick:()=>i(null),className:"text-[rgba(255,255,255,0.4)] hover:text-[rgba(255,255,255,0.6)]",children:"✕"})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0] mb-3",children:"Policy Rules"}),e.jsx("div",{className:"bg-[rgba(255,255,255,0.03)] rounded p-4",children:e.jsx("pre",{className:"text-sm text-[rgba(255,255,255,0.6)] whitespace-pre-wrap",children:JSON.stringify(t.rules,null,2)})})]}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"font-semibold text-[#e2e8f0] mb-2",children:"Tags"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:t.tags.map(s=>e.jsx("span",{className:"px-3 py-1 bg-[rgba(59,130,246,0.15)] text-blue-400 text-sm rounded",children:s},s))})]}),e.jsxs("div",{className:"flex space-x-3",children:[e.jsx("button",{onClick:()=>o(t),className:"flex-1 bg-blue-500 text-white py-3 px-6 rounded-lg hover:bg-blue-600 transition-colors font-medium",children:"Use This Template"}),e.jsx("button",{onClick:()=>i(null),className:"px-6 py-3 border border-[rgba(255,255,255,0.08)] rounded-lg hover:bg-[rgba(255,255,255,0.04)] transition-colors text-[rgba(255,255,255,0.6)]",children:"Cancel"})]})]})})]})}export{N as default}; +//# sourceMappingURL=PolicyTemplatesPage-D4Vcprkl.js.map diff --git a/apps/console-proxy/public/assets/RiskHeatmapPage-B-jZ4L4N.js b/apps/console-proxy/public/assets/RiskHeatmapPage-B-jZ4L4N.js new file mode 100644 index 00000000..3e72ef62 --- /dev/null +++ b/apps/console-proxy/public/assets/RiskHeatmapPage-B-jZ4L4N.js @@ -0,0 +1,2 @@ +import{r as x,j as t,S as M,T as I,y as E,e as J,g as w}from"./index-C0nK3ekl.js";import{P as v}from"./PageLayout-D94mSHCV.js";function H(){const[n,g]=x.useState(null),[d,b]=x.useState("7d"),[p,S]=x.useState("risk"),[y,B]=x.useState(!1),[A,T]=x.useState(!0);if(x.useEffect(()=>{let e=!0;async function r(){var s;T(!0);try{const l=await J.get(`/analytics/risk-heatmap?range=${d}`);if(!e)return;if(l.success&&l.data){const o=[],i={T0:0,T1:0,T2:0,T3:0};l.data.forEach(a=>{o.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T0",count:a.t0_count}),o.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T1",count:a.t1_count}),o.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T2",count:a.t2_count}),o.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T3",count:a.t3_count}),i.T0+=a.t0_count,i.T1+=a.t1_count,i.T2+=a.t2_count,i.T3+=a.t3_count});const h=i.T0+i.T1+i.T2+i.T3,u=i.T2+i.T3,c=h>0?Math.round(u/h*100):0,C=((s=l.data.sort((a,F)=>F.high_risk_count-a.high_risk_count)[0])==null?void 0:s.agent_name)||"N/A";g({cells:o,totals:i,highest_risk_agent:C,risk_concentration:c})}else g({cells:[],totals:{T0:0,T1:0,T2:0,T3:0},highest_risk_agent:"N/A",risk_concentration:0})}catch(l){if(!e)return;console.error("Failed to fetch risk heatmap:",l),w("Failed to load risk heatmap data","error"),g({cells:[],totals:{T0:0,T1:0,T2:0,T3:0},highest_risk_agent:"N/A",risk_concentration:0})}finally{e&&T(!1)}}return r(),()=>{e=!1}},[d]),A||!n)return t.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:t.jsx("div",{style:{position:"relative",zIndex:1},children:t.jsx(v,{title:"Risk Distribution",description:"Loading heatmap...",children:t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"60px 0"},children:t.jsx("div",{style:{width:"40px",height:"40px",border:"3px solid rgba(251, 191, 36, 0.2)",borderTop:"3px solid #fbbf24",borderRadius:"50%",animation:"spin 1s linear infinite"}})})})})});const j=Array.from(new Set(n.cells.map(e=>e.agent_id))),_=["T0","T1","T2","T3"];let f=j;y&&(f=j.filter(e=>{var l,o;const r=((l=n.cells.find(i=>i.agent_id===e&&i.tier==="T2"))==null?void 0:l.count)||0,s=((o=n.cells.find(i=>i.agent_id===e&&i.tier==="T3"))==null?void 0:o.count)||0;return r>0||s>0})),p==="alpha"?f.sort():p==="active"?f.sort((e,r)=>{const s=n.cells.filter(o=>o.agent_id===e).reduce((o,i)=>o+i.count,0);return n.cells.filter(o=>o.agent_id===r).reduce((o,i)=>o+i.count,0)-s}):p==="risk"&&f.sort((e,r)=>{var o,i,h,u;const s=(((o=n.cells.find(c=>c.agent_id===e&&c.tier==="T2"))==null?void 0:o.count)||0)+(((i=n.cells.find(c=>c.agent_id===e&&c.tier==="T3"))==null?void 0:i.count)||0)*2;return(((h=n.cells.find(c=>c.agent_id===r&&c.tier==="T2"))==null?void 0:h.count)||0)+(((u=n.cells.find(c=>c.agent_id===r&&c.tier==="T3"))==null?void 0:u.count)||0)*2-s});const z=(e,r)=>{var s;return((s=n.cells.find(l=>l.agent_id===e&&l.tier===r))==null?void 0:s.count)||0},R=e=>e===0?"rgba(251, 191, 36, 0.05)":e<=10?"rgba(251, 191, 36, 0.2)":e<=50?"rgba(251, 191, 36, 0.4)":e<=100?"rgba(251, 191, 36, 0.6)":"rgba(251, 191, 36, 0.8)",k=e=>{switch(e){case"T0":return"#10b981";case"T1":return"#fbbf24";case"T2":return"#ef4444";case"T3":return"#991b1b";default:return"#6b7280"}};return t.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:t.jsx("div",{style:{position:"relative",zIndex:1},children:t.jsxs(v,{title:"",description:"",children:[t.jsx("div",{style:{background:"linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{margin:0,fontSize:"24px",fontWeight:700,color:"#fbbf24",fontFamily:"JetBrains Mono, monospace"},children:"RISK DISTRIBUTION"}),t.jsxs("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:["Agent activity by risk tier - last ",d]})]}),t.jsx("div",{style:{display:"flex",gap:"8px"},children:["24h","7d","30d","90d"].map(e=>t.jsx("button",{onClick:()=>b(e),style:{padding:"6px 12px",background:d===e?"#fbbf24":"rgba(251, 191, 36, 0.1)",border:d===e?"none":"1px solid rgba(251, 191, 36, 0.3)",color:d===e?"#0A0E14":"#fbbf24",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"JetBrains Mono, monospace"},children:e.toUpperCase()},e))})]})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px",marginBottom:"24px"},children:[t.jsx(m,{icon:t.jsx(M,{size:16}),label:"Total Actions",value:(n.totals.T0+n.totals.T1+n.totals.T2+n.totals.T3).toLocaleString(),color:"#10b981"}),t.jsx(m,{icon:t.jsx(I,{size:16}),label:"High Risk (T2+)",value:`${n.risk_concentration}%`,sublabel:`${n.totals.T2+n.totals.T3} actions`,color:"#ef4444"}),t.jsx(m,{icon:t.jsx(E,{size:16}),label:"Highest Risk Agent",value:n.highest_risk_agent,color:"#fbbf24"})]}),t.jsxs("div",{style:{display:"flex",gap:"16px",marginBottom:"16px",alignItems:"center"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"11px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:"SORT:"}),[{key:"risk",label:"Risk"},{key:"active",label:"Active"},{key:"alpha",label:"A-Z"}].map(({key:e,label:r})=>t.jsx("button",{onClick:()=>S(e),style:{padding:"4px 10px",background:p===e?"rgba(251, 191, 36, 0.2)":"transparent",border:"1px solid rgba(251, 191, 36, 0.3)",color:p===e?"#fbbf24":"#94a3b8",fontSize:"10px",fontWeight:600,cursor:"pointer",fontFamily:"JetBrains Mono, monospace"},children:r},e))]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:y,onChange:e=>B(e.target.checked),style:{cursor:"pointer"}}),"Show only T2+ agents"]})]}),t.jsx("div",{style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"JetBrains Mono, monospace",fontSize:"12px"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"rgba(251, 191, 36, 0.05)"},children:[t.jsx("th",{style:{padding:"12px",textAlign:"left",borderBottom:"1px solid rgba(255,255,255,0.1)",borderRight:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"10px",fontWeight:700,position:"sticky",left:0,background:"#0A0E14",zIndex:10},children:"AGENT"}),_.map(e=>t.jsxs("th",{style:{padding:"12px",textAlign:"center",borderBottom:"1px solid rgba(255,255,255,0.1)",color:k(e),fontSize:"11px",fontWeight:700},children:[t.jsx("div",{children:e}),t.jsx("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"2px"},children:n.totals[e].toLocaleString()})]},e))]})}),t.jsx("tbody",{children:f.map(e=>t.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[t.jsx("td",{style:{padding:"12px",borderRight:"1px solid rgba(255,255,255,0.1)",color:"#fff",fontSize:"11px",position:"sticky",left:0,background:"#0A0E14",zIndex:5},children:e}),_.map(r=>{const s=z(e,r),l=R(s);return t.jsx("td",{style:{padding:"12px",textAlign:"center",background:l,color:s>50?"#0A0E14":"#fff",cursor:s>0?"pointer":"default",transition:"all 0.2s",position:"relative"},onMouseEnter:o=>{s>0&&(o.currentTarget.style.boxShadow=`inset 0 0 0 2px ${k(r)}`)},onMouseLeave:o=>{o.currentTarget.style.boxShadow="none"},title:s>0?`${e}: ${s} ${r} actions`:"",children:s>0?s.toLocaleString():"—"},r)})]},e))})]})}),t.jsxs("div",{style:{marginTop:"16px",padding:"12px",background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)"},children:[t.jsx("div",{style:{fontSize:"10px",color:"#94a3b8",marginBottom:"8px",fontFamily:"JetBrains Mono, monospace",fontWeight:700},children:"COLOR SCALE"}),t.jsx("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[{label:"0",color:"rgba(251, 191, 36, 0.05)"},{label:"1-10",color:"rgba(251, 191, 36, 0.2)"},{label:"11-50",color:"rgba(251, 191, 36, 0.4)"},{label:"51-100",color:"rgba(251, 191, 36, 0.6)"},{label:"100+",color:"rgba(251, 191, 36, 0.8)"}].map(({label:e,color:r})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsx("div",{style:{width:"24px",height:"16px",background:r,border:"1px solid rgba(255,255,255,0.1)"}}),t.jsx("span",{style:{fontSize:"10px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:e})]},e))})]})]})})})}function m({icon:n,label:g,value:d,sublabel:b,color:p}){return t.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[t.jsx("div",{style:{color:p},children:n}),t.jsx("div",{style:{fontSize:"10px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace",fontWeight:700},children:g.toUpperCase()})]}),t.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:p,fontFamily:"JetBrains Mono, monospace"},children:d}),b&&t.jsx("div",{style:{fontSize:"10px",color:"#64748b",marginTop:"4px",fontFamily:"JetBrains Mono, monospace"},children:b})]})}export{H as RiskHeatmapPage}; +//# sourceMappingURL=RiskHeatmapPage-B-jZ4L4N.js.map diff --git a/apps/console-proxy/public/assets/RiskHeatmapPage-DE7V8HUL.js b/apps/console-proxy/public/assets/RiskHeatmapPage-DE7V8HUL.js deleted file mode 100644 index 8b0794b5..00000000 --- a/apps/console-proxy/public/assets/RiskHeatmapPage-DE7V8HUL.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as x,j as t,S as M,T as I,a as E,b as J}from"./index-D_7YXFSJ.js";import{P as v}from"./PageLayout-CTYKc2go.js";import{T as w}from"./trending-up-xPmnKzgu.js";function N(){const[n,g]=x.useState(null),[d,b]=x.useState("7d"),[p,S]=x.useState("risk"),[y,B]=x.useState(!1),[A,T]=x.useState(!0);if(x.useEffect(()=>{let e=!0;async function r(){var s;T(!0);try{const l=await E.get(`/analytics/risk-heatmap?range=${d}`);if(!e)return;if(l.success&&l.data){const i=[],o={T0:0,T1:0,T2:0,T3:0};l.data.forEach(a=>{i.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T0",count:a.t0_count}),i.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T1",count:a.t1_count}),i.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T2",count:a.t2_count}),i.push({agent_id:a.agent_id,agent_name:a.agent_name,tier:"T3",count:a.t3_count}),o.T0+=a.t0_count,o.T1+=a.t1_count,o.T2+=a.t2_count,o.T3+=a.t3_count});const h=o.T0+o.T1+o.T2+o.T3,u=o.T2+o.T3,c=h>0?Math.round(u/h*100):0,C=((s=l.data.sort((a,F)=>F.high_risk_count-a.high_risk_count)[0])==null?void 0:s.agent_name)||"N/A";g({cells:i,totals:o,highest_risk_agent:C,risk_concentration:c})}else g({cells:[],totals:{T0:0,T1:0,T2:0,T3:0},highest_risk_agent:"N/A",risk_concentration:0})}catch(l){if(!e)return;console.error("Failed to fetch risk heatmap:",l),J("Failed to load risk heatmap data","error"),g({cells:[],totals:{T0:0,T1:0,T2:0,T3:0},highest_risk_agent:"N/A",risk_concentration:0})}finally{e&&T(!1)}}return r(),()=>{e=!1}},[d]),A||!n)return t.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:t.jsx("div",{style:{position:"relative",zIndex:1},children:t.jsx(v,{title:"Risk Distribution",description:"Loading heatmap...",children:t.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"60px 0"},children:t.jsx("div",{style:{width:"40px",height:"40px",border:"3px solid rgba(251, 191, 36, 0.2)",borderTop:"3px solid #fbbf24",borderRadius:"50%",animation:"spin 1s linear infinite"}})})})})});const j=Array.from(new Set(n.cells.map(e=>e.agent_id))),_=["T0","T1","T2","T3"];let f=j;y&&(f=j.filter(e=>{var l,i;const r=((l=n.cells.find(o=>o.agent_id===e&&o.tier==="T2"))==null?void 0:l.count)||0,s=((i=n.cells.find(o=>o.agent_id===e&&o.tier==="T3"))==null?void 0:i.count)||0;return r>0||s>0})),p==="alpha"?f.sort():p==="active"?f.sort((e,r)=>{const s=n.cells.filter(i=>i.agent_id===e).reduce((i,o)=>i+o.count,0);return n.cells.filter(i=>i.agent_id===r).reduce((i,o)=>i+o.count,0)-s}):p==="risk"&&f.sort((e,r)=>{var i,o,h,u;const s=(((i=n.cells.find(c=>c.agent_id===e&&c.tier==="T2"))==null?void 0:i.count)||0)+(((o=n.cells.find(c=>c.agent_id===e&&c.tier==="T3"))==null?void 0:o.count)||0)*2;return(((h=n.cells.find(c=>c.agent_id===r&&c.tier==="T2"))==null?void 0:h.count)||0)+(((u=n.cells.find(c=>c.agent_id===r&&c.tier==="T3"))==null?void 0:u.count)||0)*2-s});const z=(e,r)=>{var s;return((s=n.cells.find(l=>l.agent_id===e&&l.tier===r))==null?void 0:s.count)||0},R=e=>e===0?"rgba(251, 191, 36, 0.05)":e<=10?"rgba(251, 191, 36, 0.2)":e<=50?"rgba(251, 191, 36, 0.4)":e<=100?"rgba(251, 191, 36, 0.6)":"rgba(251, 191, 36, 0.8)",k=e=>{switch(e){case"T0":return"#10b981";case"T1":return"#fbbf24";case"T2":return"#ef4444";case"T3":return"#991b1b";default:return"#6b7280"}};return t.jsx("div",{style:{position:"relative",minHeight:"100vh"},children:t.jsx("div",{style:{position:"relative",zIndex:1},children:t.jsxs(v,{title:"",description:"",children:[t.jsx("div",{style:{background:"linear-gradient(180deg, rgba(251, 191, 36, 0.1) 0%, transparent 100%)",borderBottom:"1px solid rgba(251, 191, 36, 0.2)",padding:"20px",marginBottom:"20px"},children:t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsx("h1",{style:{margin:0,fontSize:"24px",fontWeight:700,color:"#fbbf24",fontFamily:"JetBrains Mono, monospace"},children:"RISK DISTRIBUTION"}),t.jsxs("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:["Agent activity by risk tier - last ",d]})]}),t.jsx("div",{style:{display:"flex",gap:"8px"},children:["24h","7d","30d","90d"].map(e=>t.jsx("button",{onClick:()=>b(e),style:{padding:"6px 12px",background:d===e?"#fbbf24":"rgba(251, 191, 36, 0.1)",border:d===e?"none":"1px solid rgba(251, 191, 36, 0.3)",color:d===e?"#0A0E14":"#fbbf24",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"JetBrains Mono, monospace"},children:e.toUpperCase()},e))})]})}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(200px, 1fr))",gap:"16px",marginBottom:"24px"},children:[t.jsx(m,{icon:t.jsx(M,{size:16}),label:"Total Actions",value:(n.totals.T0+n.totals.T1+n.totals.T2+n.totals.T3).toLocaleString(),color:"#10b981"}),t.jsx(m,{icon:t.jsx(I,{size:16}),label:"High Risk (T2+)",value:`${n.risk_concentration}%`,sublabel:`${n.totals.T2+n.totals.T3} actions`,color:"#ef4444"}),t.jsx(m,{icon:t.jsx(w,{size:16}),label:"Highest Risk Agent",value:n.highest_risk_agent,color:"#fbbf24"})]}),t.jsxs("div",{style:{display:"flex",gap:"16px",marginBottom:"16px",alignItems:"center"},children:[t.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"11px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:"SORT:"}),[{key:"risk",label:"Risk"},{key:"active",label:"Active"},{key:"alpha",label:"A-Z"}].map(({key:e,label:r})=>t.jsx("button",{onClick:()=>S(e),style:{padding:"4px 10px",background:p===e?"rgba(251, 191, 36, 0.2)":"transparent",border:"1px solid rgba(251, 191, 36, 0.3)",color:p===e?"#fbbf24":"#94a3b8",fontSize:"10px",fontWeight:600,cursor:"pointer",fontFamily:"JetBrains Mono, monospace"},children:r},e))]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace",cursor:"pointer"},children:[t.jsx("input",{type:"checkbox",checked:y,onChange:e=>B(e.target.checked),style:{cursor:"pointer"}}),"Show only T2+ agents"]})]}),t.jsx("div",{style:{background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",overflow:"auto"},children:t.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontFamily:"JetBrains Mono, monospace",fontSize:"12px"},children:[t.jsx("thead",{children:t.jsxs("tr",{style:{background:"rgba(251, 191, 36, 0.05)"},children:[t.jsx("th",{style:{padding:"12px",textAlign:"left",borderBottom:"1px solid rgba(255,255,255,0.1)",borderRight:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"10px",fontWeight:700,position:"sticky",left:0,background:"#0A0E14",zIndex:10},children:"AGENT"}),_.map(e=>t.jsxs("th",{style:{padding:"12px",textAlign:"center",borderBottom:"1px solid rgba(255,255,255,0.1)",color:k(e),fontSize:"11px",fontWeight:700},children:[t.jsx("div",{children:e}),t.jsx("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"2px"},children:n.totals[e].toLocaleString()})]},e))]})}),t.jsx("tbody",{children:f.map(e=>t.jsxs("tr",{style:{borderBottom:"1px solid rgba(255,255,255,0.05)"},children:[t.jsx("td",{style:{padding:"12px",borderRight:"1px solid rgba(255,255,255,0.1)",color:"#fff",fontSize:"11px",position:"sticky",left:0,background:"#0A0E14",zIndex:5},children:e}),_.map(r=>{const s=z(e,r),l=R(s);return t.jsx("td",{style:{padding:"12px",textAlign:"center",background:l,color:s>50?"#0A0E14":"#fff",cursor:s>0?"pointer":"default",transition:"all 0.2s",position:"relative"},onMouseEnter:i=>{s>0&&(i.currentTarget.style.boxShadow=`inset 0 0 0 2px ${k(r)}`)},onMouseLeave:i=>{i.currentTarget.style.boxShadow="none"},title:s>0?`${e}: ${s} ${r} actions`:"",children:s>0?s.toLocaleString():"—"},r)})]},e))})]})}),t.jsxs("div",{style:{marginTop:"16px",padding:"12px",background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)"},children:[t.jsx("div",{style:{fontSize:"10px",color:"#94a3b8",marginBottom:"8px",fontFamily:"JetBrains Mono, monospace",fontWeight:700},children:"COLOR SCALE"}),t.jsx("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[{label:"0",color:"rgba(251, 191, 36, 0.05)"},{label:"1-10",color:"rgba(251, 191, 36, 0.2)"},{label:"11-50",color:"rgba(251, 191, 36, 0.4)"},{label:"51-100",color:"rgba(251, 191, 36, 0.6)"},{label:"100+",color:"rgba(251, 191, 36, 0.8)"}].map(({label:e,color:r})=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t.jsx("div",{style:{width:"24px",height:"16px",background:r,border:"1px solid rgba(255,255,255,0.1)"}}),t.jsx("span",{style:{fontSize:"10px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace"},children:e})]},e))})]})]})})})}function m({icon:n,label:g,value:d,sublabel:b,color:p}){return t.jsxs("div",{style:{background:"rgba(10, 14, 20, 0.6)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[t.jsx("div",{style:{color:p},children:n}),t.jsx("div",{style:{fontSize:"10px",color:"#94a3b8",fontFamily:"JetBrains Mono, monospace",fontWeight:700},children:g.toUpperCase()})]}),t.jsx("div",{style:{fontSize:"24px",fontWeight:700,color:p,fontFamily:"JetBrains Mono, monospace"},children:d}),b&&t.jsx("div",{style:{fontSize:"10px",color:"#64748b",marginTop:"4px",fontFamily:"JetBrains Mono, monospace"},children:b})]})}export{N as RiskHeatmapPage}; -//# sourceMappingURL=RiskHeatmapPage-DE7V8HUL.js.map diff --git a/apps/console-proxy/public/assets/RuntimePage-uu1XVo6e.js b/apps/console-proxy/public/assets/RuntimePage-uu1XVo6e.js deleted file mode 100644 index 5b9dcc09..00000000 --- a/apps/console-proxy/public/assets/RuntimePage-uu1XVo6e.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as s,j as e}from"./index-D_7YXFSJ.js";import{P as m}from"./PageLayout-CTYKc2go.js";import{u as y}from"./useEventStream-VJ5QEnuI.js";async function u(a){return(await fetch(a,{credentials:"include"})).json()}function w(){const[a,d]=s.useState(null),[l,o]=s.useState([]),[r,b]=s.useState("24h"),[g,f]=s.useState(!0),{connected:h,events:c}=y({enabled:!0,maxEvents:10}),p=s.useCallback(async()=>{try{const[t,x]=await Promise.all([u(`/api/v1/runtime/stats?window=${r}`),u("/api/v1/execution-records?limit=10")]);d(t.data),o(x.data||[])}catch{}finally{f(!1)}},[r]);s.useEffect(()=>{p();const t=setInterval(p,15e3);return()=>clearInterval(t)},[p]),s.useEffect(()=>{c.length>0&&p()},[c.length]);const n={executed:"#10b981",denied:"#ef4444",expired:"#94a3b8",revoked:"#f97316",pending:"#f59e0b"};return e.jsxs(m,{title:"Runtime",description:"Execution pipeline health and metrics",children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"20px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:(a==null?void 0:a.health)==="healthy"?"#10b981":"#ef4444",boxShadow:(a==null?void 0:a.health)==="healthy"?"0 0 12px rgba(74, 222, 128, 0.6), 0 0 6px rgba(74, 222, 128, 0.4)":"0 0 12px rgba(248, 113, 113, 0.6), 0 0 6px rgba(248, 113, 113, 0.4)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:700,color:"var(--text-primary)",textTransform:"uppercase"},children:(a==null?void 0:a.health)||"loading"})]}),h&&e.jsx("span",{style:{fontSize:"10px",padding:"2px 8px",borderRadius:"4px",background:"rgba(74, 222, 128, 0.08)",color:"#10b981",border:"1px solid rgba(74, 222, 128, 0.2)",fontFamily:"var(--font-mono)",fontWeight:600,boxShadow:"0 0 8px rgba(74, 222, 128, 0.3)"},children:"SSE LIVE"}),e.jsx("div",{style:{marginLeft:"auto",display:"flex",gap:"4px"},children:["5m","1h","24h","7d"].map(t=>e.jsx("button",{onClick:()=>b(t),style:{padding:"4px 10px",borderRadius:"5px",fontSize:"11px",fontWeight:600,background:r===t?"rgba(167, 139, 250, 0.15)":"transparent",border:`1px solid ${r===t?"rgba(167, 139, 250, 0.3)":"var(--border-subtle)"}`,color:r===t?"#f59e0b":"var(--text-tertiary)",cursor:"pointer",fontFamily:"var(--font-mono)",boxShadow:r===t?"0 0 8px rgba(124, 58, 237, 0.2)":"none",transition:"all 0.2s ease"},children:t},t))})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"12px",marginBottom:"24px"},children:[e.jsx(i,{label:"Proposals",value:a.envelopes.total,color:"#60a5fa"}),e.jsx(i,{label:"Succeeded",value:a.envelopes.succeeded,color:"#10b981"}),e.jsx(i,{label:"Failed",value:a.envelopes.failed,color:"#ef4444"}),e.jsx(i,{label:"Queue",value:a.queueDepth,color:"#f59e0b"}),e.jsx(i,{label:"Throughput",value:a.throughputPerMinute,suffix:"/min",color:"#f59e0b"}),e.jsx(i,{label:"Error Rate",value:Math.round(a.errorRate*100),suffix:"%",color:a.errorRate>.1?"#ef4444":"#10b981"}),e.jsx(i,{label:"Audit Events",value:a.auditEvents,color:"#94a3b8"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",marginBottom:"10px"},children:"Recent Executions"}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"10px",overflow:"hidden"},children:l.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No execution records yet."}):l.map((t,x)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"10px 14px",borderBottom:x{r.currentTarget.style.transform="translateY(-2px)",r.currentTarget.style.boxShadow=`0 0 20px ${o}15, 0 4px 8px rgba(0, 0, 0, 0.15)`},onMouseLeave:r=>{r.currentTarget.style.transform="translateY(0)",r.currentTarget.style.boxShadow=`0 0 15px ${o}08, 0 2px 4px rgba(0, 0, 0, 0.1)`},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"4px"},children:a}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:"2px"},children:[e.jsx("span",{style:{fontSize:"24px",fontWeight:700,color:o,fontFamily:"var(--font-mono)",lineHeight:1,textShadow:`0 0 8px ${o}40`},children:d}),l&&e.jsx("span",{style:{fontSize:"11px",color:"var(--text-tertiary)"},children:l})]})]})}export{w as RuntimePage}; -//# sourceMappingURL=RuntimePage-uu1XVo6e.js.map diff --git a/apps/console-proxy/public/assets/ServicesPage-DGzG-Sg8.js b/apps/console-proxy/public/assets/ServicesPage-DGzG-Sg8.js deleted file mode 100644 index e41f0e5c..00000000 --- a/apps/console-proxy/public/assets/ServicesPage-DGzG-Sg8.js +++ /dev/null @@ -1,2 +0,0 @@ -import{r as o,j as e}from"./index-D_7YXFSJ.js";import{P as C}from"./PageLayout-CTYKc2go.js";const D=[{name:"Policy Engine",icon:"📋",desc:"Rule evaluation & enforcement",key:"pipeline"},{name:"Warrant System",icon:"🔐",desc:"Cryptographic signing & TTL",key:"pipeline"},{name:"Agent Registry",icon:"🤖",desc:"Trust scores & rate limiting",key:"agents"},{name:"Webhook Dispatch",icon:"🔔",desc:"Event notifications via HTTP",key:"webhooks"},{name:"SSE Streaming",icon:"📡",desc:"Real-time event stream",key:"sse"},{name:"Auth & RBAC",icon:"🔑",desc:"JWT, API keys, rate limiting",key:"auth"}];function $(){var p,x,u,h,y,m,g,f,b,v,j,S,k,T,E,R,w,z;const[t,l]=o.useState(null),[c,n]=o.useState(!0),d=o.useCallback(async()=>{try{const i=await(await fetch("/api/v1/health",{credentials:"include"})).json();l(i)}catch{}finally{n(!1)}},[]);o.useEffect(()=>{d();const a=setInterval(d,15e3);return()=>clearInterval(a)},[d]);const A=a=>{if(!(t!=null&&t.checks))return{status:"unknown",color:"#94a3b8"};const i=t.checks[a];if(!i)return{status:"unknown",color:"#94a3b8"};const s=i.status;return{status:s==="healthy"?"Operational":s==="warning"?"Warning":s==="unhealthy"?"Down":s,color:s==="healthy"?"#10b981":s==="warning"?"#f59e0b":"#ef4444"}},W=a=>a<60?`${Math.floor(a)}s`:a<3600?`${Math.floor(a/60)}m`:`${Math.floor(a/3600)}h ${Math.floor(a%3600/60)}m`;return e.jsxs(C,{title:"Services",description:"Infrastructure health & governance engine status",children:[t&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"20px",padding:"12px 0"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:t.status==="healthy"?"#10b981":"#ef4444"}}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:600,color:t.status==="healthy"?"#10b981":"#ef4444"},children:["ALL SYSTEMS ",t.status==="healthy"?"OPERATIONAL":"DEGRADED"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginLeft:"auto",fontFamily:"var(--font-mono)"},children:["v",t.version," · ",t.mode," · uptime ",W(t.uptime_seconds)]})]}),t&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(120px, 1fr))",gap:"10px",marginBottom:"24px"},children:[e.jsx(r,{label:"Endpoints",value:((p=t.endpoints)==null?void 0:p.total)||0,sub:`${((x=t.endpoints)==null?void 0:x.healthy)||0} healthy`,color:"#f59e0b"}),e.jsx(r,{label:"DB Latency",value:((h=(u=t.checks)==null?void 0:u.database)==null?void 0:h.latency_ms)||0,sub:"ms",color:((m=(y=t.checks)==null?void 0:y.database)==null?void 0:m.latency_ms)>200?"#ef4444":"#10b981"}),e.jsx(r,{label:"Proposals",value:((f=(g=t.checks)==null?void 0:g.pipeline)==null?void 0:f.proposals)||0,sub:"total",color:"#60a5fa"}),e.jsx(r,{label:"Audit Events",value:((v=(b=t.checks)==null?void 0:b.pipeline)==null?void 0:v.audit_events)||0,sub:"total",color:"#94a3b8"}),e.jsx(r,{label:"Agents",value:((S=(j=t.checks)==null?void 0:j.agents)==null?void 0:S.count)||0,sub:"registered",color:"#D4A520"}),e.jsx(r,{label:"Webhooks",value:((T=(k=t.checks)==null?void 0:k.webhooks)==null?void 0:T.active)||0,sub:"active",color:"#f97316"})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"10px"},children:"Governance Engines"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(260px, 1fr))",gap:"10px"},children:D.map(a=>{const{status:i,color:s}=A(a.key);return e.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"10px",padding:"14px 16px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:a.icon}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:a.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"1px"},children:a.desc})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px",padding:"3px 8px",borderRadius:"100px",background:`${s}10`,border:`1px solid ${s}25`},children:[e.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:s}}),e.jsx("span",{style:{fontSize:"10px",fontWeight:600,color:s,textTransform:"uppercase"},children:i})]})]},a.name)})})]}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"10px"},children:"Infrastructure"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"10px"},children:[{label:"Database",value:"Neon Postgres",sub:`${((R=(E=t==null?void 0:t.checks)==null?void 0:E.database)==null?void 0:R.latency_ms)||"?"}ms latency`,icon:"💾",status:(z=(w=t==null?void 0:t.checks)==null?void 0:w.database)==null?void 0:z.status},{label:"Compute",value:"Vercel Serverless",sub:"US East (iad1)",icon:"⚡",status:"healthy"},{label:"CDN",value:"Vercel Edge",sub:"Global distribution",icon:"🌐",status:"healthy"},{label:"DNS",value:"Vercel DNS",sub:"*.regulator.ai",icon:"🔗",status:"healthy"},{label:"SSL",value:"Let's Encrypt",sub:"Auto-renewed",icon:"🔒",status:"healthy"},{label:"Email",value:"Resend",sub:"Transactional",icon:"📧",status:"healthy"}].map(a=>e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"10px",padding:"14px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"6px"},children:[e.jsx("span",{style:{fontSize:"16px"},children:a.icon}),e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:a.label}),e.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",background:a.status==="healthy"?"#10b981":"#ef4444",marginLeft:"auto"}})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",fontFamily:"var(--font-mono)"},children:a.value}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:a.sub})]},a.label))})]}),c&&!t&&e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"60px 0"},children:e.jsx("div",{style:{width:"32px",height:"32px",border:"3px solid var(--border-subtle)",borderTopColor:"#f59e0b",borderRadius:"50%",animation:"spin 0.8s linear infinite"}})})]})}function r({label:t,value:l,sub:c,color:n}){return e.jsxs("div",{style:{background:`${n}06`,border:`1px solid ${n}12`,borderRadius:"8px",padding:"12px",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:"22px",fontWeight:700,color:n,fontFamily:"var(--font-mono)",lineHeight:1},children:l}),e.jsx("div",{style:{fontSize:"10px",color:"var(--text-tertiary)",marginTop:"2px"},children:c}),e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",marginTop:"4px"},children:t})]})}export{$ as ServicesPage}; -//# sourceMappingURL=ServicesPage-DGzG-Sg8.js.map diff --git a/apps/console-proxy/public/assets/SettingsPage-C6VhOSia.js b/apps/console-proxy/public/assets/SettingsPage-Cffft1gX.js similarity index 91% rename from apps/console-proxy/public/assets/SettingsPage-C6VhOSia.js rename to apps/console-proxy/public/assets/SettingsPage-Cffft1gX.js index 79aacf33..ed651c81 100644 --- a/apps/console-proxy/public/assets/SettingsPage-C6VhOSia.js +++ b/apps/console-proxy/public/assets/SettingsPage-Cffft1gX.js @@ -1,17 +1,22 @@ -import{c as O,r as s,a as m,j as e,S as D,U as ie,d as se,e as ne,f as ae}from"./index-D_7YXFSJ.js";import{P as le}from"./PageLayout-CTYKc2go.js";import{P as de}from"./plus-BYo2vOpk.js";import{T as ce}from"./trash-2-BKcMh7SV.js";/** +import{c as B,r as s,e as m,j as e,S as N,U as ie,f as se,h as ne,x as ae}from"./index-C0nK3ekl.js";import{P as le}from"./PageLayout-D94mSHCV.js";import{T as de}from"./trash-2-_FGaWZX1.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const pe=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],xe=O("history",pe);/** + */const ce=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],pe=B("history",ce);/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const ge=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],ue=O("user-minus",ge);/** + */const xe=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],ge=B("plus",xe);/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const be=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],fe=O("user-plus",be);function he(){const[r,l]=s.useState("roles"),[n,c]=s.useState([]),[i,g]=s.useState([]),[u,b]=s.useState([]),[x,p]=s.useState([]),[f,y]=s.useState([]),[h,j]=s.useState(!1),[k,o]=s.useState(!1),[a,C]=s.useState(!1),[w,S]=s.useState(""),[R,L]=s.useState(""),[P,$]=s.useState(""),[U,G]=s.useState([]),[A,V]=s.useState(""),[z,Y]=s.useState("");s.useEffect(()=>{B(),q(),K()},[]),s.useEffect(()=>{r==="assignments"&&I(),r==="audit"&&X()},[r]);const B=async()=>{j(!0);try{const t=await m.get("/roles");c(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load roles:",t)}finally{j(!1)}},I=async()=>{try{const t=await m.get("/roles/assignments");g(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load assignments:",t)}},q=async()=>{try{const t=await m.get("/roles/users");b(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load users:",t)}},K=async()=>{try{const t=await m.get("/roles/permissions");p(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load permissions:",t)}},X=async()=>{try{const t=await m.get("/roles/audit?limit=50");y(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load audit log:",t)}},Q=async()=>{if(!(!w.trim()||!R.trim()))try{await m.post("/roles",{role_name:w,display_name:R,description:P,permissions:U}),o(!1),S(""),L(""),$(""),G([]),B()}catch(t){console.error("Failed to create role:",t)}},Z=async(t,T)=>{if(confirm(`Delete role "${T}"? This cannot be undone.`))try{await m.delete(`/roles/${t}`),B()}catch(_){console.error("Failed to delete role:",_)}},ee=async()=>{if(!(!A||!z))try{await m.post("/roles/assign",{user_id:A,role_id:z}),C(!1),V(""),Y(""),I()}catch(t){console.error("Failed to assign role:",t)}},te=async(t,T,_)=>{if(confirm(`Revoke role "${_}" from ${T}?`))try{const E=i.find(oe=>oe.id===t);if(!E)return;await m.post("/roles/revoke",{user_id:E.user_id,role_id:E.role_id}),I()}catch(E){console.error("Failed to revoke role:",E)}},re=t=>{G(T=>T.includes(t)?T.filter(_=>_!==t):[...T,t])};return e.jsxs("div",{style:{fontFamily:"JetBrains Mono, monospace"},children:[e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:["roles","assignments","audit"].map(t=>e.jsxs("button",{onClick:()=>l(t),style:{padding:"8px 16px",background:"none",border:"none",borderBottom:r===t?"2px solid #fbbf24":"2px solid transparent",color:r===t?"#fbbf24":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:"pointer",textTransform:"uppercase",fontFamily:"inherit"},children:[t==="roles"&&e.jsx(D,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t==="assignments"&&e.jsx(ie,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t==="audit"&&e.jsx(xe,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t]},t))}),r==="roles"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8"},children:[n.length," roles (",n.filter(t=>t.is_system_role).length," system, ",n.filter(t=>!t.is_system_role).length," custom)"]}),e.jsxs("button",{onClick:()=>o(!k),style:{padding:"6px 12px",background:"#fbbf24",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(de,{size:14}),"New Role"]})]}),k&&e.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#fbbf24",marginBottom:"12px"},children:"CREATE CUSTOM ROLE"}),e.jsxs("div",{style:{display:"grid",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"ROLE NAME (lowercase, no spaces)"}),e.jsx("input",{type:"text",value:w,onChange:t=>S(t.target.value.toLowerCase().replace(/\s/g,"_")),placeholder:"e.g., compliance_reviewer",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"DISPLAY NAME"}),e.jsx("input",{type:"text",value:R,onChange:t=>L(t.target.value),placeholder:"e.g., Compliance Reviewer",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"DESCRIPTION"}),e.jsx("input",{type:"text",value:P,onChange:t=>$(t.target.value),placeholder:"e.g., Can review compliance reports and approve low-risk proposals",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"8px"},children:"PERMISSIONS"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"8px"},children:x.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",padding:"8px",border:"1px solid rgba(255,255,255,0.05)"},children:[e.jsx("div",{style:{fontSize:"9px",color:"#fbbf24",fontWeight:700,marginBottom:"6px"},children:t.group.toUpperCase()}),t.permissions.map(T=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"10px",color:"#94a3b8",marginBottom:"4px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:U.includes(T),onChange:()=>re(T),style:{cursor:"pointer"}}),T.replace(`${t.group}.`,"")]},T))]},t.group))})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>o(!1),style:{padding:"8px 16px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{onClick:Q,disabled:!w||!R,style:{padding:"8px 16px",background:w&&R?"#fbbf24":"rgba(251, 191, 36, 0.3)",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:w&&R?"pointer":"not-allowed",fontFamily:"inherit"},children:"Create Role"})]})]})]}),e.jsx("div",{style:{display:"grid",gap:"8px"},children:n.map(t=>e.jsxs("div",{style:{background:t.is_system_role?"rgba(251, 191, 36, 0.05)":"rgba(255,255,255,0.02)",border:t.is_system_role?"1px solid rgba(251, 191, 36, 0.2)":"1px solid rgba(255,255,255,0.08)",padding:"12px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[e.jsx(D,{size:14,color:t.is_system_role?"#fbbf24":"#94a3b8"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#fff"},children:t.display_name}),t.is_system_role&&e.jsx("span",{style:{fontSize:"9px",color:"#fbbf24",background:"rgba(251, 191, 36, 0.1)",padding:"2px 6px",fontWeight:700},children:"SYSTEM"}),t.assignment_count!==void 0&&e.jsxs("span",{style:{fontSize:"10px",color:"#94a3b8"},children:[t.assignment_count," user",t.assignment_count!==1?"s":""]})]}),e.jsx("div",{style:{fontSize:"11px",color:"#94a3b8",marginBottom:"6px"},children:t.description}),e.jsxs("div",{style:{fontSize:"9px",color:"#64748b"},children:[t.permissions.length," permission",t.permissions.length!==1?"s":"",": ",t.permissions.slice(0,3).join(", "),t.permissions.length>3&&` +${t.permissions.length-3} more`]})]}),!t.is_system_role&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("button",{onClick:()=>Z(t.id,t.display_name),style:{padding:"6px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",cursor:"pointer",display:"flex",alignItems:"center"},title:"Delete role",children:e.jsx(ce,{size:14})})})]},t.id))})]}),r==="assignments"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8"},children:[i.length," active assignment",i.length!==1?"s":""]}),e.jsxs("button",{onClick:()=>C(!a),style:{padding:"6px 12px",background:"#fbbf24",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(fe,{size:14}),"Assign Role"]})]}),a&&e.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#fbbf24",marginBottom:"12px"},children:"ASSIGN ROLE TO USER"}),e.jsxs("div",{style:{display:"grid",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"USER"}),e.jsxs("select",{value:A,onChange:t=>V(t.target.value),style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"},children:[e.jsx("option",{value:"",children:"Select user..."}),u.map(t=>e.jsxs("option",{value:t.id,children:[t.email," (",t.name,")"]},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"ROLE"}),e.jsxs("select",{value:z,onChange:t=>Y(t.target.value),style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"},children:[e.jsx("option",{value:"",children:"Select role..."}),n.map(t=>e.jsx("option",{value:t.id,children:t.display_name},t.id))]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>C(!1),style:{padding:"8px 16px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{onClick:ee,disabled:!A||!z,style:{padding:"8px 16px",background:A&&z?"#fbbf24":"rgba(251, 191, 36, 0.3)",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:A&&z?"pointer":"not-allowed",fontFamily:"inherit"},children:"Assign"})]})]})]}),e.jsx("div",{style:{display:"grid",gap:"8px"},children:i.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#fff",marginBottom:"4px"},children:[t.user_email," (",t.user_name,")"]}),e.jsxs("div",{style:{fontSize:"11px",color:"#fbbf24"},children:[e.jsx(D,{size:12,style:{display:"inline",verticalAlign:"middle",marginRight:"4px"}}),t.role_display_name]}),e.jsxs("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"4px"},children:["Assigned ",new Date(t.assigned_at).toLocaleDateString()," by ",t.assigned_by]})]}),e.jsxs("button",{onClick:()=>te(t.id,t.user_email,t.role_display_name),style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",fontSize:"10px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(ue,{size:12}),"Revoke"]})]},t.id))})]}),r==="audit"&&e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8",marginBottom:"16px"},children:["Last ",f.length," RBAC changes"]}),e.jsx("div",{style:{display:"grid",gap:"6px"},children:f.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.05)",padding:"10px",fontSize:"11px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{color:"#fbbf24",fontWeight:600},children:t.action.toUpperCase()}),e.jsx("span",{style:{color:"#64748b",fontSize:"9px"},children:new Date(t.timestamp).toLocaleString()})]}),e.jsxs("div",{style:{color:"#94a3b8"},children:[t.role_name&&e.jsxs("span",{children:["Role: ",e.jsx("span",{style:{color:"#fff"},children:t.role_name})]}),t.user_email&&e.jsxs("span",{children:[" • User: ",e.jsx("span",{style:{color:"#fff"},children:t.user_email})]})," • "," By: ",e.jsx("span",{style:{color:"#fff"},children:t.performed_by})]}),Object.keys(t.details||{}).length>0&&e.jsx("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"4px",fontFamily:"monospace"},children:JSON.stringify(t.details)})]},t.id))})]})]})}const ye=[{value:"*",label:"All events"},{value:"warrant_issued",label:"Warrant issued"},{value:"proposal_pending",label:"Proposal pending approval"},{value:"proposal_denied",label:"Proposal denied"},{value:"execution_completed",label:"Execution completed"},{value:"execution_failed",label:"Execution failed"},{value:"warrant_revoked",label:"Warrant revoked"},{value:"warrant_expired",label:"Warrant expired"}];function me(){const[r,l]=s.useState([]),[n,c]=s.useState(!0),[i,g]=s.useState(!1),[u,b]=s.useState(""),[x,p]=s.useState(["*"]),[f,y]=s.useState(!1),h=()=>{fetch("/api/v1/webhooks",{credentials:"include"}).then(o=>o.json()).then(o=>l(o.data||[])).catch(()=>{}).finally(()=>c(!1))};s.useEffect(()=>{h()},[]);const j=async()=>{if(u.trim()){y(!0);try{await fetch("/api/v1/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:u,events:x})}),b(""),g(!1),h()}catch{}finally{y(!1)}}},k=async o=>{confirm("Delete this webhook?")&&(await fetch(`/api/v1/webhooks/${o}`,{method:"DELETE",credentials:"include"}),h())};return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:700,color:"var(--text-primary)"},children:"Webhooks"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"2px"},children:"Receive HTTP callbacks for pipeline events"})]}),e.jsx("button",{onClick:()=>g(!i),style:{padding:"6px 14px",borderRadius:"6px",fontSize:"12px",fontWeight:600,background:"#f59e0b",border:"none",color:"#fff",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"+ Add Webhook"})]}),i&&e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"10px",padding:"14px",marginBottom:"16px"},children:[e.jsx("input",{value:u,onChange:o=>b(o.target.value),placeholder:"https://your-server.com/webhooks/vienna",style:{width:"100%",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",background:"var(--bg-primary)",border:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",marginBottom:"8px",boxSizing:"border-box"}}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"10px"},children:ye.map(o=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.includes(o.value),onChange:a=>{if(o.value==="*"){p(a.target.checked?["*"]:[]);return}p(C=>{const w=C.filter(S=>S!=="*");return a.target.checked?[...w,o.value]:w.filter(S=>S!==o.value)})},style:{accentColor:"#f59e0b"}}),o.label]},o.value))}),e.jsx("button",{onClick:j,disabled:f||!u.trim(),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"12px",fontWeight:600,background:f?"var(--bg-tertiary)":"#f59e0b",border:"none",color:"#fff",cursor:f?"default":"pointer",fontFamily:"var(--font-sans)"},children:f?"Creating...":"Create Webhook"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"10px",overflow:"hidden"},children:n?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"Loading..."}):r.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No webhooks configured. Add one to receive pipeline event notifications."}):r.map((o,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 14px",borderBottom:ak(o.id),style:{padding:"4px 10px",borderRadius:"4px",fontSize:"10px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",color:"#ef4444",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Delete"})]},o.id))})]})}async function ve(){return m.get("/simulation/status")}async function je(){await m.post("/simulation/start",{})}async function Se(){await m.post("/simulation/stop",{})}async function ke(){return m.post("/simulation/seed",{})}async function Te(){await m.post("/simulation/reset",{})}function Ie(){const{user:r,logout:l}=se(),{isMobile:n}=ne();return e.jsx(le,{title:"Settings",description:"Operator configuration and system information",children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:n?"1fr":"1fr 1fr",gap:"16px"},children:[e.jsxs(v,{title:"Session",children:[e.jsx(d,{label:"Operator",value:(r==null?void 0:r.email)||"User"}),e.jsx(d,{label:"Status",value:"Active",valueColor:"#10b981"}),e.jsx(d,{label:"Environment",value:"Production"}),e.jsx(d,{label:"Tenant",value:"system"}),e.jsx("div",{style:{marginTop:"16px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:()=>{confirm("Logout?")&&l()},style:{padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(248, 113, 113, 0.2)",background:"rgba(248, 113, 113, 0.08)",color:"#ef4444",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Logout"})})]}),e.jsx(ze,{}),e.jsx(we,{}),e.jsx(Re,{}),e.jsxs(v,{title:"System",children:[e.jsx(d,{label:"Vienna OS",value:"v0.9.0",mono:!0}),e.jsx(d,{label:"Runtime",value:"Node 22 · Vercel Serverless"}),e.jsx(d,{label:"Database",value:"Neon Postgres · regulator schema"}),e.jsx(d,{label:"Region",value:"US East (us-east-1)"}),e.jsx(d,{label:"Streaming",value:"SSE · /api/v1/stream/events",mono:!0})]}),e.jsx(Ce,{}),e.jsx(Ae,{}),e.jsxs(v,{title:"API & Integrations",children:[e.jsx(d,{label:"Intent Gateway",value:"Enabled",valueColor:"#10b981"}),e.jsx(d,{label:"Agent Auth",value:"Source-based"}),e.jsx(d,{label:"Rate Limit",value:"60 req/min per IP"}),e.jsx(d,{label:"CORS Origins",value:"regulator.ai, localhost"}),e.jsx(d,{label:"SSE Streaming",value:"Enabled",valueColor:"#10b981"})]}),e.jsx(v,{title:"Webhook Notifications",children:e.jsx(me,{})}),e.jsx(_e,{}),e.jsx(v,{title:"Team & Access Control",children:e.jsx(he,{})}),e.jsx(Ee,{}),e.jsxs(v,{title:"Resources",children:[e.jsx(W,{label:"📖 Documentation",href:"https://regulator.ai/docs"}),e.jsx(W,{label:"🔐 Security",href:"https://regulator.ai/security"}),e.jsx(W,{label:"📋 Changelog",href:"https://regulator.ai/changelog"}),e.jsx(W,{label:"💻 GitHub",href:"https://github.com/risk-ai/regulator.ai"}),e.jsx(W,{label:"📧 Support",href:"mailto:admin@ai.ventures"})]}),e.jsx(v,{title:"About",children:e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",lineHeight:1.7},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"Vienna OS"})," is the governance control plane for autonomous AI agents."]}),e.jsxs("p",{style:{marginTop:"8px"},children:["Built by ",e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"Max Anderson"})," (Cornell Law) at ",e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"ai.ventures"}),"."]}),e.jsx("p",{style:{marginTop:"8px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-muted)"},children:"© 2026 Technetwork 2 LLC dba ai.ventures"})]})})]})})}function we(){const{isDemoMode:r,hasRealAgents:l,agentCount:n,forcedDemo:c,setForcedDemo:i}=ae();return e.jsxs(v,{title:"Demo Mode",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"13px",color:"var(--text-primary)",fontWeight:500},children:"Show sample data"}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:"Display demo governance data to explore Vienna OS features"})]}),e.jsx("div",{onClick:()=>i(!c),style:{width:"36px",height:"20px",borderRadius:"0",cursor:"pointer",background:c?"rgba(245,158,11,0.3)":"rgba(255,255,255,0.08)",border:`1px solid ${c?"rgba(245,158,11,0.4)":"var(--border-subtle)"}`,position:"relative",transition:"all 150ms"},children:e.jsx("div",{style:{width:"14px",height:"14px",borderRadius:"50%",position:"absolute",top:"2px",left:c?"18px":"2px",background:c?"#f59e0b":"var(--text-tertiary)",transition:"all 150ms"}})})]}),e.jsxs("div",{style:{padding:"8px 12px",borderRadius:"0",fontSize:"11px",background:r?"rgba(245,158,11,0.06)":"rgba(16,185,129,0.06)",color:r?"#f59e0b":"#10b981",display:"flex",alignItems:"center",gap:"6px"},children:[r?"🧪":"✅",r?`Demo mode active${l?" (forced)":" — no agents connected"}`:`Live mode — ${n} agent${n!==1?"s":""} connected`]})]})}const N="vienna_governance_config",F={riskThresholds:{low:25,medium:50,high:75,critical:90},warrantTtlT0:3600,warrantTtlT1:900,warrantTtlT2:300,autoApproveLowRisk:!0,auditRetentionYears:7};function Ce(){const[r,l]=s.useState(()=>{try{const p=localStorage.getItem(N);return p?{...F,...JSON.parse(p)}:F}catch{return F}}),[n,c]=s.useState(!1),[i,g]=s.useState(!1),u=()=>{localStorage.setItem(N,JSON.stringify(r)),c(!0),g(!1),setTimeout(()=>c(!1),2e3)},b=()=>{l(F),localStorage.removeItem(N),c(!1)},x={width:"80px",padding:"4px 8px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"12px",fontFamily:"var(--font-mono)",textAlign:"right"};return i?e.jsxs(v,{title:"Governance Configuration",children:[e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Risk Tier Thresholds (score 0-100)"}),["low","medium","high","critical"].map(p=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)",textTransform:"capitalize"},children:p}),e.jsx("input",{type:"number",min:0,max:100,value:r.riskThresholds[p],style:x,onChange:f=>l(y=>({...y,riskThresholds:{...y.riskThresholds,[p]:Number(f.target.value)}}))})]},p))]}),e.jsxs("div",{style:{marginBottom:"12px",paddingTop:"8px",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Warrant TTL (seconds)"}),[{label:"T0 (Minimal)",key:"warrantTtlT0"},{label:"T1 (Moderate)",key:"warrantTtlT1"},{label:"T2 (High)",key:"warrantTtlT2"}].map(({label:p,key:f})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:p}),e.jsx("input",{type:"number",min:60,max:86400,value:r[f],style:x,onChange:y=>l(h=>({...h,[f]:Number(y.target.value)}))})]},f))]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Auto-approve low-risk (T0)"}),e.jsx("button",{onClick:()=>l(p=>({...p,autoApproveLowRisk:!p.autoApproveLowRisk})),style:{padding:"4px 12px",borderRadius:"0",fontSize:"11px",fontWeight:600,cursor:"pointer",border:`1px solid ${r.autoApproveLowRisk?"rgba(74, 222, 128, 0.3)":"rgba(248, 113, 113, 0.3)"}`,background:r.autoApproveLowRisk?"rgba(74, 222, 128, 0.08)":"rgba(248, 113, 113, 0.08)",color:r.autoApproveLowRisk?"#10b981":"#ef4444"},children:r.autoApproveLowRisk?"ON":"OFF"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Audit Retention (years)"}),e.jsx("input",{type:"number",min:1,max:99,value:r.auditRetentionYears,style:x,onChange:p=>l(f=>({...f,auditRetentionYears:Number(p.target.value)}))})]}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)",display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:u,style:{flex:1,padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(74, 222, 128, 0.3)",background:"rgba(74, 222, 128, 0.08)",color:"#10b981",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Save Settings"}),e.jsx("button",{onClick:b,style:{padding:"8px 16px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Reset"}),e.jsx("button",{onClick:()=>g(!1),style:{padding:"8px 16px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"})]}),n&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(74, 222, 128, 0.06)",border:"1px solid rgba(74, 222, 128, 0.15)",fontSize:"11px",color:"#10b981",textAlign:"center"},children:"✓ Settings saved"})]}):e.jsxs(v,{title:"Governance Configuration",children:[e.jsx(d,{label:"Risk Tiers",value:"T0, T1, T2"}),e.jsx(d,{label:"T0 Threshold",value:`≤ ${r.riskThresholds.low}`,mono:!0}),e.jsx(d,{label:"T1 Threshold",value:`≤ ${r.riskThresholds.medium}`,mono:!0}),e.jsx(d,{label:"T2 Threshold",value:`≤ ${r.riskThresholds.high}`,mono:!0}),e.jsx(d,{label:"T0 Policy",value:r.autoApproveLowRisk?"Auto-approve":"Manual",valueColor:r.autoApproveLowRisk?"#10b981":"#f59e0b"}),e.jsx(d,{label:"T1 Policy",value:"Single operator approval",valueColor:"#f59e0b"}),e.jsx(d,{label:"T2 Policy",value:"Multi-party approval",valueColor:"#ef4444"}),e.jsx(d,{label:"Warrant TTL (T0)",value:`${r.warrantTtlT0}s`,mono:!0}),e.jsx(d,{label:"Warrant TTL (T1)",value:`${r.warrantTtlT1}s`,mono:!0}),e.jsx(d,{label:"Warrant TTL (T2)",value:`${r.warrantTtlT2}s`,mono:!0}),e.jsx(d,{label:"Audit Retention",value:`${r.auditRetentionYears} years`}),e.jsx("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:()=>g(!0),style:{padding:"6px 16px",borderRadius:"0",border:"1px solid rgba(251, 191, 36, 0.3)",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Edit Configuration"})})]})}function Re(){var j,k,o;const[r,l]=s.useState(null),[n,c]=s.useState(!1),[i,g]=s.useState(null),u=s.useCallback(async()=>{try{const a=await ve();l(a)}catch{}},[]);s.useEffect(()=>{u();const a=setInterval(u,1e4);return()=>clearInterval(a)},[u]);const b=async()=>{c(!0);try{r!=null&&r.running?(await Se(),g("Stopped")):(await je(),g("Started")),await u()}catch{g("Error")}c(!1),setTimeout(()=>g(null),2e3)},x=async()=>{c(!0),g("Seeding...");try{const a=await ke();g(`Seeded ${a.actions} actions`),await u()}catch{g("Seed failed")}c(!1),setTimeout(()=>g(null),3e3)},p=async()=>{if(confirm("Reset all simulation data? This will clear generated activity, alerts, and evaluations.")){c(!0),g("Resetting...");try{await Te(),g("Data cleared"),await u()}catch{g("Reset failed")}c(!1),setTimeout(()=>g(null),3e3)}},f=a=>a?new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—",y=a=>{if(!a)return"—";const C=new Date(a).getTime(),w=Date.now(),S=Math.floor((w-C)/1e3);if(S<60)return`${S}s`;if(S<3600)return`${Math.floor(S/60)}m ${S%60}s`;const R=Math.floor(S/3600),L=Math.floor(S%3600/60);return`${R}h ${L}m`},h=(r==null?void 0:r.running)??!1;return e.jsxs(v,{title:"Simulation Engine",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:h?"#10b981":"#6b7280",boxShadow:h?"0 0 6px rgba(74, 222, 128, 0.5)":"none"}}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Status"})]}),e.jsx("button",{onClick:b,disabled:n,style:{padding:"4px 12px",borderRadius:"0",border:`1px solid ${h?"rgba(248, 113, 113, 0.3)":"rgba(74, 222, 128, 0.3)"}`,background:h?"rgba(248, 113, 113, 0.08)":"rgba(74, 222, 128, 0.08)",color:h?"#ef4444":"#10b981",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:h?"Stop":"Start"})]}),e.jsx(d,{label:"Actions Generated",value:((j=r==null?void 0:r.actionsGenerated)==null?void 0:j.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Alerts Generated",value:((k=r==null?void 0:r.alertsGenerated)==null?void 0:k.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Ticks",value:((o=r==null?void 0:r.tickCount)==null?void 0:o.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Running Since",value:h?y((r==null?void 0:r.startedAt)??null):"Stopped",valueColor:h?"#10b981":"#6b7280"}),e.jsx(d,{label:"Last Tick",value:f((r==null?void 0:r.lastTickAt)??null),mono:!0}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)",display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:x,disabled:n,style:{flex:1,padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(99, 102, 241, 0.2)",background:"rgba(99, 102, 241, 0.08)",color:"#818cf8",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:"Seed 24h Data"}),e.jsx("button",{onClick:p,disabled:n,style:{flex:1,padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(248, 113, 113, 0.2)",background:"rgba(248, 113, 113, 0.08)",color:"#ef4444",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:"Reset Data"})]}),i&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(99, 102, 241, 0.06)",border:"1px solid rgba(99, 102, 241, 0.15)",fontSize:"11px",color:"#a5b4fc",textAlign:"center"},children:i})]})}const H={T0:"direct",T1:"direct",T2:"passback",T3:"passback",default:"direct"};function Ae(){const[r,l]=s.useState(H),[n,c]=s.useState(!1),[i,g]=s.useState(!0),[u,b]=s.useState(null);s.useEffect(()=>{x()},[]);const x=async()=>{try{g(!0);const o=await fetch("/api/v1/settings/execution-modes",{credentials:"include",headers:{Authorization:`Bearer ${localStorage.getItem("vienna_access_token")}`}});if(o.ok){const a=await o.json();l(a.data)}else throw new Error("Failed to fetch execution modes")}catch(o){b(o instanceof Error?o.message:"Unknown error")}finally{g(!1)}},p=async()=>{try{g(!0),b(null);const o=await fetch("/api/v1/settings/execution-modes",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("vienna_access_token")}`},credentials:"include",body:JSON.stringify(r)});if(o.ok){const a=await o.json();l(a.data),c(!0),setTimeout(()=>c(!1),2e3)}else{const a=await o.json();throw new Error(a.error||"Failed to save execution modes")}}catch(o){b(o instanceof Error?o.message:"Save failed")}finally{g(!1)}},f=o=>{l(a=>({...a,[o]:a[o]==="direct"?"passback":"direct"}))},y=o=>{switch(o){case"all-direct":l({T0:"direct",T1:"direct",T2:"direct",T3:"direct",default:"direct"});break;case"all-passback":l({T0:"passback",T1:"passback",T2:"passback",T3:"passback",default:"passback"});break;case"recommended":l(H);break}},h={T0:"Auto-approved, lowest risk",T1:"Low risk, single operator",T2:"Medium risk, multi-party",T3:"Critical, requires justification",default:"Fallback for unclassified actions"},j=o=>o==="direct"?"#f59e0b":"#10b981",k=o=>o==="direct"?"⚡":"🔄";return i&&!r?e.jsx(v,{title:"Execution Mode Preferences",children:e.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-tertiary)"},children:"Loading execution modes..."})}):e.jsxs(v,{title:"Execution Mode Preferences",children:[u&&e.jsx("div",{style:{marginBottom:"12px",padding:"8px 12px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"0",fontSize:"11px",color:"#ef4444"},children:u}),e.jsxs("div",{style:{marginBottom:"16px",paddingBottom:"12px",borderBottom:"1px solid var(--border-subtle)",display:"flex",gap:"8px",flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>y("all-direct"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(251, 191, 36, 0.3)",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"All Vienna Direct"}),e.jsx("button",{onClick:()=>y("all-passback"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.1)",color:"#f59e0b",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"All Agent Passback"}),e.jsx("button",{onClick:()=>y("recommended"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"Recommended"})]}),e.jsx("div",{style:{marginBottom:"16px"},children:["T0","T1","T2","T3","default"].map(o=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 0",borderBottom:o!=="default"?"1px solid var(--border-subtle)":"none"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-secondary)"},children:o==="default"?"Default":o}),e.jsx("div",{style:{fontSize:"10px",color:"var(--text-tertiary)"},children:h[o]})]}),e.jsxs("button",{onClick:()=>f(o),disabled:i,style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderRadius:"0",border:`1px solid ${j(r[o])}30`,background:`${j(r[o])}10`,color:j(r[o]),fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1,transition:"all 150ms"},children:[e.jsx("span",{children:k(r[o])}),e.jsx("span",{children:r[o]==="direct"?"Vienna Direct":"Agent Passback"})]})]},o))}),e.jsx("div",{style:{marginTop:"16px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:p,disabled:i,style:{width:"100%",padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",fontSize:"12px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:i?"Saving...":"Save Execution Mode Preferences"})}),n&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(16, 185, 129, 0.06)",border:"1px solid rgba(16, 185, 129, 0.15)",fontSize:"11px",color:"#10b981",textAlign:"center"},children:"✓ Execution mode preferences saved"})]})}function v({title:r,children:l}){return e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"0",padding:"20px"},children:[e.jsx("h3",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"14px"},children:r}),l]})}function d({label:r,value:l,valueColor:n,mono:c}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:r}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:n||"var(--text-secondary)",fontFamily:c?"var(--font-mono)":"inherit"},children:l})]})}function W({label:r,href:l}){return e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"8px 12px",borderRadius:"0",fontSize:"12px",color:"var(--text-secondary)",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",textDecoration:"none",marginBottom:"4px",transition:"all 150ms"},onMouseEnter:n=>{n.currentTarget.style.borderColor="rgba(212, 165, 32, 0.2)"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border-subtle)"},children:r})}function ze(){var y,h,j,k,o;const[r,l]=s.useState(!1),[n,c]=s.useState(null),[i,g]=s.useState(null);s.useEffect(()=>{m.get("/api/v1/billing").then(a=>g(a)).catch(()=>{})},[]);const u=async()=>{l(!0),c(null);try{const a=await m.post("/api/v1/billing/portal",{});window.open(a.url,"_blank")}catch(a){c((a==null?void 0:a.message)||"Failed to open billing portal. Ensure you have an active subscription.")}finally{l(!1)}},b=((y=i==null?void 0:i.plan)==null?void 0:y.name)||"Professional",x=((h=i==null?void 0:i.subscription)==null?void 0:h.status)||((j=i==null?void 0:i.plan)==null?void 0:j.status)||"active",p=x==="active"?"#10b981":x==="trialing"?"#f59e0b":"#ef4444",f=(k=i==null?void 0:i.subscription)!=null&&k.current_period_end?new Date(i.subscription.current_period_end).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—";return e.jsxs(v,{title:"Billing & Subscription",children:[e.jsx(d,{label:"Plan",value:b,valueColor:"#f59e0b"}),e.jsx(d,{label:"Status",value:x.charAt(0).toUpperCase()+x.slice(1),valueColor:p}),e.jsx(d,{label:"Next billing",value:f}),((o=i==null?void 0:i.subscription)==null?void 0:o.cancel_at_period_end)&&e.jsx(d,{label:"Note",value:"Cancels at period end",valueColor:"#ef4444"}),n&&e.jsx("div",{style:{marginTop:"12px",padding:"8px 12px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"0",fontSize:"11px",color:"#ef4444"},children:n}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("button",{onClick:u,disabled:r,style:{width:"100%",padding:"8px 16px",borderRadius:"0",border:"1px solid #f59e0b",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:r?"not-allowed":"pointer",fontFamily:"inherit",opacity:r?.6:1},children:r?"Opening...":"Manage Billing"}),e.jsx("p",{style:{marginTop:"8px",fontSize:"10px",color:"var(--text-tertiary)",textAlign:"center",margin:"8px 0 0 0"},children:"Update payment method, view invoices, or cancel subscription"})]})]})}const J="vienna_notification_prefs",M={emailApprovals:!0,emailAlerts:!0,emailWeeklyDigest:!1,slackApprovals:!1,slackAlerts:!1,slackWeeklyDigest:!1};function _e(){const[r,l]=s.useState(()=>{try{const x=localStorage.getItem(J);return x?{...M,...JSON.parse(x)}:M}catch{return M}}),[n,c]=s.useState(!1),i=x=>{const p={...r,[x]:!r[x]};l(p),localStorage.setItem(J,JSON.stringify(p)),m.put("/settings/notifications",p).catch(()=>{}),c(!0),setTimeout(()=>c(!1),1500)},g=x=>({width:"36px",height:"20px",borderRadius:"0",cursor:"pointer",background:x?"rgba(16,185,129,0.3)":"rgba(255,255,255,0.08)",border:`1px solid ${x?"rgba(16,185,129,0.4)":"var(--border-subtle)"}`,position:"relative",transition:"all 150ms",flexShrink:0,display:"inline-block"}),u=x=>({width:"14px",height:"14px",borderRadius:"50%",position:"absolute",top:"2px",left:x?"18px":"2px",background:x?"#10b981":"var(--text-tertiary)",transition:"all 150ms"}),b=({label:x,pref:p})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:x}),e.jsx("div",{style:g(r[p]),onClick:()=>i(p),children:e.jsx("div",{style:u(r[p])})})]});return e.jsxs(v,{title:`Notification Preferences ${n?"✓":""}`,children:[e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"📧 Email"}),e.jsx(b,{label:"Approval requests",pref:"emailApprovals"}),e.jsx(b,{label:"System alerts",pref:"emailAlerts"}),e.jsx(b,{label:"Weekly digest",pref:"emailWeeklyDigest"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"12px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"💬 Slack"}),e.jsx(b,{label:"Approval requests",pref:"slackApprovals"}),e.jsx(b,{label:"System alerts",pref:"slackAlerts"}),e.jsx(b,{label:"Weekly digest",pref:"slackWeeklyDigest"})]})]})}function Ee(){const[r,l]=s.useState([]),[n,c]=s.useState(!0);return s.useEffect(()=>{m.get("/settings/audit-log").then(i=>l(i)).catch(()=>{l([{id:"1",action:"notification_prefs_updated",actor:"current_user",timestamp:new Date().toISOString(),details:"Notification preferences modified"}])}).finally(()=>c(!1))},[]),e.jsx(v,{title:"Settings Audit Log",children:n?e.jsx("div",{style:{padding:"16px",textAlign:"center"},children:e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Loading audit log..."})}):r.length===0?e.jsx("div",{style:{padding:"16px",textAlign:"center"},children:e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"No settings changes recorded yet"})}):e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto"},children:r.map(i=>e.jsxs("div",{style:{padding:"8px 0",borderBottom:"1px solid rgba(255,255,255,0.03)",fontSize:"11px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:i.action}),e.jsx("span",{style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",fontSize:"10px"},children:new Date(i.timestamp).toLocaleString()})]}),e.jsxs("div",{style:{color:"var(--text-tertiary)",marginTop:"2px"},children:[i.actor," — ",i.details]})]},i.id))})})}export{Ie as SettingsPage}; -//# sourceMappingURL=SettingsPage-C6VhOSia.js.map + */const ue=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],be=B("user-minus",ue);/** + * @license lucide-react v1.7.0 - ISC + * + * This source code is licensed under the ISC license. + * See the LICENSE file in the root directory of this source tree. + */const fe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],he=B("user-plus",fe);function ye(){const[r,l]=s.useState("roles"),[n,c]=s.useState([]),[i,g]=s.useState([]),[u,b]=s.useState([]),[x,p]=s.useState([]),[f,y]=s.useState([]),[h,j]=s.useState(!1),[k,o]=s.useState(!1),[a,C]=s.useState(!1),[w,S]=s.useState(""),[R,L]=s.useState(""),[P,$]=s.useState(""),[U,G]=s.useState([]),[A,V]=s.useState(""),[z,Y]=s.useState("");s.useEffect(()=>{I(),q(),K()},[]),s.useEffect(()=>{r==="assignments"&&D(),r==="audit"&&X()},[r]);const I=async()=>{j(!0);try{const t=await m.get("/roles");c(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load roles:",t)}finally{j(!1)}},D=async()=>{try{const t=await m.get("/roles/assignments");g(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load assignments:",t)}},q=async()=>{try{const t=await m.get("/roles/users");b(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load users:",t)}},K=async()=>{try{const t=await m.get("/roles/permissions");p(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load permissions:",t)}},X=async()=>{try{const t=await m.get("/roles/audit?limit=50");y(Array.isArray(t)?t:[])}catch(t){console.error("Failed to load audit log:",t)}},Q=async()=>{if(!(!w.trim()||!R.trim()))try{await m.post("/roles",{role_name:w,display_name:R,description:P,permissions:U}),o(!1),S(""),L(""),$(""),G([]),I()}catch(t){console.error("Failed to create role:",t)}},Z=async(t,T)=>{if(confirm(`Delete role "${T}"? This cannot be undone.`))try{await m.delete(`/roles/${t}`),I()}catch(_){console.error("Failed to delete role:",_)}},ee=async()=>{if(!(!A||!z))try{await m.post("/roles/assign",{user_id:A,role_id:z}),C(!1),V(""),Y(""),D()}catch(t){console.error("Failed to assign role:",t)}},te=async(t,T,_)=>{if(confirm(`Revoke role "${_}" from ${T}?`))try{const E=i.find(oe=>oe.id===t);if(!E)return;await m.post("/roles/revoke",{user_id:E.user_id,role_id:E.role_id}),D()}catch(E){console.error("Failed to revoke role:",E)}},re=t=>{G(T=>T.includes(t)?T.filter(_=>_!==t):[...T,t])};return e.jsxs("div",{style:{fontFamily:"JetBrains Mono, monospace"},children:[e.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px",borderBottom:"1px solid rgba(255,255,255,0.1)"},children:["roles","assignments","audit"].map(t=>e.jsxs("button",{onClick:()=>l(t),style:{padding:"8px 16px",background:"none",border:"none",borderBottom:r===t?"2px solid #fbbf24":"2px solid transparent",color:r===t?"#fbbf24":"#94a3b8",fontSize:"12px",fontWeight:600,cursor:"pointer",textTransform:"uppercase",fontFamily:"inherit"},children:[t==="roles"&&e.jsx(N,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t==="assignments"&&e.jsx(ie,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t==="audit"&&e.jsx(pe,{size:14,style:{display:"inline",verticalAlign:"middle",marginRight:"6px"}}),t]},t))}),r==="roles"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8"},children:[n.length," roles (",n.filter(t=>t.is_system_role).length," system, ",n.filter(t=>!t.is_system_role).length," custom)"]}),e.jsxs("button",{onClick:()=>o(!k),style:{padding:"6px 12px",background:"#fbbf24",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ge,{size:14}),"New Role"]})]}),k&&e.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#fbbf24",marginBottom:"12px"},children:"CREATE CUSTOM ROLE"}),e.jsxs("div",{style:{display:"grid",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"ROLE NAME (lowercase, no spaces)"}),e.jsx("input",{type:"text",value:w,onChange:t=>S(t.target.value.toLowerCase().replace(/\s/g,"_")),placeholder:"e.g., compliance_reviewer",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"DISPLAY NAME"}),e.jsx("input",{type:"text",value:R,onChange:t=>L(t.target.value),placeholder:"e.g., Compliance Reviewer",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"DESCRIPTION"}),e.jsx("input",{type:"text",value:P,onChange:t=>$(t.target.value),placeholder:"e.g., Can review compliance reports and approve low-risk proposals",style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"8px"},children:"PERMISSIONS"}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:"8px"},children:x.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",padding:"8px",border:"1px solid rgba(255,255,255,0.05)"},children:[e.jsx("div",{style:{fontSize:"9px",color:"#fbbf24",fontWeight:700,marginBottom:"6px"},children:t.group.toUpperCase()}),t.permissions.map(T=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"10px",color:"#94a3b8",marginBottom:"4px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:U.includes(T),onChange:()=>re(T),style:{cursor:"pointer"}}),T.replace(`${t.group}.`,"")]},T))]},t.group))})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>o(!1),style:{padding:"8px 16px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{onClick:Q,disabled:!w||!R,style:{padding:"8px 16px",background:w&&R?"#fbbf24":"rgba(251, 191, 36, 0.3)",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:w&&R?"pointer":"not-allowed",fontFamily:"inherit"},children:"Create Role"})]})]})]}),e.jsx("div",{style:{display:"grid",gap:"8px"},children:n.map(t=>e.jsxs("div",{style:{background:t.is_system_role?"rgba(251, 191, 36, 0.05)":"rgba(255,255,255,0.02)",border:t.is_system_role?"1px solid rgba(251, 191, 36, 0.2)":"1px solid rgba(255,255,255,0.08)",padding:"12px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"4px"},children:[e.jsx(N,{size:14,color:t.is_system_role?"#fbbf24":"#94a3b8"}),e.jsx("span",{style:{fontSize:"13px",fontWeight:700,color:"#fff"},children:t.display_name}),t.is_system_role&&e.jsx("span",{style:{fontSize:"9px",color:"#fbbf24",background:"rgba(251, 191, 36, 0.1)",padding:"2px 6px",fontWeight:700},children:"SYSTEM"}),t.assignment_count!==void 0&&e.jsxs("span",{style:{fontSize:"10px",color:"#94a3b8"},children:[t.assignment_count," user",t.assignment_count!==1?"s":""]})]}),e.jsx("div",{style:{fontSize:"11px",color:"#94a3b8",marginBottom:"6px"},children:t.description}),e.jsxs("div",{style:{fontSize:"9px",color:"#64748b"},children:[t.permissions.length," permission",t.permissions.length!==1?"s":"",": ",t.permissions.slice(0,3).join(", "),t.permissions.length>3&&` +${t.permissions.length-3} more`]})]}),!t.is_system_role&&e.jsx("div",{style:{display:"flex",gap:"8px"},children:e.jsx("button",{onClick:()=>Z(t.id,t.display_name),style:{padding:"6px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",cursor:"pointer",display:"flex",alignItems:"center"},title:"Delete role",children:e.jsx(de,{size:14})})})]},t.id))})]}),r==="assignments"&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"16px"},children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8"},children:[i.length," active assignment",i.length!==1?"s":""]}),e.jsxs("button",{onClick:()=>C(!a),style:{padding:"6px 12px",background:"#fbbf24",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(he,{size:14}),"Assign Role"]})]}),a&&e.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.05)",border:"1px solid rgba(251, 191, 36, 0.2)",padding:"16px",marginBottom:"16px"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:700,color:"#fbbf24",marginBottom:"12px"},children:"ASSIGN ROLE TO USER"}),e.jsxs("div",{style:{display:"grid",gap:"12px"},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"USER"}),e.jsxs("select",{value:A,onChange:t=>V(t.target.value),style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"},children:[e.jsx("option",{value:"",children:"Select user..."}),u.map(t=>e.jsxs("option",{value:t.id,children:[t.email," (",t.name,")"]},t.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",fontSize:"10px",color:"#94a3b8",marginBottom:"4px"},children:"ROLE"}),e.jsxs("select",{value:z,onChange:t=>Y(t.target.value),style:{width:"100%",padding:"8px",background:"#0A0E14",border:"1px solid rgba(251, 191, 36, 0.2)",color:"#fff",fontSize:"12px",fontFamily:"inherit"},children:[e.jsx("option",{value:"",children:"Select role..."}),n.map(t=>e.jsx("option",{value:t.id,children:t.display_name},t.id))]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>C(!1),style:{padding:"8px 16px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.1)",color:"#94a3b8",fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"}),e.jsx("button",{onClick:ee,disabled:!A||!z,style:{padding:"8px 16px",background:A&&z?"#fbbf24":"rgba(251, 191, 36, 0.3)",border:"none",color:"#0A0E14",fontSize:"11px",fontWeight:700,cursor:A&&z?"pointer":"not-allowed",fontFamily:"inherit"},children:"Assign"})]})]})]}),e.jsx("div",{style:{display:"grid",gap:"8px"},children:i.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.08)",padding:"12px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontSize:"13px",fontWeight:600,color:"#fff",marginBottom:"4px"},children:[t.user_email," (",t.user_name,")"]}),e.jsxs("div",{style:{fontSize:"11px",color:"#fbbf24"},children:[e.jsx(N,{size:12,style:{display:"inline",verticalAlign:"middle",marginRight:"4px"}}),t.role_display_name]}),e.jsxs("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"4px"},children:["Assigned ",new Date(t.assigned_at).toLocaleDateString()," by ",t.assigned_by]})]}),e.jsxs("button",{onClick:()=>te(t.id,t.user_email,t.role_display_name),style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",color:"#ef4444",fontSize:"10px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(be,{size:12}),"Revoke"]})]},t.id))})]}),r==="audit"&&e.jsxs("div",{children:[e.jsxs("div",{style:{fontSize:"13px",color:"#94a3b8",marginBottom:"16px"},children:["Last ",f.length," RBAC changes"]}),e.jsx("div",{style:{display:"grid",gap:"6px"},children:f.map(t=>e.jsxs("div",{style:{background:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.05)",padding:"10px",fontSize:"11px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"4px"},children:[e.jsx("span",{style:{color:"#fbbf24",fontWeight:600},children:t.action.toUpperCase()}),e.jsx("span",{style:{color:"#64748b",fontSize:"9px"},children:new Date(t.timestamp).toLocaleString()})]}),e.jsxs("div",{style:{color:"#94a3b8"},children:[t.role_name&&e.jsxs("span",{children:["Role: ",e.jsx("span",{style:{color:"#fff"},children:t.role_name})]}),t.user_email&&e.jsxs("span",{children:[" • User: ",e.jsx("span",{style:{color:"#fff"},children:t.user_email})]})," • "," By: ",e.jsx("span",{style:{color:"#fff"},children:t.performed_by})]}),Object.keys(t.details||{}).length>0&&e.jsx("div",{style:{fontSize:"9px",color:"#64748b",marginTop:"4px",fontFamily:"monospace"},children:JSON.stringify(t.details)})]},t.id))})]})]})}const me=[{value:"*",label:"All events"},{value:"warrant_issued",label:"Warrant issued"},{value:"proposal_pending",label:"Proposal pending approval"},{value:"proposal_denied",label:"Proposal denied"},{value:"execution_completed",label:"Execution completed"},{value:"execution_failed",label:"Execution failed"},{value:"warrant_revoked",label:"Warrant revoked"},{value:"warrant_expired",label:"Warrant expired"}];function ve(){const[r,l]=s.useState([]),[n,c]=s.useState(!0),[i,g]=s.useState(!1),[u,b]=s.useState(""),[x,p]=s.useState(["*"]),[f,y]=s.useState(!1),h=()=>{fetch("/api/v1/webhooks",{credentials:"include"}).then(o=>o.json()).then(o=>l(o.data||[])).catch(()=>{}).finally(()=>c(!1))};s.useEffect(()=>{h()},[]);const j=async()=>{if(u.trim()){y(!0);try{await fetch("/api/v1/webhooks",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({url:u,events:x})}),b(""),g(!1),h()}catch{}finally{y(!1)}}},k=async o=>{confirm("Delete this webhook?")&&(await fetch(`/api/v1/webhooks/${o}`,{method:"DELETE",credentials:"include"}),h())};return e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"15px",fontWeight:700,color:"var(--text-primary)"},children:"Webhooks"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"2px"},children:"Receive HTTP callbacks for pipeline events"})]}),e.jsx("button",{onClick:()=>g(!i),style:{padding:"6px 14px",borderRadius:"6px",fontSize:"12px",fontWeight:600,background:"#f59e0b",border:"none",color:"#fff",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"+ Add Webhook"})]}),i&&e.jsxs("div",{style:{background:"var(--bg-secondary)",border:"1px solid var(--border-default)",borderRadius:"10px",padding:"14px",marginBottom:"16px"},children:[e.jsx("input",{value:u,onChange:o=>b(o.target.value),placeholder:"https://your-server.com/webhooks/vienna",style:{width:"100%",padding:"8px 12px",borderRadius:"6px",fontSize:"13px",background:"var(--bg-primary)",border:"1px solid var(--border-default)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",outline:"none",marginBottom:"8px",boxSizing:"border-box"}}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px",marginBottom:"10px"},children:me.map(o=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"11px",color:"var(--text-secondary)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.includes(o.value),onChange:a=>{if(o.value==="*"){p(a.target.checked?["*"]:[]);return}p(C=>{const w=C.filter(S=>S!=="*");return a.target.checked?[...w,o.value]:w.filter(S=>S!==o.value)})},style:{accentColor:"#f59e0b"}}),o.label]},o.value))}),e.jsx("button",{onClick:j,disabled:f||!u.trim(),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"12px",fontWeight:600,background:f?"var(--bg-tertiary)":"#f59e0b",border:"none",color:"#fff",cursor:f?"default":"pointer",fontFamily:"var(--font-sans)"},children:f?"Creating...":"Create Webhook"})]}),e.jsx("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"10px",overflow:"hidden"},children:n?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"Loading..."}):r.length===0?e.jsx("div",{style:{padding:"24px",textAlign:"center",color:"var(--text-tertiary)",fontSize:"13px"},children:"No webhooks configured. Add one to receive pipeline event notifications."}):r.map((o,a)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px 14px",borderBottom:ak(o.id),style:{padding:"4px 10px",borderRadius:"4px",fontSize:"10px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",color:"#ef4444",cursor:"pointer",fontFamily:"var(--font-sans)"},children:"Delete"})]},o.id))})]})}async function je(){return m.get("/simulation/status")}async function Se(){await m.post("/simulation/start",{})}async function ke(){await m.post("/simulation/stop",{})}async function Te(){return m.post("/simulation/seed",{})}async function we(){await m.post("/simulation/reset",{})}function Ie(){const{user:r,logout:l}=se(),{isMobile:n}=ne();return e.jsx(le,{title:"Settings",description:"Operator configuration and system information",children:e.jsxs("div",{style:{display:"grid",gridTemplateColumns:n?"1fr":"1fr 1fr",gap:"16px"},children:[e.jsxs(v,{title:"Session",children:[e.jsx(d,{label:"Operator",value:(r==null?void 0:r.email)||"User"}),e.jsx(d,{label:"Status",value:"Active",valueColor:"#10b981"}),e.jsx(d,{label:"Environment",value:"Production"}),e.jsx(d,{label:"Tenant",value:"system"}),e.jsx("div",{style:{marginTop:"16px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:()=>{confirm("Logout?")&&l()},style:{padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(248, 113, 113, 0.2)",background:"rgba(248, 113, 113, 0.08)",color:"#ef4444",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Logout"})})]}),e.jsx(_e,{}),e.jsx(Ce,{}),e.jsx(Ae,{}),e.jsxs(v,{title:"System",children:[e.jsx(d,{label:"Vienna OS",value:"v0.9.0",mono:!0}),e.jsx(d,{label:"Runtime",value:"Node 22 · Vercel Serverless"}),e.jsx(d,{label:"Database",value:"Neon Postgres · regulator schema"}),e.jsx(d,{label:"Region",value:"US East (us-east-1)"}),e.jsx(d,{label:"Streaming",value:"SSE · /api/v1/stream/events",mono:!0})]}),e.jsx(Re,{}),e.jsx(ze,{}),e.jsxs(v,{title:"API & Integrations",children:[e.jsx(d,{label:"Intent Gateway",value:"Enabled",valueColor:"#10b981"}),e.jsx(d,{label:"Agent Auth",value:"Source-based"}),e.jsx(d,{label:"Rate Limit",value:"60 req/min per IP"}),e.jsx(d,{label:"CORS Origins",value:"regulator.ai, localhost"}),e.jsx(d,{label:"SSE Streaming",value:"Enabled",valueColor:"#10b981"})]}),e.jsx(v,{title:"Webhook Notifications",children:e.jsx(ve,{})}),e.jsx(Ee,{}),e.jsx(v,{title:"Team & Access Control",children:e.jsx(ye,{})}),e.jsx(We,{}),e.jsxs(v,{title:"Resources",children:[e.jsx(W,{label:"📖 Documentation",href:"https://regulator.ai/docs"}),e.jsx(W,{label:"🔐 Security",href:"https://regulator.ai/security"}),e.jsx(W,{label:"📋 Changelog",href:"https://regulator.ai/changelog"}),e.jsx(W,{label:"💻 GitHub",href:"https://github.com/risk-ai/regulator.ai"}),e.jsx(W,{label:"📧 Support",href:"mailto:admin@ai.ventures"})]}),e.jsx(v,{title:"About",children:e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",lineHeight:1.7},children:[e.jsxs("p",{children:[e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"Vienna OS"})," is the governance control plane for autonomous AI agents."]}),e.jsxs("p",{style:{marginTop:"8px"},children:["Built by ",e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"Max Anderson"})," (Cornell Law) at ",e.jsx("strong",{style:{color:"var(--text-secondary)"},children:"ai.ventures"}),"."]}),e.jsx("p",{style:{marginTop:"8px",fontFamily:"var(--font-mono)",fontSize:"11px",color:"var(--text-muted)"},children:"© 2026 Technetwork 2 LLC dba ai.ventures"})]})})]})})}function Ce(){const{isDemoMode:r,hasRealAgents:l,agentCount:n,forcedDemo:c,setForcedDemo:i}=ae();return e.jsxs(v,{title:"Demo Mode",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"13px",color:"var(--text-primary)",fontWeight:500},children:"Show sample data"}),e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",marginTop:"2px"},children:"Display demo governance data to explore Vienna OS features"})]}),e.jsx("div",{onClick:()=>i(!c),style:{width:"36px",height:"20px",borderRadius:"0",cursor:"pointer",background:c?"rgba(245,158,11,0.3)":"rgba(255,255,255,0.08)",border:`1px solid ${c?"rgba(245,158,11,0.4)":"var(--border-subtle)"}`,position:"relative",transition:"all 150ms"},children:e.jsx("div",{style:{width:"14px",height:"14px",borderRadius:"50%",position:"absolute",top:"2px",left:c?"18px":"2px",background:c?"#f59e0b":"var(--text-tertiary)",transition:"all 150ms"}})})]}),e.jsxs("div",{style:{padding:"8px 12px",borderRadius:"0",fontSize:"11px",background:r?"rgba(245,158,11,0.06)":"rgba(16,185,129,0.06)",color:r?"#f59e0b":"#10b981",display:"flex",alignItems:"center",gap:"6px"},children:[r?"🧪":"✅",r?`Demo mode active${l?" (forced)":" — no agents connected"}`:`Live mode — ${n} agent${n!==1?"s":""} connected`]})]})}const M="vienna_governance_config",F={riskThresholds:{low:25,medium:50,high:75,critical:90},warrantTtlT0:3600,warrantTtlT1:900,warrantTtlT2:300,autoApproveLowRisk:!0,auditRetentionYears:7};function Re(){const[r,l]=s.useState(()=>{try{const p=localStorage.getItem(M);return p?{...F,...JSON.parse(p)}:F}catch{return F}}),[n,c]=s.useState(!1),[i,g]=s.useState(!1),u=()=>{localStorage.setItem(M,JSON.stringify(r)),c(!0),g(!1),setTimeout(()=>c(!1),2e3)},b=()=>{l(F),localStorage.removeItem(M),c(!1)},x={width:"80px",padding:"4px 8px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:"12px",fontFamily:"var(--font-mono)",textAlign:"right"};return i?e.jsxs(v,{title:"Governance Configuration",children:[e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Risk Tier Thresholds (score 0-100)"}),["low","medium","high","critical"].map(p=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)",textTransform:"capitalize"},children:p}),e.jsx("input",{type:"number",min:0,max:100,value:r.riskThresholds[p],style:x,onChange:f=>l(y=>({...y,riskThresholds:{...y.riskThresholds,[p]:Number(f.target.value)}}))})]},p))]}),e.jsxs("div",{style:{marginBottom:"12px",paddingTop:"8px",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--text-tertiary)",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"Warrant TTL (seconds)"}),[{label:"T0 (Minimal)",key:"warrantTtlT0"},{label:"T1 (Moderate)",key:"warrantTtlT1"},{label:"T2 (High)",key:"warrantTtlT2"}].map(({label:p,key:f})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:p}),e.jsx("input",{type:"number",min:60,max:86400,value:r[f],style:x,onChange:y=>l(h=>({...h,[f]:Number(y.target.value)}))})]},f))]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Auto-approve low-risk (T0)"}),e.jsx("button",{onClick:()=>l(p=>({...p,autoApproveLowRisk:!p.autoApproveLowRisk})),style:{padding:"4px 12px",borderRadius:"0",fontSize:"11px",fontWeight:600,cursor:"pointer",border:`1px solid ${r.autoApproveLowRisk?"rgba(74, 222, 128, 0.3)":"rgba(248, 113, 113, 0.3)"}`,background:r.autoApproveLowRisk?"rgba(74, 222, 128, 0.08)":"rgba(248, 113, 113, 0.08)",color:r.autoApproveLowRisk?"#10b981":"#ef4444"},children:r.autoApproveLowRisk?"ON":"OFF"})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"4px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Audit Retention (years)"}),e.jsx("input",{type:"number",min:1,max:99,value:r.auditRetentionYears,style:x,onChange:p=>l(f=>({...f,auditRetentionYears:Number(p.target.value)}))})]}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)",display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:u,style:{flex:1,padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(74, 222, 128, 0.3)",background:"rgba(74, 222, 128, 0.08)",color:"#10b981",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Save Settings"}),e.jsx("button",{onClick:b,style:{padding:"8px 16px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Reset"}),e.jsx("button",{onClick:()=>g(!1),style:{padding:"8px 16px",borderRadius:"0",border:"1px solid var(--border-subtle)",background:"transparent",color:"var(--text-tertiary)",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Cancel"})]}),n&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(74, 222, 128, 0.06)",border:"1px solid rgba(74, 222, 128, 0.15)",fontSize:"11px",color:"#10b981",textAlign:"center"},children:"✓ Settings saved"})]}):e.jsxs(v,{title:"Governance Configuration",children:[e.jsx(d,{label:"Risk Tiers",value:"T0, T1, T2"}),e.jsx(d,{label:"T0 Threshold",value:`≤ ${r.riskThresholds.low}`,mono:!0}),e.jsx(d,{label:"T1 Threshold",value:`≤ ${r.riskThresholds.medium}`,mono:!0}),e.jsx(d,{label:"T2 Threshold",value:`≤ ${r.riskThresholds.high}`,mono:!0}),e.jsx(d,{label:"T0 Policy",value:r.autoApproveLowRisk?"Auto-approve":"Manual",valueColor:r.autoApproveLowRisk?"#10b981":"#f59e0b"}),e.jsx(d,{label:"T1 Policy",value:"Single operator approval",valueColor:"#f59e0b"}),e.jsx(d,{label:"T2 Policy",value:"Multi-party approval",valueColor:"#ef4444"}),e.jsx(d,{label:"Warrant TTL (T0)",value:`${r.warrantTtlT0}s`,mono:!0}),e.jsx(d,{label:"Warrant TTL (T1)",value:`${r.warrantTtlT1}s`,mono:!0}),e.jsx(d,{label:"Warrant TTL (T2)",value:`${r.warrantTtlT2}s`,mono:!0}),e.jsx(d,{label:"Audit Retention",value:`${r.auditRetentionYears} years`}),e.jsx("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:()=>g(!0),style:{padding:"6px 16px",borderRadius:"0",border:"1px solid rgba(251, 191, 36, 0.3)",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Edit Configuration"})})]})}function Ae(){var j,k,o;const[r,l]=s.useState(null),[n,c]=s.useState(!1),[i,g]=s.useState(null),u=s.useCallback(async()=>{try{const a=await je();l(a)}catch{}},[]);s.useEffect(()=>{u();const a=setInterval(u,1e4);return()=>clearInterval(a)},[u]);const b=async()=>{c(!0);try{r!=null&&r.running?(await ke(),g("Stopped")):(await Se(),g("Started")),await u()}catch{g("Error")}c(!1),setTimeout(()=>g(null),2e3)},x=async()=>{c(!0),g("Seeding...");try{const a=await Te();g(`Seeded ${a.actions} actions`),await u()}catch{g("Seed failed")}c(!1),setTimeout(()=>g(null),3e3)},p=async()=>{if(confirm("Reset all simulation data? This will clear generated activity, alerts, and evaluations.")){c(!0),g("Resetting...");try{await we(),g("Data cleared"),await u()}catch{g("Reset failed")}c(!1),setTimeout(()=>g(null),3e3)}},f=a=>a?new Date(a).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}):"—",y=a=>{if(!a)return"—";const C=new Date(a).getTime(),w=Date.now(),S=Math.floor((w-C)/1e3);if(S<60)return`${S}s`;if(S<3600)return`${Math.floor(S/60)}m ${S%60}s`;const R=Math.floor(S/3600),L=Math.floor(S%3600/60);return`${R}h ${L}m`},h=(r==null?void 0:r.running)??!1;return e.jsxs(v,{title:"Simulation Engine",children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:h?"#10b981":"#6b7280",boxShadow:h?"0 0 6px rgba(74, 222, 128, 0.5)":"none"}}),e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Status"})]}),e.jsx("button",{onClick:b,disabled:n,style:{padding:"4px 12px",borderRadius:"0",border:`1px solid ${h?"rgba(248, 113, 113, 0.3)":"rgba(74, 222, 128, 0.3)"}`,background:h?"rgba(248, 113, 113, 0.08)":"rgba(74, 222, 128, 0.08)",color:h?"#ef4444":"#10b981",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:h?"Stop":"Start"})]}),e.jsx(d,{label:"Actions Generated",value:((j=r==null?void 0:r.actionsGenerated)==null?void 0:j.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Alerts Generated",value:((k=r==null?void 0:r.alertsGenerated)==null?void 0:k.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Ticks",value:((o=r==null?void 0:r.tickCount)==null?void 0:o.toLocaleString())??"—",mono:!0}),e.jsx(d,{label:"Running Since",value:h?y((r==null?void 0:r.startedAt)??null):"Stopped",valueColor:h?"#10b981":"#6b7280"}),e.jsx(d,{label:"Last Tick",value:f((r==null?void 0:r.lastTickAt)??null),mono:!0}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)",display:"flex",gap:"8px"},children:[e.jsx("button",{onClick:x,disabled:n,style:{flex:1,padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(99, 102, 241, 0.2)",background:"rgba(99, 102, 241, 0.08)",color:"#818cf8",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:"Seed 24h Data"}),e.jsx("button",{onClick:p,disabled:n,style:{flex:1,padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(248, 113, 113, 0.2)",background:"rgba(248, 113, 113, 0.08)",color:"#ef4444",fontSize:"11px",fontWeight:600,cursor:n?"wait":"pointer",fontFamily:"inherit",opacity:n?.6:1},children:"Reset Data"})]}),i&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(99, 102, 241, 0.06)",border:"1px solid rgba(99, 102, 241, 0.15)",fontSize:"11px",color:"#a5b4fc",textAlign:"center"},children:i})]})}const H={T0:"direct",T1:"direct",T2:"passback",T3:"passback",default:"direct"};function ze(){const[r,l]=s.useState(H),[n,c]=s.useState(!1),[i,g]=s.useState(!0),[u,b]=s.useState(null);s.useEffect(()=>{x()},[]);const x=async()=>{try{g(!0);const o=await fetch("/api/v1/settings/execution-modes",{credentials:"include",headers:{Authorization:`Bearer ${localStorage.getItem("vienna_access_token")}`}});if(o.ok){const a=await o.json();l(a.data)}else throw new Error("Failed to fetch execution modes")}catch(o){b(o instanceof Error?o.message:"Unknown error")}finally{g(!1)}},p=async()=>{try{g(!0),b(null);const o=await fetch("/api/v1/settings/execution-modes",{method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${localStorage.getItem("vienna_access_token")}`},credentials:"include",body:JSON.stringify(r)});if(o.ok){const a=await o.json();l(a.data),c(!0),setTimeout(()=>c(!1),2e3)}else{const a=await o.json();throw new Error(a.error||"Failed to save execution modes")}}catch(o){b(o instanceof Error?o.message:"Save failed")}finally{g(!1)}},f=o=>{l(a=>({...a,[o]:a[o]==="direct"?"passback":"direct"}))},y=o=>{switch(o){case"all-direct":l({T0:"direct",T1:"direct",T2:"direct",T3:"direct",default:"direct"});break;case"all-passback":l({T0:"passback",T1:"passback",T2:"passback",T3:"passback",default:"passback"});break;case"recommended":l(H);break}},h={T0:"Auto-approved, lowest risk",T1:"Low risk, single operator",T2:"Medium risk, multi-party",T3:"Critical, requires justification",default:"Fallback for unclassified actions"},j=o=>o==="direct"?"#f59e0b":"#10b981",k=o=>o==="direct"?"⚡":"🔄";return i&&!r?e.jsx(v,{title:"Execution Mode Preferences",children:e.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-tertiary)"},children:"Loading execution modes..."})}):e.jsxs(v,{title:"Execution Mode Preferences",children:[u&&e.jsx("div",{style:{marginBottom:"12px",padding:"8px 12px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"0",fontSize:"11px",color:"#ef4444"},children:u}),e.jsxs("div",{style:{marginBottom:"16px",paddingBottom:"12px",borderBottom:"1px solid var(--border-subtle)",display:"flex",gap:"8px",flexWrap:"wrap"},children:[e.jsx("button",{onClick:()=>y("all-direct"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(251, 191, 36, 0.3)",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"All Vienna Direct"}),e.jsx("button",{onClick:()=>y("all-passback"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.1)",color:"#f59e0b",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"All Agent Passback"}),e.jsx("button",{onClick:()=>y("recommended"),disabled:i,style:{padding:"6px 12px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:"Recommended"})]}),e.jsx("div",{style:{marginBottom:"16px"},children:["T0","T1","T2","T3","default"].map(o=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 0",borderBottom:o!=="default"?"1px solid var(--border-subtle)":"none"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-secondary)"},children:o==="default"?"Default":o}),e.jsx("div",{style:{fontSize:"10px",color:"var(--text-tertiary)"},children:h[o]})]}),e.jsxs("button",{onClick:()=>f(o),disabled:i,style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",borderRadius:"0",border:`1px solid ${j(r[o])}30`,background:`${j(r[o])}10`,color:j(r[o]),fontSize:"11px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1,transition:"all 150ms"},children:[e.jsx("span",{children:k(r[o])}),e.jsx("span",{children:r[o]==="direct"?"Vienna Direct":"Agent Passback"})]})]},o))}),e.jsx("div",{style:{marginTop:"16px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:e.jsx("button",{onClick:p,disabled:i,style:{width:"100%",padding:"8px 16px",borderRadius:"0",border:"1px solid rgba(16, 185, 129, 0.3)",background:"rgba(16, 185, 129, 0.08)",color:"#10b981",fontSize:"12px",fontWeight:600,cursor:i?"not-allowed":"pointer",fontFamily:"inherit",opacity:i?.6:1},children:i?"Saving...":"Save Execution Mode Preferences"})}),n&&e.jsx("div",{style:{marginTop:"8px",padding:"6px 10px",borderRadius:"0",background:"rgba(16, 185, 129, 0.06)",border:"1px solid rgba(16, 185, 129, 0.15)",fontSize:"11px",color:"#10b981",textAlign:"center"},children:"✓ Execution mode preferences saved"})]})}function v({title:r,children:l}){return e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"0",padding:"20px"},children:[e.jsx("h3",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"14px"},children:r}),l]})}function d({label:r,value:l,valueColor:n,mono:c}){return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:r}),e.jsx("span",{style:{fontSize:"12px",fontWeight:600,color:n||"var(--text-secondary)",fontFamily:c?"var(--font-mono)":"inherit"},children:l})]})}function W({label:r,href:l}){return e.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",style:{display:"block",padding:"8px 12px",borderRadius:"0",fontSize:"12px",color:"var(--text-secondary)",background:"var(--bg-secondary)",border:"1px solid var(--border-subtle)",textDecoration:"none",marginBottom:"4px",transition:"all 150ms"},onMouseEnter:n=>{n.currentTarget.style.borderColor="rgba(212, 165, 32, 0.2)"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border-subtle)"},children:r})}function _e(){var y,h,j,k,o;const[r,l]=s.useState(!1),[n,c]=s.useState(null),[i,g]=s.useState(null);s.useEffect(()=>{m.get("/api/v1/billing").then(a=>g(a)).catch(()=>{})},[]);const u=async()=>{l(!0),c(null);try{const a=await m.post("/api/v1/billing/portal",{});window.open(a.url,"_blank")}catch(a){c((a==null?void 0:a.message)||"Failed to open billing portal. Ensure you have an active subscription.")}finally{l(!1)}},b=((y=i==null?void 0:i.plan)==null?void 0:y.name)||"Professional",x=((h=i==null?void 0:i.subscription)==null?void 0:h.status)||((j=i==null?void 0:i.plan)==null?void 0:j.status)||"active",p=x==="active"?"#10b981":x==="trialing"?"#f59e0b":"#ef4444",f=(k=i==null?void 0:i.subscription)!=null&&k.current_period_end?new Date(i.subscription.current_period_end).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"—";return e.jsxs(v,{title:"Billing & Subscription",children:[e.jsx(d,{label:"Plan",value:b,valueColor:"#f59e0b"}),e.jsx(d,{label:"Status",value:x.charAt(0).toUpperCase()+x.slice(1),valueColor:p}),e.jsx(d,{label:"Next billing",value:f}),((o=i==null?void 0:i.subscription)==null?void 0:o.cancel_at_period_end)&&e.jsx(d,{label:"Note",value:"Cancels at period end",valueColor:"#ef4444"}),n&&e.jsx("div",{style:{marginTop:"12px",padding:"8px 12px",background:"rgba(248, 113, 113, 0.08)",border:"1px solid rgba(248, 113, 113, 0.2)",borderRadius:"0",fontSize:"11px",color:"#ef4444"},children:n}),e.jsxs("div",{style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("button",{onClick:u,disabled:r,style:{width:"100%",padding:"8px 16px",borderRadius:"0",border:"1px solid #f59e0b",background:"rgba(251, 191, 36, 0.1)",color:"#f59e0b",fontSize:"12px",fontWeight:600,cursor:r?"not-allowed":"pointer",fontFamily:"inherit",opacity:r?.6:1},children:r?"Opening...":"Manage Billing"}),e.jsx("p",{style:{marginTop:"8px",fontSize:"10px",color:"var(--text-tertiary)",textAlign:"center",margin:"8px 0 0 0"},children:"Update payment method, view invoices, or cancel subscription"})]})]})}const J="vienna_notification_prefs",O={emailApprovals:!0,emailAlerts:!0,emailWeeklyDigest:!1,slackApprovals:!1,slackAlerts:!1,slackWeeklyDigest:!1};function Ee(){const[r,l]=s.useState(()=>{try{const x=localStorage.getItem(J);return x?{...O,...JSON.parse(x)}:O}catch{return O}}),[n,c]=s.useState(!1),i=x=>{const p={...r,[x]:!r[x]};l(p),localStorage.setItem(J,JSON.stringify(p)),m.put("/settings/notifications",p).catch(()=>{}),c(!0),setTimeout(()=>c(!1),1500)},g=x=>({width:"36px",height:"20px",borderRadius:"0",cursor:"pointer",background:x?"rgba(16,185,129,0.3)":"rgba(255,255,255,0.08)",border:`1px solid ${x?"rgba(16,185,129,0.4)":"var(--border-subtle)"}`,position:"relative",transition:"all 150ms",flexShrink:0,display:"inline-block"}),u=x=>({width:"14px",height:"14px",borderRadius:"50%",position:"absolute",top:"2px",left:x?"18px":"2px",background:x?"#10b981":"var(--text-tertiary)",transition:"all 150ms"}),b=({label:x,pref:p})=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0"},children:[e.jsx("span",{style:{fontSize:"12px",color:"var(--text-secondary)"},children:x}),e.jsx("div",{style:g(r[p]),onClick:()=>i(p),children:e.jsx("div",{style:u(r[p])})})]});return e.jsxs(v,{title:`Notification Preferences ${n?"✓":""}`,children:[e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"📧 Email"}),e.jsx(b,{label:"Approval requests",pref:"emailApprovals"}),e.jsx(b,{label:"System alerts",pref:"emailAlerts"}),e.jsx(b,{label:"Weekly digest",pref:"emailWeeklyDigest"})]}),e.jsxs("div",{style:{borderTop:"1px solid var(--border-subtle)",paddingTop:"12px"},children:[e.jsx("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:"8px"},children:"💬 Slack"}),e.jsx(b,{label:"Approval requests",pref:"slackApprovals"}),e.jsx(b,{label:"System alerts",pref:"slackAlerts"}),e.jsx(b,{label:"Weekly digest",pref:"slackWeeklyDigest"})]})]})}function We(){const[r,l]=s.useState([]),[n,c]=s.useState(!0);return s.useEffect(()=>{m.get("/settings/audit-log").then(i=>l(i)).catch(()=>{l([{id:"1",action:"notification_prefs_updated",actor:"current_user",timestamp:new Date().toISOString(),details:"Notification preferences modified"}])}).finally(()=>c(!1))},[]),e.jsx(v,{title:"Settings Audit Log",children:n?e.jsx("div",{style:{padding:"16px",textAlign:"center"},children:e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"Loading audit log..."})}):r.length===0?e.jsx("div",{style:{padding:"16px",textAlign:"center"},children:e.jsx("span",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:"No settings changes recorded yet"})}):e.jsx("div",{style:{maxHeight:"200px",overflowY:"auto"},children:r.map(i=>e.jsxs("div",{style:{padding:"8px 0",borderBottom:"1px solid rgba(255,255,255,0.03)",fontSize:"11px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("span",{style:{color:"var(--text-secondary)",fontWeight:500},children:i.action}),e.jsx("span",{style:{color:"var(--text-tertiary)",fontFamily:"var(--font-mono)",fontSize:"10px"},children:new Date(i.timestamp).toLocaleString()})]}),e.jsxs("div",{style:{color:"var(--text-tertiary)",marginTop:"2px"},children:[i.actor," — ",i.details]})]},i.id))})})}export{Ie as SettingsPage}; +//# sourceMappingURL=SettingsPage-Cffft1gX.js.map diff --git a/apps/console-proxy/public/assets/SimulationPage-DZJ2vZt5.js b/apps/console-proxy/public/assets/SimulationPage-DZJ2vZt5.js deleted file mode 100644 index f1c33532..00000000 --- a/apps/console-proxy/public/assets/SimulationPage-DZJ2vZt5.js +++ /dev/null @@ -1,4 +0,0 @@ -import{r as s,j as e,Z as v,z as j,F as S,A as m,C as _,b as n}from"./index-D_7YXFSJ.js";import{P as z}from"./PageLayout-CTYKc2go.js";import{C as k}from"./circle-x-DJXSWLrE.js";const R=[{id:"agent-001",name:"Marketing Bot",type:"autonomous"},{id:"agent-002",name:"Finance Agent",type:"semi-autonomous"},{id:"agent-003",name:"Data Processor",type:"supervised"}],C=["send_email","update_database","deploy_code","charge_card","access_pii","delete_resource","modify_permissions"];function A(){const[l,y]=s.useState(""),[d,h]=s.useState(""),[x,b]=s.useState(`{ - "example": "data" -}`),[t,g]=s.useState(null),[o,u]=s.useState(!1),[p,c]=s.useState(null),f=async()=>{if(!l||!d){n("Please select agent and action type","warning");return}let r;try{r=JSON.parse(x)}catch{n("Invalid JSON payload","error");return}u(!0),c(null),g(null);try{const i=await(await fetch("/api/v1/simulation/run",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({agent_id:l,action_type:d,payload:r})})).json();i.success?(g(i.data),n("Simulation complete","success")):(c(i.error||"Simulation failed"),n(i.error||"Simulation failed","error"))}catch(a){const i=a instanceof Error?a.message:"Network error";c(i),n(i,"error")}finally{u(!1)}};return e.jsx(z,{title:"Simulation & Sandbox",description:"Test proposals against policies without real execution",children:e.jsxs("div",{style:{maxWidth:"1400px",margin:"0 auto",display:"grid",gridTemplateColumns:"1fr 1fr",gap:"24px"},children:[e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[e.jsxs("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(v,{size:20,className:"text-amber-500"}),"Simulation Input"]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Agent"}),e.jsxs("select",{value:l,onChange:r=>y(r.target.value),style:{width:"100%",padding:"10px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Select an agent..."}),R.map(r=>e.jsxs("option",{value:r.id,children:[r.name," (",r.type,")"]},r.id))]})]}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Action Type"}),e.jsxs("select",{value:d,onChange:r=>h(r.target.value),style:{width:"100%",padding:"10px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"14px"},children:[e.jsx("option",{value:"",children:"Select action type..."}),C.map(r=>e.jsx("option",{value:r,children:r},r))]})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Payload (JSON)"}),e.jsx("textarea",{value:x,onChange:r=>b(r.target.value),style:{width:"100%",height:"200px",padding:"12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"13px",fontFamily:"var(--font-mono)",resize:"vertical"}})]}),e.jsxs("button",{onClick:f,disabled:o||!l||!d,style:{width:"100%",padding:"12px 24px",background:o?"var(--bg-secondary)":"linear-gradient(135deg, #f59e0b, #d97706)",border:"none",borderRadius:"8px",color:"#fff",fontSize:"14px",fontWeight:600,cursor:o?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[e.jsx(j,{size:16}),o?"Running Simulation...":"Run Simulation"]})]}),e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[e.jsxs("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(S,{size:20,className:"text-blue-500"}),"Simulation Results"]}),p&&e.jsxs("div",{style:{padding:"12px 16px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"8px",color:"#fca5a5",fontSize:"14px",marginBottom:"16px"},children:[e.jsx("strong",{children:"Error:"})," ",p]}),!t&&!p&&!o&&e.jsxs("div",{style:{textAlign:"center",padding:"48px 24px",color:"var(--text-tertiary)"},children:[e.jsx(m,{size:48,style:{margin:"0 auto 16px",opacity:.5}}),e.jsx("p",{children:"Configure and run a simulation to see results"})]}),t&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[e.jsxs("div",{style:{padding:"16px",background:t.final_decision==="auto_approve"?"rgba(16, 185, 129, 0.1)":t.final_decision==="denied"?"rgba(239, 68, 68, 0.1)":"rgba(245, 158, 11, 0.1)",border:t.final_decision==="auto_approve"?"1px solid rgba(16, 185, 129, 0.3)":t.final_decision==="denied"?"1px solid rgba(239, 68, 68, 0.3)":"1px solid rgba(245, 158, 11, 0.3)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[t.final_decision==="auto_approve"&&e.jsx(_,{size:20,className:"text-green-500"}),t.final_decision==="denied"&&e.jsx(k,{size:20,className:"text-red-500"}),t.final_decision==="requires_approval"&&e.jsx(m,{size:20,className:"text-amber-500"}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:["Final Decision: ",t.final_decision.replace("_"," ").toUpperCase()]})]}),e.jsxs("div",{style:{fontSize:"13px",color:"var(--text-secondary)"},children:["Risk Tier: ",e.jsx("span",{style:{fontWeight:600,fontFamily:"var(--font-mono)"},children:t.risk_tier})]})]}),e.jsxs("div",{children:[e.jsxs("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"12px"},children:["Policy Evaluations (",t.policy_evaluations.length,")"]}),t.policy_evaluations.map((r,a)=>e.jsxs("div",{style:{padding:"12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:"6px"},children:[e.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)"},children:r.policy_name}),e.jsx("span",{style:{fontSize:"11px",fontWeight:600,padding:"2px 8px",borderRadius:"4px",background:r.result==="allow"?"rgba(16, 185, 129, 0.2)":r.result==="deny"?"rgba(239, 68, 68, 0.2)":"rgba(245, 158, 11, 0.2)",color:r.result==="allow"?"#6ee7b7":r.result==="deny"?"#fca5a5":"#fcd34d"},children:r.result.toUpperCase()})]}),r.conditions_matched.length>0&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"6px"},children:["Matched: ",r.conditions_matched.join(", ")]})]},a))]}),t.approval_requirements&&e.jsxs("div",{style:{padding:"12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Approval Requirements"}),e.jsxs("div",{style:{fontSize:"13px",color:"var(--text-primary)"},children:[e.jsxs("div",{children:["Required Tier: ",e.jsx("strong",{children:t.approval_requirements.required_tier})]}),e.jsxs("div",{children:["Approvers Needed: ",e.jsx("strong",{children:t.approval_requirements.approvers_needed})]}),t.approval_requirements.suggested_approvers.length>0&&e.jsxs("div",{children:["Suggested: ",t.approval_requirements.suggested_approvers.join(", ")]})]})]}),t.warnings&&t.warnings.length>0&&e.jsxs("div",{style:{padding:"12px",background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.3)",borderRadius:"8px"},children:[e.jsx("h3",{style:{fontSize:"14px",fontWeight:600,color:"#fcd34d",marginBottom:"8px"},children:"Warnings"}),e.jsx("ul",{style:{fontSize:"13px",color:"var(--text-secondary)",paddingLeft:"20px"},children:t.warnings.map((r,a)=>e.jsx("li",{children:r},a))})]})]})]})]})})}export{A as SimulationPage,A as default}; -//# sourceMappingURL=SimulationPage-DZJ2vZt5.js.map diff --git a/apps/console-proxy/public/assets/TeamManagementPage-C8lv3W2D.js b/apps/console-proxy/public/assets/TeamManagementPage-C4k4wAgd.js similarity index 97% rename from apps/console-proxy/public/assets/TeamManagementPage-C8lv3W2D.js rename to apps/console-proxy/public/assets/TeamManagementPage-C4k4wAgd.js index 1829f91b..9e8e8458 100644 --- a/apps/console-proxy/public/assets/TeamManagementPage-C8lv3W2D.js +++ b/apps/console-proxy/public/assets/TeamManagementPage-C4k4wAgd.js @@ -1,4 +1,4 @@ -import{c as S,r as n,a as o,b as r,j as e,U as B,C as M}from"./index-D_7YXFSJ.js";import{P as b}from"./PageLayout-CTYKc2go.js";import{C as j}from"./clock-DwbEOyPD.js";import{C as L}from"./circle-x-DJXSWLrE.js";import{T as E}from"./trash-2-BKcMh7SV.js";/** +import{c as S,r as n,e as o,g as r,j as e,U as B,C as M}from"./index-C0nK3ekl.js";import{P as b}from"./PageLayout-D94mSHCV.js";import{C as j}from"./clock-C0m9VzJk.js";import{C as L}from"./circle-x-DX5Kt33e.js";import{T as E}from"./trash-2-_FGaWZX1.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. @@ -9,4 +9,4 @@ import{c as S,r as n,a as o,b as r,j as e,U as B,C as M}from"./index-D_7YXFSJ.js * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const P=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],_=S("pen",P),p=[{id:"admin",name:"Admin",description:"Full access: manage team, policies, agents, and settings",icon:"👑",color:"#ef4444"},{id:"operator",name:"Operator",description:"Approve actions, view audit logs, manage agents",icon:"⚡",color:"#f59e0b"},{id:"viewer",name:"Viewer",description:"Read-only access to governance data and analytics",icon:"👁️",color:"#10b981"}];function X(){const[v,z]=n.useState([]),[g,k]=n.useState([]),[R,u]=n.useState(!0),[I,x]=n.useState(!1),[c,m]=n.useState(""),[d,f]=n.useState("operator"),[y,h]=n.useState(null);n.useEffect(()=>{l()},[]);const l=async()=>{try{u(!0);const[t,i]=await Promise.all([o.get("/api/v1/team/members"),o.get("/api/v1/team/invitations")]);z(Array.isArray(t)?t:[]),k(Array.isArray(i)?i:[])}catch{r("Failed to load team data","error")}finally{u(!1)}},C=async()=>{if(!c||!d){r("Email and role required","warning");return}try{await o.post("/api/v1/team/invite",{email:c,role:d}),r(`Invitation sent to ${c}`,"success"),x(!1),m(""),f("operator"),l()}catch(t){r((t==null?void 0:t.message)||"Failed to send invitation","error")}},w=async(t,i)=>{try{await o.patch(`/api/v1/team/members/${t}/role`,{role:i}),r("Role updated","success"),h(null),l()}catch(a){r((a==null?void 0:a.message)||"Failed to update role","error")}},W=async(t,i)=>{if(confirm(`Remove ${i} from the team?`))try{await o.delete(`/api/v1/team/members/${t}`),r("Member removed","success"),l()}catch(a){r((a==null?void 0:a.message)||"Failed to remove member","error")}},T=async t=>{try{await o.delete(`/api/v1/team/invitations/${t}`),r("Invitation revoked","success"),l()}catch(i){r((i==null?void 0:i.message)||"Failed to revoke invitation","error")}};return R?e.jsx(b,{title:"Team Management",description:"Loading...",children:e.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading team data..."})}):e.jsxs(b,{title:"Team Management",description:"Invite users and manage role-based access",children:[e.jsxs("div",{style:{maxWidth:"1200px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",gap:"16px",alignItems:"center"},children:[e.jsxs("div",{style:{fontSize:"14px",color:"var(--text-secondary)"},children:[e.jsx("strong",{children:v.length})," team members"]}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--text-tertiary)"},children:[g.filter(t=>t.status==="pending").length," pending invitations"]})]}),e.jsxs("button",{onClick:()=>x(!0),style:{padding:"10px 20px",background:"linear-gradient(135deg, #f59e0b, #d97706)",border:"none",borderRadius:"8px",color:"#fff",fontSize:"14px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(D,{size:16}),"Invite Member"]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"16px",marginBottom:"32px"},children:p.map(t=>e.jsxs("div",{style:{background:"var(--bg-primary)",border:`1px solid ${t.color}33`,borderRadius:"8px",padding:"16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"8px"},children:[e.jsx("span",{style:{fontSize:"20px"},children:t.icon}),e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:t.color},children:t.name})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)",margin:0,lineHeight:1.4},children:t.description})]},t.id))}),e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(B,{size:18,className:"text-amber-500"}),e.jsx("h2",{style:{fontSize:"16px",fontWeight:700,color:"var(--text-primary)",margin:0},children:"Team Members"})]}),e.jsx("div",{style:{overflowX:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:"var(--bg-app)",borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("th",{style:{padding:"12px 20px",textAlign:"left",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase"},children:"Member"}),e.jsx("th",{style:{padding:"12px 20px",textAlign:"left",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase"},children:"Role"}),e.jsx("th",{style:{padding:"12px 20px",textAlign:"left",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase"},children:"Status"}),e.jsx("th",{style:{padding:"12px 20px",textAlign:"left",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase"},children:"Last Login"}),e.jsx("th",{style:{padding:"12px 20px",textAlign:"right",fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",textTransform:"uppercase"},children:"Actions"})]})}),e.jsx("tbody",{children:v.map(t=>{const i=p.find(s=>s.id===t.role),a=(y==null?void 0:y.id)===t.id;return e.jsxs("tr",{style:{borderBottom:"1px solid var(--border-subtle)"},children:[e.jsx("td",{style:{padding:"16px 20px"},children:e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:t.name||t.email}),t.name&&e.jsx("div",{style:{fontSize:"12px",color:"var(--text-tertiary)"},children:t.email})]})}),e.jsx("td",{style:{padding:"16px 20px"},children:a?e.jsx("select",{value:t.role,onChange:s=>{const A=s.target.value;w(t.id,A)},style:{padding:"6px 10px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-primary)",fontSize:"13px"},children:p.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))}):e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",padding:"4px 12px",background:`${i==null?void 0:i.color}22`,color:i==null?void 0:i.color,borderRadius:"6px",fontSize:"12px",fontWeight:600},children:[e.jsx("span",{children:i==null?void 0:i.icon}),i==null?void 0:i.name]})}),e.jsx("td",{style:{padding:"16px 20px"},children:e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"6px",fontSize:"12px",fontWeight:600,color:t.status==="active"?"#10b981":t.status==="pending"?"#f59e0b":"#ef4444"},children:[t.status==="active"&&e.jsx(M,{size:14}),t.status==="pending"&&e.jsx(j,{size:14}),t.status==="suspended"&&e.jsx(L,{size:14}),t.status.charAt(0).toUpperCase()+t.status.slice(1)]})}),e.jsx("td",{style:{padding:"16px 20px",fontSize:"13px",color:"var(--text-secondary)"},children:t.last_login?new Date(t.last_login).toLocaleDateString():"Never"}),e.jsx("td",{style:{padding:"16px 20px",textAlign:"right"},children:e.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[a?e.jsx("button",{onClick:()=>h(null),style:{padding:"6px 10px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-secondary)",cursor:"pointer",fontSize:"12px"},children:"Cancel"}):e.jsxs("button",{onClick:()=>h(t),style:{padding:"6px 10px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px",fontSize:"12px"},children:[e.jsx(_,{size:12}),"Edit"]}),e.jsxs("button",{onClick:()=>W(t.id,t.email),style:{padding:"6px 10px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"6px",color:"#fca5a5",cursor:"pointer",display:"flex",alignItems:"center",gap:"4px",fontSize:"12px"},children:[e.jsx(E,{size:12}),"Remove"]})]})})]},t.id)})})]})})]}),g.filter(t=>t.status==="pending").length>0&&e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",overflow:"hidden",marginTop:"24px"},children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(j,{size:18,className:"text-amber-500"}),e.jsx("h2",{style:{fontSize:"16px",fontWeight:700,color:"var(--text-primary)",margin:0},children:"Pending Invitations"})]}),e.jsx("div",{style:{padding:"16px 20px"},children:g.filter(t=>t.status==="pending").map(t=>{const i=p.find(a=>a.id===t.role);return e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",marginBottom:"8px"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:t.email}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--text-tertiary)",marginTop:"4px"},children:["Invited ",new Date(t.invited_at).toLocaleDateString()," • Role: ",i==null?void 0:i.name]})]}),e.jsx("button",{onClick:()=>T(t.id),style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"6px",color:"#fca5a5",cursor:"pointer",fontSize:"12px",fontWeight:600},children:"Revoke"})]},t.id)})})]})]}),I&&e.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.7)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"20px"},onClick:()=>x(!1),children:e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",width:"100%",maxWidth:"500px",padding:"28px"},onClick:t=>t.stopPropagation(),children:[e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px"},children:"Invite Team Member"}),e.jsxs("div",{style:{marginBottom:"20px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Email Address"}),e.jsx("input",{type:"email",value:c,onChange:t=>m(t.target.value),placeholder:"colleague@company.com",style:{width:"100%",padding:"10px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-primary)",fontSize:"14px"}})]}),e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("label",{style:{display:"block",fontSize:"13px",fontWeight:600,color:"var(--text-secondary)",marginBottom:"8px"},children:"Role"}),p.map(t=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"12px",padding:"12px",background:d===t.id?`${t.color}22`:"var(--bg-app)",border:d===t.id?`1px solid ${t.color}66`:"1px solid var(--border-subtle)",borderRadius:"8px",marginBottom:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:"role",value:t.id,checked:d===t.id,onChange:i=>f(i.target.value),style:{marginTop:"2px"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"},children:[e.jsx("span",{children:t.icon}),e.jsx("span",{style:{fontSize:"14px",fontWeight:600,color:"var(--text-primary)"},children:t.name})]}),e.jsx("p",{style:{fontSize:"12px",color:"var(--text-tertiary)",margin:0},children:t.description})]})]},t.id))]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>x(!1),style:{padding:"10px 20px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",color:"var(--text-secondary)",fontSize:"14px",fontWeight:600,cursor:"pointer"},children:"Cancel"}),e.jsx("button",{onClick:C,style:{padding:"10px 20px",background:"linear-gradient(135deg, #f59e0b, #d97706)",border:"none",borderRadius:"8px",color:"#fff",fontSize:"14px",fontWeight:600,cursor:"pointer"},children:"Send Invitation"})]})]})})]})}export{X as TeamManagementPage,X as default}; -//# sourceMappingURL=TeamManagementPage-C8lv3W2D.js.map +//# sourceMappingURL=TeamManagementPage-C4k4wAgd.js.map diff --git a/apps/console-proxy/public/assets/UsageDashboardPage-Dg93a7Ek.js b/apps/console-proxy/public/assets/UsageDashboardPage-BBENTGn2.js similarity index 95% rename from apps/console-proxy/public/assets/UsageDashboardPage-Dg93a7Ek.js rename to apps/console-proxy/public/assets/UsageDashboardPage-BBENTGn2.js index 0e8499ba..25935d2b 100644 --- a/apps/console-proxy/public/assets/UsageDashboardPage-Dg93a7Ek.js +++ b/apps/console-proxy/public/assets/UsageDashboardPage-BBENTGn2.js @@ -1,7 +1,7 @@ -import{c as b,r as x,j as t,S as f,Z as v,U as _}from"./index-D_7YXFSJ.js";import{P as h}from"./PageLayout-CTYKc2go.js";import{A as j}from"./activity-C-iTiNlh.js";import{T as S}from"./trending-up-xPmnKzgu.js";/** +import{c as b,r as x,j as t,S as f,Z as v,U as _,y as j}from"./index-C0nK3ekl.js";import{P as h}from"./PageLayout-D94mSHCV.js";import{A as S}from"./activity-DFouDeMs.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. - */const w=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],z=b("arrow-up",w);function C(){const[e,r]=x.useState(null),[a,i]=x.useState(!0),[o,g]=x.useState("30d");x.useEffect(()=>{l()},[o]);const l=async()=>{try{i(!0);const u=await(await fetch(`/api/v1/usage/metrics?range=${o}`,{credentials:"include"})).json();u.success&&r(u.data)}catch(s){console.error("Failed to load usage metrics:",s)}finally{i(!1)}};if(a)return t.jsx(h,{title:"Usage Dashboard",description:"Loading metrics...",children:t.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading usage data..."})});if(!e)return t.jsx(h,{title:"Usage Dashboard",description:"Error loading metrics",children:t.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Failed to load usage data. Please try again."})});const n=e.proposals_this_month/e.plan_limits.proposals_per_month*100,d=e.agents_active/e.plan_limits.agents_max*100,p=e.api_calls_this_month/e.plan_limits.api_calls_per_month*100,y=n>80||d>80||p>80;return t.jsx(h,{title:"Usage Dashboard",description:"Real-time metrics and plan usage",children:t.jsxs("div",{style:{maxWidth:"1400px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:t.jsx("div",{style:{display:"flex",gap:"8px"},children:["7d","30d","90d"].map(s=>t.jsxs("button",{onClick:()=>g(s),style:{padding:"8px 16px",background:o===s?"rgba(245, 158, 11, 0.2)":"var(--bg-app)",border:o===s?"1px solid rgba(245, 158, 11, 0.4)":"1px solid var(--border-subtle)",borderRadius:"8px",color:o===s?"#f59e0b":"var(--text-secondary)",fontSize:"13px",fontWeight:o===s?600:400,cursor:"pointer"},children:[s==="7d"&&"Last 7 Days",s==="30d"&&"Last 30 Days",s==="90d"&&"Last 90 Days"]},s))})}),y&&t.jsxs("div",{style:{background:"linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15))",border:"2px solid rgba(245, 158, 11, 0.4)",borderRadius:"12px",padding:"20px",marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"16px",fontWeight:700,color:"#f59e0b",marginBottom:"6px"},children:"Approaching Plan Limits"}),t.jsxs("p",{style:{fontSize:"14px",color:"var(--text-secondary)",margin:0},children:["You're using ",Math.max(n,d,p).toFixed(0),"% of your plan capacity. Upgrade to continue scaling."]})]}),t.jsxs("a",{href:"/settings?tab=billing",style:{padding:"12px 24px",background:"#f59e0b",color:"#000",borderRadius:"8px",fontSize:"14px",fontWeight:600,textDecoration:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(z,{size:16}),"Upgrade Plan"]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"16px",marginBottom:"32px"},children:[t.jsx(c,{icon:t.jsx(j,{size:20}),label:"Proposals Today",value:e.proposals_today,total:e.proposals_this_month,subtitle:`${e.proposals_this_month} this month`,color:"#f59e0b",usage:n,limit:e.plan_limits.proposals_per_month}),t.jsx(c,{icon:t.jsx(f,{size:20}),label:"Warrants Issued",value:e.warrants_issued_today,total:e.warrants_issued_this_month,subtitle:`${e.warrants_issued_this_month} this month`,color:"#10b981"}),t.jsx(c,{icon:t.jsx(v,{size:20}),label:"API Calls Today",value:e.api_calls_today,total:e.api_calls_this_month,subtitle:`${e.api_calls_this_month} this month`,color:"#3b82f6",usage:p,limit:e.plan_limits.api_calls_per_month}),t.jsx(c,{icon:t.jsx(_,{size:20}),label:"Active Agents",value:e.agents_active,total:e.agents_total,subtitle:`${e.agents_total} total registered`,color:"#8b5cf6",usage:d,limit:e.plan_limits.agents_max})]}),t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[t.jsxs("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(S,{size:20,className:"text-amber-500"}),"Usage Trends"]}),t.jsx("div",{style:{height:"300px",position:"relative"},children:t.jsx(k,{data:e.trend_data})})]}),t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px",marginTop:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px"},children:"Plan Limits"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"16px"},children:[t.jsx(m,{label:"Proposals",used:e.proposals_this_month,limit:e.plan_limits.proposals_per_month,percentage:n}),t.jsx(m,{label:"API Calls",used:e.api_calls_this_month,limit:e.plan_limits.api_calls_per_month,percentage:p}),t.jsx(m,{label:"Agents",used:e.agents_active,limit:e.plan_limits.agents_max,percentage:d})]})]})]})})}function c({icon:e,label:r,value:a,total:i,subtitle:o,color:g,usage:l,limit:n}){return t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",color:g},children:[e,t.jsx("span",{style:{fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",color:"var(--text-tertiary)"},children:r})]}),t.jsx("div",{style:{fontSize:"32px",fontWeight:700,color:"var(--text-primary)",marginBottom:"8px"},children:a.toLocaleString()}),t.jsx("div",{style:{fontSize:"13px",color:"var(--text-secondary)"},children:o}),l!==void 0&&n!==void 0&&t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"11px",color:"var(--text-tertiary)",marginBottom:"4px"},children:[t.jsxs("span",{children:[l.toFixed(0),"% of limit"]}),t.jsx("span",{children:n.toLocaleString()})]}),t.jsx("div",{style:{height:"4px",background:"var(--bg-app)",borderRadius:"2px",overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",width:`${Math.min(l,100)}%`,background:l>80?"#ef4444":l>60?"#f59e0b":"#10b981",transition:"width 300ms"}})})]})]})}function m({label:e,used:r,limit:a,percentage:i}){return t.jsxs("div",{style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"16px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"12px",textTransform:"uppercase"},children:e}),t.jsxs("div",{style:{fontSize:"24px",fontWeight:700,color:"var(--text-primary)",marginBottom:"4px"},children:[r.toLocaleString()," / ",a.toLocaleString()]}),t.jsx("div",{style:{height:"6px",background:"var(--bg-primary)",borderRadius:"3px",overflow:"hidden",marginTop:"8px"},children:t.jsx("div",{style:{height:"100%",width:`${Math.min(i,100)}%`,background:i>80?"#ef4444":i>60?"#f59e0b":"#10b981"}})})]})}function k({data:e}){if(!e||e.length===0)return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-tertiary)"},children:"No trend data available"});const r=Math.max(...e.map(a=>Math.max(a.proposals,a.warrants,a.api_calls)));return t.jsx("div",{style:{display:"flex",gap:"4px",alignItems:"flex-end",height:"100%"},children:e.map((a,i)=>t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},children:[t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"flex-end",width:"100%",gap:"2px"},children:[t.jsx("div",{title:`Proposals: ${a.proposals}`,style:{height:`${a.proposals/r*100}%`,background:"#f59e0b",borderRadius:"2px 2px 0 0"}}),t.jsx("div",{title:`Warrants: ${a.warrants}`,style:{height:`${a.warrants/r*100}%`,background:"#10b981",borderRadius:"2px 2px 0 0"}})]}),t.jsx("span",{style:{fontSize:"10px",color:"var(--text-tertiary)",marginTop:"4px"},children:new Date(a.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},i))})}export{C as UsageDashboardPage,C as default}; -//# sourceMappingURL=UsageDashboardPage-Dg93a7Ek.js.map + */const w=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],z=b("arrow-up",w);function C(){const[e,r]=x.useState(null),[a,i]=x.useState(!0),[o,g]=x.useState("30d");x.useEffect(()=>{l()},[o]);const l=async()=>{try{i(!0);const u=await(await fetch(`/api/v1/usage/metrics?range=${o}`,{credentials:"include"})).json();u.success&&r(u.data)}catch(s){console.error("Failed to load usage metrics:",s)}finally{i(!1)}};if(a)return t.jsx(h,{title:"Usage Dashboard",description:"Loading metrics...",children:t.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading usage data..."})});if(!e)return t.jsx(h,{title:"Usage Dashboard",description:"Error loading metrics",children:t.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Failed to load usage data. Please try again."})});const n=e.proposals_this_month/e.plan_limits.proposals_per_month*100,d=e.agents_active/e.plan_limits.agents_max*100,p=e.api_calls_this_month/e.plan_limits.api_calls_per_month*100,y=n>80||d>80||p>80;return t.jsx(h,{title:"Usage Dashboard",description:"Real-time metrics and plan usage",children:t.jsxs("div",{style:{maxWidth:"1400px",margin:"0 auto"},children:[t.jsx("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:t.jsx("div",{style:{display:"flex",gap:"8px"},children:["7d","30d","90d"].map(s=>t.jsxs("button",{onClick:()=>g(s),style:{padding:"8px 16px",background:o===s?"rgba(245, 158, 11, 0.2)":"var(--bg-app)",border:o===s?"1px solid rgba(245, 158, 11, 0.4)":"1px solid var(--border-subtle)",borderRadius:"8px",color:o===s?"#f59e0b":"var(--text-secondary)",fontSize:"13px",fontWeight:o===s?600:400,cursor:"pointer"},children:[s==="7d"&&"Last 7 Days",s==="30d"&&"Last 30 Days",s==="90d"&&"Last 90 Days"]},s))})}),y&&t.jsxs("div",{style:{background:"linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.15))",border:"2px solid rgba(245, 158, 11, 0.4)",borderRadius:"12px",padding:"20px",marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:"16px",fontWeight:700,color:"#f59e0b",marginBottom:"6px"},children:"Approaching Plan Limits"}),t.jsxs("p",{style:{fontSize:"14px",color:"var(--text-secondary)",margin:0},children:["You're using ",Math.max(n,d,p).toFixed(0),"% of your plan capacity. Upgrade to continue scaling."]})]}),t.jsxs("a",{href:"/settings?tab=billing",style:{padding:"12px 24px",background:"#f59e0b",color:"#000",borderRadius:"8px",fontSize:"14px",fontWeight:600,textDecoration:"none",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(z,{size:16}),"Upgrade Plan"]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"16px",marginBottom:"32px"},children:[t.jsx(c,{icon:t.jsx(S,{size:20}),label:"Proposals Today",value:e.proposals_today,total:e.proposals_this_month,subtitle:`${e.proposals_this_month} this month`,color:"#f59e0b",usage:n,limit:e.plan_limits.proposals_per_month}),t.jsx(c,{icon:t.jsx(f,{size:20}),label:"Warrants Issued",value:e.warrants_issued_today,total:e.warrants_issued_this_month,subtitle:`${e.warrants_issued_this_month} this month`,color:"#10b981"}),t.jsx(c,{icon:t.jsx(v,{size:20}),label:"API Calls Today",value:e.api_calls_today,total:e.api_calls_this_month,subtitle:`${e.api_calls_this_month} this month`,color:"#3b82f6",usage:p,limit:e.plan_limits.api_calls_per_month}),t.jsx(c,{icon:t.jsx(_,{size:20}),label:"Active Agents",value:e.agents_active,total:e.agents_total,subtitle:`${e.agents_total} total registered`,color:"#8b5cf6",usage:d,limit:e.plan_limits.agents_max})]}),t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px"},children:[t.jsxs("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px",display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx(j,{size:20,className:"text-amber-500"}),"Usage Trends"]}),t.jsx("div",{style:{height:"300px",position:"relative"},children:t.jsx(k,{data:e.trend_data})})]}),t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"24px",marginTop:"24px"},children:[t.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--text-primary)",marginBottom:"20px"},children:"Plan Limits"}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:"16px"},children:[t.jsx(m,{label:"Proposals",used:e.proposals_this_month,limit:e.plan_limits.proposals_per_month,percentage:n}),t.jsx(m,{label:"API Calls",used:e.api_calls_this_month,limit:e.plan_limits.api_calls_per_month,percentage:p}),t.jsx(m,{label:"Agents",used:e.agents_active,limit:e.plan_limits.agents_max,percentage:d})]})]})]})})}function c({icon:e,label:r,value:a,total:i,subtitle:o,color:g,usage:l,limit:n}){return t.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginBottom:"12px",color:g},children:[e,t.jsx("span",{style:{fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.5px",color:"var(--text-tertiary)"},children:r})]}),t.jsx("div",{style:{fontSize:"32px",fontWeight:700,color:"var(--text-primary)",marginBottom:"8px"},children:a.toLocaleString()}),t.jsx("div",{style:{fontSize:"13px",color:"var(--text-secondary)"},children:o}),l!==void 0&&n!==void 0&&t.jsxs("div",{style:{marginTop:"12px"},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:"11px",color:"var(--text-tertiary)",marginBottom:"4px"},children:[t.jsxs("span",{children:[l.toFixed(0),"% of limit"]}),t.jsx("span",{children:n.toLocaleString()})]}),t.jsx("div",{style:{height:"4px",background:"var(--bg-app)",borderRadius:"2px",overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",width:`${Math.min(l,100)}%`,background:l>80?"#ef4444":l>60?"#f59e0b":"#10b981",transition:"width 300ms"}})})]})]})}function m({label:e,used:r,limit:a,percentage:i}){return t.jsxs("div",{style:{background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"8px",padding:"16px"},children:[t.jsx("div",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"12px",textTransform:"uppercase"},children:e}),t.jsxs("div",{style:{fontSize:"24px",fontWeight:700,color:"var(--text-primary)",marginBottom:"4px"},children:[r.toLocaleString()," / ",a.toLocaleString()]}),t.jsx("div",{style:{height:"6px",background:"var(--bg-primary)",borderRadius:"3px",overflow:"hidden",marginTop:"8px"},children:t.jsx("div",{style:{height:"100%",width:`${Math.min(i,100)}%`,background:i>80?"#ef4444":i>60?"#f59e0b":"#10b981"}})})]})}function k({data:e}){if(!e||e.length===0)return t.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--text-tertiary)"},children:"No trend data available"});const r=Math.max(...e.map(a=>Math.max(a.proposals,a.warrants,a.api_calls)));return t.jsx("div",{style:{display:"flex",gap:"4px",alignItems:"flex-end",height:"100%"},children:e.map((a,i)=>t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:"2px"},children:[t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",justifyContent:"flex-end",width:"100%",gap:"2px"},children:[t.jsx("div",{title:`Proposals: ${a.proposals}`,style:{height:`${a.proposals/r*100}%`,background:"#f59e0b",borderRadius:"2px 2px 0 0"}}),t.jsx("div",{title:`Warrants: ${a.warrants}`,style:{height:`${a.warrants/r*100}%`,background:"#10b981",borderRadius:"2px 2px 0 0"}})]}),t.jsx("span",{style:{fontSize:"10px",color:"var(--text-tertiary)",marginTop:"4px"},children:new Date(a.date).toLocaleDateString("en-US",{month:"short",day:"numeric"})})]},i))})}export{C as UsageDashboardPage,C as default}; +//# sourceMappingURL=UsageDashboardPage-BBENTGn2.js.map diff --git a/apps/console-proxy/public/assets/WebhookConfigPage-BRwuAhTc.js b/apps/console-proxy/public/assets/WebhookConfigPage-BRwuAhTc.js deleted file mode 100644 index dcb66e00..00000000 --- a/apps/console-proxy/public/assets/WebhookConfigPage-BRwuAhTc.js +++ /dev/null @@ -1,12 +0,0 @@ -import{c,u as y,r as o,b as s,j as e}from"./index-D_7YXFSJ.js";import{P as h}from"./PageLayout-CTYKc2go.js";import{P as b}from"./plus-BYo2vOpk.js";import{T as v}from"./trash-2-BKcMh7SV.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const m=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]],j=c("bell",m);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const k=[["path",{d:"M14.5 2v17.5c0 1.4-1.1 2.5-2.5 2.5c-1.4 0-2.5-1.1-2.5-2.5V2",key:"125lnx"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M14.5 16h-5",key:"1ox875"}]],S=c("test-tube",k),T=[{value:"approval_required",label:"Approval Required",icon:"⏸️"},{value:"approval_resolved",label:"Approval Resolved",icon:"✅"},{value:"action_executed",label:"Action Executed",icon:"▶️"},{value:"action_failed",label:"Action Failed",icon:"❌"},{value:"policy_violation",label:"Policy Violation",icon:"⚠️"},{value:"warrant_issued",label:"Warrant Issued",icon:"🛡️"}];function C(){const n=y(),[l,p]=o.useState([]),[x,d]=o.useState(!0),[W,z]=o.useState(!1);o.useEffect(()=>{i()},[]);const i=async()=>{try{d(!0);const r=await(await fetch("/api/v1/integrations",{credentials:"include"})).json();r.success&&p(r.data)}catch{s("Failed to load webhooks","error")}finally{d(!1)}},g=async t=>{try{(await(await fetch(`/api/v1/integrations/${t}/toggle`,{method:"POST",credentials:"include"})).json()).success&&(s("Webhook updated","success"),i())}catch{s("Failed to toggle webhook","error")}},u=async t=>{try{(await(await fetch(`/api/v1/integrations/${t}/test`,{method:"POST",credentials:"include"})).json()).success?s("Test notification sent","success"):s("Test failed","error")}catch{s("Network error","error")}},f=async(t,r)=>{if(confirm(`Delete webhook "${r}"?`))try{(await(await fetch(`/api/v1/integrations/${t}`,{method:"DELETE",credentials:"include"})).json()).success&&(s("Webhook deleted","success"),i())}catch{s("Failed to delete webhook","error")}};return e.jsx(h,{title:"Webhook Notifications",description:"Configure alerts for governance events",children:e.jsxs("div",{style:{maxWidth:"1000px",margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--text-secondary)"},children:"Get notified when approvals are required, actions execute, or policies are violated."}),e.jsxs("button",{onClick:()=>n("/integrations"),style:{padding:"10px 20px",background:"linear-gradient(135deg, #f59e0b, #d97706)",border:"none",borderRadius:"8px",color:"#fff",fontSize:"14px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(b,{size:16}),"Add Webhook"]})]}),x?e.jsx("div",{style:{textAlign:"center",padding:"48px",color:"var(--text-tertiary)"},children:"Loading webhooks..."}):l.length===0?e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"48px",textAlign:"center"},children:[e.jsx(j,{size:48,style:{margin:"0 auto 16px",opacity:.5,color:"var(--text-tertiary)"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",marginBottom:"8px"},children:"No webhooks configured"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--text-tertiary)",marginBottom:"24px"},children:"Set up Slack, email, or custom webhook notifications to stay informed of governance events."}),e.jsx("button",{onClick:()=>n("/integrations"),style:{padding:"10px 20px",background:"#f59e0b",border:"none",borderRadius:"8px",color:"#000",fontSize:"14px",fontWeight:600,cursor:"pointer"},children:"Add Your First Webhook"})]}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:l.map(t=>e.jsxs("div",{style:{background:"var(--bg-primary)",border:"1px solid var(--border-subtle)",borderRadius:"12px",padding:"20px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"start",marginBottom:"12px"},children:[e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",marginBottom:"8px"},children:[e.jsx("h3",{style:{fontSize:"16px",fontWeight:700,color:"var(--text-primary)",margin:0},children:t.name}),e.jsx("span",{style:{padding:"3px 8px",background:t.type==="slack"?"rgba(99, 102, 241, 0.2)":t.type==="email"?"rgba(16, 185, 129, 0.2)":"rgba(245, 158, 11, 0.2)",color:t.type==="slack"?"#a5b4fc":t.type==="email"?"#6ee7b7":"#fcd34d",borderRadius:"6px",fontSize:"11px",fontWeight:600,textTransform:"uppercase"},children:t.type}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:()=>g(t.id)}),e.jsx("span",{style:{fontSize:"13px",color:"var(--text-secondary)"},children:"Enabled"})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--text-tertiary)"},children:t.event_filters.length>0?e.jsxs("span",{children:["Triggers: ",t.event_filters.join(", ")]}):e.jsx("span",{children:"All events"})})]}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("button",{onClick:()=>u(t.id),style:{padding:"6px 12px",background:"var(--bg-app)",border:"1px solid var(--border-subtle)",borderRadius:"6px",color:"var(--text-secondary)",fontSize:"12px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(S,{size:14}),"Test"]}),e.jsxs("button",{onClick:()=>f(t.id,t.name),style:{padding:"6px 12px",background:"rgba(239, 68, 68, 0.1)",border:"1px solid rgba(239, 68, 68, 0.3)",borderRadius:"6px",color:"#fca5a5",fontSize:"12px",fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(v,{size:14}),"Delete"]})]})]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--border-subtle)"},children:[e.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-tertiary)",marginBottom:"8px"},children:"MONITORED EVENTS"}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:T.map(r=>{const a=t.event_filters.includes(r.value)||t.event_filters.length===0;return e.jsxs("span",{style:{padding:"4px 10px",background:a?"rgba(245, 158, 11, 0.2)":"var(--bg-app)",border:a?"1px solid rgba(245, 158, 11, 0.3)":"1px solid var(--border-subtle)",borderRadius:"6px",fontSize:"12px",color:a?"#fcd34d":"var(--text-tertiary)",opacity:a?1:.5},children:[r.icon," ",r.label]},r.value)})})]})]},t.id))})]})})}export{C as WebhookConfigPage,C as default}; -//# sourceMappingURL=WebhookConfigPage-BRwuAhTc.js.map diff --git a/apps/console-proxy/public/assets/WorkspacePage-9pXkK0Q1.js b/apps/console-proxy/public/assets/WorkspacePage-C3FThH_4.js similarity index 99% rename from apps/console-proxy/public/assets/WorkspacePage-9pXkK0Q1.js rename to apps/console-proxy/public/assets/WorkspacePage-C3FThH_4.js index d21f46f3..6b4f43f7 100644 --- a/apps/console-proxy/public/assets/WorkspacePage-9pXkK0Q1.js +++ b/apps/console-proxy/public/assets/WorkspacePage-C3FThH_4.js @@ -1,4 +1,4 @@ -import{a as L,j as e,r as m}from"./index-D_7YXFSJ.js";import{P}from"./PageLayout-CTYKc2go.js";async function R(s={}){return L.get("/investigations",s)}async function D(s){return L.get(`/investigations/${s}`)}async function G(s,a){return L.fetch(`/investigations/${s}`,{method:"PATCH",body:JSON.stringify(a)})}async function O(s){await L.delete(`/investigations/${s}`)}async function Y(s={}){return L.get("/artifacts",s)}async function U(s){const a=await fetch(`/api/v1/artifacts/${s}/content`,{credentials:"include"});if(!a.ok)throw new Error(`Failed to fetch artifact content: ${a.statusText}`);return a.text()}async function K(s){return(await L.get(`/intents/${s}/timeline`)).timeline}async function J(s){return(await L.get(`/intents/${s}/graph`)).graph}async function q(s){return(await L.get(`/intents/${s}/explanation`)).explanation}const Q={open:{label:"Open",color:"text-blue-400",bg:"bg-blue-900/30 border-blue-700/50"},investigating:{label:"Investigating",color:"text-yellow-400",bg:"bg-yellow-900/30 border-yellow-700/50"},resolved:{label:"Resolved",color:"text-green-400",bg:"bg-green-900/30 border-green-700/50"},archived:{label:"Archived",color:"text-gray-500",bg:"bg-gray-800/30 border-gray-700/50"}};function T({status:s,size:a="md"}){const o=Q[s],t=a==="sm"?"text-xs px-2 py-0.5":"text-sm px-2.5 py-1";return e.jsx("span",{className:`inline-flex items-center font-medium border rounded ${o.bg} ${o.color} ${t}`,children:o.label})}function F({onSelectInvestigation:s}){const[a,o]=m.useState([]),[t,c]=m.useState(!0),[h,g]=m.useState(null),[l,x]=m.useState("all");m.useEffect(()=>{f()},[l]);const f=async()=>{try{c(!0),g(null);const N=await R(l==="all"?{}:{status:l});o(N.investigations)}catch(n){console.error("Failed to load investigations:",n),g(n.message||"Failed to load investigations")}finally{c(!1)}},j=n=>{s?s(n):console.log("Navigate to investigation:",n)},p=n=>{const N=new Date(n),k=new Date().getTime()-N.getTime(),w=Math.floor(k/6e4),y=Math.floor(k/36e5),_=Math.floor(k/864e5);return w<1?"Just now":w<60?`${w}m ago`:y<24?`${y}h ago`:_<7?`${_}d ago`:N.toLocaleDateString()};return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("svg",{className:"animate-spin h-8 w-8 text-blue-400 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e.jsx("p",{className:"text-gray-400",children:"Loading investigations..."})]})}):h?e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 mr-3 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-red-300 font-medium mb-1",children:"Failed to Load Investigations"}),e.jsx("p",{className:"text-red-400/80 text-sm",children:h}),e.jsx("button",{onClick:f,className:"mt-3 text-sm text-red-300 hover:text-red-200 underline",children:"Try again"})]})]})}):a.length===0?e.jsx("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-12 text-center",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:l==="all"?"No Investigations":`No ${l} Investigations`}),e.jsx("p",{className:"text-gray-400 mb-6",children:l==="all"?"No investigations have been created yet. Start an investigation to track incident analysis, evidence collection, and resolution.":`No investigations with status "${l}". Try a different filter.`}),l!=="all"&&e.jsx("button",{onClick:()=>x("all"),className:"text-blue-400 hover:text-blue-300 text-sm font-medium",children:"Show all investigations"})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["all","open","investigating","resolved","archived"].map(n=>e.jsx("button",{onClick:()=>x(n),className:`px-3 py-1.5 text-sm font-medium rounded border transition-colors ${l===n?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300 hover:border-gray-600"}`,children:n==="all"?"All":n.charAt(0).toUpperCase()+n.slice(1)},n))}),e.jsxs("div",{className:"text-sm text-gray-500",children:[a.length," investigation",a.length!==1?"s":""]})]}),e.jsx("div",{className:"grid gap-4",children:a.map(n=>e.jsxs("div",{onClick:()=>j(n.investigation_id),className:"bg-gray-800 border border-gray-700 rounded-lg p-5 hover:border-gray-600 cursor-pointer transition-all hover:shadow-lg",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-white font-semibold text-lg mb-1 truncate",children:n.name}),n.description&&e.jsx("p",{className:"text-gray-400 text-sm line-clamp-2",children:n.description})]}),e.jsx(T,{status:n.status})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-gray-500",children:[n.objective_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsxs("span",{children:[n.objective_count," objective",n.objective_count!==1?"s":""]})]}),n.intent_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsxs("span",{children:[n.intent_count," intent",n.intent_count!==1?"s":""]})]}),n.artifact_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("span",{children:[n.artifact_count," artifact",n.artifact_count!==1?"s":""]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-4",children:[e.jsxs("span",{children:["Created ",p(n.created_at)]}),n.updated_at!==n.created_at&&e.jsxs("span",{children:["Updated ",p(n.updated_at)]})]})]})]},n.investigation_id))})]})}const E=[{id:"investigation",label:"Investigation",icon:"📋",types:["investigation_workspace","investigation_notes","investigation_report"]},{id:"trace",label:"Traces",icon:"🔍",types:["trace","intent_trace","execution_graph","timeline_export"]},{id:"execution",label:"Execution",icon:"⚙️",types:["execution_output","execution_stdout","execution_stderr","verification_report"]},{id:"objective",label:"Objectives",icon:"🎯",types:["objective_history","objective_analysis"]},{id:"incident",label:"Incidents",icon:"🚨",types:["incident_timeline","incident_postmortem"]},{id:"system",label:"System",icon:"🖥️",types:["state_snapshot","config_snapshot","system_snapshot"]}];function M(s){if(s===0)return"0 B";const a=1024,o=["B","KB","MB","GB"],t=Math.floor(Math.log(s)/Math.log(a));return`${parseFloat((s/Math.pow(a,t)).toFixed(2))} ${o[t]}`}function C(s){const a=new Date(s),o=new Date,t=o.getTime()-a.getTime(),c=Math.floor(t/6e4),h=Math.floor(t/36e5),g=Math.floor(t/864e5);return c<1?"just now":c<60?`${c}m ago`:h<24?`${h}h ago`:g<7?`${g}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:a.getFullYear()!==o.getFullYear()?"numeric":void 0})}function $(s){return["text/plain","text/markdown","application/json","text/html","text/csv"].some(o=>s.startsWith(o))}function X(s){for(const a of E)if(a.types.includes(s))return a;return null}function V({investigationId:s,selectedArtifactId:a,onSelectArtifact:o}){const[t,c]=m.useState([]),[h,g]=m.useState(a||null),[l,x]=m.useState(null),[f,j]=m.useState(null),[p,n]=m.useState(!0),[N,i]=m.useState(!1),[k,w]=m.useState(null);m.useEffect(()=>{y()},[s]),m.useEffect(()=>{h?_(h):(x(null),j(null))},[h]);async function y(){try{n(!0),w(null);const d=await Y({investigation_id:s,limit:200});c(d.artifacts),h&&!d.artifacts.find(b=>b.artifact_id===h)&&(g(null),o==null||o(null))}catch(d){console.error("Failed to load artifacts:",d),w(d.message||"Failed to load artifacts")}finally{n(!1)}}async function _(d){const b=t.find(u=>u.artifact_id===d);if(b)if(x(b),$(b.mime_type))try{i(!0);const u=await U(d);j(u)}catch(u){console.error("Failed to load artifact content:",u),j(`[Error loading content: ${u.message}]`)}finally{i(!1)}else j(null)}function v(d){g(d),o==null||o(d)}const r=new Map;for(const d of t){const b=X(d.artifact_type),u=(b==null?void 0:b.id)||"other";r.has(u)||r.set(u,[]),r.get(u).push(d)}return p?e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-1",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 animate-pulse h-96"})}),e.jsx("div",{className:"col-span-2",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 animate-pulse h-96"})})]}):k?e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-red-300 mb-2",children:"Failed to load artifacts"}),e.jsx("p",{className:"text-red-400 mb-4",children:k}),e.jsx("button",{onClick:y,className:"px-4 py-2 bg-red-700 text-white rounded hover:bg-red-600",children:"Retry"})]})]})}):t.length===0?e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-600 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No artifacts yet"}),e.jsx("p",{className:"text-gray-400",children:"No artifacts are linked to this investigation."})]})}):e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-1 space-y-4",children:e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 max-h-[600px] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Artifacts"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.length," total"]})]}),e.jsxs("div",{className:"space-y-6",children:[E.map(d=>{const b=r.get(d.id)||[];return b.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-medium text-gray-400",children:[e.jsx("span",{children:d.icon}),e.jsx("span",{children:d.label}),e.jsx("span",{className:"ml-auto text-gray-600",children:b.length})]}),e.jsx("div",{className:"space-y-1",children:b.map(u=>e.jsxs("button",{onClick:()=>v(u.artifact_id),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${h===u.artifact_id?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-700"}`,children:[e.jsx("div",{className:"font-medium truncate",children:u.name}),e.jsxs("div",{className:`text-xs mt-0.5 ${h===u.artifact_id?"text-blue-200":"text-gray-500"}`,children:[C(u.created_at)," · ",M(u.size_bytes)]})]},u.artifact_id))})]},d.id)}),r.has("other")&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-medium text-gray-400",children:[e.jsx("span",{children:"📦"}),e.jsx("span",{children:"Other"}),e.jsx("span",{className:"ml-auto text-gray-600",children:r.get("other").length})]}),e.jsx("div",{className:"space-y-1",children:r.get("other").map(d=>e.jsxs("button",{onClick:()=>v(d.artifact_id),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${h===d.artifact_id?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-700"}`,children:[e.jsx("div",{className:"font-medium truncate",children:d.name}),e.jsxs("div",{className:`text-xs mt-0.5 ${h===d.artifact_id?"text-blue-200":"text-gray-500"}`,children:[C(d.created_at)," · ",M(d.size_bytes)]})]},d.artifact_id))})]})]})]})}),e.jsx("div",{className:"col-span-2",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 max-h-[600px] overflow-y-auto",children:l?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:l.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded",children:l.artifact_type}),e.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded",children:l.mime_type}),$(l.mime_type)&&e.jsx("span",{className:"px-2 py-1 bg-green-900/50 text-green-300 rounded",children:"Previewable"})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Metadata"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"ID"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.artifact_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Created"}),e.jsx("div",{className:"text-gray-300",children:C(l.created_at)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Size"}),e.jsx("div",{className:"text-gray-300",children:M(l.size_bytes)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Created By"}),e.jsx("div",{className:"text-gray-300",children:l.created_by})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Integrity Hash"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.content_hash})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Path"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.file_path})]})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Linked Entities"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[l.investigation_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Investigation:"}),e.jsx("span",{className:"px-2 py-0.5 bg-blue-900/50 text-blue-300 rounded font-mono text-xs",children:l.investigation_id})]}),l.intent_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Intent:"}),e.jsx("span",{className:"px-2 py-0.5 bg-amber-900/50 text-amber-300 rounded font-mono text-xs",children:l.intent_id})]}),l.execution_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Execution:"}),e.jsx("span",{className:"px-2 py-0.5 bg-green-900/50 text-green-300 rounded font-mono text-xs",children:l.execution_id})]}),l.objective_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Objective:"}),e.jsx("span",{className:"px-2 py-0.5 bg-yellow-900/50 text-yellow-300 rounded font-mono text-xs",children:l.objective_id})]}),!l.investigation_id&&!l.intent_id&&!l.execution_id&&!l.objective_id&&e.jsx("div",{className:"text-gray-600 italic",children:"No linked entities"})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Content Preview"}),N?e.jsx("div",{className:"bg-gray-950 border border-gray-800 rounded p-4 text-center text-gray-500",children:e.jsx("div",{className:"animate-pulse",children:"Loading content..."})}):$(l.mime_type)?f?e.jsx("div",{className:"bg-gray-950 border border-gray-800 rounded p-4 max-h-[400px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:f.length>1e4?f.substring(0,1e4)+` +import{e as L,j as e,r as m}from"./index-C0nK3ekl.js";import{P}from"./PageLayout-D94mSHCV.js";async function R(s={}){return L.get("/investigations",s)}async function D(s){return L.get(`/investigations/${s}`)}async function G(s,a){return L.fetch(`/investigations/${s}`,{method:"PATCH",body:JSON.stringify(a)})}async function O(s){await L.delete(`/investigations/${s}`)}async function Y(s={}){return L.get("/artifacts",s)}async function U(s){const a=await fetch(`/api/v1/artifacts/${s}/content`,{credentials:"include"});if(!a.ok)throw new Error(`Failed to fetch artifact content: ${a.statusText}`);return a.text()}async function K(s){return(await L.get(`/intents/${s}/timeline`)).timeline}async function J(s){return(await L.get(`/intents/${s}/graph`)).graph}async function q(s){return(await L.get(`/intents/${s}/explanation`)).explanation}const Q={open:{label:"Open",color:"text-blue-400",bg:"bg-blue-900/30 border-blue-700/50"},investigating:{label:"Investigating",color:"text-yellow-400",bg:"bg-yellow-900/30 border-yellow-700/50"},resolved:{label:"Resolved",color:"text-green-400",bg:"bg-green-900/30 border-green-700/50"},archived:{label:"Archived",color:"text-gray-500",bg:"bg-gray-800/30 border-gray-700/50"}};function T({status:s,size:a="md"}){const o=Q[s],t=a==="sm"?"text-xs px-2 py-0.5":"text-sm px-2.5 py-1";return e.jsx("span",{className:`inline-flex items-center font-medium border rounded ${o.bg} ${o.color} ${t}`,children:o.label})}function F({onSelectInvestigation:s}){const[a,o]=m.useState([]),[t,c]=m.useState(!0),[h,g]=m.useState(null),[l,x]=m.useState("all");m.useEffect(()=>{f()},[l]);const f=async()=>{try{c(!0),g(null);const N=await R(l==="all"?{}:{status:l});o(N.investigations)}catch(n){console.error("Failed to load investigations:",n),g(n.message||"Failed to load investigations")}finally{c(!1)}},j=n=>{s?s(n):console.log("Navigate to investigation:",n)},p=n=>{const N=new Date(n),k=new Date().getTime()-N.getTime(),w=Math.floor(k/6e4),y=Math.floor(k/36e5),_=Math.floor(k/864e5);return w<1?"Just now":w<60?`${w}m ago`:y<24?`${y}h ago`:_<7?`${_}d ago`:N.toLocaleDateString()};return t?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsxs("div",{className:"text-center",children:[e.jsxs("svg",{className:"animate-spin h-8 w-8 text-blue-400 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e.jsx("p",{className:"text-gray-400",children:"Loading investigations..."})]})}):h?e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 mr-3 flex-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-red-300 font-medium mb-1",children:"Failed to Load Investigations"}),e.jsx("p",{className:"text-red-400/80 text-sm",children:h}),e.jsx("button",{onClick:f,className:"mt-3 text-sm text-red-300 hover:text-red-200 underline",children:"Try again"})]})]})}):a.length===0?e.jsx("div",{className:"bg-gray-800/50 border border-gray-700 rounded-lg p-12 text-center",children:e.jsxs("div",{className:"max-w-md mx-auto",children:[e.jsx("div",{className:"text-6xl mb-4",children:"🔍"}),e.jsx("h3",{className:"text-xl font-semibold text-white mb-2",children:l==="all"?"No Investigations":`No ${l} Investigations`}),e.jsx("p",{className:"text-gray-400 mb-6",children:l==="all"?"No investigations have been created yet. Start an investigation to track incident analysis, evidence collection, and resolution.":`No investigations with status "${l}". Try a different filter.`}),l!=="all"&&e.jsx("button",{onClick:()=>x("all"),className:"text-blue-400 hover:text-blue-300 text-sm font-medium",children:"Show all investigations"})]})}):e.jsxs("div",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("div",{className:"flex gap-2",children:["all","open","investigating","resolved","archived"].map(n=>e.jsx("button",{onClick:()=>x(n),className:`px-3 py-1.5 text-sm font-medium rounded border transition-colors ${l===n?"bg-blue-600 border-blue-500 text-white":"bg-gray-800 border-gray-700 text-gray-400 hover:text-gray-300 hover:border-gray-600"}`,children:n==="all"?"All":n.charAt(0).toUpperCase()+n.slice(1)},n))}),e.jsxs("div",{className:"text-sm text-gray-500",children:[a.length," investigation",a.length!==1?"s":""]})]}),e.jsx("div",{className:"grid gap-4",children:a.map(n=>e.jsxs("div",{onClick:()=>j(n.investigation_id),className:"bg-gray-800 border border-gray-700 rounded-lg p-5 hover:border-gray-600 cursor-pointer transition-all hover:shadow-lg",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-white font-semibold text-lg mb-1 truncate",children:n.name}),n.description&&e.jsx("p",{className:"text-gray-400 text-sm line-clamp-2",children:n.description})]}),e.jsx(T,{status:n.status})]}),e.jsxs("div",{className:"flex items-center gap-6 text-sm text-gray-500",children:[n.objective_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),e.jsxs("span",{children:[n.objective_count," objective",n.objective_count!==1?"s":""]})]}),n.intent_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),e.jsxs("span",{children:[n.intent_count," intent",n.intent_count!==1?"s":""]})]}),n.artifact_count!==void 0&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsxs("span",{children:[n.artifact_count," artifact",n.artifact_count!==1?"s":""]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-4",children:[e.jsxs("span",{children:["Created ",p(n.created_at)]}),n.updated_at!==n.created_at&&e.jsxs("span",{children:["Updated ",p(n.updated_at)]})]})]})]},n.investigation_id))})]})}const E=[{id:"investigation",label:"Investigation",icon:"📋",types:["investigation_workspace","investigation_notes","investigation_report"]},{id:"trace",label:"Traces",icon:"🔍",types:["trace","intent_trace","execution_graph","timeline_export"]},{id:"execution",label:"Execution",icon:"⚙️",types:["execution_output","execution_stdout","execution_stderr","verification_report"]},{id:"objective",label:"Objectives",icon:"🎯",types:["objective_history","objective_analysis"]},{id:"incident",label:"Incidents",icon:"🚨",types:["incident_timeline","incident_postmortem"]},{id:"system",label:"System",icon:"🖥️",types:["state_snapshot","config_snapshot","system_snapshot"]}];function M(s){if(s===0)return"0 B";const a=1024,o=["B","KB","MB","GB"],t=Math.floor(Math.log(s)/Math.log(a));return`${parseFloat((s/Math.pow(a,t)).toFixed(2))} ${o[t]}`}function C(s){const a=new Date(s),o=new Date,t=o.getTime()-a.getTime(),c=Math.floor(t/6e4),h=Math.floor(t/36e5),g=Math.floor(t/864e5);return c<1?"just now":c<60?`${c}m ago`:h<24?`${h}h ago`:g<7?`${g}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:a.getFullYear()!==o.getFullYear()?"numeric":void 0})}function $(s){return["text/plain","text/markdown","application/json","text/html","text/csv"].some(o=>s.startsWith(o))}function X(s){for(const a of E)if(a.types.includes(s))return a;return null}function V({investigationId:s,selectedArtifactId:a,onSelectArtifact:o}){const[t,c]=m.useState([]),[h,g]=m.useState(a||null),[l,x]=m.useState(null),[f,j]=m.useState(null),[p,n]=m.useState(!0),[N,i]=m.useState(!1),[k,w]=m.useState(null);m.useEffect(()=>{y()},[s]),m.useEffect(()=>{h?_(h):(x(null),j(null))},[h]);async function y(){try{n(!0),w(null);const d=await Y({investigation_id:s,limit:200});c(d.artifacts),h&&!d.artifacts.find(b=>b.artifact_id===h)&&(g(null),o==null||o(null))}catch(d){console.error("Failed to load artifacts:",d),w(d.message||"Failed to load artifacts")}finally{n(!1)}}async function _(d){const b=t.find(u=>u.artifact_id===d);if(b)if(x(b),$(b.mime_type))try{i(!0);const u=await U(d);j(u)}catch(u){console.error("Failed to load artifact content:",u),j(`[Error loading content: ${u.message}]`)}finally{i(!1)}else j(null)}function v(d){g(d),o==null||o(d)}const r=new Map;for(const d of t){const b=X(d.artifact_type),u=(b==null?void 0:b.id)||"other";r.has(u)||r.set(u,[]),r.get(u).push(d)}return p?e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-1",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 animate-pulse h-96"})}),e.jsx("div",{className:"col-span-2",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 animate-pulse h-96"})})]}):k?e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-red-300 mb-2",children:"Failed to load artifacts"}),e.jsx("p",{className:"text-red-400 mb-4",children:k}),e.jsx("button",{onClick:y,className:"px-4 py-2 bg-red-700 text-white rounded hover:bg-red-600",children:"Retry"})]})]})}):t.length===0?e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-600 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No artifacts yet"}),e.jsx("p",{className:"text-gray-400",children:"No artifacts are linked to this investigation."})]})}):e.jsxs("div",{className:"grid grid-cols-3 gap-6",children:[e.jsx("div",{className:"col-span-1 space-y-4",children:e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 max-h-[600px] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Artifacts"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[t.length," total"]})]}),e.jsxs("div",{className:"space-y-6",children:[E.map(d=>{const b=r.get(d.id)||[];return b.length===0?null:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-medium text-gray-400",children:[e.jsx("span",{children:d.icon}),e.jsx("span",{children:d.label}),e.jsx("span",{className:"ml-auto text-gray-600",children:b.length})]}),e.jsx("div",{className:"space-y-1",children:b.map(u=>e.jsxs("button",{onClick:()=>v(u.artifact_id),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${h===u.artifact_id?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-700"}`,children:[e.jsx("div",{className:"font-medium truncate",children:u.name}),e.jsxs("div",{className:`text-xs mt-0.5 ${h===u.artifact_id?"text-blue-200":"text-gray-500"}`,children:[C(u.created_at)," · ",M(u.size_bytes)]})]},u.artifact_id))})]},d.id)}),r.has("other")&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2 text-sm font-medium text-gray-400",children:[e.jsx("span",{children:"📦"}),e.jsx("span",{children:"Other"}),e.jsx("span",{className:"ml-auto text-gray-600",children:r.get("other").length})]}),e.jsx("div",{className:"space-y-1",children:r.get("other").map(d=>e.jsxs("button",{onClick:()=>v(d.artifact_id),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${h===d.artifact_id?"bg-blue-600 text-white":"text-gray-300 hover:bg-gray-700"}`,children:[e.jsx("div",{className:"font-medium truncate",children:d.name}),e.jsxs("div",{className:`text-xs mt-0.5 ${h===d.artifact_id?"text-blue-200":"text-gray-500"}`,children:[C(d.created_at)," · ",M(d.size_bytes)]})]},d.artifact_id))})]})]})]})}),e.jsx("div",{className:"col-span-2",children:e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 max-h-[600px] overflow-y-auto",children:l?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:l.name}),e.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[e.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded",children:l.artifact_type}),e.jsx("span",{className:"px-2 py-1 bg-gray-700 text-gray-300 rounded",children:l.mime_type}),$(l.mime_type)&&e.jsx("span",{className:"px-2 py-1 bg-green-900/50 text-green-300 rounded",children:"Previewable"})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Metadata"}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"ID"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.artifact_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Created"}),e.jsx("div",{className:"text-gray-300",children:C(l.created_at)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Size"}),e.jsx("div",{className:"text-gray-300",children:M(l.size_bytes)})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Created By"}),e.jsx("div",{className:"text-gray-300",children:l.created_by})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Integrity Hash"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.content_hash})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("div",{className:"text-gray-500 mb-1",children:"Path"}),e.jsx("div",{className:"text-gray-300 font-mono text-xs break-all",children:l.file_path})]})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Linked Entities"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[l.investigation_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Investigation:"}),e.jsx("span",{className:"px-2 py-0.5 bg-blue-900/50 text-blue-300 rounded font-mono text-xs",children:l.investigation_id})]}),l.intent_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Intent:"}),e.jsx("span",{className:"px-2 py-0.5 bg-amber-900/50 text-amber-300 rounded font-mono text-xs",children:l.intent_id})]}),l.execution_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Execution:"}),e.jsx("span",{className:"px-2 py-0.5 bg-green-900/50 text-green-300 rounded font-mono text-xs",children:l.execution_id})]}),l.objective_id&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-gray-500",children:"Objective:"}),e.jsx("span",{className:"px-2 py-0.5 bg-yellow-900/50 text-yellow-300 rounded font-mono text-xs",children:l.objective_id})]}),!l.investigation_id&&!l.intent_id&&!l.execution_id&&!l.objective_id&&e.jsx("div",{className:"text-gray-600 italic",children:"No linked entities"})]})]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded-lg p-4",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-400 mb-3",children:"Content Preview"}),N?e.jsx("div",{className:"bg-gray-950 border border-gray-800 rounded p-4 text-center text-gray-500",children:e.jsx("div",{className:"animate-pulse",children:"Loading content..."})}):$(l.mime_type)?f?e.jsx("div",{className:"bg-gray-950 border border-gray-800 rounded p-4 max-h-[400px] overflow-auto",children:e.jsx("pre",{className:"text-xs text-gray-300 whitespace-pre-wrap font-mono leading-relaxed",children:f.length>1e4?f.substring(0,1e4)+` [Content truncated - showing first 10KB]`:f})}):e.jsx("div",{className:"bg-gray-950 border border-gray-800 rounded p-4 text-center text-gray-500",children:"No content available"}):e.jsxs("div",{className:"bg-gray-950 border border-gray-800 rounded p-6 text-center",children:[e.jsxs("svg",{className:"w-12 h-12 text-gray-700 mx-auto mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})]}),e.jsx("p",{className:"text-sm text-gray-500 mb-1",children:"Preview unavailable"}),e.jsxs("p",{className:"text-xs text-gray-600",children:["Content type: ",l.mime_type]})]})]})]}):e.jsx("div",{className:"flex items-center justify-center h-full min-h-[400px] text-gray-600",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 mx-auto mb-4 text-gray-700",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsx("p",{className:"text-base",children:"Select an artifact to inspect its metadata and preview"})]})})})})]})}function S(s){const a=new Date(s),t=new Date().getTime()-a.getTime(),c=Math.floor(t/6e4),h=Math.floor(t/36e5),g=Math.floor(t/864e5);return c<1?"just now":c<60?`${c}m ago`:h<24?`${h}h ago`:g<7?`${g}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Z(s){return{intent:"📥",normalization:"⚙️",resolution:"🔧",policy:"📋",governance:"⚖️",reconciliation:"🔄",execution:"▶️",verification:"✓",outcome:"🎯",artifact_export:"📦",other:"•"}[s]||"•"}function I(s){const a={allowed:"text-green-400 bg-green-900/30",succeeded:"text-green-400 bg-green-900/30",denied:"text-red-400 bg-red-900/30",failed:"text-red-400 bg-red-900/30",started:"text-blue-400 bg-blue-900/30",pending:"text-yellow-400 bg-yellow-900/30",partial:"text-orange-400 bg-orange-900/30",unknown:"text-gray-400 bg-gray-800"};return s&&a[s]||a.unknown}function ee(s){return{allowed:"✓",denied:"✗",partial:"⚠",unknown:"?"}[s]||"?"}function te(s){const a={allowed:"text-green-400 bg-green-900/50 border-green-700",denied:"text-red-400 bg-red-900/50 border-red-700",partial:"text-orange-400 bg-orange-900/50 border-orange-700",unknown:"text-gray-400 bg-gray-900/50 border-gray-700"};return a[s]||a.unknown}function H({investigationId:s,intentId:a,traceId:o,className:t=""}){var _,v;const[c,h]=m.useState(null),[g,l]=m.useState(null),[x,f]=m.useState(null),[j,p]=m.useState(!0),[n,N]=m.useState(null),i=a||o;m.useEffect(()=>{i?k(i):p(!1)},[i,s]);async function k(r){try{p(!0),N(null);const[d,b,u]=await Promise.allSettled([K(r),J(r),q(r)]);if(d.status==="fulfilled"&&h(d.value),b.status==="fulfilled"&&l(b.value),u.status==="fulfilled"&&f(u.value),d.status==="rejected"&&b.status==="rejected"&&u.status==="rejected")throw new Error("Failed to load trace data")}catch(d){console.error("Failed to load trace data:",d),N(d.message||"Failed to load trace timeline")}finally{p(!1)}}if(j)return e.jsxs("div",{className:`space-y-4 ${t}`,children:[e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 animate-pulse h-32"}),e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 animate-pulse h-64"})]});if(n&&!c)return e.jsx("div",{className:`bg-red-900/20 border border-red-700/50 rounded-lg p-6 ${t}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-red-300 mb-2",children:"Failed to load trace timeline"}),e.jsx("p",{className:"text-red-400 mb-4",children:n}),e.jsx("button",{onClick:()=>i&&k(i),className:"px-4 py-2 bg-red-700 text-white rounded hover:bg-red-600",children:"Retry"})]})]})});if(!i&&!c)return e.jsx("div",{className:`bg-gray-800 border border-gray-700 rounded-lg p-12 ${t}`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-600 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No trace timeline available"}),e.jsx("p",{className:"text-gray-400",children:"No trace timeline is available for this investigation yet."})]})});if(c&&c.events.length===0)return e.jsx("div",{className:`bg-gray-800 border border-gray-700 rounded-lg p-12 ${t}`,children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-600 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Partial timeline"}),e.jsx("p",{className:"text-gray-400",children:"Trace found but no timeline events were reconstructed."})]})});const w=(c==null?void 0:c.events)||[],y=w.length>0?w[w.length-1]:null;return e.jsxs("div",{className:`space-y-6 ${t}`,children:[c&&e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Current Status"}),e.jsxs("div",{className:"flex items-center gap-2",children:[(y==null?void 0:y.status)&&e.jsx("span",{className:`px-2 py-1 text-xs rounded ${I(y.status)}`,children:y.status}),e.jsx("span",{className:"text-white font-medium",children:(y==null?void 0:y.title)||((_=c.summary)==null?void 0:_.status)||"Unknown"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Events"}),e.jsx("div",{className:"text-white font-medium",children:w.length})]}),((v=c.summary)==null?void 0:v.last_event)&&e.jsxs("div",{className:"text-right",children:[e.jsx("div",{className:"text-sm text-gray-500 mb-1",children:"Last Activity"}),e.jsx("div",{className:"text-white font-medium",children:S(c.summary.last_event)})]})]})}),x&&e.jsxs("div",{className:`border-2 rounded-lg p-5 ${te(x.decision)}`,children:[e.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[e.jsx("div",{className:"text-3xl",children:ee(x.decision)}),e.jsxs("div",{children:[e.jsxs("h3",{className:"text-lg font-bold mb-1",children:["Why Vienna ",x.decision," it"]}),e.jsx("p",{className:"text-sm opacity-90",children:x.summary})]})]}),(x.policy_evaluation||x.governance_decision||x.bounded_authority)&&e.jsxs("div",{className:"mt-4 space-y-2 text-sm border-t border-current/20 pt-4",children:[x.policy_evaluation&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Policy: "}),e.jsx("span",{className:"opacity-80",children:x.policy_evaluation})]}),x.governance_decision&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Governance: "}),e.jsx("span",{className:"opacity-80",children:x.governance_decision})]}),x.bounded_authority&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Authority: "}),e.jsx("span",{className:"opacity-80",children:x.bounded_authority})]}),x.safe_mode_status&&e.jsxs("div",{children:[e.jsx("span",{className:"font-semibold",children:"Safe Mode: "}),e.jsx("span",{className:"opacity-80",children:x.safe_mode_status})]})]}),x.reasons&&x.reasons.length>0&&e.jsxs("div",{className:"mt-4 border-t border-current/20 pt-4",children:[e.jsx("div",{className:"text-sm font-semibold mb-2",children:"Decision Factors:"}),e.jsx("ul",{className:"space-y-1 text-sm opacity-80",children:x.reasons.map((r,d)=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:"mt-1",children:"•"}),e.jsx("span",{children:r})]},d))})]})]}),c&&w.length>0&&e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Execution Timeline"}),e.jsx("div",{className:"space-y-3",children:w.map((r,d)=>e.jsx("div",{className:"border-l-2 border-gray-700 pl-4 py-2 hover:border-blue-600 transition-colors",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"text-xl flex-shrink-0",children:Z(r.kind)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("h4",{className:"font-medium text-white",children:r.title}),r.status&&e.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${I(r.status)}`,children:r.status}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-gray-700 text-gray-400 rounded",children:r.kind})]}),r.description&&e.jsx("p",{className:"text-sm text-gray-400 mb-2",children:r.description}),r.explanation&&e.jsxs("div",{className:"bg-gray-900/50 border border-gray-700 rounded p-3 mb-2",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-1",children:"Explanation:"}),e.jsx("p",{className:"text-sm text-gray-300",children:r.explanation})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs text-gray-600",children:[r.timestamp&&e.jsx("span",{children:S(r.timestamp)}),r.actor&&e.jsxs("span",{children:["Actor: ",r.actor]}),r.source&&e.jsxs("span",{children:["Source: ",r.source]})]}),(r.intent_id||r.execution_id||r.objective_id||r.artifact_id)&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2",children:[r.intent_id&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-amber-900/50 text-amber-300 rounded font-mono",children:["intent:",r.intent_id.substring(0,8)]}),r.execution_id&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-green-900/50 text-green-300 rounded font-mono",children:["exec:",r.execution_id.substring(0,8)]}),r.objective_id&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-yellow-900/50 text-yellow-300 rounded font-mono",children:["obj:",r.objective_id.substring(0,8)]}),r.artifact_id&&e.jsxs("span",{className:"px-2 py-0.5 text-xs bg-blue-900/50 text-blue-300 rounded font-mono",children:["artifact:",r.artifact_id.substring(0,8)]})]})]})]})},r.id||d))})]}),g&&g.nodes.length>0&&e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Execution Graph"}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded p-4",children:[e.jsx("div",{className:"space-y-3",children:g.nodes.map(r=>e.jsxs("div",{className:"flex items-center gap-3 text-sm",children:[e.jsx("div",{className:"w-32 flex-shrink-0",children:e.jsx("span",{className:"px-2 py-1 bg-gray-800 text-gray-300 rounded text-xs",children:r.kind})}),e.jsx("div",{className:"flex-1 font-mono text-gray-400",children:r.label}),r.status&&e.jsx("span",{className:`px-2 py-0.5 text-xs rounded ${I(r.status)}`,children:r.status})]},r.id))}),g.edges.length>0&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-gray-700",children:[e.jsx("div",{className:"text-xs text-gray-500 mb-2",children:"Flow:"}),e.jsx("div",{className:"space-y-1 text-xs text-gray-600",children:g.edges.map((r,d)=>e.jsxs("div",{className:"font-mono",children:[r.from," → ",r.to,r.label&&e.jsxs("span",{className:"ml-2 text-gray-500",children:["(",r.label,")"]})]},d))})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-700",children:e.jsx("p",{className:"text-xs text-gray-600 italic",children:"Full graph visualization will be added in a future iteration."})})]})]}),(!g||g.nodes.length===0)&&c&&e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-4",children:"Execution Graph"}),e.jsxs("div",{className:"bg-gray-900/50 border border-gray-700 rounded p-8 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-gray-700 mx-auto mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),e.jsx("p",{className:"text-sm text-gray-500",children:"Graph preview unavailable for this trace"})]})]})]})}function B(s){const a=new Date(s),t=new Date().getTime()-a.getTime(),c=Math.floor(t/6e4),h=Math.floor(t/36e5),g=Math.floor(t/864e5);return c<1?"just now":c<60?`${c}m ago`:h<24?`${h}h ago`:g<7?`${g}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric"})}function A({investigationId:s,onSelectIntent:a,onSelectArtifact:o}){const[t,c]=m.useState(null),[h,g]=m.useState(!0),[l,x]=m.useState(null);m.useEffect(()=>{f()},[s]);async function f(){try{g(!0),x(null);const i=await D(s);c(i)}catch(i){console.error("Failed to load related entities:",i),x(i.message||"Failed to load related entities")}finally{g(!1)}}if(h)return e.jsxs("div",{className:"space-y-4 animate-pulse",children:[e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5 h-32"}),e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5 h-32"}),e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5 h-32"})]});if(l||!t)return e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-red-300 mb-2",children:"Failed to load related entities"}),e.jsx("p",{className:"text-red-400 mb-4",children:l||"Unknown error"}),e.jsx("button",{onClick:f,className:"px-4 py-2 bg-red-700 text-white rounded hover:bg-red-600",children:"Retry"})]})]})});const j=t.objectives||[],p=t.intents||[],n=t.artifacts||[],N=j.length+p.length+n.length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Related Entities"}),e.jsxs("span",{className:"text-sm text-gray-500",children:[N," total"]})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})}),"Objectives"]}),e.jsx("span",{className:"text-sm text-gray-500",children:j.length})]}),j.length===0?e.jsx("div",{className:"text-sm text-gray-600 italic",children:"No linked objectives"}):e.jsx("div",{className:"space-y-2",children:j.map(i=>{var k;return e.jsxs("div",{className:"bg-gray-900/50 border border-gray-700 rounded p-3 hover:bg-gray-900 transition-colors",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("div",{className:"font-medium text-white text-sm",children:i.name||i.objective_type||"Unnamed objective"}),i.status&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-blue-900/50 text-blue-300 rounded",children:i.status})]}),i.description&&e.jsx("div",{className:"text-xs text-gray-400 mb-2",children:i.description}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600",children:[e.jsx("span",{className:"font-mono",children:(k=i.objective_id||i.id)==null?void 0:k.substring(0,12)}),i.created_at&&e.jsx("span",{children:B(i.created_at)})]})]},i.objective_id||i.id)})})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),"Intents"]}),e.jsx("span",{className:"text-sm text-gray-500",children:p.length})]}),p.length===0?e.jsx("div",{className:"text-sm text-gray-600 italic",children:"No linked intents"}):e.jsx("div",{className:"space-y-2",children:p.map(i=>e.jsxs("button",{onClick:()=>a==null?void 0:a(i.intent_id),className:"w-full bg-gray-900/50 border border-gray-700 rounded p-3 hover:bg-gray-900 hover:border-amber-600 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("div",{className:"font-medium text-white text-sm",children:i.intent_type||"Unknown intent"}),i.status&&e.jsx("span",{className:"px-2 py-0.5 text-xs bg-amber-900/50 text-amber-300 rounded",children:i.status})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600",children:[e.jsx("span",{className:"font-mono",children:i.intent_id.substring(0,12)}),i.submitted_at&&e.jsx("span",{children:B(i.submitted_at)})]}),a&&e.jsx("div",{className:"mt-2 text-xs text-amber-400",children:"Click to view trace timeline →"})]},i.intent_id))})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h4",{className:"text-white font-medium flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})}),"Artifacts"]}),e.jsx("span",{className:"text-sm text-gray-500",children:n.length})]}),n.length===0?e.jsx("div",{className:"text-sm text-gray-600 italic",children:"No linked artifacts"}):e.jsxs("div",{className:"space-y-2",children:[n.slice(0,5).map(i=>e.jsxs("button",{onClick:()=>o==null?void 0:o(i.artifact_id),className:"w-full bg-gray-900/50 border border-gray-700 rounded p-3 hover:bg-gray-900 hover:border-green-600 transition-colors text-left",children:[e.jsxs("div",{className:"flex items-start justify-between mb-1",children:[e.jsx("div",{className:"font-medium text-white text-sm truncate",children:i.name}),e.jsx("span",{className:"px-2 py-0.5 text-xs bg-green-900/50 text-green-300 rounded flex-shrink-0",children:i.artifact_type})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-gray-600",children:[e.jsx("span",{className:"font-mono",children:i.artifact_id.substring(0,12)}),e.jsx("span",{children:B(i.created_at)}),e.jsxs("span",{children:[(i.size_bytes/1024).toFixed(1)," KB"]})]}),o&&e.jsx("div",{className:"mt-2 text-xs text-green-400",children:"Click to preview artifact →"})]},i.artifact_id)),n.length>5&&e.jsx("div",{className:"text-center py-2",children:e.jsxs("span",{className:"text-sm text-gray-500",children:["... and ",n.length-5," more artifacts"]})})]})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-5",children:[e.jsxs("h4",{className:"text-white font-medium mb-4 flex items-center gap-2",children:[e.jsx("svg",{className:"w-5 h-5 text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),"Investigation Graph"]}),e.jsxs("div",{className:"bg-gray-900 border border-gray-700 rounded p-4",children:[e.jsxs("div",{className:"space-y-3 text-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-400",children:"Investigation"}),e.jsx("span",{className:"text-white font-medium",children:t.name})]}),j.length>0&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-700 pt-3",children:[e.jsx("span",{className:"text-gray-400",children:"Links to objectives"}),e.jsx("span",{className:"text-blue-400 font-medium",children:j.length})]}),p.length>0&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-700 pt-3",children:[e.jsx("span",{className:"text-gray-400",children:"Links to intents"}),e.jsx("span",{className:"text-amber-400 font-medium",children:p.length})]}),n.length>0&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-700 pt-3",children:[e.jsx("span",{className:"text-gray-400",children:"Contains artifacts"}),e.jsx("span",{className:"text-green-400 font-medium",children:n.length})]}),t.objective_id&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-700 pt-3",children:[e.jsx("span",{className:"text-gray-400",children:"Parent objective"}),e.jsx("span",{className:"text-yellow-400 font-mono text-xs",children:t.objective_id.substring(0,12)})]}),t.incident_id&&e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-700 pt-3",children:[e.jsx("span",{className:"text-gray-400",children:"Parent incident"}),e.jsx("span",{className:"text-red-400 font-mono text-xs",children:t.incident_id.substring(0,12)})]}),N===0&&!t.objective_id&&!t.incident_id&&e.jsx("div",{className:"text-center py-6 text-gray-600 italic",children:"No relationships discovered yet"})]}),e.jsx("div",{className:"mt-4 pt-4 border-t border-gray-700",children:e.jsx("p",{className:"text-xs text-gray-600 italic",children:"Visual graph rendering will be added in a future iteration."})})]})]}),N===0&&e.jsxs("div",{className:"bg-gray-900/50 border border-gray-700 rounded-lg p-8 text-center",children:[e.jsx("svg",{className:"w-12 h-12 text-gray-700 mx-auto mb-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"})}),e.jsx("h4",{className:"text-white font-medium mb-2",children:"No related entities yet"}),e.jsx("p",{className:"text-sm text-gray-500",children:"Entities will appear here as they are linked to this investigation."})]})]})}function se({investigationId:s,onClose:a,onUpdate:o}){var _;const[t,c]=m.useState(null),[h,g]=m.useState(!0),[l,x]=m.useState(null),[f,j]=m.useState(!1);m.useEffect(()=>{p()},[s]);async function p(){try{g(!0),x(null);const v=await D(s);c(v)}catch(v){console.error("Failed to load investigation:",v),x(v.message||"Failed to load investigation")}finally{g(!1)}}async function n(v){if(t)try{j(!0),await G(t.investigation_id,{status:v}),await p(),o==null||o()}catch(r){console.error("Failed to update status:",r),x(r.message||"Failed to update status")}finally{j(!1)}}async function N(){if(t&&confirm("Archive this investigation? It can be restored later."))try{j(!0),await O(t.investigation_id),o==null||o(),a==null||a()}catch(v){console.error("Failed to archive investigation:",v),x(v.message||"Failed to archive investigation")}finally{j(!1)}}function i(v){const r=new Date(v),d=new Date,b=d.getTime()-r.getTime(),u=Math.floor(b/6e4),W=Math.floor(b/36e5),z=Math.floor(b/864e5);return u<1?"just now":u<60?`${u}m ago`:W<24?`${W}h ago`:z<7?`${z}d ago`:r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:r.getFullYear()!==d.getFullYear()?"numeric":void 0})}if(h)return e.jsxs("div",{className:"space-y-6 animate-pulse",children:[e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 h-48"}),e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 h-32"}),e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6 h-64"})]});if(l&&!t)return e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-red-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-red-300 mb-2",children:"Failed to load investigation"}),e.jsx("p",{className:"text-red-400 mb-4",children:l}),e.jsx("button",{onClick:p,className:"px-4 py-2 bg-red-700 text-white rounded hover:bg-red-600",children:"Retry"})]})]})});if(!t)return e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("svg",{className:"w-6 h-6 text-gray-400 flex-shrink-0 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"Investigation not found"}),e.jsx("p",{className:"text-gray-400",children:"The requested investigation could not be found."})]})]})});const k=t.status==="open",w=t.status==="investigating",y=t.status==="resolved";return e.jsxs("div",{className:"space-y-6",children:[l&&e.jsx("div",{className:"bg-red-900/20 border border-red-700/50 rounded-lg p-4",children:e.jsx("p",{className:"text-sm text-red-300",children:l})}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-2xl font-bold text-white mb-2",children:t.name}),t.description&&e.jsx("p",{className:"text-gray-400 text-base leading-relaxed",children:t.description})]}),e.jsxs("div",{className:"flex items-center gap-3 ml-4",children:[e.jsx(T,{status:t.status}),a&&e.jsx("button",{onClick:a,className:"text-gray-400 hover:text-gray-300 transition-colors",title:"Close",children:e.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-4 text-sm text-gray-500",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Created ",i(t.created_at)]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Updated ",i(t.updated_at)]}),e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})}),t.created_by]}),e.jsxs("span",{className:"flex items-center gap-1.5 text-gray-600",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 20l4-16m2 16l4-16M6 9h14M4 15h14"})}),t.investigation_id]})]})]}),e.jsxs("div",{className:"grid grid-cols-4 gap-4",children:[e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:bg-gray-750 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-400",children:"Objectives"}),e.jsx("svg",{className:"w-5 h-5 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"})})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:t.objective_count||0})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:bg-gray-750 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-400",children:"Intents"}),e.jsx("svg",{className:"w-5 h-5 text-amber-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:t.intent_count||0})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:bg-gray-750 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-400",children:"Artifacts"}),e.jsx("svg",{className:"w-5 h-5 text-green-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z"})})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:t.artifact_count||0})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-4 hover:bg-gray-750 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("div",{className:"text-sm font-medium text-gray-400",children:"Traces"}),e.jsx("svg",{className:"w-5 h-5 text-yellow-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})]}),e.jsx("div",{className:"text-2xl font-bold text-white",children:t.intent_count||0})]})]}),e.jsxs("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-white",children:"Investigation Notes"}),e.jsx("span",{className:"text-xs text-gray-500 bg-gray-900 px-2 py-1 rounded",children:"READ-ONLY"})]}),e.jsx("div",{className:"bg-gray-900 border border-gray-700 rounded p-4",children:t.description?e.jsx("div",{className:"text-gray-300 whitespace-pre-wrap leading-relaxed",children:t.description}):e.jsx("p",{className:"text-gray-500 text-sm italic",children:"No notes recorded yet."})}),e.jsx("p",{className:"text-xs text-gray-600 mt-2",children:"Note: Markdown editor integration will be added in a future update."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{children:e.jsx(V,{investigationId:t.investigation_id})}),e.jsx("div",{children:t.intents&&t.intents.length>0?e.jsx(H,{investigationId:t.investigation_id,intentId:(_=t.intents[0])==null?void 0:_.intent_id}):e.jsx("div",{className:"bg-gray-800 border border-gray-700 rounded-lg p-12",children:e.jsxs("div",{className:"text-center",children:[e.jsx("svg",{className:"w-16 h-16 text-gray-600 mx-auto mb-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsx("h3",{className:"text-lg font-semibold text-white mb-2",children:"No trace timeline available"}),e.jsx("p",{className:"text-gray-400",children:"No intents are linked to this investigation yet."})]})})}),e.jsx("div",{children:e.jsx(A,{investigationId:t.investigation_id})})]}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[k&&e.jsx("button",{onClick:()=>n("investigating"),disabled:f,className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Mark Investigating"}),w&&e.jsx("button",{onClick:()=>n("resolved"),disabled:f,className:"px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Mark Resolved"}),y&&e.jsx("button",{onClick:()=>n("investigating"),disabled:f,className:"px-4 py-2 bg-yellow-600 text-white rounded hover:bg-yellow-700 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Reopen Investigation"}),e.jsx("button",{onClick:N,disabled:f||t.status==="archived",className:"px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Archive"}),e.jsx("button",{onClick:p,disabled:f,className:"px-4 py-2 bg-gray-700 text-white rounded hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors ml-auto",title:"Refresh",children:e.jsx("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})})]})]})}function ne(){const[s,a]=m.useState("index"),[o,t]=m.useState(null),c=l=>{t(l),a("detail")},h=()=>{a("index"),t(null)},g=()=>{switch(s){case"index":return e.jsx(F,{onSelectInvestigation:c});case"detail":return o?e.jsx(se,{investigationId:o,onClose:h,onUpdate:()=>{}}):e.jsx("div",{className:"text-gray-500",children:"No investigation selected"});case"artifacts":return o?e.jsx(V,{investigationId:o}):e.jsx("div",{className:"text-gray-500",children:"No investigation selected"});case"traces":return e.jsx(H,{investigationId:o||void 0});case"related":return o?e.jsx(A,{investigationId:o}):e.jsx("div",{className:"text-gray-500",children:"No investigation selected"});default:return e.jsx(F,{onSelectInvestigation:c})}};return e.jsxs(P,{title:"Workspace",description:"Investigation environment",children:[e.jsxs("div",{className:"mb-6 flex items-center gap-4 border-b border-gray-700 pb-4",children:[e.jsx("button",{onClick:()=>a("index"),className:`px-4 py-2 text-sm font-medium rounded transition-colors ${s==="index"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-300 hover:bg-gray-800"}`,children:"Investigations"}),e.jsx("button",{onClick:()=>a("artifacts"),className:`px-4 py-2 text-sm font-medium rounded transition-colors ${s==="artifacts"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-300 hover:bg-gray-800"}`,children:"Artifacts"}),e.jsx("button",{onClick:()=>a("traces"),className:`px-4 py-2 text-sm font-medium rounded transition-colors ${s==="traces"?"bg-blue-600 text-white":"text-gray-400 hover:text-gray-300 hover:bg-gray-800"}`,children:"Traces"}),e.jsx("button",{onClick:()=>a("related"),disabled:!o,className:`px-4 py-2 text-sm font-medium rounded transition-colors ${s==="related"?"bg-blue-600 text-white":o?"text-gray-400 hover:text-gray-300 hover:bg-gray-800":"text-gray-600 cursor-not-allowed"}`,children:"Related"}),s!=="index"&&e.jsxs("button",{onClick:h,className:"ml-auto text-sm text-gray-400 hover:text-gray-300 flex items-center gap-1",children:[e.jsx("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 19l-7-7m0 0l7-7m-7 7h18"})}),"Back to Index"]})]}),g()]})}export{ne as WorkspacePage}; -//# sourceMappingURL=WorkspacePage-9pXkK0Q1.js.map +//# sourceMappingURL=WorkspacePage-C3FThH_4.js.map diff --git a/apps/console-proxy/public/assets/activity-C-iTiNlh.js b/apps/console-proxy/public/assets/activity-DFouDeMs.js similarity index 80% rename from apps/console-proxy/public/assets/activity-C-iTiNlh.js rename to apps/console-proxy/public/assets/activity-DFouDeMs.js index c0fe9245..9e70a402 100644 --- a/apps/console-proxy/public/assets/activity-C-iTiNlh.js +++ b/apps/console-proxy/public/assets/activity-DFouDeMs.js @@ -1,7 +1,7 @@ -import{c as t}from"./index-D_7YXFSJ.js";/** +import{c as t}from"./index-C0nK3ekl.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const c=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],o=t("activity",c);export{o as A}; -//# sourceMappingURL=activity-C-iTiNlh.js.map +//# sourceMappingURL=activity-DFouDeMs.js.map diff --git a/apps/console-proxy/public/assets/approvals-DjAVQ-Zj.js b/apps/console-proxy/public/assets/approvals-DjAVQ-Zj.js deleted file mode 100644 index b4b56c13..00000000 --- a/apps/console-proxy/public/assets/approvals-DjAVQ-Zj.js +++ /dev/null @@ -1,2 +0,0 @@ -import{a as t}from"./index-D_7YXFSJ.js";async function s(a){const n=new URLSearchParams;return a!=null&&a.status&&n.append("status",a.status),a!=null&&a.tier&&n.append("tier",a.tier),a!=null&&a.target_id&&n.append("target_id",a.target_id),a!=null&&a.limit&&n.append("limit",a.limit.toString()),await t.get(`/approvals?${n.toString()}`)}async function c(a){return await t.get(`/approvals/${a}`)}async function r(a,n,p){return await t.post(`/approvals/${a}/approve`,{reviewed_by:n,decision_reason:p||null})}async function u(a,n,p){return await t.post(`/approvals/${a}/deny`,{reviewed_by:n,decision_reason:p})}async function i(a,n,p){return await t.post("/approvals/bulk/approve",{approval_ids:a,reviewed_by:n,decision_reason:null})}async function v(a,n,p){return await t.post("/approvals/bulk/deny",{approval_ids:a,reviewed_by:n,decision_reason:p})}export{r as a,i as b,v as c,u as d,c as g,s as l}; -//# sourceMappingURL=approvals-DjAVQ-Zj.js.map diff --git a/apps/console-proxy/public/assets/bot-CFwUaWgF.js b/apps/console-proxy/public/assets/bot-CFwUaWgF.js deleted file mode 100644 index 095230a2..00000000 --- a/apps/console-proxy/public/assets/bot-CFwUaWgF.js +++ /dev/null @@ -1,7 +0,0 @@ -import{c as t}from"./index-D_7YXFSJ.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const e=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],a=t("bot",e);export{a as B}; -//# sourceMappingURL=bot-CFwUaWgF.js.map diff --git a/apps/console-proxy/public/assets/circle-check-BIUeiM-B.js b/apps/console-proxy/public/assets/circle-check-BIUeiM-B.js deleted file mode 100644 index e9f394f6..00000000 --- a/apps/console-proxy/public/assets/circle-check-BIUeiM-B.js +++ /dev/null @@ -1,7 +0,0 @@ -import{c}from"./index-D_7YXFSJ.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],r=c("circle-check",e);export{r as C}; -//# sourceMappingURL=circle-check-BIUeiM-B.js.map diff --git a/apps/console-proxy/public/assets/circle-x-DJXSWLrE.js b/apps/console-proxy/public/assets/circle-x-DX5Kt33e.js similarity index 79% rename from apps/console-proxy/public/assets/circle-x-DJXSWLrE.js rename to apps/console-proxy/public/assets/circle-x-DX5Kt33e.js index caf0db83..da07d09c 100644 --- a/apps/console-proxy/public/assets/circle-x-DJXSWLrE.js +++ b/apps/console-proxy/public/assets/circle-x-DX5Kt33e.js @@ -1,7 +1,7 @@ -import{c}from"./index-D_7YXFSJ.js";/** +import{c}from"./index-C0nK3ekl.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const e=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],o=c("circle-x",e);export{o as C}; -//# sourceMappingURL=circle-x-DJXSWLrE.js.map +//# sourceMappingURL=circle-x-DX5Kt33e.js.map diff --git a/apps/console-proxy/public/assets/clock-DwbEOyPD.js b/apps/console-proxy/public/assets/clock-C0m9VzJk.js similarity index 78% rename from apps/console-proxy/public/assets/clock-DwbEOyPD.js rename to apps/console-proxy/public/assets/clock-C0m9VzJk.js index 2cfd49eb..5ec7bf5a 100644 --- a/apps/console-proxy/public/assets/clock-DwbEOyPD.js +++ b/apps/console-proxy/public/assets/clock-C0m9VzJk.js @@ -1,7 +1,7 @@ -import{c}from"./index-D_7YXFSJ.js";/** +import{c}from"./index-C0nK3ekl.js";/** * @license lucide-react v1.7.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */const o=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6l4 2",key:"mmk7yg"}]],r=c("clock",o);export{r as C}; -//# sourceMappingURL=clock-DwbEOyPD.js.map +//# sourceMappingURL=clock-C0m9VzJk.js.map diff --git a/apps/console-proxy/public/assets/copy-DPJWkP7J.js b/apps/console-proxy/public/assets/copy-DPJWkP7J.js deleted file mode 100644 index 9eddca3f..00000000 --- a/apps/console-proxy/public/assets/copy-DPJWkP7J.js +++ /dev/null @@ -1,12 +0,0 @@ -import{c as o}from"./index-D_7YXFSJ.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const c=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],a=o("code",c);/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const e=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],d=o("copy",e);export{d as C,a}; -//# sourceMappingURL=copy-DPJWkP7J.js.map diff --git a/apps/console-proxy/public/assets/eye-46CiQ26c.js b/apps/console-proxy/public/assets/eye-46CiQ26c.js deleted file mode 100644 index 47359077..00000000 --- a/apps/console-proxy/public/assets/eye-46CiQ26c.js +++ /dev/null @@ -1,7 +0,0 @@ -import{c}from"./index-D_7YXFSJ.js";/** - * @license lucide-react v1.7.0 - ISC - * - * This source code is licensed under the ISC license. - * See the LICENSE file in the root directory of this source tree. - */const e=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],r=c("eye",e);export{r as E}; -//# sourceMappingURL=eye-46CiQ26c.js.map diff --git a/apps/console-proxy/public/assets/fleet-Bmy_93a8.js b/apps/console-proxy/public/assets/fleet-ClHE8wrR.js similarity index 81% rename from apps/console-proxy/public/assets/fleet-Bmy_93a8.js rename to apps/console-proxy/public/assets/fleet-ClHE8wrR.js index 93e6e630..e609cbdd 100644 --- a/apps/console-proxy/public/assets/fleet-Bmy_93a8.js +++ b/apps/console-proxy/public/assets/fleet-ClHE8wrR.js @@ -1,2 +1,2 @@ -import{a as t}from"./index-D_7YXFSJ.js";const a={getOverview:()=>t.get("/fleet"),getSummary:()=>t.get("/fleet/summary"),getAlerts:()=>t.get("/fleet/alerts"),resolveAlert:e=>t.post(`/fleet/alerts/${e}/resolve`,{}),getAgent:e=>t.get(`/fleet/${e}`),getActivity:(e,s=50,l=0)=>t.get(`/fleet/${e}/activity`,{limit:s,offset:l}),getMetrics:e=>t.get(`/fleet/${e}/metrics`),suspend:e=>t.post(`/fleet/${e}/suspend`,{}),activate:e=>t.post(`/fleet/${e}/activate`,{}),adjustTrust:(e,s)=>t.put(`/fleet/${e}/trust`,{trust_score:s})};export{a as f}; -//# sourceMappingURL=fleet-Bmy_93a8.js.map +import{e as t}from"./index-C0nK3ekl.js";const a={getOverview:()=>t.get("/fleet"),getSummary:()=>t.get("/fleet/summary"),getAlerts:()=>t.get("/fleet/alerts"),resolveAlert:e=>t.post(`/fleet/alerts/${e}/resolve`,{}),getAgent:e=>t.get(`/fleet/${e}`),getActivity:(e,s=50,l=0)=>t.get(`/fleet/${e}/activity`,{limit:s,offset:l}),getMetrics:e=>t.get(`/fleet/${e}/metrics`),suspend:e=>t.post(`/fleet/${e}/suspend`,{}),activate:e=>t.post(`/fleet/${e}/activate`,{}),adjustTrust:(e,s)=>t.put(`/fleet/${e}/trust`,{trust_score:s})};export{a as f}; +//# sourceMappingURL=fleet-ClHE8wrR.js.map diff --git a/apps/console-proxy/public/assets/index-C0nK3ekl.js b/apps/console-proxy/public/assets/index-C0nK3ekl.js new file mode 100644 index 00000000..cb693937 --- /dev/null +++ b/apps/console-proxy/public/assets/index-C0nK3ekl.js @@ -0,0 +1,338 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/FleetDashboardPage-nC3mT2F1.js","assets/fleet-ClHE8wrR.js","assets/AgentDetailPage-Cjo-fR2O.js","assets/circle-x-DX5Kt33e.js","assets/activity-DFouDeMs.js","assets/ApprovalsPage-BuPTwH8y.js","assets/PageLayout-D94mSHCV.js","assets/clock-C0m9VzJk.js","assets/ExecutionPage-CzELhGv6.js","assets/ExecutionPage-B98Y90xS.css","assets/PolicyBuilderPage-Bg5susqy.js","assets/HistoryPage-Ck44Svwk.js","assets/SettingsPage-Cffft1gX.js","assets/trash-2-_FGaWZX1.js","assets/ConnectAgentPage-BeQD2oWm.js","assets/IntegrationsPage-SbHmQPUH.js","assets/RiskHeatmapPage-B-jZ4L4N.js","assets/TeamManagementPage-C4k4wAgd.js","assets/UsageDashboardPage-BBENTGn2.js","assets/WorkspacePage-C3FThH_4.js"])))=>i.map(i=>d[i]); +var Lf=Object.defineProperty;var If=(e,t,n)=>t in e?Lf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ot=(e,t,n)=>If(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();function Ou(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fu={exports:{}},Yo={},$u={exports:{}},z={};/** + * @license React + * react.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var Lr=Symbol.for("react.element"),zf=Symbol.for("react.portal"),Df=Symbol.for("react.fragment"),Mf=Symbol.for("react.strict_mode"),Af=Symbol.for("react.profiler"),Of=Symbol.for("react.provider"),Ff=Symbol.for("react.context"),$f=Symbol.for("react.forward_ref"),Uf=Symbol.for("react.suspense"),Bf=Symbol.for("react.memo"),Vf=Symbol.for("react.lazy"),es=Symbol.iterator;function Wf(e){return e===null||typeof e!="object"?null:(e=es&&e[es]||e["@@iterator"],typeof e=="function"?e:null)}var Uu={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},Bu=Object.assign,Vu={};function zn(e,t,n){this.props=e,this.context=t,this.refs=Vu,this.updater=n||Uu}zn.prototype.isReactComponent={};zn.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};zn.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function Wu(){}Wu.prototype=zn.prototype;function Gl(e,t,n){this.props=e,this.context=t,this.refs=Vu,this.updater=n||Uu}var ql=Gl.prototype=new Wu;ql.constructor=Gl;Bu(ql,zn.prototype);ql.isPureReactComponent=!0;var ts=Array.isArray,Hu=Object.prototype.hasOwnProperty,Xl={current:null},Ku={key:!0,ref:!0,__self:!0,__source:!0};function Qu(e,t,n){var r,o={},i=null,l=null;if(t!=null)for(r in t.ref!==void 0&&(l=t.ref),t.key!==void 0&&(i=""+t.key),t)Hu.call(t,r)&&!Ku.hasOwnProperty(r)&&(o[r]=t[r]);var s=arguments.length-2;if(s===1)o.children=n;else if(1>>1,ee=N[K];if(0>>1;Ko(Bn,I))oto(R,Bn)?(N[K]=R,N[ot]=I,K=ot):(N[K]=Bn,N[rt]=I,K=rt);else if(oto(R,I))N[K]=R,N[ot]=I,K=ot;else break e}}return P}function o(N,P){var I=N.sortIndex-P.sortIndex;return I!==0?I:N.id-P.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var l=Date,s=l.now();e.unstable_now=function(){return l.now()-s}}var u=[],c=[],m=1,d=null,f=3,x=!1,v=!1,w=!1,_=typeof setTimeout=="function"?setTimeout:null,h=typeof clearTimeout=="function"?clearTimeout:null,p=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function y(N){for(var P=n(c);P!==null;){if(P.callback===null)r(c);else if(P.startTime<=N)r(c),P.sortIndex=P.expirationTime,t(u,P);else break;P=n(c)}}function k(N){if(w=!1,y(N),!v)if(n(u)!==null)v=!0,$n(S);else{var P=n(c);P!==null&&Un(k,P.startTime-N)}}function S(N,P){v=!1,w&&(w=!1,h(b),b=-1),x=!0;var I=f;try{for(y(P),d=n(u);d!==null&&(!(d.expirationTime>P)||N&&!ue());){var K=d.callback;if(typeof K=="function"){d.callback=null,f=d.priorityLevel;var ee=K(d.expirationTime<=P);P=e.unstable_now(),typeof ee=="function"?d.callback=ee:d===n(u)&&r(u),y(P)}else r(u);d=n(u)}if(d!==null)var tn=!0;else{var rt=n(c);rt!==null&&Un(k,rt.startTime-P),tn=!1}return tn}finally{d=null,f=I,x=!1}}var C=!1,j=null,b=-1,A=5,L=-1;function ue(){return!(e.unstable_now()-LN||125K?(N.sortIndex=I,t(c,N),n(u)===null&&N===n(c)&&(w?(h(b),b=-1):w=!0,Un(k,I-K))):(N.sortIndex=ee,t(u,N),v||x||(v=!0,$n(S))),N},e.unstable_shouldYield=ue,e.unstable_wrapCallback=function(N){var P=f;return function(){var I=f;f=P;try{return N.apply(this,arguments)}finally{f=I}}}})(Ju);Xu.exports=Ju;var tp=Xu.exports;/** + * @license React + * react-dom.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */var np=g,Ne=tp;function E(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Xi=Object.prototype.hasOwnProperty,rp=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,rs={},os={};function op(e){return Xi.call(os,e)?!0:Xi.call(rs,e)?!1:rp.test(e)?os[e]=!0:(rs[e]=!0,!1)}function ip(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function lp(e,t,n,r){if(t===null||typeof t>"u"||ip(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ve(e,t,n,r,o,i,l){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=o,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=i,this.removeEmptyString=l}var se={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){se[e]=new ve(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];se[t]=new ve(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){se[e]=new ve(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){se[e]=new ve(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){se[e]=new ve(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){se[e]=new ve(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){se[e]=new ve(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){se[e]=new ve(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){se[e]=new ve(e,5,!1,e.toLowerCase(),null,!1,!1)});var Zl=/[\-:]([a-z])/g;function ea(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(Zl,ea);se[t]=new ve(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(Zl,ea);se[t]=new ve(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(Zl,ea);se[t]=new ve(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){se[e]=new ve(e,1,!1,e.toLowerCase(),null,!1,!1)});se.xlinkHref=new ve("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){se[e]=new ve(e,1,!1,e.toLowerCase(),null,!0,!0)});function ta(e,t,n,r){var o=se.hasOwnProperty(t)?se[t]:null;(o!==null?o.type!==0:r||!(2s||o[l]!==i[s]){var u=` +`+o[l].replace(" at new "," at ");return e.displayName&&u.includes("")&&(u=u.replace("",e.displayName)),u}while(1<=l&&0<=s);break}}}finally{yi=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Jn(e):""}function ap(e){switch(e.tag){case 5:return Jn(e.type);case 16:return Jn("Lazy");case 13:return Jn("Suspense");case 19:return Jn("SuspenseList");case 0:case 2:case 15:return e=vi(e.type,!1),e;case 11:return e=vi(e.type.render,!1),e;case 1:return e=vi(e.type,!0),e;default:return""}}function tl(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case ln:return"Fragment";case on:return"Portal";case Ji:return"Profiler";case na:return"StrictMode";case Zi:return"Suspense";case el:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case tc:return(e.displayName||"Context")+".Consumer";case ec:return(e._context.displayName||"Context")+".Provider";case ra:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case oa:return t=e.displayName||null,t!==null?t:tl(e.type)||"Memo";case xt:t=e._payload,e=e._init;try{return tl(e(t))}catch{}}return null}function sp(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return tl(t);case 8:return t===na?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function It(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function rc(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function up(e){var t=rc(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var o=n.get,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return o.call(this)},set:function(l){r=""+l,i.call(this,l)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ur(e){e._valueTracker||(e._valueTracker=up(e))}function oc(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=rc(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function So(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function nl(e,t){var n=t.checked;return q({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function ls(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=It(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function ic(e,t){t=t.checked,t!=null&&ta(e,"checked",t,!1)}function rl(e,t){ic(e,t);var n=It(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?ol(e,t.type,n):t.hasOwnProperty("defaultValue")&&ol(e,t.type,It(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function as(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function ol(e,t,n){(t!=="number"||So(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var Zn=Array.isArray;function yn(e,t,n,r){if(e=e.options,t){t={};for(var o=0;o"+t.valueOf().toString()+"",t=Br.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function hr(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var nr={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},cp=["Webkit","ms","Moz","O"];Object.keys(nr).forEach(function(e){cp.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),nr[t]=nr[e]})});function uc(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||nr.hasOwnProperty(e)&&nr[e]?(""+t).trim():t+"px"}function cc(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,o=uc(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,o):e[n]=o}}var dp=q({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function al(e,t){if(t){if(dp[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(E(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(E(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(E(61))}if(t.style!=null&&typeof t.style!="object")throw Error(E(62))}}function sl(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ul=null;function ia(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var cl=null,vn=null,xn=null;function cs(e){if(e=Dr(e)){if(typeof cl!="function")throw Error(E(280));var t=e.stateNode;t&&(t=Zo(t),cl(e.stateNode,e.type,t))}}function dc(e){vn?xn?xn.push(e):xn=[e]:vn=e}function fc(){if(vn){var e=vn,t=xn;if(xn=vn=null,cs(e),t)for(e=0;e>>=0,e===0?32:31-(kp(e)/_p|0)|0}var Vr=64,Wr=4194304;function er(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Co(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,o=e.suspendedLanes,i=e.pingedLanes,l=n&268435455;if(l!==0){var s=l&~o;s!==0?r=er(s):(i&=l,i!==0&&(r=er(i)))}else l=n&~o,l!==0?r=er(l):i!==0&&(r=er(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&o)&&(o=r&-r,i=t&-t,o>=i||o===16&&(i&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0n;n++)t.push(e);return t}function Ir(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-He(t),e[t]=n}function Np(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0=or),xs=" ",ws=!1;function Lc(e,t){switch(e){case"keyup":return th.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ic(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var an=!1;function rh(e,t){switch(e){case"compositionend":return Ic(t);case"keypress":return t.which!==32?null:(ws=!0,xs);case"textInput":return e=t.data,e===xs&&ws?null:e;default:return null}}function oh(e,t){if(an)return e==="compositionend"||!pa&&Lc(e,t)?(e=Rc(),so=ca=_t=null,an=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Es(n)}}function Ac(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Ac(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Oc(){for(var e=window,t=So();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=So(e.document)}return t}function ha(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function ph(e){var t=Oc(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&Ac(n.ownerDocument.documentElement,n)){if(r!==null&&ha(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var o=n.textContent.length,i=Math.min(r.start,o);r=r.end===void 0?i:Math.min(r.end,o),!e.extend&&i>r&&(o=r,r=i,i=o),o=Cs(n,i);var l=Cs(n,r);o&&l&&(e.rangeCount!==1||e.anchorNode!==o.node||e.anchorOffset!==o.offset||e.focusNode!==l.node||e.focusOffset!==l.offset)&&(t=t.createRange(),t.setStart(o.node,o.offset),e.removeAllRanges(),i>r?(e.addRange(t),e.extend(l.node,l.offset)):(t.setEnd(l.node,l.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,sn=null,gl=null,lr=null,yl=!1;function js(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;yl||sn==null||sn!==So(r)||(r=sn,"selectionStart"in r&&ha(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),lr&&wr(lr,r)||(lr=r,r=bo(gl,"onSelect"),0dn||(e.current=_l[dn],_l[dn]=null,dn--)}function $(e,t){dn++,_l[dn]=e.current,e.current=t}var zt={},pe=Mt(zt),Se=Mt(!1),Qt=zt;function Cn(e,t){var n=e.type.contextTypes;if(!n)return zt;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var o={},i;for(i in n)o[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=o),o}function ke(e){return e=e.childContextTypes,e!=null}function Ro(){V(Se),V(pe)}function Is(e,t,n){if(pe.current!==zt)throw Error(E(168));$(pe,t),$(Se,n)}function Qc(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var o in r)if(!(o in t))throw Error(E(108,sp(e)||"Unknown",o));return q({},n,r)}function Po(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||zt,Qt=pe.current,$(pe,e),$(Se,Se.current),!0}function zs(e,t,n){var r=e.stateNode;if(!r)throw Error(E(169));n?(e=Qc(e,t,Qt),r.__reactInternalMemoizedMergedChildContext=e,V(Se),V(pe),$(pe,e)):V(Se),$(Se,n)}var lt=null,ei=!1,Li=!1;function Yc(e){lt===null?lt=[e]:lt.push(e)}function Ch(e){ei=!0,Yc(e)}function At(){if(!Li&<!==null){Li=!0;var e=0,t=F;try{var n=lt;for(F=1;e>=l,o-=l,at=1<<32-He(t)+o|n<b?(A=j,j=null):A=j.sibling;var L=f(h,j,y[b],k);if(L===null){j===null&&(j=A);break}e&&j&&L.alternate===null&&t(h,j),p=i(L,p,b),C===null?S=L:C.sibling=L,C=L,j=A}if(b===y.length)return n(h,j),W&&$t(h,b),S;if(j===null){for(;bb?(A=j,j=null):A=j.sibling;var ue=f(h,j,L.value,k);if(ue===null){j===null&&(j=A);break}e&&j&&ue.alternate===null&&t(h,j),p=i(ue,p,b),C===null?S=ue:C.sibling=ue,C=ue,j=A}if(L.done)return n(h,j),W&&$t(h,b),S;if(j===null){for(;!L.done;b++,L=y.next())L=d(h,L.value,k),L!==null&&(p=i(L,p,b),C===null?S=L:C.sibling=L,C=L);return W&&$t(h,b),S}for(j=r(h,j);!L.done;b++,L=y.next())L=x(j,h,b,L.value,k),L!==null&&(e&&L.alternate!==null&&j.delete(L.key===null?b:L.key),p=i(L,p,b),C===null?S=L:C.sibling=L,C=L);return e&&j.forEach(function(Ge){return t(h,Ge)}),W&&$t(h,b),S}function _(h,p,y,k){if(typeof y=="object"&&y!==null&&y.type===ln&&y.key===null&&(y=y.props.children),typeof y=="object"&&y!==null){switch(y.$$typeof){case $r:e:{for(var S=y.key,C=p;C!==null;){if(C.key===S){if(S=y.type,S===ln){if(C.tag===7){n(h,C.sibling),p=o(C,y.props.children),p.return=h,h=p;break e}}else if(C.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===xt&&As(S)===C.type){n(h,C.sibling),p=o(C,y.props),p.ref=Yn(h,C,y),p.return=h,h=p;break e}n(h,C);break}else t(h,C);C=C.sibling}y.type===ln?(p=Kt(y.props.children,h.mode,k,y.key),p.return=h,h=p):(k=yo(y.type,y.key,y.props,null,h.mode,k),k.ref=Yn(h,p,y),k.return=h,h=k)}return l(h);case on:e:{for(C=y.key;p!==null;){if(p.key===C)if(p.tag===4&&p.stateNode.containerInfo===y.containerInfo&&p.stateNode.implementation===y.implementation){n(h,p.sibling),p=o(p,y.children||[]),p.return=h,h=p;break e}else{n(h,p);break}else t(h,p);p=p.sibling}p=$i(y,h.mode,k),p.return=h,h=p}return l(h);case xt:return C=y._init,_(h,p,C(y._payload),k)}if(Zn(y))return v(h,p,y,k);if(Vn(y))return w(h,p,y,k);Xr(h,y)}return typeof y=="string"&&y!==""||typeof y=="number"?(y=""+y,p!==null&&p.tag===6?(n(h,p.sibling),p=o(p,y),p.return=h,h=p):(n(h,p),p=Fi(y,h.mode,k),p.return=h,h=p),l(h)):n(h,p)}return _}var Nn=Jc(!0),Zc=Jc(!1),zo=Mt(null),Do=null,hn=null,va=null;function xa(){va=hn=Do=null}function wa(e){var t=zo.current;V(zo),e._currentValue=t}function jl(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function Sn(e,t){Do=e,va=hn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(we=!0),e.firstContext=null)}function Ae(e){var t=e._currentValue;if(va!==e)if(e={context:e,memoizedValue:t,next:null},hn===null){if(Do===null)throw Error(E(308));hn=e,Do.dependencies={lanes:0,firstContext:e}}else hn=hn.next=e;return t}var Vt=null;function Sa(e){Vt===null?Vt=[e]:Vt.push(e)}function ed(e,t,n,r){var o=t.interleaved;return o===null?(n.next=n,Sa(t)):(n.next=o.next,o.next=n),t.interleaved=n,ft(e,r)}function ft(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var wt=!1;function ka(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function td(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function ut(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Tt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,D&2){var o=r.pending;return o===null?t.next=t:(t.next=o.next,o.next=t),r.pending=t,ft(e,n)}return o=r.interleaved,o===null?(t.next=t,Sa(r)):(t.next=o.next,o.next=t),r.interleaved=t,ft(e,n)}function co(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,aa(e,n)}}function Os(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var o=null,i=null;if(n=n.firstBaseUpdate,n!==null){do{var l={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};i===null?o=i=l:i=i.next=l,n=n.next}while(n!==null);i===null?o=i=t:i=i.next=t}else o=i=t;n={baseState:r.baseState,firstBaseUpdate:o,lastBaseUpdate:i,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Mo(e,t,n,r){var o=e.updateQueue;wt=!1;var i=o.firstBaseUpdate,l=o.lastBaseUpdate,s=o.shared.pending;if(s!==null){o.shared.pending=null;var u=s,c=u.next;u.next=null,l===null?i=c:l.next=c,l=u;var m=e.alternate;m!==null&&(m=m.updateQueue,s=m.lastBaseUpdate,s!==l&&(s===null?m.firstBaseUpdate=c:s.next=c,m.lastBaseUpdate=u))}if(i!==null){var d=o.baseState;l=0,m=c=u=null,s=i;do{var f=s.lane,x=s.eventTime;if((r&f)===f){m!==null&&(m=m.next={eventTime:x,lane:0,tag:s.tag,payload:s.payload,callback:s.callback,next:null});e:{var v=e,w=s;switch(f=t,x=n,w.tag){case 1:if(v=w.payload,typeof v=="function"){d=v.call(x,d,f);break e}d=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=w.payload,f=typeof v=="function"?v.call(x,d,f):v,f==null)break e;d=q({},d,f);break e;case 2:wt=!0}}s.callback!==null&&s.lane!==0&&(e.flags|=64,f=o.effects,f===null?o.effects=[s]:f.push(s))}else x={eventTime:x,lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},m===null?(c=m=x,u=d):m=m.next=x,l|=f;if(s=s.next,s===null){if(s=o.shared.pending,s===null)break;f=s,s=f.next,f.next=null,o.lastBaseUpdate=f,o.shared.pending=null}}while(!0);if(m===null&&(u=d),o.baseState=u,o.firstBaseUpdate=c,o.lastBaseUpdate=m,t=o.shared.interleaved,t!==null){o=t;do l|=o.lane,o=o.next;while(o!==t)}else i===null&&(o.shared.lanes=0);qt|=l,e.lanes=l,e.memoizedState=d}}function Fs(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=zi.transition;zi.transition={};try{e(!1),t()}finally{F=n,zi.transition=r}}function vd(){return Oe().memoizedState}function Th(e,t,n){var r=Pt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},xd(e))wd(t,n);else if(n=ed(e,t,n,r),n!==null){var o=ge();Ke(n,e,r,o),Sd(n,t,r)}}function Rh(e,t,n){var r=Pt(e),o={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(xd(e))wd(t,o);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var l=t.lastRenderedState,s=i(l,n);if(o.hasEagerState=!0,o.eagerState=s,Qe(s,l)){var u=t.interleaved;u===null?(o.next=o,Sa(t)):(o.next=u.next,u.next=o),t.interleaved=o;return}}catch{}finally{}n=ed(e,t,o,r),n!==null&&(o=ge(),Ke(n,e,r,o),Sd(n,t,r))}}function xd(e){var t=e.alternate;return e===Y||t!==null&&t===Y}function wd(e,t){ar=Oo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Sd(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,aa(e,n)}}var Fo={readContext:Ae,useCallback:ce,useContext:ce,useEffect:ce,useImperativeHandle:ce,useInsertionEffect:ce,useLayoutEffect:ce,useMemo:ce,useReducer:ce,useRef:ce,useState:ce,useDebugValue:ce,useDeferredValue:ce,useTransition:ce,useMutableSource:ce,useSyncExternalStore:ce,useId:ce,unstable_isNewReconciler:!1},Ph={readContext:Ae,useCallback:function(e,t){return Je().memoizedState=[e,t===void 0?null:t],e},useContext:Ae,useEffect:Us,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,po(4194308,4,pd.bind(null,t,e),n)},useLayoutEffect:function(e,t){return po(4194308,4,e,t)},useInsertionEffect:function(e,t){return po(4,2,e,t)},useMemo:function(e,t){var n=Je();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=Je();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=Th.bind(null,Y,e),[r.memoizedState,e]},useRef:function(e){var t=Je();return e={current:e},t.memoizedState=e},useState:$s,useDebugValue:Ra,useDeferredValue:function(e){return Je().memoizedState=e},useTransition:function(){var e=$s(!1),t=e[0];return e=bh.bind(null,e[1]),Je().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Y,o=Je();if(W){if(n===void 0)throw Error(E(407));n=n()}else{if(n=t(),ie===null)throw Error(E(349));Gt&30||id(r,t,n)}o.memoizedState=n;var i={value:n,getSnapshot:t};return o.queue=i,Us(ad.bind(null,r,i,e),[e]),r.flags|=2048,br(9,ld.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=Je(),t=ie.identifierPrefix;if(W){var n=st,r=at;n=(r&~(1<<32-He(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=jr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=l.createElement(n,{is:r.is}):(e=l.createElement(n),n==="select"&&(l=e,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):e=l.createElementNS(e,n),e[Ze]=t,e[_r]=r,Pd(e,t,!1,!1),t.stateNode=e;e:{switch(l=sl(n,r),n){case"dialog":B("cancel",e),B("close",e),o=r;break;case"iframe":case"object":case"embed":B("load",e),o=r;break;case"video":case"audio":for(o=0;oRn&&(t.flags|=128,r=!0,Gn(i,!1),t.lanes=4194304)}else{if(!r)if(e=Ao(l),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Gn(i,!0),i.tail===null&&i.tailMode==="hidden"&&!l.alternate&&!W)return de(t),null}else 2*Z()-i.renderingStartTime>Rn&&n!==1073741824&&(t.flags|=128,r=!0,Gn(i,!1),t.lanes=4194304);i.isBackwards?(l.sibling=t.child,t.child=l):(n=i.last,n!==null?n.sibling=l:t.child=l,i.last=l)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=Z(),t.sibling=null,n=Q.current,$(Q,r?n&1|2:n&1),t):(de(t),null);case 22:case 23:return Ma(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ee&1073741824&&(de(t),t.subtreeFlags&6&&(t.flags|=8192)):de(t),null;case 24:return null;case 25:return null}throw Error(E(156,t.tag))}function Fh(e,t){switch(ga(t),t.tag){case 1:return ke(t.type)&&Ro(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return bn(),V(Se),V(pe),Ca(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Ea(t),null;case 13:if(V(Q),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(E(340));jn()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return V(Q),null;case 4:return bn(),null;case 10:return wa(t.type._context),null;case 22:case 23:return Ma(),null;case 24:return null;default:return null}}var Zr=!1,fe=!1,$h=typeof WeakSet=="function"?WeakSet:Set,T=null;function mn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){X(e,t,r)}else n.current=null}function Dl(e,t,n){try{n()}catch(r){X(e,t,r)}}var Js=!1;function Uh(e,t){if(vl=jo,e=Oc(),ha(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var o=r.anchorOffset,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var l=0,s=-1,u=-1,c=0,m=0,d=e,f=null;t:for(;;){for(var x;d!==n||o!==0&&d.nodeType!==3||(s=l+o),d!==i||r!==0&&d.nodeType!==3||(u=l+r),d.nodeType===3&&(l+=d.nodeValue.length),(x=d.firstChild)!==null;)f=d,d=x;for(;;){if(d===e)break t;if(f===n&&++c===o&&(s=l),f===i&&++m===r&&(u=l),(x=d.nextSibling)!==null)break;d=f,f=d.parentNode}d=x}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(xl={focusedElem:e,selectionRange:n},jo=!1,T=t;T!==null;)if(t=T,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,T=e;else for(;T!==null;){t=T;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var w=v.memoizedProps,_=v.memoizedState,h=t.stateNode,p=h.getSnapshotBeforeUpdate(t.elementType===t.type?w:Be(t.type,w),_);h.__reactInternalSnapshotBeforeUpdate=p}break;case 3:var y=t.stateNode.containerInfo;y.nodeType===1?y.textContent="":y.nodeType===9&&y.documentElement&&y.removeChild(y.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(E(163))}}catch(k){X(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,T=e;break}T=t.return}return v=Js,Js=!1,v}function sr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var o=r=r.next;do{if((o.tag&e)===e){var i=o.destroy;o.destroy=void 0,i!==void 0&&Dl(t,n,i)}o=o.next}while(o!==r)}}function ri(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function Ml(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function zd(e){var t=e.alternate;t!==null&&(e.alternate=null,zd(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ze],delete t[_r],delete t[kl],delete t[_h],delete t[Eh])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Dd(e){return e.tag===5||e.tag===3||e.tag===4}function Zs(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Dd(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Al(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=To));else if(r!==4&&(e=e.child,e!==null))for(Al(e,t,n),e=e.sibling;e!==null;)Al(e,t,n),e=e.sibling}function Ol(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(Ol(e,t,n),e=e.sibling;e!==null;)Ol(e,t,n),e=e.sibling}var le=null,Ve=!1;function yt(e,t,n){for(n=n.child;n!==null;)Md(e,t,n),n=n.sibling}function Md(e,t,n){if(et&&typeof et.onCommitFiberUnmount=="function")try{et.onCommitFiberUnmount(Go,n)}catch{}switch(n.tag){case 5:fe||mn(n,t);case 6:var r=le,o=Ve;le=null,yt(e,t,n),le=r,Ve=o,le!==null&&(Ve?(e=le,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):le.removeChild(n.stateNode));break;case 18:le!==null&&(Ve?(e=le,n=n.stateNode,e.nodeType===8?Pi(e.parentNode,n):e.nodeType===1&&Pi(e,n),vr(e)):Pi(le,n.stateNode));break;case 4:r=le,o=Ve,le=n.stateNode.containerInfo,Ve=!0,yt(e,t,n),le=r,Ve=o;break;case 0:case 11:case 14:case 15:if(!fe&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){o=r=r.next;do{var i=o,l=i.destroy;i=i.tag,l!==void 0&&(i&2||i&4)&&Dl(n,t,l),o=o.next}while(o!==r)}yt(e,t,n);break;case 1:if(!fe&&(mn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){X(n,t,s)}yt(e,t,n);break;case 21:yt(e,t,n);break;case 22:n.mode&1?(fe=(r=fe)||n.memoizedState!==null,yt(e,t,n),fe=r):yt(e,t,n);break;default:yt(e,t,n)}}function eu(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new $h),t.forEach(function(r){var o=qh.bind(null,e,r);n.has(r)||(n.add(r),r.then(o,o))})}}function Ue(e,t){var n=t.deletions;if(n!==null)for(var r=0;ro&&(o=l),r&=~i}if(r=o,r=Z()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Vh(r/1960))-r,10e?16:e,Et===null)var r=!1;else{if(e=Et,Et=null,Bo=0,D&6)throw Error(E(331));var o=D;for(D|=4,T=e.current;T!==null;){var i=T,l=i.child;if(T.flags&16){var s=i.deletions;if(s!==null){for(var u=0;uZ()-za?Ht(e,0):Ia|=n),_e(e,t)}function Wd(e,t){t===0&&(e.mode&1?(t=Wr,Wr<<=1,!(Wr&130023424)&&(Wr=4194304)):t=1);var n=ge();e=ft(e,t),e!==null&&(Ir(e,t,n),_e(e,n))}function Gh(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Wd(e,n)}function qh(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,o=e.memoizedState;o!==null&&(n=o.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(E(314))}r!==null&&r.delete(t),Wd(e,n)}var Hd;Hd=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Se.current)we=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return we=!1,Ah(e,t,n);we=!!(e.flags&131072)}else we=!1,W&&t.flags&1048576&&Gc(t,Io,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;ho(e,t),e=t.pendingProps;var o=Cn(t,pe.current);Sn(t,n),o=Na(null,t,r,e,o,n);var i=ba();return t.flags|=1,typeof o=="object"&&o!==null&&typeof o.render=="function"&&o.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,ke(r)?(i=!0,Po(t)):i=!1,t.memoizedState=o.state!==null&&o.state!==void 0?o.state:null,ka(t),o.updater=ni,t.stateNode=o,o._reactInternals=t,bl(t,r,e,n),t=Pl(null,t,r,!0,i,n)):(t.tag=0,W&&i&&ma(t),me(null,t,o,n),t=t.child),t;case 16:r=t.elementType;e:{switch(ho(e,t),e=t.pendingProps,o=r._init,r=o(r._payload),t.type=r,o=t.tag=Jh(r),e=Be(r,e),o){case 0:t=Rl(null,t,r,e,n);break e;case 1:t=Gs(null,t,r,e,n);break e;case 11:t=Qs(null,t,r,e,n);break e;case 14:t=Ys(null,t,r,Be(r.type,e),n);break e}throw Error(E(306,r,""))}return t;case 0:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Be(r,o),Rl(e,t,r,o,n);case 1:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Be(r,o),Gs(e,t,r,o,n);case 3:e:{if(bd(t),e===null)throw Error(E(387));r=t.pendingProps,i=t.memoizedState,o=i.element,td(e,t),Mo(t,r,null,n);var l=t.memoizedState;if(r=l.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){o=Tn(Error(E(423)),t),t=qs(e,t,r,n,o);break e}else if(r!==o){o=Tn(Error(E(424)),t),t=qs(e,t,r,n,o);break e}else for(Ce=bt(t.stateNode.containerInfo.firstChild),je=t,W=!0,We=null,n=Zc(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(jn(),r===o){t=pt(e,t,n);break e}me(e,t,r,n)}t=t.child}return t;case 5:return nd(t),e===null&&Cl(t),r=t.type,o=t.pendingProps,i=e!==null?e.memoizedProps:null,l=o.children,wl(r,o)?l=null:i!==null&&wl(r,i)&&(t.flags|=32),Nd(e,t),me(e,t,l,n),t.child;case 6:return e===null&&Cl(t),null;case 13:return Td(e,t,n);case 4:return _a(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Nn(t,null,r,n):me(e,t,r,n),t.child;case 11:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Be(r,o),Qs(e,t,r,o,n);case 7:return me(e,t,t.pendingProps,n),t.child;case 8:return me(e,t,t.pendingProps.children,n),t.child;case 12:return me(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,o=t.pendingProps,i=t.memoizedProps,l=o.value,$(zo,r._currentValue),r._currentValue=l,i!==null)if(Qe(i.value,l)){if(i.children===o.children&&!Se.current){t=pt(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var s=i.dependencies;if(s!==null){l=i.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=ut(-1,n&-n),u.tag=2;var c=i.updateQueue;if(c!==null){c=c.shared;var m=c.pending;m===null?u.next=u:(u.next=m.next,m.next=u),c.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),jl(i.return,n,t),s.lanes|=n;break}u=u.next}}else if(i.tag===10)l=i.type===t.type?null:i.child;else if(i.tag===18){if(l=i.return,l===null)throw Error(E(341));l.lanes|=n,s=l.alternate,s!==null&&(s.lanes|=n),jl(l,n,t),l=i.sibling}else l=i.child;if(l!==null)l.return=i;else for(l=i;l!==null;){if(l===t){l=null;break}if(i=l.sibling,i!==null){i.return=l.return,l=i;break}l=l.return}i=l}me(e,t,o.children,n),t=t.child}return t;case 9:return o=t.type,r=t.pendingProps.children,Sn(t,n),o=Ae(o),r=r(o),t.flags|=1,me(e,t,r,n),t.child;case 14:return r=t.type,o=Be(r,t.pendingProps),o=Be(r.type,o),Ys(e,t,r,o,n);case 15:return Cd(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,o=t.pendingProps,o=t.elementType===r?o:Be(r,o),ho(e,t),t.tag=1,ke(r)?(e=!0,Po(t)):e=!1,Sn(t,n),kd(t,r,o),bl(t,r,o,n),Pl(null,t,r,!0,e,n);case 19:return Rd(e,t,n);case 22:return jd(e,t,n)}throw Error(E(156,t.tag))};function Kd(e,t){return xc(e,t)}function Xh(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function De(e,t,n,r){return new Xh(e,t,n,r)}function Oa(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Jh(e){if(typeof e=="function")return Oa(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ra)return 11;if(e===oa)return 14}return 2}function Lt(e,t){var n=e.alternate;return n===null?(n=De(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function yo(e,t,n,r,o,i){var l=2;if(r=e,typeof e=="function")Oa(e)&&(l=1);else if(typeof e=="string")l=5;else e:switch(e){case ln:return Kt(n.children,o,i,t);case na:l=8,o|=8;break;case Ji:return e=De(12,n,t,o|2),e.elementType=Ji,e.lanes=i,e;case Zi:return e=De(13,n,t,o),e.elementType=Zi,e.lanes=i,e;case el:return e=De(19,n,t,o),e.elementType=el,e.lanes=i,e;case nc:return ii(n,o,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case ec:l=10;break e;case tc:l=9;break e;case ra:l=11;break e;case oa:l=14;break e;case xt:l=16,r=null;break e}throw Error(E(130,e==null?e:typeof e,""))}return t=De(l,n,t,o),t.elementType=e,t.type=r,t.lanes=i,t}function Kt(e,t,n,r){return e=De(7,e,r,t),e.lanes=n,e}function ii(e,t,n,r){return e=De(22,e,r,t),e.elementType=nc,e.lanes=n,e.stateNode={isHidden:!1},e}function Fi(e,t,n){return e=De(6,e,null,t),e.lanes=n,e}function $i(e,t,n){return t=De(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Zh(e,t,n,r,o){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=wi(0),this.expirationTimes=wi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wi(0),this.identifierPrefix=r,this.onRecoverableError=o,this.mutableSourceEagerHydrationData=null}function Fa(e,t,n,r,o,i,l,s,u){return e=new Zh(e,t,n,s,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=De(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},ka(i),e}function em(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(qd)}catch(e){console.error(e)}}qd(),qu.exports=be;var im=qu.exports,su=im;qi.createRoot=su.createRoot,qi.hydrateRoot=su.hydrateRoot;/** + * react-router v7.13.2 + * + * Copyright (c) Remix Software Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE.md file in the root directory of this source tree. + * + * @license MIT + */var uu="popstate";function cu(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function lm(e={}){function t(r,o){var c;let i=(c=o.state)==null?void 0:c.masked,{pathname:l,search:s,hash:u}=i||r.location;return Vl("",{pathname:l,search:s,hash:u},o.state&&o.state.usr||null,o.state&&o.state.key||"default",i?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,o){return typeof o=="string"?o:Rr(o)}return sm(t,n,null,e)}function H(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function Fe(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function am(){return Math.random().toString(36).substring(2,10)}function du(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.unstable_mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Vl(e,t,n=null,r,o){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?An(t):t,state:n,key:t&&t.key||r||am(),unstable_mask:o}}function Rr({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function An(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function sm(e,t,n,r={}){let{window:o=document.defaultView,v5Compat:i=!1}=r,l=o.history,s="POP",u=null,c=m();c==null&&(c=0,l.replaceState({...l.state,idx:c},""));function m(){return(l.state||{idx:null}).idx}function d(){s="POP";let _=m(),h=_==null?null:_-c;c=_,u&&u({action:s,location:w.location,delta:h})}function f(_,h){s="PUSH";let p=cu(_)?_:Vl(w.location,_,h);c=m()+1;let y=du(p,c),k=w.createHref(p.unstable_mask||p);try{l.pushState(y,"",k)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;o.location.assign(k)}i&&u&&u({action:s,location:w.location,delta:1})}function x(_,h){s="REPLACE";let p=cu(_)?_:Vl(w.location,_,h);c=m();let y=du(p,c),k=w.createHref(p.unstable_mask||p);l.replaceState(y,"",k),i&&u&&u({action:s,location:w.location,delta:0})}function v(_){return um(_)}let w={get action(){return s},get location(){return e(o,l)},listen(_){if(u)throw new Error("A history only accepts one active listener");return o.addEventListener(uu,d),u=_,()=>{o.removeEventListener(uu,d),u=null}},createHref(_){return t(o,_)},createURL:v,encodeLocation(_){let h=v(_);return{pathname:h.pathname,search:h.search,hash:h.hash}},push:f,replace:x,go(_){return l.go(_)}};return w}function um(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),H(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:Rr(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Xd(e,t,n="/"){return cm(e,t,n,!1)}function cm(e,t,n,r){let o=typeof t=="string"?An(t):t,i=ht(o.pathname||"/",n);if(i==null)return null;let l=Jd(e);dm(l);let s=null;for(let u=0;s==null&&u{let m={relativePath:c===void 0?l.path||"":c,caseSensitive:l.caseSensitive===!0,childrenIndex:s,route:l};if(m.relativePath.startsWith("/")){if(!m.relativePath.startsWith(r)&&u)return;H(m.relativePath.startsWith(r),`Absolute route path "${m.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),m.relativePath=m.relativePath.slice(r.length)}let d=nt([r,m.relativePath]),f=n.concat(m);l.children&&l.children.length>0&&(H(l.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${d}".`),Jd(l.children,t,f,d,u)),!(l.path==null&&!l.index)&&t.push({path:d,score:vm(d,l.index),routesMeta:f})};return e.forEach((l,s)=>{var u;if(l.path===""||!((u=l.path)!=null&&u.includes("?")))i(l,s);else for(let c of Zd(l.path))i(l,s,!0,c)}),t}function Zd(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,o=n.endsWith("?"),i=n.replace(/\?$/,"");if(r.length===0)return o?[i,""]:[i];let l=Zd(r.join("/")),s=[];return s.push(...l.map(u=>u===""?i:[i,u].join("/"))),o&&s.push(...l),s.map(u=>e.startsWith("/")&&u===""?"/":u)}function dm(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:xm(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var fm=/^:[\w-]+$/,pm=3,hm=2,mm=1,gm=10,ym=-2,fu=e=>e==="*";function vm(e,t){let n=e.split("/"),r=n.length;return n.some(fu)&&(r+=ym),t&&(r+=hm),n.filter(o=>!fu(o)).reduce((o,i)=>o+(fm.test(i)?pm:i===""?mm:gm),r)}function xm(e,t){return e.length===t.length&&e.slice(0,-1).every((r,o)=>r===t[o])?e[e.length-1]-t[t.length-1]:0}function wm(e,t,n=!1){let{routesMeta:r}=e,o={},i="/",l=[];for(let s=0;s{if(m==="*"){let v=s[f]||"";l=i.slice(0,i.length-v.length).replace(/(.)\/+$/,"$1")}const x=s[f];return d&&!x?c[m]=void 0:c[m]=(x||"").replace(/%2F/g,"/"),c},{}),pathname:i,pathnameBase:l,pattern:e}}function Sm(e,t=!1,n=!0){Fe(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],o="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(l,s,u,c,m)=>{if(r.push({paramName:s,isOptional:u!=null}),u){let d=m.charAt(c+l.length);return d&&d!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),o+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?o+="\\/*$":e!==""&&e!=="/"&&(o+="(?:(?=\\/|$))"),[new RegExp(o,t?void 0:"i"),r]}function km(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return Fe(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function ht(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var _m=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Em(e,t="/"){let{pathname:n,search:r="",hash:o=""}=typeof e=="string"?An(e):e,i;return n?(n=n.replace(/\/\/+/g,"/"),n.startsWith("/")?i=pu(n.substring(1),"/"):i=pu(n,t)):i=t,{pathname:i,search:Nm(r),hash:bm(o)}}function pu(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(o=>{o===".."?n.length>1&&n.pop():o!=="."&&n.push(o)}),n.length>1?n.join("/"):"/"}function Ui(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Cm(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Va(e){let t=Cm(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function ci(e,t,n,r=!1){let o;typeof e=="string"?o=An(e):(o={...e},H(!o.pathname||!o.pathname.includes("?"),Ui("?","pathname","search",o)),H(!o.pathname||!o.pathname.includes("#"),Ui("#","pathname","hash",o)),H(!o.search||!o.search.includes("#"),Ui("#","search","hash",o)));let i=e===""||o.pathname==="",l=i?"/":o.pathname,s;if(l==null)s=n;else{let d=t.length-1;if(!r&&l.startsWith("..")){let f=l.split("/");for(;f[0]==="..";)f.shift(),d-=1;o.pathname=f.join("/")}s=d>=0?t[d]:"/"}let u=Em(o,s),c=l&&l!=="/"&&l.endsWith("/"),m=(i||l===".")&&n.endsWith("/");return!u.pathname.endsWith("/")&&(c||m)&&(u.pathname+="/"),u}var nt=e=>e.join("/").replace(/\/\/+/g,"/"),jm=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),Nm=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,bm=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Tm=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Rm(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Pm(e){return e.map(t=>t.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var ef=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function tf(e,t){let n=e;if(typeof n!="string"||!_m.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,o=!1;if(ef)try{let i=new URL(window.location.href),l=n.startsWith("//")?new URL(i.protocol+n):new URL(n),s=ht(l.pathname,t);l.origin===i.origin&&s!=null?n=s+l.search+l.hash:o=!0}catch{Fe(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:o,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var nf=["POST","PUT","PATCH","DELETE"];new Set(nf);var Lm=["GET",...nf];new Set(Lm);var On=g.createContext(null);On.displayName="DataRouter";var di=g.createContext(null);di.displayName="DataRouterState";var Im=g.createContext(!1),rf=g.createContext({isTransitioning:!1});rf.displayName="ViewTransition";var zm=g.createContext(new Map);zm.displayName="Fetchers";var Dm=g.createContext(null);Dm.displayName="Await";var Re=g.createContext(null);Re.displayName="Navigation";var Ar=g.createContext(null);Ar.displayName="Location";var Ye=g.createContext({outlet:null,matches:[],isDataRoute:!1});Ye.displayName="Route";var Wa=g.createContext(null);Wa.displayName="RouteError";var of="REACT_ROUTER_ERROR",Mm="REDIRECT",Am="ROUTE_ERROR_RESPONSE";function Om(e){if(e.startsWith(`${of}:${Mm}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Fm(e){if(e.startsWith(`${of}:${Am}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Tm(t.status,t.statusText,t.data)}catch{}}function $m(e,{relative:t}={}){H(Fn(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=g.useContext(Re),{hash:o,pathname:i,search:l}=Or(e,{relative:t}),s=i;return n!=="/"&&(s=i==="/"?n:nt([n,i])),r.createHref({pathname:s,search:l,hash:o})}function Fn(){return g.useContext(Ar)!=null}function Pe(){return H(Fn(),"useLocation() may be used only in the context of a component."),g.useContext(Ar).location}var lf="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function af(e){g.useContext(Re).static||g.useLayoutEffect(e)}function en(){let{isDataRoute:e}=g.useContext(Ye);return e?Zm():Um()}function Um(){H(Fn(),"useNavigate() may be used only in the context of a component.");let e=g.useContext(On),{basename:t,navigator:n}=g.useContext(Re),{matches:r}=g.useContext(Ye),{pathname:o}=Pe(),i=JSON.stringify(Va(r)),l=g.useRef(!1);return af(()=>{l.current=!0}),g.useCallback((u,c={})=>{if(Fe(l.current,lf),!l.current)return;if(typeof u=="number"){n.go(u);return}let m=ci(u,JSON.parse(i),o,c.relative==="path");e==null&&t!=="/"&&(m.pathname=m.pathname==="/"?t:nt([t,m.pathname])),(c.replace?n.replace:n.push)(m,c.state,c)},[t,n,i,o,e])}g.createContext(null);function Vv(){let{matches:e}=g.useContext(Ye),t=e[e.length-1];return t?t.params:{}}function Or(e,{relative:t}={}){let{matches:n}=g.useContext(Ye),{pathname:r}=Pe(),o=JSON.stringify(Va(n));return g.useMemo(()=>ci(e,JSON.parse(o),r,t==="path"),[e,o,r,t])}function Bm(e,t){return sf(e,t)}function sf(e,t,n){var _;H(Fn(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=g.useContext(Re),{matches:o}=g.useContext(Ye),i=o[o.length-1],l=i?i.params:{},s=i?i.pathname:"/",u=i?i.pathnameBase:"/",c=i&&i.route;{let h=c&&c.path||"";cf(s,!c||h.endsWith("*")||h.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${s}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let m=Pe(),d;if(t){let h=typeof t=="string"?An(t):t;H(u==="/"||((_=h.pathname)==null?void 0:_.startsWith(u)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${u}" but pathname "${h.pathname}" was given in the \`location\` prop.`),d=h}else d=m;let f=d.pathname||"/",x=f;if(u!=="/"){let h=u.replace(/^\//,"").split("/");x="/"+f.replace(/^\//,"").split("/").slice(h.length).join("/")}let v=Xd(e,{pathname:x});Fe(c||v!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),Fe(v==null||v[v.length-1].route.element!==void 0||v[v.length-1].route.Component!==void 0||v[v.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let w=Qm(v&&v.map(h=>Object.assign({},h,{params:Object.assign({},l,h.params),pathname:nt([u,r.encodeLocation?r.encodeLocation(h.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathname]),pathnameBase:h.pathnameBase==="/"?u:nt([u,r.encodeLocation?r.encodeLocation(h.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:h.pathnameBase])})),o,n);return t&&w?g.createElement(Ar.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",unstable_mask:void 0,...d},navigationType:"POP"}},w):w}function Vm(){let e=Jm(),t=Rm(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",o={padding:"0.5rem",backgroundColor:r},i={padding:"2px 4px",backgroundColor:r},l=null;return console.error("Error handled by React Router default ErrorBoundary:",e),l=g.createElement(g.Fragment,null,g.createElement("p",null,"💿 Hey developer 👋"),g.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",g.createElement("code",{style:i},"ErrorBoundary")," or"," ",g.createElement("code",{style:i},"errorElement")," prop on your route.")),g.createElement(g.Fragment,null,g.createElement("h2",null,"Unexpected Application Error!"),g.createElement("h3",{style:{fontStyle:"italic"}},t),n?g.createElement("pre",{style:o},n):null,l)}var Wm=g.createElement(Vm,null),uf=class extends g.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Fm(e.digest);n&&(e=n)}let t=e!==void 0?g.createElement(Ye.Provider,{value:this.props.routeContext},g.createElement(Wa.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?g.createElement(Hm,{error:e},t):t}};uf.contextType=Im;var Bi=new WeakMap;function Hm({children:e,error:t}){let{basename:n}=g.useContext(Re);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Om(t.digest);if(r){let o=Bi.get(t);if(o)throw o;let i=tf(r.location,n);if(ef&&!Bi.get(t))if(i.isExternal||r.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const l=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:r.replace}));throw Bi.set(t,l),l}return g.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function Km({routeContext:e,match:t,children:n}){let r=g.useContext(On);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),g.createElement(Ye.Provider,{value:e},n)}function Qm(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let o=e,i=r==null?void 0:r.errors;if(i!=null){let m=o.findIndex(d=>d.route.id&&(i==null?void 0:i[d.route.id])!==void 0);H(m>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),o=o.slice(0,Math.min(o.length,m+1))}let l=!1,s=-1;if(n&&r){l=r.renderFallback;for(let m=0;m=0?o=o.slice(0,s+1):o=[o[0]];break}}}}let u=n==null?void 0:n.onError,c=r&&u?(m,d)=>{var f,x;u(m,{location:r.location,params:((x=(f=r.matches)==null?void 0:f[0])==null?void 0:x.params)??{},unstable_pattern:Pm(r.matches),errorInfo:d})}:void 0;return o.reduceRight((m,d,f)=>{let x,v=!1,w=null,_=null;r&&(x=i&&d.route.id?i[d.route.id]:void 0,w=d.route.errorElement||Wm,l&&(s<0&&f===0?(cf("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),v=!0,_=null):s===f&&(v=!0,_=d.route.hydrateFallbackElement||null)));let h=t.concat(o.slice(0,f+1)),p=()=>{let y;return x?y=w:v?y=_:d.route.Component?y=g.createElement(d.route.Component,null):d.route.element?y=d.route.element:y=m,g.createElement(Km,{match:d,routeContext:{outlet:m,matches:h,isDataRoute:r!=null},children:y})};return r&&(d.route.ErrorBoundary||d.route.errorElement||f===0)?g.createElement(uf,{location:r.location,revalidation:r.revalidation,component:w,error:x,children:p(),routeContext:{outlet:null,matches:h,isDataRoute:!0},onError:c}):p()},null)}function Ha(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Ym(e){let t=g.useContext(On);return H(t,Ha(e)),t}function Gm(e){let t=g.useContext(di);return H(t,Ha(e)),t}function qm(e){let t=g.useContext(Ye);return H(t,Ha(e)),t}function Ka(e){let t=qm(e),n=t.matches[t.matches.length-1];return H(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Xm(){return Ka("useRouteId")}function Jm(){var r;let e=g.useContext(Wa),t=Gm("useRouteError"),n=Ka("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Zm(){let{router:e}=Ym("useNavigate"),t=Ka("useNavigate"),n=g.useRef(!1);return af(()=>{n.current=!0}),g.useCallback(async(o,i={})=>{Fe(n.current,lf),n.current&&(typeof o=="number"?await e.navigate(o):await e.navigate(o,{fromRouteId:t,...i}))},[e,t])}var hu={};function cf(e,t,n){!t&&!hu[e]&&(hu[e]=!0,Fe(!1,n))}g.memo(eg);function eg({routes:e,future:t,state:n,isStatic:r,onError:o}){return sf(e,void 0,{state:n,isStatic:r,onError:o})}function rn({to:e,replace:t,state:n,relative:r}){H(Fn()," may be used only in the context of a component.");let{static:o}=g.useContext(Re);Fe(!o," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:i}=g.useContext(Ye),{pathname:l}=Pe(),s=en(),u=ci(e,Va(i),l,r==="path"),c=JSON.stringify(u);return g.useEffect(()=>{s(JSON.parse(c),{replace:t,state:n,relative:r})},[s,c,r,t,n]),null}function O(e){H(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function tg({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:o,static:i=!1,unstable_useTransitions:l}){H(!Fn(),"You cannot render a inside another . You should never have more than one in your app.");let s=e.replace(/^\/*/,"/"),u=g.useMemo(()=>({basename:s,navigator:o,static:i,unstable_useTransitions:l,future:{}}),[s,o,i,l]);typeof n=="string"&&(n=An(n));let{pathname:c="/",search:m="",hash:d="",state:f=null,key:x="default",unstable_mask:v}=n,w=g.useMemo(()=>{let _=ht(c,s);return _==null?null:{location:{pathname:_,search:m,hash:d,state:f,key:x,unstable_mask:v},navigationType:r}},[s,c,m,d,f,x,r,v]);return Fe(w!=null,` is not able to match the URL "${c}${m}${d}" because it does not start with the basename, so the won't render anything.`),w==null?null:g.createElement(Re.Provider,{value:u},g.createElement(Ar.Provider,{children:t,value:w}))}function ng({children:e,location:t}){return Bm(Wl(e),t)}function Wl(e,t=[]){let n=[];return g.Children.forEach(e,(r,o)=>{if(!g.isValidElement(r))return;let i=[...t,o];if(r.type===g.Fragment){n.push.apply(n,Wl(r.props.children,i));return}H(r.type===O,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),H(!r.props.index||!r.props.children,"An index route cannot have child routes.");let l={id:r.props.id||i.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(l.children=Wl(r.props.children,i)),n.push(l)}),n}var vo="get",xo="application/x-www-form-urlencoded";function fi(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function rg(e){return fi(e)&&e.tagName.toLowerCase()==="button"}function og(e){return fi(e)&&e.tagName.toLowerCase()==="form"}function ig(e){return fi(e)&&e.tagName.toLowerCase()==="input"}function lg(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function ag(e,t){return e.button===0&&(!t||t==="_self")&&!lg(e)}function Hl(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(o=>[n,o]):[[n,r]])},[]))}function sg(e,t){let n=Hl(e);return t&&t.forEach((r,o)=>{n.has(o)||t.getAll(o).forEach(i=>{n.append(o,i)})}),n}var no=null;function ug(){if(no===null)try{new FormData(document.createElement("form"),0),no=!1}catch{no=!0}return no}var cg=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Vi(e){return e!=null&&!cg.has(e)?(Fe(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${xo}"`),null):e}function dg(e,t){let n,r,o,i,l;if(og(e)){let s=e.getAttribute("action");r=s?ht(s,t):null,n=e.getAttribute("method")||vo,o=Vi(e.getAttribute("enctype"))||xo,i=new FormData(e)}else if(rg(e)||ig(e)&&(e.type==="submit"||e.type==="image")){let s=e.form;if(s==null)throw new Error('Cannot submit a + + + {/* Error */} + {error && ( +
+ {error} + +
+ )} + + {/* Filter bar */} +
+ {CATEGORY_FILTERS.map(cat => ( + + ))} +
+ + {/* Detail panel */} + {selectedType && ( + { setEditingType(selectedType); setShowModal(true); }} + onDelete={() => handleDelete(selectedType.id)} + onClose={() => setSelectedType(null)} + riskColor={riskColor} + riskBg={riskBg} + /> + )} + + {/* Grid */} + {loading ? ( +
+

Loading action types...

+
+ ) : actionTypes.length === 0 ? ( +
+

+

No action types found

+

Register your first custom action type to get started

+
+ ) : ( +
+ {actionTypes.map(at => { + const isHovered = hoveredCard === at.id; + const isSelected = selectedType?.id === at.id; + return ( +
setHoveredCard(at.id)} + onMouseLeave={() => setHoveredCard(null)} + onClick={() => handleCardClick(at)} + > + {at.is_builtin && 🔒} + +
+
+ {getIconEmoji(at.icon)} +
+
+

{at.display_name}

+ {at.action_type} +
+
+ +

+ {at.description || 'No description'} +

+ +
+
+ + {at.category} + + + {at.default_risk_tier} + +
+ +
+ + {at.usage_count || 0} uses + + +
+
+
+ ); + })} +
+ )} + + {/* Registration / Edit Modal */} + {showModal && ( + { setShowModal(false); setEditingType(null); }} + onSaved={() => { setShowModal(false); setEditingType(null); fetchData(); setSelectedType(null); }} + onError={setError} + /> + )} + + ); +} + +// ─── Detail Panel ──────────────────────────────────────────────────────────── + +interface DetailPanelProps { + type: ActionTypeWithStats; + loading: boolean; + onEdit: () => void; + onDelete: () => void; + onClose: () => void; + riskColor: (tier: string) => string; + riskBg: (tier: string) => string; +} + +function DetailPanel({ type, loading, onEdit, onDelete, onClose, riskColor, riskBg }: DetailPanelProps) { + const { isMobile } = useResponsive(); + + if (loading) { + return ( +
+

Loading details...

+
+ ); + } + + const maxUsage = Math.max(...(type.usage_last_7_days?.map(d => d.count) || [0]), 1); + + return ( +
+
+
+
+ {getIconEmoji(type.icon)} +
+
+

{type.display_name}

+ {type.action_type} +
+
+
+ + {!type.is_builtin && ( + + )} + +
+
+ +
+
+
+
Description
+

{type.description || 'No description'}

+
+ +
+
Properties
+
+ {type.category} + + {type.default_risk_tier} + + {type.is_builtin && 🔒 built-in} + + {type.enabled ? 'enabled' : 'disabled'} + +
+
+ +
+
Payload Schema
+
+ {Object.keys(type.payload_schema || {}).length > 0 + ? JSON.stringify(type.payload_schema, null, 2) + : '(no schema defined — accepts any payload)'} +
+
+
+ +
+
+
Usage — Last 7 Days ({type.usage_count} total)
+ {type.usage_last_7_days && type.usage_last_7_days.length > 0 ? ( +
+ {type.usage_last_7_days.map((d, i) => ( +
+ ))} +
+ ) : ( +

No usage recorded

+ )} +
+ +
+
Metadata
+
+
Created by: {type.created_by}
+
Created: {new Date(type.created_at).toLocaleString()}
+
Updated: {new Date(type.updated_at).toLocaleString()}
+
+
+
+
+
+ ); +} + +// ─── Registration Modal ────────────────────────────────────────────────────── + +interface RegistrationModalProps { + editingType: ActionType | null; + onClose: () => void; + onSaved: () => void; + onError: (msg: string) => void; +} + +function RegistrationModal({ editingType, onClose, onSaved, onError }: RegistrationModalProps) { + const isEdit = !!editingType; + + const [displayName, setDisplayName] = useState(editingType?.display_name || ''); + const [actionTypeSlug, setActionTypeSlug] = useState(editingType?.action_type || ''); + const [slugEdited, setSlugEdited] = useState(isEdit); + const [description, setDescription] = useState(editingType?.description || ''); + const [category, setCategory] = useState(editingType?.category || 'custom'); + const [riskTier, setRiskTier] = useState(editingType?.default_risk_tier || 'T1'); + const [payloadSchema, setPayloadSchema] = useState( + editingType?.payload_schema && Object.keys(editingType.payload_schema).length > 0 + ? JSON.stringify(editingType.payload_schema, null, 2) + : '' + ); + const [icon, setIcon] = useState(editingType?.icon || 'activity'); + const [color, setColor] = useState(editingType?.color || '#3b82f6'); + const [saving, setSaving] = useState(false); + const [formError, setFormError] = useState(null); + const [showIconPicker, setShowIconPicker] = useState(false); + + // Auto-generate slug from display name + useEffect(() => { + if (!slugEdited && !isEdit) { + const slug = displayName + .toLowerCase() + .replace(/[^a-z0-9]+/g, '_') + .replace(/^_|_$/g, ''); + setActionTypeSlug(slug); + } + }, [displayName, slugEdited, isEdit]); + + const handleSave = async () => { + setFormError(null); + + if (!displayName.trim()) { + setFormError('Display name is required'); + return; + } + + if (!actionTypeSlug.trim()) { + setFormError('Action type identifier is required'); + return; + } + + // Parse payload schema if provided + let parsedSchema: Record = {}; + if (payloadSchema.trim()) { + try { + parsedSchema = JSON.parse(payloadSchema); + } catch { + setFormError('Invalid JSON in payload schema'); + return; + } + } + + setSaving(true); + try { + if (isEdit && editingType) { + const updatePayload: UpdateActionTypePayload = {}; + if (!editingType.is_builtin) { + updatePayload.display_name = displayName; + updatePayload.description = description; + updatePayload.category = category; + updatePayload.payload_schema = parsedSchema; + updatePayload.default_risk_tier = riskTier; + updatePayload.icon = icon; + updatePayload.color = color; + } + await actionTypesApi.update(editingType.id, updatePayload); + } else { + const createPayload: CreateActionTypePayload = { + action_type: actionTypeSlug, + display_name: displayName, + description: description || undefined, + category, + payload_schema: parsedSchema, + default_risk_tier: riskTier, + icon, + color, + }; + await actionTypesApi.create(createPayload); + } + onSaved(); + } catch (err: any) { + const msg = err?.message || 'Failed to save'; + setFormError(msg); + onError(msg); + } finally { + setSaving(false); + } + }; + + return ( +
+
e.stopPropagation()}> +
+ {isEdit ? '✏️ Edit Action Type' : '➕ Register New Action Type'} + +
+ + {formError &&
{formError}
} + + {isEdit && editingType?.is_builtin && ( +
+ 🔒 This is a built-in action type. Only the enabled toggle can be changed. +
+ )} + + {/* Display Name */} +
+ + setDisplayName(e.target.value)} + placeholder="e.g., Wire Transfer" + disabled={isEdit && editingType?.is_builtin} + /> +
+ + {/* Action Type Slug */} +
+ + { setActionTypeSlug(e.target.value); setSlugEdited(true); }} + placeholder="e.g., wire_transfer" + disabled={isEdit} + /> +
+ + {/* Description */} +
+ +