loki-mode 11.141.4 → 11.141.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/README.md +1 -1
  2. package/SKILL.md +2 -2
  3. package/VERSION +1 -1
  4. package/autonomy/CONSTITUTION.md +2 -2
  5. package/autonomy/lib/expectation-ledger.py +3 -3
  6. package/autonomy/lib/own-render.py +2 -2
  7. package/autonomy/loki +31 -10
  8. package/autonomy/run.sh +1 -1
  9. package/dashboard/__init__.py +1 -1
  10. package/dashboard/audit.py +5 -5
  11. package/dashboard/server.py +1 -1
  12. package/docs/ARCHITECTURE.md +1 -1
  13. package/docs/CLI-REFERENCE.md +1 -1
  14. package/docs/COMPONENTS.md +1 -1
  15. package/docs/INSTALLATION.md +2 -2
  16. package/docs/dev/architecture-reference.md +3 -0
  17. package/docs/environment-variables.md +3 -0
  18. package/loki-ts/dist/loki.js +1779 -1760
  19. package/mcp/__init__.py +1 -1
  20. package/package.json +2 -2
  21. package/packages/control-plane/dist/server.js +1974 -1410
  22. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  23. package/references/agent-types.md +5 -10
  24. package/skills/agents.md +2 -2
  25. package/src/audit/crosslink.js +4 -4
  26. package/src/audit/index.js +3 -3
  27. package/web-app/dist/assets/{AdminPage-Dkj5FgZn.js → AdminPage-JzeyDRHB.js} +2 -2
  28. package/web-app/dist/assets/{Avatar-D6ZOMRQj.js → Avatar-BLI-euGn.js} +1 -1
  29. package/web-app/dist/assets/{Badge-przKIrx7.js → Badge-C7UXsn3u.js} +1 -1
  30. package/web-app/dist/assets/{Button-X5VdLM9H.js → Button-BsFDYQPM.js} +1 -1
  31. package/web-app/dist/assets/{CockpitPage-CWUPO4jE.js → CockpitPage-nU0B8qMQ.js} +1 -1
  32. package/web-app/dist/assets/{ComparePage-jinxUAH3.js → ComparePage-5HK3EU2X.js} +1 -1
  33. package/web-app/dist/assets/{ErrorBoundary-B3o_toch.js → ErrorBoundary-pOL7Vuv2.js} +1 -1
  34. package/web-app/dist/assets/{EvidenceReceiptPanel-ClySg933.js → EvidenceReceiptPanel-D7g9HerN.js} +1 -1
  35. package/web-app/dist/assets/{GitHubIssuesPanel-Dm_UsFAy.js → GitHubIssuesPanel-DVABIPMQ.js} +1 -1
  36. package/web-app/dist/assets/{GitHubPRsPanel-FAkViqVu.js → GitHubPRsPanel-DLR6cd49.js} +1 -1
  37. package/web-app/dist/assets/{HomePage-VeVb73XG.js → HomePage-Dcg02AL9.js} +2 -2
  38. package/web-app/dist/assets/{LoginPage-BpEKt-6l.js → LoginPage-ChuLL9LW.js} +1 -1
  39. package/web-app/dist/assets/{MagicPage-CNC180dU.js → MagicPage-CSuWqXO4.js} +1 -1
  40. package/web-app/dist/assets/{MetricsPage-BIfpdlcf.js → MetricsPage-CVWjxNhf.js} +1 -1
  41. package/web-app/dist/assets/{NotFoundPage-D54hg346.js → NotFoundPage-yVR85r6o.js} +1 -1
  42. package/web-app/dist/assets/{ProjectPage-Dl3rZ5bV.js → ProjectPage-2URjkyCj.js} +3 -3
  43. package/web-app/dist/assets/{ProjectsPage-DzQrB1jU.js → ProjectsPage-BXbxOSsZ.js} +1 -1
  44. package/web-app/dist/assets/{SettingsPage-DYB5XNpM.js → SettingsPage-C7PjmFr9.js} +1 -1
  45. package/web-app/dist/assets/{ShowcasePage-CjhoM3rN.js → ShowcasePage-C_6WIlRG.js} +1 -1
  46. package/web-app/dist/assets/{SystemSettingsPage-BVNnfllD.js → SystemSettingsPage-C38yDlgA.js} +1 -1
  47. package/web-app/dist/assets/{TeamsPage-1KkrFd0Y.js → TeamsPage-efEIcRlH.js} +1 -1
  48. package/web-app/dist/assets/{TemplatesPage-DGDnu_RB.js → TemplatesPage-BVN8hYn5.js} +1 -1
  49. package/web-app/dist/assets/{TerminalOutput-DSomtLgf.js → TerminalOutput-DQug-ZN5.js} +1 -1
  50. package/web-app/dist/assets/{activity-CW1VLglI.js → activity-CXqxbEYH.js} +1 -1
  51. package/web-app/dist/assets/{bell-tJAz56Yb.js → bell-AVtr4iZb.js} +1 -1
  52. package/web-app/dist/assets/{bot-B6I5yrNn.js → bot-BmoTiQie.js} +1 -1
  53. package/web-app/dist/assets/{check-IVM56fVX.js → check-BaHWRoFS.js} +1 -1
  54. package/web-app/dist/assets/{chevron-left-SsA1da21.js → chevron-left-BaeSE3MB.js} +1 -1
  55. package/web-app/dist/assets/{circle-alert-Dsq3DqO-.js → circle-alert-BqhM6ffv.js} +1 -1
  56. package/web-app/dist/assets/{clock-Cj9sLcEq.js → clock-CK6yBr-X.js} +1 -1
  57. package/web-app/dist/assets/{cloud-CSbZsshu.js → cloud-CcsDRj1b.js} +1 -1
  58. package/web-app/dist/assets/{code-xml-qCQWXElP.js → code-xml-Cfpz-EBt.js} +1 -1
  59. package/web-app/dist/assets/{database-BnviiGuk.js → database-Bk1oSAQj.js} +1 -1
  60. package/web-app/dist/assets/{dollar-sign-DaU9xa0A.js → dollar-sign-Cf1Wg3hh.js} +1 -1
  61. package/web-app/dist/assets/{file-code-corner-a393d0YD.js → file-code-corner-1D-LeA_0.js} +1 -1
  62. package/web-app/dist/assets/{file-plus-C3J3IYsn.js → file-plus-C13TfPSr.js} +1 -1
  63. package/web-app/dist/assets/{globe-DKRN-OfP.js → globe-D-bdUWR9.js} +1 -1
  64. package/web-app/dist/assets/{hammer-AJ4xEMEQ.js → hammer-BDvg0Bpo.js} +1 -1
  65. package/web-app/dist/assets/{index-BmuNF2mZ.js → index-PtPpcleW.js} +3 -3
  66. package/web-app/dist/assets/{layers-ZxK3Lg-E.js → layers-CvZLTWTW.js} +1 -1
  67. package/web-app/dist/assets/{loader-circle-BQGio77U.js → loader-circle-BMRJRTe3.js} +1 -1
  68. package/web-app/dist/assets/{lock-BSMOsGRv.js → lock-Dbi-okF-.js} +1 -1
  69. package/web-app/dist/assets/{package-Dc3iyh_u.js → package-C5m2TO7-.js} +1 -1
  70. package/web-app/dist/assets/{plus-BE-oSyaC.js → plus-D30AFrWv.js} +1 -1
  71. package/web-app/dist/assets/{refresh-cw-B24IKBF1.js → refresh-cw-CZ_9FRpU.js} +1 -1
  72. package/web-app/dist/assets/{rotate-ccw-Cm9OyY5g.js → rotate-ccw-GKppHg9k.js} +1 -1
  73. package/web-app/dist/assets/{scroll-text-gdM4zNkj.js → scroll-text-DnTznFUB.js} +1 -1
  74. package/web-app/dist/assets/{server-B8YzsGPg.js → server-Dz8p0Af6.js} +1 -1
  75. package/web-app/dist/assets/{shield-alert-COu4qEAn.js → shield-alert-DR0OwBTR.js} +1 -1
  76. package/web-app/dist/assets/{thumbs-up-Bs3ZSrCN.js → thumbs-up-OMV8Huvt.js} +1 -1
  77. package/web-app/dist/assets/{trash-2-vdl0RPBK.js → trash-2-LDV528Je.js} +1 -1
  78. package/web-app/dist/assets/{trending-down-DhxJxyuC.js → trending-down-CivTGd3Q.js} +1 -1
  79. package/web-app/dist/assets/{trending-up-sBLyeLVo.js → trending-up-r9twANK7.js} +1 -1
  80. package/web-app/dist/assets/{upload-B_SYHnav.js → upload-DMl7KGNJ.js} +1 -1
  81. package/web-app/dist/assets/{usePolling-CLtoYkMM.js → usePolling-DbEcreMW.js} +1 -1
  82. package/web-app/dist/assets/{user-CIt72Y0w.js → user-DZjXIjRz.js} +1 -1
  83. package/web-app/dist/index.html +1 -1
  84. package/web-app/server.py +1 -1
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
3
3
  "name": "loki-mode",
4
4
  "displayName": "Loki Mode",
5
- "version": "11.141.4",
5
+ "version": "11.141.5",
6
6
  "description": "Autonomous spec-to-product build system with a built-in trust layer (RARV-C closure loop, 8 quality gates, completion council). Ships Loki's spec-hardening, drift-detection, and deterministic PR verification commands plus the Loki MCP server.",
7
7
  "author": {
8
8
  "name": "Autonomi",
@@ -36,7 +36,7 @@ Loki Mode has 41 specialized agent roles across 8 domains (37 domain agents + 4
36
36
  | `ops-incident` | Incident response, runbooks, RCA, post-mortems, communication |
37
37
  | `ops-release` | Versioning, changelogs, blue-green, canary, rollbacks, feature flags |
38
38
  | `ops-cost` | Cloud cost optimization, right-sizing, FinOps, reserved instances |
39
- | `ops-compliance` | SOC2, GDPR, HIPAA, PCI-DSS, audit preparation, policy enforcement |
39
+ | `ops-compliance` | Audit preparation, policy documentation and enforcement (drafts for your own review; Loki makes no compliance claim) |
40
40
 
41
41
  ---
42
42
 
@@ -517,7 +517,7 @@ Each role lists its capabilities (the domain tables above are the summary), then
517
517
  - Dependency scanning
518
518
  - Container scanning
519
519
  - Penetration testing
520
- - Compliance (SOC2, GDPR, HIPAA)
520
+ - Audit preparation and policy documentation
521
521
 
522
522
  **Task Types:**
523
523
  - `security-scan`: Run security scans
@@ -658,12 +658,7 @@ Each role lists its capabilities (the domain tables above are the summary), then
658
658
 
659
659
  #### ops-compliance
660
660
  **Capabilities:**
661
- - SOC 2 Type II preparation
662
- - GDPR compliance
663
- - HIPAA compliance
664
- - PCI-DSS compliance
665
- - ISO 27001
666
- - Audit preparation
661
+ - Audit preparation (drafts for your own review; Loki makes no compliance claim)
667
662
  - Policy documentation
668
663
 
669
664
  **Task Types:**
@@ -760,14 +755,14 @@ Each role lists its capabilities (the domain tables above are the summary), then
760
755
  - Terms of Service
761
756
  - Privacy Policy
762
757
  - Cookie Policy
763
- - GDPR compliance
758
+ - Data-protection notice drafts for legal review
764
759
  - Contract templates
765
760
  - IP protection
766
761
 
767
762
  **Task Types:**
768
763
  - `tos`: Generate Terms of Service
769
764
  - `privacy-policy`: Create privacy policy
770
- - `gdpr`: Implement GDPR compliance
765
+ - `gdpr`: Draft data-protection notices and data-handling docs for legal review
771
766
  - `contract`: Create contract template
772
767
  - `compliance`: Verify legal compliance
773
768
 
package/skills/agents.md CHANGED
@@ -14,7 +14,7 @@
14
14
  - [The 41 Agent Roles (37 Domain + 4 Orchestration)](#the-41-agent-roles-37-domain--4-orchestration)
15
15
  <!-- TOC:END -->
16
16
 
17
- > **Full agent type definitions:** See `references/agent-types.md` for complete 41 agent role specifications across 8 domains (Engineering, Operations, Business, Data, Product, Growth, Review, Orchestration). These are prompt-defined specifications the orchestrator adopts per phase; parallelism on Claude Code comes from the blind review council, the adversarial reviewer, and optional git-worktree streams, sequential on other providers.
17
+ > **Full agent type definitions:** See `references/agent-types.md` for complete agent role specifications across 8 domains (Engineering, Operations, Business, Data, Product, Growth, Review, Orchestration). These are prompt-defined specifications the orchestrator adopts per phase; parallelism on Claude Code comes from the blind review council, the adversarial reviewer, and optional git-worktree streams, sequential on other providers.
18
18
 
19
19
  ---
20
20
 
@@ -27,7 +27,7 @@
27
27
  - `Bash` - Command execution
28
28
  - `platform-orchestrator` - Deployment and service management
29
29
 
30
- **The 41 agent types are ROLES defined through prompts.** Create specialized behavior:
30
+ **The agent types are ROLES defined through prompts.** Create specialized behavior:
31
31
 
32
32
  ```python
33
33
  # Security reviewer = general-purpose + security-focused prompt
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Loki Mode Audit Cross-Link (P3-9 unification).
5
5
  *
6
- * The system has two independent tamper-evident audit chains:
6
+ * The system has two independent hash-chained audit chains:
7
7
  *
8
8
  * 1. Agent chain -- src/audit/log.js (Node)
9
9
  * file: <project>/.loki/audit/audit.jsonl
@@ -23,7 +23,7 @@
23
23
  * agent chain's hash linkage), and ships a single `verifyUnified()`
24
24
  * command that validates BOTH sub-chains AND reconciles every anchor
25
25
  * against the live dashboard chain -- treating the pair as one logical,
26
- * tamper-evident trail.
26
+ * hash-chained trail.
27
27
  *
28
28
  * It also provides an append-only / external-witness OPTION
29
29
  * (`writeWitness`) so an external party can timestamp the unified root.
@@ -448,14 +448,14 @@ function hashManifest(manifestPath) {
448
448
 
449
449
  /**
450
450
  * Link the run manifest (loki-run.json, the build bill-of-materials) into
451
- * the agent audit chain so the manifest becomes tamper-evident and
451
+ * the agent audit chain so the manifest becomes hash-chained and
452
452
  * verifiable against the evidence chain.
453
453
  *
454
454
  * The manifest already embeds sha256 hashes of the evidence files
455
455
  * (test_results, coverage, ...) computed by run.sh. By recording the
456
456
  * manifest's OWN byte-hash as an `audit_manifest_link` entry, the anchor
457
457
  * is protected by the agent chain's hash linkage, and the evidence hashes
458
- * inside the manifest become transitively tamper-evident (mutating the
458
+ * inside the manifest become transitively hash-chained (mutating the
459
459
  * manifest to point at different evidence changes its byte-hash, which no
460
460
  * longer matches the anchored hash; mutating the anchor breaks chain
461
461
  * verification). We hash the manifest itself only -- we do NOT re-hash the
@@ -3,7 +3,7 @@
3
3
  /**
4
4
  * Loki Mode Audit Trail - Public API
5
5
  *
6
- * Enterprise audit logging with tamper-evident hash chains,
6
+ * Enterprise audit logging with hash chains,
7
7
  * compliance report generation, and data residency enforcement.
8
8
  *
9
9
  * Usage:
@@ -202,7 +202,7 @@ function flush() {
202
202
 
203
203
  /**
204
204
  * Cross-link the dashboard (Python) audit chain into the agent (JS)
205
- * audit chain, producing a single verifiable tamper-evident trail.
205
+ * audit chain, producing a single verifiable hash-chained trail.
206
206
  * See src/audit/crosslink.js.
207
207
  */
208
208
  function crossLink(opts) {
@@ -230,7 +230,7 @@ function writeWitness(opts) {
230
230
 
231
231
  /**
232
232
  * Link the run manifest (loki-run.json bill-of-materials) into the agent
233
- * audit chain so it becomes tamper-evident and verifiable against the
233
+ * audit chain so it becomes hash-chained and verifiable against the
234
234
  * evidence chain. No-op (honest) when the manifest is absent.
235
235
  * See src/audit/crosslink.js (linkManifest).
236
236
  */
@@ -1,4 +1,4 @@
1
- import{c as L,r as x,j as e,w as re,Z as ne,m as le,h as ie,p as P,F as ye,U as I,X as ce,L as de,x as oe,M as Ae,T as Z,S as we,l as xe,k as me,y as Ce,E as Fe,a0 as Se,a as U,a2 as he}from"./index-BmuNF2mZ.js";import{B as C}from"./Button-X5VdLM9H.js";import{T as $e}from"./trending-up-sBLyeLVo.js";import{C as z}from"./clock-Cj9sLcEq.js";import{A as Be,U as ue,M as De}from"./Avatar-D6ZOMRQj.js";import{A as J}from"./activity-CW1VLglI.js";import{R as pe}from"./refresh-cw-B24IKBF1.js";import{G as ze}from"./globe-DKRN-OfP.js";import{C as Le}from"./chevron-left-SsA1da21.js";import{C as je}from"./check-IVM56fVX.js";import{D as Y}from"./dollar-sign-DaU9xa0A.js";import{U as Te}from"./user-CIt72Y0w.js";import{D as Me}from"./database-BnviiGuk.js";import{L as Ue}from"./lock-BSMOsGRv.js";import{S as Re}from"./scroll-text-gdM4zNkj.js";import{S as Ie}from"./shield-alert-COu4qEAn.js";/**
1
+ import{c as L,r as x,j as e,w as re,Z as ne,m as le,h as ie,p as P,F as ye,U as I,X as ce,L as de,x as oe,M as Ae,T as Z,S as we,l as xe,k as me,y as Ce,E as Fe,a0 as Se,a as U,a2 as he}from"./index-PtPpcleW.js";import{B as C}from"./Button-BsFDYQPM.js";import{T as $e}from"./trending-up-r9twANK7.js";import{C as z}from"./clock-CK6yBr-X.js";import{A as Be,U as ue,M as De}from"./Avatar-BLI-euGn.js";import{A as J}from"./activity-CXqxbEYH.js";import{R as pe}from"./refresh-cw-CZ_9FRpU.js";import{G as ze}from"./globe-D-bdUWR9.js";import{C as Le}from"./chevron-left-BaeSE3MB.js";import{C as je}from"./check-BaHWRoFS.js";import{D as Y}from"./dollar-sign-Cf1Wg3hh.js";import{U as Te}from"./user-DZjXIjRz.js";import{D as Me}from"./database-Bk1oSAQj.js";import{L as Ue}from"./lock-Dbi-okF-.js";import{S as Re}from"./scroll-text-DnTznFUB.js";import{S as Ie}from"./shield-alert-DR0OwBTR.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -29,4 +29,4 @@ import{c as L,r as x,j as e,w as re,Z as ne,m as le,h as ie,p as P,F as ye,U as
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
31
  */const Je=[["circle",{cx:"15",cy:"12",r:"3",key:"1afu0r"}],["rect",{width:"20",height:"14",x:"2",y:"5",rx:"7",key:"g7kal2"}]],Ye=L("toggle-right",Je);function R({children:s}){return e.jsxs("p",{className:"text-sm text-[#939084] py-4",children:[e.jsx("span",{className:"font-medium text-[#6B6960]",children:"Not recorded."})," ",s]})}function Ke({data:s}){const[r,c]=x.useState(null);if(s.length===0)return null;const n=600,a=200,t={top:20,right:20,bottom:30,left:60},j=n-t.left-t.right,o=a-t.top-t.bottom,b=Math.max(...s.map(i=>i.tokens)),h=0,m=b-h||1,E=s.map((i,N)=>({x:t.left+N/(s.length-1)*j,y:t.top+o-(i.tokens-h)/m*o,...i})),v=E.map((i,N)=>`${N===0?"M":"L"} ${i.x} ${i.y}`).join(" "),u=`${v} L ${E[E.length-1].x} ${t.top+o} L ${E[0].x} ${t.top+o} Z`,p=i=>i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(0)}K`:String(i),k=Array.from({length:5},(i,N)=>({value:h+m*N/4,y:t.top+o-N/4*o}));return e.jsxs("svg",{viewBox:`0 0 ${n} ${a}`,className:"w-full",preserveAspectRatio:"xMidYMid meet",children:[k.map((i,N)=>e.jsxs("g",{children:[e.jsx("line",{x1:t.left,y1:i.y,x2:n-t.right,y2:i.y,stroke:"currentColor",strokeOpacity:"0.08",strokeDasharray:"4 4"}),e.jsx("text",{x:t.left-8,y:i.y+4,textAnchor:"end",className:"text-[10px] fill-[#939084]",children:p(i.value)})]},N)),e.jsx("path",{d:u,fill:"url(#tokenGradient)",opacity:"0.15"}),e.jsx("path",{d:v,fill:"none",stroke:"#553DE9",strokeWidth:"2",strokeLinejoin:"round"}),e.jsx("defs",{children:e.jsxs("linearGradient",{id:"tokenGradient",x1:"0",y1:"0",x2:"0",y2:"1",children:[e.jsx("stop",{offset:"0%",stopColor:"#553DE9"}),e.jsx("stop",{offset:"100%",stopColor:"#553DE9",stopOpacity:"0"})]})}),E.map((i,N)=>e.jsxs("g",{children:[e.jsx("circle",{cx:i.x,cy:i.y,r:r===N?5:3,fill:r===N?"#553DE9":"white",stroke:"#553DE9",strokeWidth:"2",className:"cursor-pointer transition-all",onMouseEnter:()=>c(N),onMouseLeave:()=>c(null)}),r===N&&e.jsxs("g",{children:[e.jsx("rect",{x:i.x-50,y:i.y-36,width:"100",height:"24",rx:"4",fill:"#36342E"}),e.jsxs("text",{x:i.x,y:i.y-20,textAnchor:"middle",className:"text-[10px] fill-white font-mono",children:[p(i.tokens)," | ",i.date.slice(5)]})]})]},N)),[0,Math.floor(s.length/2),s.length-1].map(i=>e.jsx("text",{x:E[i].x,y:a-4,textAnchor:"middle",className:"text-[10px] fill-[#939084]",children:s[i].date.slice(5)},i))]})}function Xe({data:s}){const[r,c]=x.useState(null),n=s.reduce((m,E)=>m+E.cost,0),a=160,t=a/2,j=60,o=40;let b=-90;const h=s.map((m,E)=>{const v=m.percentage/100*360,u=b,p=b+v;b=p;const k=u*Math.PI/180,i=p*Math.PI/180,N=v>180?1:0,g=r===E?j+4:j,F=[`M ${t+o*Math.cos(k)} ${t+o*Math.sin(k)}`,`L ${t+g*Math.cos(k)} ${t+g*Math.sin(k)}`,`A ${g} ${g} 0 ${N} 1 ${t+g*Math.cos(i)} ${t+g*Math.sin(i)}`,`L ${t+o*Math.cos(i)} ${t+o*Math.sin(i)}`,`A ${o} ${o} 0 ${N} 0 ${t+o*Math.cos(k)} ${t+o*Math.sin(k)}`,"Z"].join(" ");return{...m,path:F,index:E}});return e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("svg",{width:a,height:a,viewBox:`0 0 ${a} ${a}`,children:[h.map(m=>e.jsx("path",{d:m.path,fill:m.color,opacity:r!==null&&r!==m.index?.4:1,className:"cursor-pointer transition-opacity",onMouseEnter:()=>c(m.index),onMouseLeave:()=>c(null)},m.index)),e.jsx("text",{x:t,y:t-6,textAnchor:"middle",className:"text-xs fill-[#939084]",children:"Total"}),e.jsxs("text",{x:t,y:t+12,textAnchor:"middle",className:"text-sm fill-[#36342E] dark:fill-[#E8E6E3] font-semibold",children:["$",n.toFixed(2)]})]}),e.jsx("div",{className:"flex flex-col gap-2",children:s.map((m,E)=>e.jsxs("div",{className:"flex items-center gap-2 text-sm",onMouseEnter:()=>c(E),onMouseLeave:()=>c(null),children:[e.jsx("span",{className:"w-3 h-3 rounded-sm flex-shrink-0",style:{backgroundColor:m.color}}),e.jsx("span",{className:"text-[#36342E] dark:text-[#E8E6E3]",children:m.provider}),e.jsxs("span",{className:"text-[#939084] ml-auto font-mono",children:["$",m.cost.toFixed(2)]})]},E))})]})}function Qe({data:s}){const r=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],c=Math.max(...s.flat()),n=a=>{const t=c>0?a/c:0;return t===0?"bg-[#F8F4F0] dark:bg-[#1A1A1E]":t<.25?"bg-[#553DE9]/10":t<.5?"bg-[#553DE9]/25":t<.75?"bg-[#553DE9]/50":"bg-[#553DE9]/80"};return e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("div",{className:"inline-block",children:[e.jsx("div",{className:"flex gap-0.5 mb-1 ml-10",children:Array.from({length:24},(a,t)=>e.jsx("div",{className:"w-4 text-center text-[9px] text-[#939084]",children:t%6===0?`${t}`:""},t))}),s.map((a,t)=>e.jsxs("div",{className:"flex items-center gap-0.5 mb-0.5",children:[e.jsx("span",{className:"w-8 text-right text-[10px] text-[#939084] mr-1",children:r[t]}),a.map((j,o)=>e.jsx("div",{className:`w-4 h-4 rounded-sm ${n(j)} transition-colors`,title:`${r[t]} ${o}:00 - ${j} builds`},o))]},t)),e.jsxs("div",{className:"flex items-center gap-1 mt-2 ml-10",children:[e.jsx("span",{className:"text-[10px] text-[#939084]",children:"Less"}),["bg-[#F8F4F0] dark:bg-[#1A1A1E]","bg-[#553DE9]/10","bg-[#553DE9]/25","bg-[#553DE9]/50","bg-[#553DE9]/80"].map((a,t)=>e.jsx("div",{className:`w-3 h-3 rounded-sm ${a}`},t)),e.jsx("span",{className:"text-[10px] text-[#939084]",children:"More"})]})]})})}function es({data:s={},className:r=""}){var t,j,o,b;const c=Object.values(s).some(h=>h!=null),n=x.useCallback(()=>{const h=new Blob([JSON.stringify(s,null,2)],{type:"application/json"}),m=URL.createObjectURL(h),E=document.createElement("a");E.href=m,E.download=`usage-analytics-${new Date().toISOString().split("T")[0]}.json`,E.click(),URL.revokeObjectURL(m)},[s]),a=s.buildSuccessRate;return e.jsxs("div",{className:`space-y-6 ${r}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(re,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Usage Analytics"})]}),c&&e.jsx(C,{size:"sm",variant:"ghost",icon:K,onClick:n,children:"Export"})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx($e,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Token Usage (30 Days)"})]}),(t=s.tokenUsage)!=null&&t.length?e.jsx(Ke,{data:s.tokenUsage}):e.jsx(R,{children:"No endpoint on this server reports daily token usage."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(Ge,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Cost by Model"})]}),(j=s.costBreakdown)!=null&&j.length?e.jsx(Xe,{data:s.costBreakdown}):e.jsx(R,{children:"No run on this project has recorded a cost yet."})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(ne,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Build Success Rate"})]}),a!=null?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsxs("span",{className:"text-3xl font-bold text-[#36342E] dark:text-[#E8E6E3]",children:[a,"%"]}),e.jsxs("div",{className:"text-xs text-[#939084]",children:[e.jsxs("div",{children:[s.successfulBuilds," passed"]}),e.jsxs("div",{children:[s.failedBuilds," failed"]}),e.jsxs("div",{children:[s.totalBuilds," total"]})]})]}),e.jsx("div",{className:"h-3 bg-[#F8F4F0] dark:bg-[#1A1A1E] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${a}%`,background:a>=80?"#1FC5A8":a>=60?"#F59E0B":"#C45B5B"}})})]}):e.jsx(R,{children:"Build outcomes are not tracked here. Verified outcomes appear as Evidence Receipts on the Metrics page."}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h4",{className:"text-xs font-medium text-[#939084] uppercase tracking-wider mb-2",children:"Top Templates"}),(o=s.templateUsage)!=null&&o.length?e.jsx("div",{className:"space-y-2",children:s.templateUsage.slice(0,5).map((h,m)=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-sm text-[#36342E] dark:text-[#E8E6E3]",children:[m+1,". ",h.name]}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:[h.count," builds"]})]},m))}):e.jsx(R,{children:"Template usage is not recorded."})]})]})]}),e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(z,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Peak Usage Hours"})]}),(b=s.peakHours)!=null&&b.length?e.jsx(Qe,{data:s.peakHours}):e.jsx(R,{children:"Build start times are not aggregated by hour on this server."})]})]})}const se={auth:"#553DE9",project:"#1FC5A8",admin:"#F59E0B",deploy:"#C45B5B",api:"#6366F1",system:"#939084"};function ss({category:s}){return e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium uppercase tracking-wide",style:{backgroundColor:`${se[s]}15`,color:se[s]},children:s})}function ts({events:s,onFetch:r,pollInterval:c=3e4,className:n=""}){const[a,t]=x.useState(s??[]),[j,o]=x.useState(null),[b,h]=x.useState(""),[m,E]=x.useState(""),[v,u]=x.useState(""),[p,k]=x.useState(""),[i,N]=x.useState(""),[g,F]=x.useState(!1),[d,f]=x.useState(null),[y,w]=x.useState(1),[T,X]=x.useState(!1),G=x.useRef(null),M=15;x.useEffect(()=>{if(!r)return;const l=async()=>{try{const A=await r({search:b,user:m,actionType:v,dateFrom:p,dateTo:i});t(A),o(null)}catch(A){o(A instanceof Error?A.message:"request failed")}};if(l(),!(c<=0))return G.current=setInterval(l,c),()=>{G.current&&clearInterval(G.current)}},[r,c,b,m,v,p,i]);const fe=[...new Set(a.map(l=>l.user))].sort(),Ee=[...new Set(a.map(l=>l.action))].sort(),B=a.filter(l=>{if(b){const A=b.toLowerCase();if(!(l.action.toLowerCase().includes(A)||l.user.toLowerCase().includes(A)||l.target.toLowerCase().includes(A)||l.details.toLowerCase().includes(A)||l.ip.includes(A)))return!1}return!(m&&l.user!==m||v&&l.action!==v||p&&l.timestamp<p||i&&l.timestamp>i+"T23:59:59")}),D=Math.ceil(B.length/M),Q=B.slice((y-1)*M,y*M);x.useEffect(()=>{w(1)},[b,m,v,p,i]);const be=x.useCallback(()=>{const l=["Timestamp","User","Action","Target","Details","IP","Category"],A=B.map($=>[$.timestamp,$.user,$.action,$.target,`"${$.details.replace(/"/g,'""')}"`,$.ip,$.category]),S=[l.join(","),...A.map($=>$.join(","))].join(`
32
- `),ke=new Blob([S],{type:"text/csv"}),ee=URL.createObjectURL(ke),H=document.createElement("a");H.href=ee,H.download=`audit-log-${new Date().toISOString().split("T")[0]}.csv`,H.click(),URL.revokeObjectURL(ee)},[B]),ve=x.useCallback(async()=>{if(r){X(!0);try{const l=await r({search:b,user:m,actionType:v,dateFrom:p,dateTo:i});t(l),o(null)}catch(l){o(l instanceof Error?l.message:"request failed")}finally{X(!1)}}},[r,b,m,v,p,i]),Ne=l=>new Date(l).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:`space-y-4 ${n}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Audit Trail"}),!j&&e.jsxs("span",{className:"text-xs text-[#939084] ml-1",children:[B.length," event",B.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"ghost",icon:pe,onClick:ve,loading:T,children:"Refresh"}),e.jsx(C,{size:"sm",variant:"ghost",icon:K,onClick:be,children:"CSV"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(le,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:b,onChange:l=>h(l.target.value),placeholder:"Search events...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]"})]}),e.jsx(C,{size:"sm",variant:g?"secondary":"ghost",icon:We,onClick:()=>F(!g),children:"Filters"})]}),g&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 p-3 border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg bg-[#F8F4F0] dark:bg-[#222228]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"User"}),e.jsxs("select",{value:m,onChange:l=>E(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Users"}),fe.map(l=>e.jsx("option",{value:l,children:l},l))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Action"}),e.jsxs("select",{value:v,onChange:l=>u(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Actions"}),Ee.map(l=>e.jsx("option",{value:l,children:l},l))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"From"}),e.jsx("input",{type:"date",value:p,onChange:l=>k(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"To"}),e.jsx("input",{type:"date",value:i,onChange:l=>N(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]"})]})]})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#F8F4F0] dark:bg-[#222228]",children:[e.jsx("th",{className:"w-8 px-2 py-2.5"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Timestamp"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"User"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Target"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960] hidden md:table-cell",children:"IP"})]})}),e.jsxs("tbody",{children:[Q.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors cursor-pointer",onClick:()=>f(d===l.id?null:l.id),children:[e.jsx("td",{className:"px-2 py-2.5 text-center",children:d===l.id?e.jsx(ie,{size:12,className:"text-[#939084]"}):e.jsx(P,{size:12,className:"text-[#939084]"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[#939084]",children:[e.jsx(z,{size:12}),e.jsx("span",{className:"font-mono",children:Ne(l.timestamp)})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{name:l.user.split("@")[0],size:"sm"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] truncate max-w-[150px]",children:l.user})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{category:l.category}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:l.action})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-[#6B6960] truncate max-w-[120px] block",children:l.target||"--"})}),e.jsx("td",{className:"px-3 py-2.5 hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[#939084]",children:[e.jsx(ze,{size:12}),e.jsx("span",{className:"font-mono",children:l.ip||"--"})]})})]},l.id),d===l.id&&e.jsx("tr",{className:"bg-[#F8F4F0] dark:bg-[#222228]",children:e.jsx("td",{colSpan:6,className:"px-6 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ye,{size:14,className:"text-[#939084] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-[#6B6960]",children:[e.jsx("p",{className:"font-medium text-[#201515] dark:text-[#E8E6E3] mb-1",children:"Details"}),e.jsx("p",{children:l.details}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[#939084]",children:[e.jsxs("span",{children:["Event ID: ",l.id]}),e.jsxs("span",{children:["Full timestamp: ",new Date(l.timestamp).toISOString()]}),e.jsxs("span",{children:["IP: ",l.ip||"not recorded"]})]})]})]})})},`${l.id}-details`)]})),Q.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-sm text-[#939084]",children:j?`Could not load the audit log (${j}). Nothing is shown rather than a guess.`:a.length===0?"No audit events recorded yet.":"No events match your filters."})})]})]})}),D>1&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-[#939084]",children:["Showing ",(y-1)*M+1,"-",Math.min(y*M,B.length)," of ",B.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>w(l=>Math.max(1,l-1)),disabled:y===1,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(Le,{size:16})}),Array.from({length:Math.min(D,5)},(l,A)=>{let S;return D<=5||y<=3?S=A+1:y>=D-2?S=D-4+A:S=y-2+A,e.jsx("button",{onClick:()=>w(S),className:`w-8 h-8 rounded-lg text-xs font-medium transition-colors ${y===S?"bg-[#553DE9] text-white":"text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]"}`,children:S},S)}),e.jsx("button",{onClick:()=>w(l=>Math.min(D,l+1)),disabled:y===D,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(P,{size:16})})]})]})]})}const V={admin:{label:"Admin",color:"#553DE9"},editor:{label:"Editor",color:"#1FC5A8"},viewer:{label:"Viewer",color:"#939084"}},te={active:{label:"Active",color:"#1FC5A8"},inactive:{label:"Inactive",color:"#939084"},invited:{label:"Invited",color:"#F59E0B"}};function q(s){if(!s)return"Never";const r=Date.now()-new Date(s).getTime(),c=Math.floor(r/6e4);if(c<1)return"Just now";if(c<60)return`${c}m ago`;const n=Math.floor(c/60);if(n<24)return`${n}h ago`;const a=Math.floor(n/24);return a<30?`${a}d ago`:`${Math.floor(a/30)}mo ago`}function ge(s){return s.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function as({onSubmit:s,onCancel:r}){const[c,n]=x.useState(""),[a,t]=x.useState("editor");return e.jsxs("div",{className:"border border-[#553DE9]/20 bg-[#553DE9]/5 dark:bg-[#553DE9]/10 rounded-lg p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Invite New User"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"email",value:c,onChange:j=>n(j.target.value),placeholder:"colleague@company.com",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]",autoFocus:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Role"}),e.jsxs("select",{value:a,onChange:j=>t(j.target.value),className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",icon:ue,onClick:()=>s(c,a),disabled:!c.trim()||!c.includes("@"),children:"Send Invite"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:r,children:"Cancel"})]})]})}function rs({user:s,onClose:r,onChangeRole:c,onToggleStatus:n}){return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"w-10 h-10 rounded-full"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-sm font-bold",children:ge(s.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:s.name}),e.jsx("p",{className:"text-xs text-[#939084]",children:s.email})]})]}),e.jsx("button",{onClick:r,className:"p-1 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]",children:e.jsx(ce,{size:16})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Role"}),e.jsxs("select",{value:s.role,onChange:a=>c(a.target.value),className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Status"}),e.jsx("button",{onClick:n,className:"flex items-center gap-2 px-3 py-2 w-full rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-sm text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(Ye,{size:16,className:"text-[#1FC5A8]"}),e.jsx("span",{className:"text-[#1FC5A8]",children:"Active"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{size:16,className:"text-[#939084]"}),e.jsx("span",{className:"text-[#939084]",children:"Inactive"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-xs text-[#939084] pt-2 border-t border-[#ECEAE3] dark:border-[#2A2A30]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{size:12}),e.jsxs("span",{children:["Last active: ",q(s.lastActive)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{size:12}),e.jsxs("span",{children:["Joined: ",q(s.joinedAt)]})]})]})]})}function ns({users:s,onChangeRole:r,onToggleStatus:c,onInviteUser:n,className:a=""}){const[t,j]=x.useState(s??[]),[o,b]=x.useState(""),[h,m]=x.useState(""),[E,v]=x.useState(!1),[u,p]=x.useState(null),k=t.filter(d=>{if(o){const f=o.toLowerCase();if(!d.name.toLowerCase().includes(f)&&!d.email.toLowerCase().includes(f))return!1}return!(h&&d.role!==h)}),i=t.find(d=>d.id===u)||null,N=x.useCallback(async(d,f)=>{if(!n)return;await n(d,f);const y={id:`u-${Date.now()}`,name:d.split("@")[0],email:d,role:f,status:"invited",lastActive:null,joinedAt:new Date().toISOString()};j(w=>[...w,y]),v(!1)},[n]),g=x.useCallback(async(d,f)=>{r&&(await r(d,f),j(y=>y.map(w=>w.id===d?{...w,role:f}:w)))},[r]),F=x.useCallback(async d=>{const f=t.find(w=>w.id===d);if(!f||!c)return;const y=f.status!=="active";await c(d,y),j(w=>w.map(T=>T.id===d?{...T,status:y?"active":"inactive"}:T))},[t,c]);return s?e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"User Management"}),e.jsxs("span",{className:"text-xs text-[#939084]",children:[t.length," users"]})]}),!E&&n&&e.jsx(C,{size:"sm",variant:"secondary",icon:ue,onClick:()=>v(!0),children:"Invite User"})]}),E&&e.jsx(as,{onSubmit:N,onCancel:()=>v(!1)}),i&&e.jsx(rs,{user:i,onClose:()=>p(null),onChangeRole:d=>g(i.id,d),onToggleStatus:()=>F(i.id)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(le,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:o,onChange:d=>b(d.target.value),placeholder:"Search users...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]"})]}),e.jsxs("select",{value:h,onChange:d=>m(d.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Roles"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]}),e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:[k.map(d=>e.jsxs("button",{type:"button",onClick:()=>p(u===d.id?null:d.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors ${u===d.id?"bg-[#F8F4F0] dark:bg-[#222228]":""}`,children:[d.avatar_url?e.jsx("img",{src:d.avatar_url,alt:"",className:"w-8 h-8 rounded-full flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:ge(d.name)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:d.name}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:d.email})]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium flex-shrink-0",style:{backgroundColor:`${V[d.role].color}15`,color:V[d.role].color},children:V[d.role].label}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:te[d.status].color}}),e.jsx("span",{className:"text-xs text-[#939084] hidden md:inline",children:te[d.status].label})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0 hidden lg:inline w-16 text-right",children:q(d.lastActive)}),e.jsx(P,{size:14,className:"text-[#939084] flex-shrink-0"})]},d.id)),k.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No users match your search."})]})]}):e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"User Management"})]}),e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg px-4 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"This server has no user directory, so no users are listed. Team membership is managed on the Teams page."})]})]})}function ls({project:s,onApprove:r,onReject:c}){const[n,a]=x.useState(!1),[t,j]=x.useState(""),[o,b]=x.useState(!1);return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(!n),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[n?e.jsx(ie,{size:14,className:"text-[#939084]"}):e.jsx(P,{size:14,className:"text-[#939084]"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-[#F59E0B]/10 text-[#F59E0B]",children:"Pending"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#939084] mt-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Te,{size:10}),s.submittedBy]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(de,{size:10}),s.template]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Y,{size:10}),"~$",s.estimatedCost.toFixed(2)]})]})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0",children:new Date(s.submittedAt).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})})]}),n&&e.jsxs("div",{className:"px-4 pb-4 pt-2 border-t border-[#ECEAE3] dark:border-[#2A2A30] space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Template"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.template})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Provider"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.provider})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Est. Cost"}),e.jsxs("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:["$",s.estimatedCost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Est. Iterations"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.estimatedIterations})]})]}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:s.description}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:t,onChange:h=>j(h.target.value),placeholder:"Add a comment (optional)...",rows:2,className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084] resize-none"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",icon:je,onClick:()=>r(t),children:"Approve"}),e.jsx(C,{size:"sm",variant:"danger",icon:ce,onClick:()=>c(t),children:"Reject"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"Cancel"})]})]}):e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(C,{size:"sm",variant:"secondary",icon:Ae,onClick:()=>b(!0),children:"Review"})})]})]})}function is({configs:s}){return e.jsx("div",{className:"space-y-3",children:s.map(r=>{const c=r.budgetLimit>0?r.budgetUsed/r.budgetLimit*100:0,n=c>=r.alertThreshold,a=c>=100;return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:r.projectName}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(Z,{size:14,className:a?"text-[#C45B5B]":"text-[#F59E0B]"}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:["$",r.budgetUsed.toFixed(2)," / $",r.budgetLimit.toFixed(2)]})]})]}),e.jsx("div",{className:"h-2 bg-[#F8F4F0] dark:bg-[#1A1A1E] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(c,100)}%`,background:a?"#C45B5B":n?"#F59E0B":"#1FC5A8"}})}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("span",{className:"text-[10px] text-[#939084]",children:[c.toFixed(0),"% used"]}),e.jsxs("span",{className:"text-[10px] text-[#939084]",children:["Alert at ",r.alertThreshold,"%"]})]})]},r.projectId)})})}function W({children:s}){return e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{size:24,className:"mx-auto text-[#939084] mb-2"}),e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:s})]})}function cs({pendingProjects:s,budgetConfigs:r,onApproveProject:c,onRejectProject:n,className:a=""}){const[t,j]=x.useState(s??[]),[o,b]=x.useState("approvals"),h=t.filter(u=>u.status==="pending").length,m=x.useCallback(async(u,p)=>{c&&(await c(u,p),j(k=>k.map(i=>i.id===u?{...i,status:"approved"}:i)))},[c]),E=x.useCallback(async(u,p)=>{n&&(await n(u,p),j(k=>k.map(i=>i.id===u?{...i,status:"rejected"}:i)))},[n]),v=[{id:"approvals",label:"Approvals",icon:je,count:h},{id:"budgets",label:"Budgets",icon:Y},{id:"templates",label:"Templates",icon:de}];return e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Project Governance"})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-[#ECEAE3] dark:border-[#2A2A30]",children:v.map(u=>e.jsxs("button",{onClick:()=>b(u.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${o===u.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(u.icon,{size:14}),u.label,u.count!==void 0&&u.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] bg-[#553DE9]/10 text-[#553DE9]",children:u.count})]},u.id))}),o==="approvals"&&!s&&e.jsx(W,{children:"No project approval workflow is wired to this server, so nothing is waiting and nothing has been reviewed."}),o==="approvals"&&s&&e.jsx("div",{className:"space-y-3",children:t.filter(u=>u.status==="pending").length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{size:24,className:"mx-auto text-[#939084] mb-2"}),e.jsx("p",{className:"text-sm text-[#939084]",children:"No pending approvals"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"All project requests have been reviewed."})]}):t.filter(u=>u.status==="pending").map(u=>e.jsx(ls,{project:u,onApprove:p=>m(u.id,p),onReject:p=>E(u.id,p)},u.id))}),o==="budgets"&&(r?e.jsx(is,{configs:r}):e.jsx(W,{children:"No per-project budgets are served here. A run's spend cap is set with LOKI_BUDGET_LIMIT and shown on the Metrics page."})),o==="templates"&&e.jsx(W,{children:"Template restrictions are not stored or enforced by this server, so none are shown."})]})}function ds({status:s}){switch(s){case"pass":return e.jsx(xe,{size:18,className:"text-[#1FC5A8]"});case"fail":return e.jsx(me,{size:18,className:"text-[#C45B5B]"});case"warning":return e.jsx(Z,{size:18,className:"text-[#F59E0B]"})}}const os={security:Ue,access:I,data:Me,audit:Ce};function xs({score:s}){const t=2*Math.PI*56,o=270/360*t,b=s/100*o,h=s>=80?"#1FC5A8":s>=60?"#F59E0B":"#C45B5B",m=135;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:140,height:140,viewBox:"0 0 140 140",children:[e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:"currentColor",strokeOpacity:"0.08",strokeWidth:10,strokeDasharray:`${o} ${t}`,strokeLinecap:"round",transform:`rotate(${m} 70 70)`}),e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:h,strokeWidth:10,strokeDasharray:`${b} ${t}`,strokeLinecap:"round",transform:`rotate(${m} 70 70)`,className:"transition-all duration-700"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsxs("span",{className:"text-3xl font-bold text-[#36342E] dark:text-[#E8E6E3]",children:[s,"%"]}),e.jsx("span",{className:"text-xs text-[#939084]",children:"Compliant"})]})]})}function ms({items:s,onRefresh:r,className:c=""}){const[n,a]=x.useState(s??[]),[t,j]=x.useState(!1),[o,b]=x.useState(null),[h,m]=x.useState(!1),E=n.filter(g=>g.status==="pass").length,v=n.filter(g=>g.status==="warning").length,u=n.filter(g=>g.status==="fail").length,p=n.length>0?Math.round(E/n.length*100):null,k=x.useCallback(async()=>{j(!0);try{if(r){const g=await r();a(g)}}catch{}finally{j(!1)}},[r]),i=x.useCallback(()=>{m(!0);const g={generatedAt:new Date().toISOString(),overallScore:p,summary:{pass:E,warning:v,fail:u,total:n.length},items:n.map(y=>({title:y.title,status:y.status,category:y.category,details:y.details,lastChecked:y.lastChecked}))},F=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),d=URL.createObjectURL(F),f=document.createElement("a");f.href=d,f.download=`compliance-report-${new Date().toISOString().split("T")[0]}.json`,f.click(),URL.revokeObjectURL(d),setTimeout(()=>m(!1),1e3)},[n,p,E,v,u]),N=["security","access","data","audit"];return e.jsxs("div",{className:`space-y-6 ${c}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Compliance"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(C,{size:"sm",variant:"ghost",icon:pe,onClick:k,loading:t,children:"Refresh"}),p!==null&&e.jsx(C,{size:"sm",variant:"secondary",icon:K,onClick:i,loading:h,children:"Generate Report"})]})]}),p===null?e.jsxs("div",{className:"card p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"No compliance checks are wired to this server, so there is no score. Nothing here has been checked."})]}):e.jsx("div",{className:"card p-6",children:e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsx(xs,{score:p}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Compliance Score"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:16,className:"text-[#1FC5A8]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:E}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Passing"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{size:16,className:"text-[#F59E0B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:v}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Warnings"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:16,className:"text-[#C45B5B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:u}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Failing"})]})]})]})]})]})}),N.map(g=>{const F=n.filter(f=>f.category===g);if(F.length===0)return null;const d=os[g];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-xs font-semibold text-[#6B6960] uppercase tracking-wider",children:g})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:F.map(f=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>b(o===f.id?null:f.id),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx(ds,{status:f.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:f.title}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:f.description})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#939084] flex-shrink-0",children:[e.jsx(z,{size:10}),"Checked ",new Date(f.lastChecked).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]})]}),o===f.id&&e.jsxs("div",{className:"px-4 pb-3 pt-1 bg-[#F8F4F0] dark:bg-[#222228]",children:[f.details&&e.jsx("p",{className:"text-sm text-[#6B6960] mb-2",children:f.details}),f.remediationUrl&&f.status!=="pass"&&e.jsxs("a",{href:f.remediationUrl,className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:underline",children:[e.jsx(Fe,{size:12}),"Fix this issue"]})]})]},f.id))})]},g)})]})}function hs(s){return s==null?"Not recorded":`$${s.toFixed(2)}`}function O(s,r){return s===void 0?"...":s===null?"Unavailable":r(s)}const ae=["#553DE9","#1FC5A8","#F59E0B","#6366F1","#C45B5B","#939084"];function us(s){if(!s||s.cost_recorded!==!0)return;const r=Object.entries(s.by_model||{}).map(([n,a])=>{const t=typeof a=="number"?a:a==null?void 0:a.cost_usd;return{model:n,usd:typeof t=="number"&&isFinite(t)?t:null}}).filter(n=>n.usd!==null);if(r.length===0)return;const c=r.reduce((n,a)=>n+a.usd,0);return r.map((n,a)=>({provider:n.model,cost:n.usd,percentage:c>0?n.usd/c*100:0,color:ae[a%ae.length]}))}function ps(s){const r=s.split(".")[0].toLowerCase();return["user","auth","login","logout"].includes(r)?"auth":["team","member","role","settings"].includes(r)?"admin":["deploy","build","session"].includes(r)?"deploy":["key","secret","api"].includes(r)?"api":r==="project"?"project":"system"}function js(s){return{id:s.id,timestamp:s.timestamp,user:s.user||"unknown",action:s.action,target:s.target||"",details:s.details||"",ip:"",category:ps(s.action)}}function _({label:s,value:r,note:c,icon:n,color:a}){return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-[#6B6960] uppercase tracking-wider",children:s}),e.jsx("p",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] mt-1",children:r}),e.jsx("p",{className:"text-xs mt-1 text-[#939084]",children:c})]}),e.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:`${a}10`,color:a},children:e.jsx(n,{size:20})})]})})}function gs({entries:s}){const r=n=>new Date(n).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}),c=(s||[]).slice().sort((n,a)=>n.timestamp<a.timestamp?1:-1).slice(0,20);return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(J,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Recent Activity"})]}),e.jsx("p",{className:"text-[11px] text-[#939084] mb-3",children:"From this server's recent-activity log. It keeps the last 500 entries and is not tamper-evident."}),s===void 0&&e.jsx("p",{className:"text-sm text-[#939084]",children:"Loading..."}),s===null&&e.jsx("p",{className:"text-sm text-[#939084]",children:"Could not load the activity log. Nothing is shown rather than a guess."}),s&&c.length===0&&e.jsx("p",{className:"text-sm text-[#939084]",children:"No activity recorded yet."}),c.length>0&&e.jsx("div",{className:"space-y-1 max-h-[400px] overflow-y-auto terminal-scroll",children:c.map(n=>e.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 rounded-lg hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#939084] flex-shrink-0 w-24",children:r(n.timestamp)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("span",{className:"text-xs",children:[e.jsx("span",{className:"text-[#553DE9] font-medium",children:n.user||"unknown"}),e.jsxs("span",{className:"text-[#6B6960]",children:[" ",n.action," "]}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:n.target})]})})]},n.id))})]})}function fs(){return e.jsxs("div",{className:"max-w-[500px] mx-auto px-6 py-20 text-center",children:[e.jsx(Ie,{size:48,className:"mx-auto text-[#C45B5B] mb-4"}),e.jsx("h1",{className:"font-heading text-h1 text-[#36342E] dark:text-[#E8E6E3] mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:"You do not have permission to access the admin dashboard. Contact your organization administrator for access."})]})}const Es=[{id:"overview",label:"Overview",icon:J},{id:"users",label:"Users",icon:I},{id:"analytics",label:"Analytics",icon:re},{id:"governance",label:"Governance",icon:he},{id:"audit",label:"Audit Trail",icon:z},{id:"compliance",label:"Compliance",icon:ne}];function Ms(){const{user:s,isLocalMode:r}=Se(),[c,n]=x.useState("overview"),[a,t]=x.useState({projects:void 0,teams:void 0,cost:void 0,audit:void 0}),j=r||(s==null?void 0:s.authenticated)===!0;x.useEffect(()=>{if(!j)return;let h=!1;return Promise.allSettled([U.getSessionsHistory(),U.getTeams(),U.getCost(),U.getAuditLog()]).then(([m,E,v,u])=>{if(h)return;const p=g=>g.status==="fulfilled"?g.value:null,k=p(E),i=p(m),N=p(u);t({projects:Array.isArray(i)?i.length:null,teams:Array.isArray(k)?{count:k.length,members:k.reduce((g,F)=>{var d;return g+(((d=F.members)==null?void 0:d.length)??0)},0)}:null,cost:p(v),audit:Array.isArray(N)?N:null})}),()=>{h=!0}},[j]);const o=x.useCallback(async()=>(await U.getAuditLog()).map(js),[]);if(!j)return e.jsx(fs,{});const b=us(a.cost);return e.jsxs("div",{className:"max-w-[1200px] mx-auto px-6 py-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsx("h1",{className:"font-heading text-h1 text-[#36342E] dark:text-[#E8E6E3]",children:"Admin"})}),e.jsx("div",{className:"flex items-center gap-1 border-b border-[#ECEAE3] dark:border-[#2A2A30] mb-6 overflow-x-auto",children:Es.map(h=>e.jsxs("button",{onClick:()=>n(h.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${c===h.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(h.icon,{size:14}),h.label]},h.id))}),c==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(_,{label:"Projects",value:O(a.projects,String),note:"Recent project folders (history lists up to 20 per location)",icon:he,color:"#1FC5A8"}),e.jsx(_,{label:"Teams",value:O(a.teams,h=>String(h.count)),note:a.teams?`${a.teams.members} member${a.teams.members===1?"":"s"}`:"Team membership",icon:I,color:"#553DE9"}),e.jsx(_,{label:"Total cost",value:O(a.cost,h=>hs(h.estimated_cost_usd)),note:"Recorded for the current project",icon:Y,color:"#C45B5B"}),e.jsx(_,{label:"Audit events",value:O(a.audit,h=>String(h.length)),note:"Recent-activity log entries",icon:Re,color:"#F59E0B"})]}),e.jsx(gs,{entries:a.audit})]}),c==="users"&&e.jsx(ns,{}),c==="analytics"&&e.jsx(es,{data:b?{costBreakdown:b}:{}}),c==="governance"&&e.jsx(cs,{}),c==="audit"&&e.jsx(ts,{onFetch:o}),c==="compliance"&&e.jsx(ms,{})]})}export{Ms as default};
32
+ `),ke=new Blob([S],{type:"text/csv"}),ee=URL.createObjectURL(ke),H=document.createElement("a");H.href=ee,H.download=`audit-log-${new Date().toISOString().split("T")[0]}.csv`,H.click(),URL.revokeObjectURL(ee)},[B]),ve=x.useCallback(async()=>{if(r){X(!0);try{const l=await r({search:b,user:m,actionType:v,dateFrom:p,dateTo:i});t(l),o(null)}catch(l){o(l instanceof Error?l.message:"request failed")}finally{X(!1)}}},[r,b,m,v,p,i]),Ne=l=>new Date(l).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1});return e.jsxs("div",{className:`space-y-4 ${n}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Audit Trail"}),!j&&e.jsxs("span",{className:"text-xs text-[#939084] ml-1",children:[B.length," event",B.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",variant:"ghost",icon:pe,onClick:ve,loading:T,children:"Refresh"}),e.jsx(C,{size:"sm",variant:"ghost",icon:K,onClick:be,children:"CSV"})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(le,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:b,onChange:l=>h(l.target.value),placeholder:"Search events...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]"})]}),e.jsx(C,{size:"sm",variant:g?"secondary":"ghost",icon:We,onClick:()=>F(!g),children:"Filters"})]}),g&&e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 p-3 border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg bg-[#F8F4F0] dark:bg-[#222228]",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"User"}),e.jsxs("select",{value:m,onChange:l=>E(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Users"}),fe.map(l=>e.jsx("option",{value:l,children:l},l))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Action"}),e.jsxs("select",{value:v,onChange:l=>u(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Actions"}),Ee.map(l=>e.jsx("option",{value:l,children:l},l))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"From"}),e.jsx("input",{type:"date",value:p,onChange:l=>k(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"To"}),e.jsx("input",{type:"date",value:i,onChange:l=>N(l.target.value),className:"w-full px-2 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]"})]})]})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"bg-[#F8F4F0] dark:bg-[#222228]",children:[e.jsx("th",{className:"w-8 px-2 py-2.5"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Timestamp"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"User"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Action"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960]",children:"Target"}),e.jsx("th",{className:"text-left px-3 py-2.5 text-xs font-medium text-[#6B6960] hidden md:table-cell",children:"IP"})]})}),e.jsxs("tbody",{children:[Q.map(l=>e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors cursor-pointer",onClick:()=>f(d===l.id?null:l.id),children:[e.jsx("td",{className:"px-2 py-2.5 text-center",children:d===l.id?e.jsx(ie,{size:12,className:"text-[#939084]"}):e.jsx(P,{size:12,className:"text-[#939084]"})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-[#939084]",children:[e.jsx(z,{size:12}),e.jsx("span",{className:"font-mono",children:Ne(l.timestamp)})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Be,{name:l.user.split("@")[0],size:"sm"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] truncate max-w-[150px]",children:l.user})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ss,{category:l.category}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:l.action})]})}),e.jsx("td",{className:"px-3 py-2.5",children:e.jsx("span",{className:"text-[#6B6960] truncate max-w-[120px] block",children:l.target||"--"})}),e.jsx("td",{className:"px-3 py-2.5 hidden md:table-cell",children:e.jsxs("div",{className:"flex items-center gap-1 text-xs text-[#939084]",children:[e.jsx(ze,{size:12}),e.jsx("span",{className:"font-mono",children:l.ip||"--"})]})})]},l.id),d===l.id&&e.jsx("tr",{className:"bg-[#F8F4F0] dark:bg-[#222228]",children:e.jsx("td",{colSpan:6,className:"px-6 py-3",children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(ye,{size:14,className:"text-[#939084] flex-shrink-0 mt-0.5"}),e.jsxs("div",{className:"text-sm text-[#6B6960]",children:[e.jsx("p",{className:"font-medium text-[#201515] dark:text-[#E8E6E3] mb-1",children:"Details"}),e.jsx("p",{children:l.details}),e.jsxs("div",{className:"flex items-center gap-4 mt-2 text-xs text-[#939084]",children:[e.jsxs("span",{children:["Event ID: ",l.id]}),e.jsxs("span",{children:["Full timestamp: ",new Date(l.timestamp).toISOString()]}),e.jsxs("span",{children:["IP: ",l.ip||"not recorded"]})]})]})]})})},`${l.id}-details`)]})),Q.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"px-4 py-8 text-center text-sm text-[#939084]",children:j?`Could not load the audit log (${j}). Nothing is shown rather than a guess.`:a.length===0?"No audit events recorded yet.":"No events match your filters."})})]})]})}),D>1&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-[#939084]",children:["Showing ",(y-1)*M+1,"-",Math.min(y*M,B.length)," of ",B.length]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>w(l=>Math.max(1,l-1)),disabled:y===1,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(Le,{size:16})}),Array.from({length:Math.min(D,5)},(l,A)=>{let S;return D<=5||y<=3?S=A+1:y>=D-2?S=D-4+A:S=y-2+A,e.jsx("button",{onClick:()=>w(S),className:`w-8 h-8 rounded-lg text-xs font-medium transition-colors ${y===S?"bg-[#553DE9] text-white":"text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]"}`,children:S},S)}),e.jsx("button",{onClick:()=>w(l=>Math.min(D,l+1)),disabled:y===D,className:"p-1.5 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228] disabled:opacity-40 transition-colors",children:e.jsx(P,{size:16})})]})]})]})}const V={admin:{label:"Admin",color:"#553DE9"},editor:{label:"Editor",color:"#1FC5A8"},viewer:{label:"Viewer",color:"#939084"}},te={active:{label:"Active",color:"#1FC5A8"},inactive:{label:"Inactive",color:"#939084"},invited:{label:"Invited",color:"#F59E0B"}};function q(s){if(!s)return"Never";const r=Date.now()-new Date(s).getTime(),c=Math.floor(r/6e4);if(c<1)return"Just now";if(c<60)return`${c}m ago`;const n=Math.floor(c/60);if(n<24)return`${n}h ago`;const a=Math.floor(n/24);return a<30?`${a}d ago`:`${Math.floor(a/30)}mo ago`}function ge(s){return s.split(" ").map(r=>r[0]).join("").toUpperCase().slice(0,2)}function as({onSubmit:s,onCancel:r}){const[c,n]=x.useState(""),[a,t]=x.useState("editor");return e.jsxs("div",{className:"border border-[#553DE9]/20 bg-[#553DE9]/5 dark:bg-[#553DE9]/10 rounded-lg p-4 space-y-3",children:[e.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Invite New User"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Email"}),e.jsxs("div",{className:"relative",children:[e.jsx(De,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"email",value:c,onChange:j=>n(j.target.value),placeholder:"colleague@company.com",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]",autoFocus:!0})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Role"}),e.jsxs("select",{value:a,onChange:j=>t(j.target.value),className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",icon:ue,onClick:()=>s(c,a),disabled:!c.trim()||!c.includes("@"),children:"Send Invite"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:r,children:"Cancel"})]})]})}function rs({user:s,onClose:r,onChangeRole:c,onToggleStatus:n}){return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[s.avatar_url?e.jsx("img",{src:s.avatar_url,alt:"",className:"w-10 h-10 rounded-full"}):e.jsx("div",{className:"w-10 h-10 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-sm font-bold",children:ge(s.name)}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:s.name}),e.jsx("p",{className:"text-xs text-[#939084]",children:s.email})]})]}),e.jsx("button",{onClick:r,className:"p-1 rounded-lg text-[#939084] hover:bg-[#F8F4F0] dark:hover:bg-[#222228]",children:e.jsx(ce,{size:16})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Role"}),e.jsxs("select",{value:s.role,onChange:a=>c(a.target.value),className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#6B6960] mb-1",children:"Status"}),e.jsx("button",{onClick:n,className:"flex items-center gap-2 px-3 py-2 w-full rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-sm text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:s.status==="active"?e.jsxs(e.Fragment,{children:[e.jsx(Ye,{size:16,className:"text-[#1FC5A8]"}),e.jsx("span",{className:"text-[#1FC5A8]",children:"Active"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{size:16,className:"text-[#939084]"}),e.jsx("span",{className:"text-[#939084]",children:"Inactive"})]})})]})]}),e.jsxs("div",{className:"flex items-center gap-6 text-xs text-[#939084] pt-2 border-t border-[#ECEAE3] dark:border-[#2A2A30]",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{size:12}),e.jsxs("span",{children:["Last active: ",q(s.lastActive)]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{size:12}),e.jsxs("span",{children:["Joined: ",q(s.joinedAt)]})]})]})]})}function ns({users:s,onChangeRole:r,onToggleStatus:c,onInviteUser:n,className:a=""}){const[t,j]=x.useState(s??[]),[o,b]=x.useState(""),[h,m]=x.useState(""),[E,v]=x.useState(!1),[u,p]=x.useState(null),k=t.filter(d=>{if(o){const f=o.toLowerCase();if(!d.name.toLowerCase().includes(f)&&!d.email.toLowerCase().includes(f))return!1}return!(h&&d.role!==h)}),i=t.find(d=>d.id===u)||null,N=x.useCallback(async(d,f)=>{if(!n)return;await n(d,f);const y={id:`u-${Date.now()}`,name:d.split("@")[0],email:d,role:f,status:"invited",lastActive:null,joinedAt:new Date().toISOString()};j(w=>[...w,y]),v(!1)},[n]),g=x.useCallback(async(d,f)=>{r&&(await r(d,f),j(y=>y.map(w=>w.id===d?{...w,role:f}:w)))},[r]),F=x.useCallback(async d=>{const f=t.find(w=>w.id===d);if(!f||!c)return;const y=f.status!=="active";await c(d,y),j(w=>w.map(T=>T.id===d?{...T,status:y?"active":"inactive"}:T))},[t,c]);return s?e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"User Management"}),e.jsxs("span",{className:"text-xs text-[#939084]",children:[t.length," users"]})]}),!E&&n&&e.jsx(C,{size:"sm",variant:"secondary",icon:ue,onClick:()=>v(!0),children:"Invite User"})]}),E&&e.jsx(as,{onSubmit:N,onCancel:()=>v(!1)}),i&&e.jsx(rs,{user:i,onClose:()=>p(null),onChangeRole:d=>g(i.id,d),onToggleStatus:()=>F(i.id)}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(le,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-[#939084]"}),e.jsx("input",{type:"text",value:o,onChange:d=>b(d.target.value),placeholder:"Search users...",className:"w-full pl-9 pr-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084]"})]}),e.jsxs("select",{value:h,onChange:d=>m(d.target.value),className:"px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3]",children:[e.jsx("option",{value:"",children:"All Roles"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"viewer",children:"Viewer"})]})]}),e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:[k.map(d=>e.jsxs("button",{type:"button",onClick:()=>p(u===d.id?null:d.id),className:`w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors ${u===d.id?"bg-[#F8F4F0] dark:bg-[#222228]":""}`,children:[d.avatar_url?e.jsx("img",{src:d.avatar_url,alt:"",className:"w-8 h-8 rounded-full flex-shrink-0"}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-[#553DE9] flex items-center justify-center text-white text-xs font-bold flex-shrink-0",children:ge(d.name)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:d.name}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:d.email})]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-medium flex-shrink-0",style:{backgroundColor:`${V[d.role].color}15`,color:V[d.role].color},children:V[d.role].label}),e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full",style:{backgroundColor:te[d.status].color}}),e.jsx("span",{className:"text-xs text-[#939084] hidden md:inline",children:te[d.status].label})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0 hidden lg:inline w-16 text-right",children:q(d.lastActive)}),e.jsx(P,{size:14,className:"text-[#939084] flex-shrink-0"})]},d.id)),k.length===0&&e.jsx("div",{className:"px-4 py-8 text-center text-sm text-[#939084]",children:"No users match your search."})]})]}):e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"User Management"})]}),e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg px-4 py-8 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"This server has no user directory, so no users are listed. Team membership is managed on the Teams page."})]})]})}function ls({project:s,onApprove:r,onReject:c}){const[n,a]=x.useState(!1),[t,j]=x.useState(""),[o,b]=x.useState(!1);return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[e.jsxs("button",{type:"button",onClick:()=>a(!n),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[n?e.jsx(ie,{size:14,className:"text-[#939084]"}):e.jsx(P,{size:14,className:"text-[#939084]"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:s.name}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-[#F59E0B]/10 text-[#F59E0B]",children:"Pending"})]}),e.jsxs("div",{className:"flex items-center gap-3 text-xs text-[#939084] mt-0.5",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Te,{size:10}),s.submittedBy]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(de,{size:10}),s.template]}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Y,{size:10}),"~$",s.estimatedCost.toFixed(2)]})]})]}),e.jsx("span",{className:"text-xs text-[#939084] flex-shrink-0",children:new Date(s.submittedAt).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})})]}),n&&e.jsxs("div",{className:"px-4 pb-4 pt-2 border-t border-[#ECEAE3] dark:border-[#2A2A30] space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Template"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.template})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Provider"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.provider})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Est. Cost"}),e.jsxs("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:["$",s.estimatedCost.toFixed(2)]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-[#6B6960]",children:"Est. Iterations"}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:s.estimatedIterations})]})]}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:s.description}),o?e.jsxs("div",{className:"space-y-2",children:[e.jsx("textarea",{value:t,onChange:h=>j(h.target.value),placeholder:"Add a comment (optional)...",rows:2,className:"w-full px-3 py-2 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#1A1A1E] text-[#201515] dark:text-[#E8E6E3] placeholder-[#939084] resize-none"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{size:"sm",icon:je,onClick:()=>r(t),children:"Approve"}),e.jsx(C,{size:"sm",variant:"danger",icon:ce,onClick:()=>c(t),children:"Reject"}),e.jsx(C,{size:"sm",variant:"ghost",onClick:()=>b(!1),children:"Cancel"})]})]}):e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(C,{size:"sm",variant:"secondary",icon:Ae,onClick:()=>b(!0),children:"Review"})})]})]})}function is({configs:s}){return e.jsx("div",{className:"space-y-3",children:s.map(r=>{const c=r.budgetLimit>0?r.budgetUsed/r.budgetLimit*100:0,n=c>=r.alertThreshold,a=c>=100;return e.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:r.projectName}),e.jsxs("div",{className:"flex items-center gap-2",children:[n&&e.jsx(Z,{size:14,className:a?"text-[#C45B5B]":"text-[#F59E0B]"}),e.jsxs("span",{className:"text-xs font-mono text-[#939084]",children:["$",r.budgetUsed.toFixed(2)," / $",r.budgetLimit.toFixed(2)]})]})]}),e.jsx("div",{className:"h-2 bg-[#F8F4F0] dark:bg-[#1A1A1E] rounded-full overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(c,100)}%`,background:a?"#C45B5B":n?"#F59E0B":"#1FC5A8"}})}),e.jsxs("div",{className:"flex items-center justify-between mt-1",children:[e.jsxs("span",{className:"text-[10px] text-[#939084]",children:[c.toFixed(0),"% used"]}),e.jsxs("span",{className:"text-[10px] text-[#939084]",children:["Alert at ",r.alertThreshold,"%"]})]})]},r.projectId)})})}function W({children:s}){return e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{size:24,className:"mx-auto text-[#939084] mb-2"}),e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:s})]})}function cs({pendingProjects:s,budgetConfigs:r,onApproveProject:c,onRejectProject:n,className:a=""}){const[t,j]=x.useState(s??[]),[o,b]=x.useState("approvals"),h=t.filter(u=>u.status==="pending").length,m=x.useCallback(async(u,p)=>{c&&(await c(u,p),j(k=>k.map(i=>i.id===u?{...i,status:"approved"}:i)))},[c]),E=x.useCallback(async(u,p)=>{n&&(await n(u,p),j(k=>k.map(i=>i.id===u?{...i,status:"rejected"}:i)))},[n]),v=[{id:"approvals",label:"Approvals",icon:je,count:h},{id:"budgets",label:"Budgets",icon:Y},{id:"templates",label:"Templates",icon:de}];return e.jsxs("div",{className:`space-y-4 ${a}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(_e,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Project Governance"})]}),e.jsx("div",{className:"flex items-center gap-1 border-b border-[#ECEAE3] dark:border-[#2A2A30]",children:v.map(u=>e.jsxs("button",{onClick:()=>b(u.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors ${o===u.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(u.icon,{size:14}),u.label,u.count!==void 0&&u.count>0&&e.jsx("span",{className:"ml-1 px-1.5 py-0.5 rounded-full text-[10px] bg-[#553DE9]/10 text-[#553DE9]",children:u.count})]},u.id))}),o==="approvals"&&!s&&e.jsx(W,{children:"No project approval workflow is wired to this server, so nothing is waiting and nothing has been reviewed."}),o==="approvals"&&s&&e.jsx("div",{className:"space-y-3",children:t.filter(u=>u.status==="pending").length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(oe,{size:24,className:"mx-auto text-[#939084] mb-2"}),e.jsx("p",{className:"text-sm text-[#939084]",children:"No pending approvals"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"All project requests have been reviewed."})]}):t.filter(u=>u.status==="pending").map(u=>e.jsx(ls,{project:u,onApprove:p=>m(u.id,p),onReject:p=>E(u.id,p)},u.id))}),o==="budgets"&&(r?e.jsx(is,{configs:r}):e.jsx(W,{children:"No per-project budgets are served here. A run's spend cap is set with LOKI_BUDGET_LIMIT and shown on the Metrics page."})),o==="templates"&&e.jsx(W,{children:"Template restrictions are not stored or enforced by this server, so none are shown."})]})}function ds({status:s}){switch(s){case"pass":return e.jsx(xe,{size:18,className:"text-[#1FC5A8]"});case"fail":return e.jsx(me,{size:18,className:"text-[#C45B5B]"});case"warning":return e.jsx(Z,{size:18,className:"text-[#F59E0B]"})}}const os={security:Ue,access:I,data:Me,audit:Ce};function xs({score:s}){const t=2*Math.PI*56,o=270/360*t,b=s/100*o,h=s>=80?"#1FC5A8":s>=60?"#F59E0B":"#C45B5B",m=135;return e.jsxs("div",{className:"relative inline-flex items-center justify-center",children:[e.jsxs("svg",{width:140,height:140,viewBox:"0 0 140 140",children:[e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:"currentColor",strokeOpacity:"0.08",strokeWidth:10,strokeDasharray:`${o} ${t}`,strokeLinecap:"round",transform:`rotate(${m} 70 70)`}),e.jsx("circle",{cx:70,cy:70,r:56,fill:"none",stroke:h,strokeWidth:10,strokeDasharray:`${b} ${t}`,strokeLinecap:"round",transform:`rotate(${m} 70 70)`,className:"transition-all duration-700"})]}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center",children:[e.jsxs("span",{className:"text-3xl font-bold text-[#36342E] dark:text-[#E8E6E3]",children:[s,"%"]}),e.jsx("span",{className:"text-xs text-[#939084]",children:"Compliant"})]})]})}function ms({items:s,onRefresh:r,className:c=""}){const[n,a]=x.useState(s??[]),[t,j]=x.useState(!1),[o,b]=x.useState(null),[h,m]=x.useState(!1),E=n.filter(g=>g.status==="pass").length,v=n.filter(g=>g.status==="warning").length,u=n.filter(g=>g.status==="fail").length,p=n.length>0?Math.round(E/n.length*100):null,k=x.useCallback(async()=>{j(!0);try{if(r){const g=await r();a(g)}}catch{}finally{j(!1)}},[r]),i=x.useCallback(()=>{m(!0);const g={generatedAt:new Date().toISOString(),overallScore:p,summary:{pass:E,warning:v,fail:u,total:n.length},items:n.map(y=>({title:y.title,status:y.status,category:y.category,details:y.details,lastChecked:y.lastChecked}))},F=new Blob([JSON.stringify(g,null,2)],{type:"application/json"}),d=URL.createObjectURL(F),f=document.createElement("a");f.href=d,f.download=`compliance-report-${new Date().toISOString().split("T")[0]}.json`,f.click(),URL.revokeObjectURL(d),setTimeout(()=>m(!1),1e3)},[n,p,E,v,u]),N=["security","access","data","audit"];return e.jsxs("div",{className:`space-y-6 ${c}`,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(we,{size:18,className:"text-[#553DE9]"}),e.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"Compliance"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[r&&e.jsx(C,{size:"sm",variant:"ghost",icon:pe,onClick:k,loading:t,children:"Refresh"}),p!==null&&e.jsx(C,{size:"sm",variant:"secondary",icon:K,onClick:i,loading:h,children:"Generate Report"})]})]}),p===null?e.jsxs("div",{className:"card p-6 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Not connected"}),e.jsx("p",{className:"text-xs text-[#939084] mt-1",children:"No compliance checks are wired to this server, so there is no score. Nothing here has been checked."})]}):e.jsx("div",{className:"card p-6",children:e.jsxs("div",{className:"flex items-center gap-8",children:[e.jsx(xs,{score:p}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Compliance Score"}),e.jsxs("div",{className:"grid grid-cols-3 gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(xe,{size:16,className:"text-[#1FC5A8]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:E}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Passing"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{size:16,className:"text-[#F59E0B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:v}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Warnings"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(me,{size:16,className:"text-[#C45B5B]"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg font-bold text-[#36342E] dark:text-[#E8E6E3]",children:u}),e.jsx("span",{className:"text-xs text-[#939084] ml-1",children:"Failing"})]})]})]})]})]})}),N.map(g=>{const F=n.filter(f=>f.category===g);if(F.length===0)return null;const d=os[g];return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-xs font-semibold text-[#6B6960] uppercase tracking-wider",children:g})]}),e.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:F.map(f=>e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>b(o===f.id?null:f.id),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx(ds,{status:f.status}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:f.title}),e.jsx("p",{className:"text-xs text-[#939084] truncate",children:f.description})]}),e.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-[#939084] flex-shrink-0",children:[e.jsx(z,{size:10}),"Checked ",new Date(f.lastChecked).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1})]})]}),o===f.id&&e.jsxs("div",{className:"px-4 pb-3 pt-1 bg-[#F8F4F0] dark:bg-[#222228]",children:[f.details&&e.jsx("p",{className:"text-sm text-[#6B6960] mb-2",children:f.details}),f.remediationUrl&&f.status!=="pass"&&e.jsxs("a",{href:f.remediationUrl,className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:underline",children:[e.jsx(Fe,{size:12}),"Fix this issue"]})]})]},f.id))})]},g)})]})}function hs(s){return s==null?"Not recorded":`$${s.toFixed(2)}`}function O(s,r){return s===void 0?"...":s===null?"Unavailable":r(s)}const ae=["#553DE9","#1FC5A8","#F59E0B","#6366F1","#C45B5B","#939084"];function us(s){if(!s||s.cost_recorded!==!0)return;const r=Object.entries(s.by_model||{}).map(([n,a])=>{const t=typeof a=="number"?a:a==null?void 0:a.cost_usd;return{model:n,usd:typeof t=="number"&&isFinite(t)?t:null}}).filter(n=>n.usd!==null);if(r.length===0)return;const c=r.reduce((n,a)=>n+a.usd,0);return r.map((n,a)=>({provider:n.model,cost:n.usd,percentage:c>0?n.usd/c*100:0,color:ae[a%ae.length]}))}function ps(s){const r=s.split(".")[0].toLowerCase();return["user","auth","login","logout"].includes(r)?"auth":["team","member","role","settings"].includes(r)?"admin":["deploy","build","session"].includes(r)?"deploy":["key","secret","api"].includes(r)?"api":r==="project"?"project":"system"}function js(s){return{id:s.id,timestamp:s.timestamp,user:s.user||"unknown",action:s.action,target:s.target||"",details:s.details||"",ip:"",category:ps(s.action)}}function _({label:s,value:r,note:c,icon:n,color:a}){return e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-[#6B6960] uppercase tracking-wider",children:s}),e.jsx("p",{className:"text-2xl font-bold text-[#36342E] dark:text-[#E8E6E3] mt-1",children:r}),e.jsx("p",{className:"text-xs mt-1 text-[#939084]",children:c})]}),e.jsx("div",{className:"p-2 rounded-lg",style:{backgroundColor:`${a}10`,color:a},children:e.jsx(n,{size:20})})]})})}function gs({entries:s}){const r=n=>new Date(n).toLocaleString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hour12:!1}),c=(s||[]).slice().sort((n,a)=>n.timestamp<a.timestamp?1:-1).slice(0,20);return e.jsxs("div",{className:"card p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(J,{size:14,className:"text-[#553DE9]"}),e.jsx("h4",{className:"text-sm font-medium text-[#36342E] dark:text-[#E8E6E3]",children:"Recent Activity"})]}),e.jsx("p",{className:"text-[11px] text-[#939084] mb-3",children:"From this server's recent-activity log. It keeps the last 500 entries and is not hash-chained."}),s===void 0&&e.jsx("p",{className:"text-sm text-[#939084]",children:"Loading..."}),s===null&&e.jsx("p",{className:"text-sm text-[#939084]",children:"Could not load the activity log. Nothing is shown rather than a guess."}),s&&c.length===0&&e.jsx("p",{className:"text-sm text-[#939084]",children:"No activity recorded yet."}),c.length>0&&e.jsx("div",{className:"space-y-1 max-h-[400px] overflow-y-auto terminal-scroll",children:c.map(n=>e.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 rounded-lg hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#939084] flex-shrink-0 w-24",children:r(n.timestamp)}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("span",{className:"text-xs",children:[e.jsx("span",{className:"text-[#553DE9] font-medium",children:n.user||"unknown"}),e.jsxs("span",{className:"text-[#6B6960]",children:[" ",n.action," "]}),e.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] font-medium",children:n.target})]})})]},n.id))})]})}function fs(){return e.jsxs("div",{className:"max-w-[500px] mx-auto px-6 py-20 text-center",children:[e.jsx(Ie,{size:48,className:"mx-auto text-[#C45B5B] mb-4"}),e.jsx("h1",{className:"font-heading text-h1 text-[#36342E] dark:text-[#E8E6E3] mb-2",children:"Access Denied"}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:"You do not have permission to access the admin dashboard. Contact your organization administrator for access."})]})}const Es=[{id:"overview",label:"Overview",icon:J},{id:"users",label:"Users",icon:I},{id:"analytics",label:"Analytics",icon:re},{id:"governance",label:"Governance",icon:he},{id:"audit",label:"Audit Trail",icon:z},{id:"compliance",label:"Compliance",icon:ne}];function Ms(){const{user:s,isLocalMode:r}=Se(),[c,n]=x.useState("overview"),[a,t]=x.useState({projects:void 0,teams:void 0,cost:void 0,audit:void 0}),j=r||(s==null?void 0:s.authenticated)===!0;x.useEffect(()=>{if(!j)return;let h=!1;return Promise.allSettled([U.getSessionsHistory(),U.getTeams(),U.getCost(),U.getAuditLog()]).then(([m,E,v,u])=>{if(h)return;const p=g=>g.status==="fulfilled"?g.value:null,k=p(E),i=p(m),N=p(u);t({projects:Array.isArray(i)?i.length:null,teams:Array.isArray(k)?{count:k.length,members:k.reduce((g,F)=>{var d;return g+(((d=F.members)==null?void 0:d.length)??0)},0)}:null,cost:p(v),audit:Array.isArray(N)?N:null})}),()=>{h=!0}},[j]);const o=x.useCallback(async()=>(await U.getAuditLog()).map(js),[]);if(!j)return e.jsx(fs,{});const b=us(a.cost);return e.jsxs("div",{className:"max-w-[1200px] mx-auto px-6 py-8",children:[e.jsx("div",{className:"flex items-center justify-between mb-6",children:e.jsx("h1",{className:"font-heading text-h1 text-[#36342E] dark:text-[#E8E6E3]",children:"Admin"})}),e.jsx("div",{className:"flex items-center gap-1 border-b border-[#ECEAE3] dark:border-[#2A2A30] mb-6 overflow-x-auto",children:Es.map(h=>e.jsxs("button",{onClick:()=>n(h.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium border-b-2 transition-colors whitespace-nowrap ${c===h.id?"border-[#553DE9] text-[#553DE9]":"border-transparent text-[#939084] hover:text-[#36342E] dark:hover:text-[#E8E6E3]"}`,children:[e.jsx(h.icon,{size:14}),h.label]},h.id))}),c==="overview"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(_,{label:"Projects",value:O(a.projects,String),note:"Recent project folders (history lists up to 20 per location)",icon:he,color:"#1FC5A8"}),e.jsx(_,{label:"Teams",value:O(a.teams,h=>String(h.count)),note:a.teams?`${a.teams.members} member${a.teams.members===1?"":"s"}`:"Team membership",icon:I,color:"#553DE9"}),e.jsx(_,{label:"Total cost",value:O(a.cost,h=>hs(h.estimated_cost_usd)),note:"Recorded for the current project",icon:Y,color:"#C45B5B"}),e.jsx(_,{label:"Audit events",value:O(a.audit,h=>String(h.length)),note:"Recent-activity log entries",icon:Re,color:"#F59E0B"})]}),e.jsx(gs,{entries:a.audit})]}),c==="users"&&e.jsx(ns,{}),c==="analytics"&&e.jsx(es,{data:b?{costBreakdown:b}:{}}),c==="governance"&&e.jsx(cs,{}),c==="audit"&&e.jsx(ts,{onFetch:o}),c==="compliance"&&e.jsx(ms,{})]})}export{Ms as default};
@@ -1,4 +1,4 @@
1
- import{c as l,j as s}from"./index-BmuNF2mZ.js";/**
1
+ import{c as l,j as s}from"./index-PtPpcleW.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{j as e}from"./index-BmuNF2mZ.js";import{C as r}from"./clock-Cj9sLcEq.js";import{C as a}from"./circle-alert-Dsq3DqO-.js";import{C as l}from"./check-IVM56fVX.js";const i={completed:"bg-[#1FC5A8]/10 text-[#1FC5A8]",running:"bg-[#553DE9]/10 text-[#553DE9]",failed:"bg-[#C45B5B]/10 text-[#C45B5B]",started:"bg-[#D4A03C]/10 text-[#D4A03C]",empty:"bg-[#F8F4F0] text-[#6B6960]",version:"bg-[#553DE9]/10 text-[#553DE9]"};function o({status:t}){switch(t){case"completed":return e.jsx(l,{size:12});case"running":return e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping motion-reduce:animate-none absolute inline-flex h-full w-full rounded-full bg-current opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-current"})]});case"failed":return e.jsx(a,{size:12});case"started":return e.jsx(r,{size:12});default:return null}}function f({status:t,children:n,className:s=""}){return e.jsxs("span",{className:["inline-flex items-center gap-1 rounded-btn px-2.5 py-0.5 text-xs font-semibold",i[t],s].filter(Boolean).join(" "),children:[e.jsx(o,{status:t}),n]})}export{f as B};
1
+ import{j as e}from"./index-PtPpcleW.js";import{C as r}from"./clock-CK6yBr-X.js";import{C as a}from"./circle-alert-BqhM6ffv.js";import{C as l}from"./check-BaHWRoFS.js";const i={completed:"bg-[#1FC5A8]/10 text-[#1FC5A8]",running:"bg-[#553DE9]/10 text-[#553DE9]",failed:"bg-[#C45B5B]/10 text-[#C45B5B]",started:"bg-[#D4A03C]/10 text-[#D4A03C]",empty:"bg-[#F8F4F0] text-[#6B6960]",version:"bg-[#553DE9]/10 text-[#553DE9]"};function o({status:t}){switch(t){case"completed":return e.jsx(l,{size:12});case"running":return e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"animate-ping motion-reduce:animate-none absolute inline-flex h-full w-full rounded-full bg-current opacity-75"}),e.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-current"})]});case"failed":return e.jsx(a,{size:12});case"started":return e.jsx(r,{size:12});default:return null}}function f({status:t,children:n,className:s=""}){return e.jsxs("span",{className:["inline-flex items-center gap-1 rounded-btn px-2.5 py-0.5 text-xs font-semibold",i[t],s].filter(Boolean).join(" "),children:[e.jsx(o,{status:t}),n]})}export{f as B};
@@ -1 +1 @@
1
- import{r as p,j as t}from"./index-BmuNF2mZ.js";const m={primary:"bg-[#553DE9] text-white hover:bg-[#4432c4] shadow-button rounded-btn",secondary:"border border-[#553DE9] text-[#553DE9] hover:bg-[#E8E4FD] bg-transparent rounded-btn",ghost:"text-[#36342E] hover:bg-[#F8F4F0] rounded-btn",danger:"bg-[#C45B5B]/10 text-[#C45B5B] border border-[#C45B5B]/20 hover:bg-[#C45B5B]/20 rounded-btn"},b={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},u={sm:14,md:16,lg:18};function h({size:e}){return t.jsxs("svg",{className:"animate-spin",width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}const B=p.forwardRef(({variant:e="primary",size:o="md",icon:n,iconRight:i,loading:r=!1,disabled:a,className:c="",children:l,...x},d)=>{const s=u[o];return t.jsxs("button",{ref:d,disabled:a||r,className:["inline-flex items-center justify-center gap-2 font-medium transition-colors",m[e],b[o],(a||r)&&"opacity-60 cursor-not-allowed",c].filter(Boolean).join(" "),...x,children:[r?t.jsx(h,{size:s}):n?t.jsx(n,{size:s}):null,l,i&&!r&&t.jsx(i,{size:s})]})});B.displayName="Button";export{B};
1
+ import{r as p,j as t}from"./index-PtPpcleW.js";const m={primary:"bg-[#553DE9] text-white hover:bg-[#4432c4] shadow-button rounded-btn",secondary:"border border-[#553DE9] text-[#553DE9] hover:bg-[#E8E4FD] bg-transparent rounded-btn",ghost:"text-[#36342E] hover:bg-[#F8F4F0] rounded-btn",danger:"bg-[#C45B5B]/10 text-[#C45B5B] border border-[#C45B5B]/20 hover:bg-[#C45B5B]/20 rounded-btn"},b={sm:"px-3 py-1.5 text-xs",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},u={sm:14,md:16,lg:18};function h({size:e}){return t.jsxs("svg",{className:"animate-spin",width:e,height:e,viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]})}const B=p.forwardRef(({variant:e="primary",size:o="md",icon:n,iconRight:i,loading:r=!1,disabled:a,className:c="",children:l,...x},d)=>{const s=u[o];return t.jsxs("button",{ref:d,disabled:a||r,className:["inline-flex items-center justify-center gap-2 font-medium transition-colors",m[e],b[o],(a||r)&&"opacity-60 cursor-not-allowed",c].filter(Boolean).join(" "),...x,children:[r?t.jsx(h,{size:s}):n?t.jsx(n,{size:s}):null,l,i&&!r&&t.jsx(i,{size:s})]})});B.displayName="Button";export{B};
@@ -1,4 +1,4 @@
1
- import{c as $,r as l,j as e,G as we,Q as Se,F as Ce,h as Re,T as U,Z as Ee,a as S,V as Me,S as $e,Y as Te,X as Pe,P as ie,i as Ae,g as ze,C as Ie,l as Le,N as I,J as _e,K as De,O as Fe,u as Oe}from"./index-BmuNF2mZ.js";import{P as K,S as He,E as Be}from"./ErrorBoundary-B3o_toch.js";import{C as qe,F as Ge,M as Ue,H as Ke,a as We,G as Ve,T as Qe}from"./thumbs-up-Bs3ZSrCN.js";import{C as oe}from"./check-IVM56fVX.js";import{C as Ye}from"./clock-Cj9sLcEq.js";import{D as Xe}from"./dollar-sign-DaU9xa0A.js";import{U as Ze}from"./upload-B_SYHnav.js";import{L as V}from"./loader-circle-BQGio77U.js";/**
1
+ import{c as $,r as l,j as e,G as we,Q as Se,F as Ce,h as Re,T as U,Z as Ee,a as S,V as Me,S as $e,Y as Te,X as Pe,P as ie,i as Ae,g as ze,C as Ie,l as Le,N as I,J as _e,K as De,O as Fe,u as Oe}from"./index-PtPpcleW.js";import{P as K,S as He,E as Be}from"./ErrorBoundary-pOL7Vuv2.js";import{C as qe,F as Ge,M as Ue,H as Ke,a as We,G as Ve,T as Qe}from"./thumbs-up-OMV8Huvt.js";import{C as oe}from"./check-BaHWRoFS.js";import{C as Ye}from"./clock-CK6yBr-X.js";import{D as Xe}from"./dollar-sign-Cf1Wg3hh.js";import{U as Ze}from"./upload-DMl7KGNJ.js";import{L as V}from"./loader-circle-BMRJRTe3.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as o,j as e}from"./index-BmuNF2mZ.js";function f({value:l,prefix:t="",suffix:s=""}){const[u,n]=o.useState(0),c=o.useRef(0);return o.useEffect(()=>{const a=c.current,h=l-a;if(h===0)return;const i=600,d=performance.now();function r(b){const v=b-d,m=Math.min(v/i,1),N=1-Math.pow(1-m,3),p=Math.round(a+h*N);n(p),c.current=p,m<1&&requestAnimationFrame(r)}requestAnimationFrame(r)},[l]),e.jsxs("span",{className:"tabular-nums",children:[t,u.toLocaleString(),s]})}function g(){const[l,t]=o.useState(5),[s,u]=o.useState(30),[n,c]=o.useState(75),a=.4,i=Math.round(l*s*a*4.33),d=Math.round(i*n);return e.jsxs("div",{className:"bg-white border border-[#ECEAE3] rounded-xl p-6 shadow-sm",children:[e.jsx("h3",{className:"text-lg font-bold text-[#36342E] mb-1",children:"ROI Calculator"}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-6",children:"Estimate how much your team could save with autonomous development."}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Team size"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:[l," developers"]})]}),e.jsx("input",{type:"range",min:1,max:50,value:l,onChange:r=>t(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"1"}),e.jsx("span",{children:"50"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Hours coding per week"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:[s,"h"]})]}),e.jsx("input",{type:"range",min:5,max:60,value:s,onChange:r=>u(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"5h"}),e.jsx("span",{children:"60h"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Average hourly rate"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:["$",n,"/hr"]})]}),e.jsx("input",{type:"range",min:25,max:250,step:5,value:n,onChange:r=>c(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"$25"}),e.jsx("span",{children:"$250"})]})]})]}),e.jsxs("div",{className:"mt-6 pt-6 border-t border-[#ECEAE3]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-[#553DE9]",children:e.jsx(f,{value:i,suffix:"h"})}),e.jsx("div",{className:"text-xs text-[#6B6960] mt-1",children:"Est. hours saved / month"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-[#1FC5A8]",children:e.jsx(f,{value:d,prefix:"$"})}),e.jsx("div",{className:"text-xs text-[#6B6960] mt-1",children:"Est. cost saved / month"})]})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-[#553DE9]/5 border border-[#553DE9]/10",children:[e.jsxs("p",{className:"text-sm text-[#36342E] text-center",children:["If Loki Mode saved ",Math.round(a*100),"% of coding time, your team could save"," ",e.jsxs("span",{className:"font-bold text-[#553DE9]",children:[i.toLocaleString()," hours"]})," ","and"," ",e.jsxs("span",{className:"font-bold text-[#1FC5A8]",children:["$",d.toLocaleString()]})," ","per month."]}),e.jsxs("p",{className:"mt-2 text-xs text-[#6B6960] text-center",children:["The ",Math.round(a*100),"% is an assumption, not a measurement. Model and API spend is not included."]})]})]})]})}const j=[{feature:"Claude (Opus/Sonnet/Haiku)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!0},{feature:"Any model via opencode (OpenRouter, local)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Provider auto-failover (Claude Code, opencode)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"8 automated quality gates",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Blind 3-reviewer code review",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Anti-sycophancy checks",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Automated test generation",category:"Quality",lokiMode:!0,boltNew:!1,replit:"Partial",lovable:!1},{feature:"Docker container generation",category:"Deployment",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"CI/CD pipeline generation",category:"Deployment",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"One-click cloud deploy",category:"Deployment",lokiMode:"Planned",boltNew:!0,replit:!0,lovable:!0},{feature:"Self-hosted (your keys)",category:"Cost",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Free tier available",category:"Cost",lokiMode:"Source-available (BUSL-1.1)",boltNew:!0,replit:!0,lovable:!0},{feature:"No vendor lock-in",category:"Cost",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"SSO / OIDC authentication",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"RBAC access control",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"Audit logging",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"Air-gapped deployment",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1}];function y(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-[#1FC5A8]",children:e.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function w(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-[#C45B5B]/40",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function x({value:l}){return typeof l=="string"?e.jsx("span",{className:"text-xs text-[#6B6960] font-medium",children:l}):l?e.jsx(y,{}):e.jsx(w,{})}const k=[{title:"Full Autonomy",description:"Describe what you want. Loki Mode handles planning, coding, testing, and verification automatically.",icon:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#553DE9]",children:e.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{title:"Production Quality",description:"8 quality gates, blind code review, and anti-sycophancy checks ensure code that actually works.",icon:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#1FC5A8]",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{title:"Your Infrastructure",description:"Self-hosted, source-available (BUSL-1.1), no data leaves your network. Use your own API keys across 5 providers.",icon:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#2F71E3]",children:[e.jsx("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",stroke:"currentColor",strokeWidth:"2"}),e.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"6",cy:"6",r:"1",fill:"currentColor"}),e.jsx("circle",{cx:"6",cy:"18",r:"1",fill:"currentColor"})]})},{title:"Built for Teams",description:"Enterprise auth, RBAC, audit logs, and parallel workflows for teams of any size.",icon:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#E93D82]",children:[e.jsx("path",{d:"M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("circle",{cx:"9",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}];function C(){const l=[...new Set(j.map(t=>t.category))];return e.jsx("div",{className:"min-h-screen bg-[#FAF9F6]",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-[#36342E]",children:"Compare"}),e.jsx("p",{className:"text-[#6B6960] mt-1",children:"See how Loki Mode stacks up against other AI development platforms."})]}),e.jsx("div",{className:"bg-white border border-[#ECEAE3] rounded-xl overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#ECEAE3]",children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-[#6B6960] w-[240px]",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-bold text-[#553DE9] bg-[#553DE9]/5 w-[130px]",children:"Loki Mode"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"bolt.new"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"Replit"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"Lovable"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-[#FAF9F6]",children:e.jsx("td",{colSpan:5,className:"px-4 py-2 text-xs font-bold text-[#939084] uppercase tracking-wider",children:t})},`cat-${t}`),j.filter(s=>s.category===t).map(s=>e.jsxs("tr",{className:"border-b border-[#ECEAE3] last:border-b-0",children:[e.jsx("td",{className:"px-4 py-2.5 text-[#36342E]",children:s.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center bg-[#553DE9]/5",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.lokiMode})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.boltNew})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.replit})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.lovable})})})]},s.feature))]}))})]})})}),e.jsxs("div",{className:"mt-12",children:[e.jsx("h2",{className:"text-xl font-bold text-[#36342E] mb-6",children:"Why developers choose Loki Mode"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:k.map(t=>e.jsxs("div",{className:"bg-white border border-[#ECEAE3] rounded-xl p-5 shadow-sm hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mb-3",children:t.icon}),e.jsx("h3",{className:"text-base font-bold text-[#36342E] mb-1",children:t.title}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:t.description})]},t.title))})]}),e.jsx("div",{className:"mt-12 max-w-xl mx-auto",children:e.jsx(g,{})})]})})}export{C as default};
1
+ import{r as o,j as e}from"./index-PtPpcleW.js";function f({value:l,prefix:t="",suffix:s=""}){const[u,n]=o.useState(0),c=o.useRef(0);return o.useEffect(()=>{const a=c.current,h=l-a;if(h===0)return;const i=600,d=performance.now();function r(b){const v=b-d,m=Math.min(v/i,1),N=1-Math.pow(1-m,3),p=Math.round(a+h*N);n(p),c.current=p,m<1&&requestAnimationFrame(r)}requestAnimationFrame(r)},[l]),e.jsxs("span",{className:"tabular-nums",children:[t,u.toLocaleString(),s]})}function g(){const[l,t]=o.useState(5),[s,u]=o.useState(30),[n,c]=o.useState(75),a=.4,i=Math.round(l*s*a*4.33),d=Math.round(i*n);return e.jsxs("div",{className:"bg-white border border-[#ECEAE3] rounded-xl p-6 shadow-sm",children:[e.jsx("h3",{className:"text-lg font-bold text-[#36342E] mb-1",children:"ROI Calculator"}),e.jsx("p",{className:"text-sm text-[#6B6960] mb-6",children:"Estimate how much your team could save with autonomous development."}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Team size"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:[l," developers"]})]}),e.jsx("input",{type:"range",min:1,max:50,value:l,onChange:r=>t(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"1"}),e.jsx("span",{children:"50"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Hours coding per week"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:[s,"h"]})]}),e.jsx("input",{type:"range",min:5,max:60,value:s,onChange:r=>u(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"5h"}),e.jsx("span",{children:"60h"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-sm font-medium text-[#36342E]",children:"Average hourly rate"}),e.jsxs("span",{className:"text-sm font-semibold text-[#553DE9] tabular-nums",children:["$",n,"/hr"]})]}),e.jsx("input",{type:"range",min:25,max:250,step:5,value:n,onChange:r=>c(Number(r.target.value)),className:"w-full h-2 bg-[#ECEAE3] rounded-full appearance-none cursor-pointer accent-[#553DE9]"}),e.jsxs("div",{className:"flex justify-between text-xs text-[#939084] mt-1",children:[e.jsx("span",{children:"$25"}),e.jsx("span",{children:"$250"})]})]})]}),e.jsxs("div",{className:"mt-6 pt-6 border-t border-[#ECEAE3]",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-center",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-[#553DE9]",children:e.jsx(f,{value:i,suffix:"h"})}),e.jsx("div",{className:"text-xs text-[#6B6960] mt-1",children:"Est. hours saved / month"})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold text-[#1FC5A8]",children:e.jsx(f,{value:d,prefix:"$"})}),e.jsx("div",{className:"text-xs text-[#6B6960] mt-1",children:"Est. cost saved / month"})]})]}),e.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-[#553DE9]/5 border border-[#553DE9]/10",children:[e.jsxs("p",{className:"text-sm text-[#36342E] text-center",children:["If Loki Mode saved ",Math.round(a*100),"% of coding time, your team could save"," ",e.jsxs("span",{className:"font-bold text-[#553DE9]",children:[i.toLocaleString()," hours"]})," ","and"," ",e.jsxs("span",{className:"font-bold text-[#1FC5A8]",children:["$",d.toLocaleString()]})," ","per month."]}),e.jsxs("p",{className:"mt-2 text-xs text-[#6B6960] text-center",children:["The ",Math.round(a*100),"% is an assumption, not a measurement. Model and API spend is not included."]})]})]})]})}const j=[{feature:"Claude (Opus/Sonnet/Haiku)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!0},{feature:"Any model via opencode (OpenRouter, local)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Provider auto-failover (Claude Code, opencode)",category:"AI Models",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"8 automated quality gates",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Blind 3-reviewer code review",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Anti-sycophancy checks",category:"Quality",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Automated test generation",category:"Quality",lokiMode:!0,boltNew:!1,replit:"Partial",lovable:!1},{feature:"Docker container generation",category:"Deployment",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"CI/CD pipeline generation",category:"Deployment",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"One-click cloud deploy",category:"Deployment",lokiMode:"Planned",boltNew:!0,replit:!0,lovable:!0},{feature:"Self-hosted (your keys)",category:"Cost",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"Free tier available",category:"Cost",lokiMode:"Source-available (BUSL-1.1)",boltNew:!0,replit:!0,lovable:!0},{feature:"No vendor lock-in",category:"Cost",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1},{feature:"SSO / OIDC authentication",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"RBAC access control",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"Audit logging",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!0,lovable:!1},{feature:"Air-gapped deployment",category:"Enterprise",lokiMode:!0,boltNew:!1,replit:!1,lovable:!1}];function y(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-[#1FC5A8]",children:e.jsx("path",{d:"M20 6L9 17l-5-5",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function w(){return e.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",className:"text-[#C45B5B]/40",children:e.jsx("path",{d:"M18 6L6 18M6 6l12 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function x({value:l}){return typeof l=="string"?e.jsx("span",{className:"text-xs text-[#6B6960] font-medium",children:l}):l?e.jsx(y,{}):e.jsx(w,{})}const k=[{title:"Full Autonomy",description:"Describe what you want. Loki Mode handles planning, coding, testing, and verification automatically.",icon:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#553DE9]",children:e.jsx("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{title:"Production Quality",description:"8 quality gates, blind code review, and anti-sycophancy checks ensure code that actually works.",icon:e.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#1FC5A8]",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})},{title:"Your Infrastructure",description:"Self-hosted, source-available (BUSL-1.1), no data leaves your network. Use your own API keys across 5 providers.",icon:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#2F71E3]",children:[e.jsx("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",stroke:"currentColor",strokeWidth:"2"}),e.jsx("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",stroke:"currentColor",strokeWidth:"2"}),e.jsx("circle",{cx:"6",cy:"6",r:"1",fill:"currentColor"}),e.jsx("circle",{cx:"6",cy:"18",r:"1",fill:"currentColor"})]})},{title:"Built for Teams",description:"Enterprise auth, RBAC, audit logs, and parallel workflows for teams of any size.",icon:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",className:"text-[#E93D82]",children:[e.jsx("path",{d:"M17 21v-2a4 4 0 00-4-4H5a4 4 0 00-4 4v2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("circle",{cx:"9",cy:"7",r:"4",stroke:"currentColor",strokeWidth:"2"}),e.jsx("path",{d:"M23 21v-2a4 4 0 00-3-3.87M16 3.13a4 4 0 010 7.75",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}];function C(){const l=[...new Set(j.map(t=>t.category))];return e.jsx("div",{className:"min-h-screen bg-[#FAF9F6]",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-bold text-[#36342E]",children:"Compare"}),e.jsx("p",{className:"text-[#6B6960] mt-1",children:"See how Loki Mode stacks up against other AI development platforms."})]}),e.jsx("div",{className:"bg-white border border-[#ECEAE3] rounded-xl overflow-hidden shadow-sm",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-[#ECEAE3]",children:[e.jsx("th",{className:"text-left px-4 py-3 font-medium text-[#6B6960] w-[240px]",children:"Feature"}),e.jsx("th",{className:"text-center px-4 py-3 font-bold text-[#553DE9] bg-[#553DE9]/5 w-[130px]",children:"Loki Mode"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"bolt.new"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"Replit"}),e.jsx("th",{className:"text-center px-4 py-3 font-medium text-[#6B6960] w-[130px]",children:"Lovable"})]})}),e.jsx("tbody",{children:l.map(t=>e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"bg-[#FAF9F6]",children:e.jsx("td",{colSpan:5,className:"px-4 py-2 text-xs font-bold text-[#939084] uppercase tracking-wider",children:t})},`cat-${t}`),j.filter(s=>s.category===t).map(s=>e.jsxs("tr",{className:"border-b border-[#ECEAE3] last:border-b-0",children:[e.jsx("td",{className:"px-4 py-2.5 text-[#36342E]",children:s.feature}),e.jsx("td",{className:"px-4 py-2.5 text-center bg-[#553DE9]/5",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.lokiMode})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.boltNew})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.replit})})}),e.jsx("td",{className:"px-4 py-2.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(x,{value:s.lovable})})})]},s.feature))]}))})]})})}),e.jsxs("div",{className:"mt-12",children:[e.jsx("h2",{className:"text-xl font-bold text-[#36342E] mb-6",children:"Why developers choose Loki Mode"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-5",children:k.map(t=>e.jsxs("div",{className:"bg-white border border-[#ECEAE3] rounded-xl p-5 shadow-sm hover:shadow-md transition-shadow",children:[e.jsx("div",{className:"mb-3",children:t.icon}),e.jsx("h3",{className:"text-base font-bold text-[#36342E] mb-1",children:t.title}),e.jsx("p",{className:"text-sm text-[#6B6960]",children:t.description})]},t.title))})]}),e.jsx("div",{className:"mt-12 max-w-xl mx-auto",children:e.jsx(g,{})})]})})}export{C as default};
@@ -1,4 +1,4 @@
1
- import{c as o,r as a,j as e,T as n,h as i,p as c}from"./index-BmuNF2mZ.js";/**
1
+ import{c as o,r as a,j as e,T as n,h as i,p as c}from"./index-PtPpcleW.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- import{r as l,a as x,j as e}from"./index-BmuNF2mZ.js";const N={verified:{badge:"bg-success/10 text-success border-success/20",dot:"bg-success",label:"Verified",proven:"The server recomputed the integrity hash and it matches, and the gpg signature verified against its keyring.",notProven:"That the code is correct, or that the recorded diff still matches your repo. A receipt records which checks ran, not that the result is right."},unsigned:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Unsigned",proven:"The server recomputed the integrity hash and it matches these receipt bytes.",notProven:"Who produced it. An unsigned receipt is forgeable: whoever controls the builder can rewrite the facts and recompute the hash."},unchecked:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Not checked",proven:"The server recomputed the integrity hash and it matches.",notProven:"Provenance. A signature is present but was not evaluated here, which is not the same as a bad signature."},tampered:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Tampered",proven:"Nothing. The server recomputed the integrity hash and it does not match the contents.",notProven:"Anything at all. This receipt was edited after it was written. Do not trust this build."},failed:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Failed verification",proven:"Nothing. A verification check ran on the server and said no.",notProven:"Anything the receipt claims. Read the reason below."},not_verified:{badge:"border-muted/20 text-muted",dot:"bg-muted/40",label:"Not verified here",proven:"Nothing. No verification result was computed for this receipt here.",notProven:"Integrity or provenance. Run the command below to check it yourself."}};function w(t){const n=t==null?void 0:t.integrity_check,r=t==null?void 0:t.verification;return n?n.status==="tampered"?"tampered":n.status==="failed"?"failed":n.status!=="verified"?"not_verified":n.gpg_ok===!0?"verified":r!=null&&r.attestation||r!=null&&r.gpg_signature?"unchecked":"unsigned":"not_verified"}const v=[{key:"verified",label:"Verified",bar:"bg-success",text:"text-success"},{key:"with_gaps",label:"With gaps",bar:"bg-warning",text:"text-warning"},{key:"not_verified",label:"Not verified",bar:"bg-danger",text:"text-danger"},{key:"unknown",label:"Unknown",bar:"bg-muted/40",text:"text-muted"}];function y({summary:t}){const n=t.total_receipts;return n?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex h-1.5 rounded-full overflow-hidden bg-muted/10",children:v.map(({key:r,bar:s})=>{const i=t[r];return i?e.jsx("div",{className:s,style:{width:`${i/n*100}%`},title:`${i} ${r}`},r):null})}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs",children:v.map(({key:r,label:s,text:i})=>{const c=t[r];return c?e.jsxs("span",{className:i,children:[e.jsx("span",{className:"font-semibold",children:c})," ",s.toLowerCase()]},r):null})}),e.jsxs("p",{className:"text-muted text-xs",children:["Recorded verdicts across ",n," receipt",n===1?"":"s",", not re-verified here."]})]}):null}function u({label:t,value:n}){return e.jsxs("div",{className:"flex items-baseline gap-2 text-xs",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:t}),e.jsx("span",{className:"font-mono truncate",title:n,children:n})]})}function k({proof:t}){var m,p,g,f,b;const[n,r]=l.useState(!1),[s,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(!n||s||c)return;let o=!1;return x.getProof(t.run_id).then(h=>{o||i(h)}).catch(h=>{o||d((h==null?void 0:h.message)||"could not load this receipt")}),()=>{o=!0}},[n,t.run_id,s,c]);const a=N[w(s)],j=t.generated_at?new Date(t.generated_at).toLocaleString():"unknown";return e.jsxs("div",{className:`border rounded-card overflow-hidden ${s?a.badge:"border-muted/20"}`,children:[e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-3 py-2.5 text-left",onClick:()=>r(!n),"aria-expanded":n,children:[e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?a.dot:"bg-muted/40"}`}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:t.headline?`Recorded: ${t.headline}`:t.run_id}),t.final_verdict&&e.jsxs("span",{className:"text-xs font-mono uppercase tracking-wider flex-shrink-0 text-muted",children:["council ",t.final_verdict]}),e.jsx("span",{className:"text-muted text-xs flex-shrink-0",children:n?"−":"+"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-current/10 pt-3",children:[c&&e.jsxs("p",{className:"text-xs text-danger",children:["Could not load this receipt: ",c]}),!c&&!s&&e.jsx("p",{className:"text-xs text-muted",children:"Loading receipt…"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{label:"Run",value:s.run_id}),e.jsx(u,{label:"Generated",value:j}),e.jsx(u,{label:"Loki version",value:s.loki_version||"unknown"}),e.jsx(u,{label:"Cost",value:typeof((m=s.cost)==null?void 0:m.usd)=="number"?`${s.cost.cost_partial===!0?"at least ":""}$${s.cost.usd.toFixed(2)}`:"unknown"}),e.jsx(u,{label:"Files changed",value:typeof((p=s.files_changed)==null?void 0:p.count)=="number"?String(s.files_changed.count):"unknown"}),((g=s.verification)==null?void 0:g.hash)&&e.jsx(u,{label:"Recorded hash",value:s.verification.hash})]}),e.jsxs("div",{className:`rounded-card border px-3 py-2 ${a.badge}`,children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider mb-1",children:a.label}),e.jsxs("p",{className:"text-xs mb-1",children:[e.jsx("span",{className:"font-semibold",children:"Proven: "}),a.proven]}),e.jsxs("p",{className:"text-xs opacity-80",children:[e.jsx("span",{className:"font-semibold",children:"Not proven: "}),a.notProven]}),(((f=s.integrity_check)==null?void 0:f.reasons)||[]).slice(0,2).map(o=>e.jsx("p",{className:"text-xs opacity-80 mt-1",children:o},o))]}),e.jsxs("p",{className:"text-xs text-muted",children:["Verify it yourself (also re-derives the diff against your repo):"," ",e.jsxs("code",{className:"font-mono",children:["loki proof verify ",s.run_id,(b=s.verification)!=null&&b.attestation?" --jwks <url|file>":""]})]}),t.pr_url&&e.jsx("a",{href:t.pr_url,target:"_blank",rel:"noreferrer noopener",className:"text-xs text-primary underline",children:"View the pull request"})]})]})]})}function P(){const[t,n]=l.useState(null),[r,s]=l.useState(null),[i,c]=l.useState(null);return l.useEffect(()=>{let d=!1;return x.listProofs().then(a=>{d||n(a.proofs||[])}).catch(a=>{d||c((a==null?void 0:a.message)||"could not load receipts")}),x.proofsSummary().then(a=>{d||s(a)}).catch(()=>{}),()=>{d=!0}},[]),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Evidence Receipts"}),e.jsx("p",{className:"text-muted text-xs mt-1",children:"What each build actually checked, recorded so you can verify it yourself."})]}),i&&e.jsxs("p",{className:"text-xs text-danger",children:["Could not load receipts: ",i]}),!i&&t===null&&e.jsx("p",{className:"text-xs text-muted",children:"Loading…"}),r&&e.jsx(y,{summary:r}),t!==null&&t.length===0&&e.jsxs("p",{className:"text-xs text-muted",children:["No receipts yet. One is written at the end of each run (set ",e.jsx("code",{className:"font-mono",children:"LOKI_PROOF=0"})," to opt out)."]}),e.jsx("div",{className:"space-y-2",children:t==null?void 0:t.map(d=>e.jsx(k,{proof:d},d.run_id))})]})}export{P as E};
1
+ import{r as l,a as x,j as e}from"./index-PtPpcleW.js";const N={verified:{badge:"bg-success/10 text-success border-success/20",dot:"bg-success",label:"Verified",proven:"The server recomputed the integrity hash and it matches, and the gpg signature verified against its keyring.",notProven:"That the code is correct, or that the recorded diff still matches your repo. A receipt records which checks ran, not that the result is right."},unsigned:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Unsigned",proven:"The server recomputed the integrity hash and it matches these receipt bytes.",notProven:"Who produced it. An unsigned receipt is forgeable: whoever controls the builder can rewrite the facts and recompute the hash."},unchecked:{badge:"bg-warning/10 text-warning border-warning/20",dot:"bg-warning",label:"Not checked",proven:"The server recomputed the integrity hash and it matches.",notProven:"Provenance. A signature is present but was not evaluated here, which is not the same as a bad signature."},tampered:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Tampered",proven:"Nothing. The server recomputed the integrity hash and it does not match the contents.",notProven:"Anything at all. This receipt was edited after it was written. Do not trust this build."},failed:{badge:"bg-danger/10 text-danger border-danger/20",dot:"bg-danger",label:"Failed verification",proven:"Nothing. A verification check ran on the server and said no.",notProven:"Anything the receipt claims. Read the reason below."},not_verified:{badge:"border-muted/20 text-muted",dot:"bg-muted/40",label:"Not verified here",proven:"Nothing. No verification result was computed for this receipt here.",notProven:"Integrity or provenance. Run the command below to check it yourself."}};function w(t){const n=t==null?void 0:t.integrity_check,r=t==null?void 0:t.verification;return n?n.status==="tampered"?"tampered":n.status==="failed"?"failed":n.status!=="verified"?"not_verified":n.gpg_ok===!0?"verified":r!=null&&r.attestation||r!=null&&r.gpg_signature?"unchecked":"unsigned":"not_verified"}const v=[{key:"verified",label:"Verified",bar:"bg-success",text:"text-success"},{key:"with_gaps",label:"With gaps",bar:"bg-warning",text:"text-warning"},{key:"not_verified",label:"Not verified",bar:"bg-danger",text:"text-danger"},{key:"unknown",label:"Unknown",bar:"bg-muted/40",text:"text-muted"}];function y({summary:t}){const n=t.total_receipts;return n?e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex h-1.5 rounded-full overflow-hidden bg-muted/10",children:v.map(({key:r,bar:s})=>{const i=t[r];return i?e.jsx("div",{className:s,style:{width:`${i/n*100}%`},title:`${i} ${r}`},r):null})}),e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-xs",children:v.map(({key:r,label:s,text:i})=>{const c=t[r];return c?e.jsxs("span",{className:i,children:[e.jsx("span",{className:"font-semibold",children:c})," ",s.toLowerCase()]},r):null})}),e.jsxs("p",{className:"text-muted text-xs",children:["Recorded verdicts across ",n," receipt",n===1?"":"s",", not re-verified here."]})]}):null}function u({label:t,value:n}){return e.jsxs("div",{className:"flex items-baseline gap-2 text-xs",children:[e.jsx("span",{className:"text-muted w-28 flex-shrink-0",children:t}),e.jsx("span",{className:"font-mono truncate",title:n,children:n})]})}function k({proof:t}){var m,p,g,f,b;const[n,r]=l.useState(!1),[s,i]=l.useState(null),[c,d]=l.useState(null);l.useEffect(()=>{if(!n||s||c)return;let o=!1;return x.getProof(t.run_id).then(h=>{o||i(h)}).catch(h=>{o||d((h==null?void 0:h.message)||"could not load this receipt")}),()=>{o=!0}},[n,t.run_id,s,c]);const a=N[w(s)],j=t.generated_at?new Date(t.generated_at).toLocaleString():"unknown";return e.jsxs("div",{className:`border rounded-card overflow-hidden ${s?a.badge:"border-muted/20"}`,children:[e.jsxs("button",{type:"button",className:"w-full flex items-center gap-3 px-3 py-2.5 text-left",onClick:()=>r(!n),"aria-expanded":n,children:[e.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${s?a.dot:"bg-muted/40"}`}),e.jsx("span",{className:"text-sm font-medium flex-1 truncate",children:t.headline?`Recorded: ${t.headline}`:t.run_id}),t.final_verdict&&e.jsxs("span",{className:"text-xs font-mono uppercase tracking-wider flex-shrink-0 text-muted",children:["council ",t.final_verdict]}),e.jsx("span",{className:"text-muted text-xs flex-shrink-0",children:n?"−":"+"})]}),n&&e.jsxs("div",{className:"px-3 pb-3 space-y-3 border-t border-current/10 pt-3",children:[c&&e.jsxs("p",{className:"text-xs text-danger",children:["Could not load this receipt: ",c]}),!c&&!s&&e.jsx("p",{className:"text-xs text-muted",children:"Loading receipt…"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(u,{label:"Run",value:s.run_id}),e.jsx(u,{label:"Generated",value:j}),e.jsx(u,{label:"Loki version",value:s.loki_version||"unknown"}),e.jsx(u,{label:"Cost",value:typeof((m=s.cost)==null?void 0:m.usd)=="number"?`${s.cost.cost_partial===!0?"at least ":""}$${s.cost.usd.toFixed(2)}`:"unknown"}),e.jsx(u,{label:"Files changed",value:typeof((p=s.files_changed)==null?void 0:p.count)=="number"?String(s.files_changed.count):"unknown"}),((g=s.verification)==null?void 0:g.hash)&&e.jsx(u,{label:"Recorded hash",value:s.verification.hash})]}),e.jsxs("div",{className:`rounded-card border px-3 py-2 ${a.badge}`,children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wider mb-1",children:a.label}),e.jsxs("p",{className:"text-xs mb-1",children:[e.jsx("span",{className:"font-semibold",children:"Proven: "}),a.proven]}),e.jsxs("p",{className:"text-xs opacity-80",children:[e.jsx("span",{className:"font-semibold",children:"Not proven: "}),a.notProven]}),(((f=s.integrity_check)==null?void 0:f.reasons)||[]).slice(0,2).map(o=>e.jsx("p",{className:"text-xs opacity-80 mt-1",children:o},o))]}),e.jsxs("p",{className:"text-xs text-muted",children:["Verify it yourself (also re-derives the diff against your repo):"," ",e.jsxs("code",{className:"font-mono",children:["loki proof verify ",s.run_id,(b=s.verification)!=null&&b.attestation?" --jwks <url|file>":""]})]}),t.pr_url&&e.jsx("a",{href:t.pr_url,target:"_blank",rel:"noreferrer noopener",className:"text-xs text-primary underline",children:"View the pull request"})]})]})]})}function P(){const[t,n]=l.useState(null),[r,s]=l.useState(null),[i,c]=l.useState(null);return l.useEffect(()=>{let d=!1;return x.listProofs().then(a=>{d||n(a.proofs||[])}).catch(a=>{d||c((a==null?void 0:a.message)||"could not load receipts")}),x.proofsSummary().then(a=>{d||s(a)}).catch(()=>{}),()=>{d=!0}},[]),e.jsxs("section",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Evidence Receipts"}),e.jsx("p",{className:"text-muted text-xs mt-1",children:"What each build actually checked, recorded so you can verify it yourself."})]}),i&&e.jsxs("p",{className:"text-xs text-danger",children:["Could not load receipts: ",i]}),!i&&t===null&&e.jsx("p",{className:"text-xs text-muted",children:"Loading…"}),r&&e.jsx(y,{summary:r}),t!==null&&t.length===0&&e.jsxs("p",{className:"text-xs text-muted",children:["No receipts yet. One is written at the end of each run (set ",e.jsx("code",{className:"font-mono",children:"LOKI_PROOF=0"})," to opt out)."]}),e.jsx("div",{className:"space-y-2",children:t==null?void 0:t.map(d=>e.jsx(k,{proof:d},d.run_id))})]})}export{P as E};
@@ -1,4 +1,4 @@
1
- import{c as _,r as o,a as k,j as e,m as B,J as v,N as h,a5 as H,M as L,l as q}from"./index-BmuNF2mZ.js";import{B as N}from"./Button-X5VdLM9H.js";import{C as y}from"./thumbs-up-Bs3ZSrCN.js";import{R as S}from"./refresh-cw-B24IKBF1.js";import{C as z}from"./circle-alert-Dsq3DqO-.js";import{U as D}from"./user-CIt72Y0w.js";import{L as G}from"./loader-circle-BQGio77U.js";import{R as T}from"./rotate-ccw-Cm9OyY5g.js";/**
1
+ import{c as _,r as o,a as k,j as e,m as B,J as v,N as h,a5 as H,M as L,l as q}from"./index-PtPpcleW.js";import{B as N}from"./Button-BsFDYQPM.js";import{C as y}from"./thumbs-up-OMV8Huvt.js";import{R as S}from"./refresh-cw-CZ_9FRpU.js";import{C as z}from"./circle-alert-BqhM6ffv.js";import{U as D}from"./user-DZjXIjRz.js";import{L as G}from"./loader-circle-BMRJRTe3.js";import{R as T}from"./rotate-ccw-GKppHg9k.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,4 +1,4 @@
1
- import{c as I,r as c,a as b,j as e,G as me,A as ue,S as Z,k as ee,m as pe,h as he,p as fe,X as te,M as be}from"./index-BmuNF2mZ.js";import{B as y}from"./Button-X5VdLM9H.js";import{C as ge}from"./chevron-left-SsA1da21.js";import{G as P}from"./thumbs-up-Bs3ZSrCN.js";import{R as $}from"./refresh-cw-B24IKBF1.js";import{C as Ne}from"./circle-alert-Dsq3DqO-.js";import{L as Q,S as je}from"./ProjectPage-Dl3rZ5bV.js";import{S as se}from"./shield-alert-COu4qEAn.js";import{F as ye}from"./file-code-corner-a393d0YD.js";import{C as V}from"./clock-Cj9sLcEq.js";import{C as re}from"./check-IVM56fVX.js";import"./ErrorBoundary-B3o_toch.js";import"./TerminalOutput-DSomtLgf.js";import"./lock-BSMOsGRv.js";import"./package-Dc3iyh_u.js";import"./file-plus-C3J3IYsn.js";import"./activity-CW1VLglI.js";import"./scroll-text-gdM4zNkj.js";import"./bot-B6I5yrNn.js";import"./loader-circle-BQGio77U.js";import"./hammer-AJ4xEMEQ.js";import"./dollar-sign-DaU9xa0A.js";import"./globe-DKRN-OfP.js";import"./trash-2-vdl0RPBK.js";import"./upload-B_SYHnav.js";import"./plus-BE-oSyaC.js";import"./rotate-ccw-Cm9OyY5g.js";import"./code-xml-qCQWXElP.js";import"./trending-up-sBLyeLVo.js";import"./layers-ZxK3Lg-E.js";import"./trending-down-DhxJxyuC.js";import"./server-B8YzsGPg.js";/**
1
+ import{c as I,r as c,a as b,j as e,G as me,A as ue,S as Z,k as ee,m as pe,h as he,p as fe,X as te,M as be}from"./index-PtPpcleW.js";import{B as y}from"./Button-BsFDYQPM.js";import{C as ge}from"./chevron-left-BaeSE3MB.js";import{G as P}from"./thumbs-up-OMV8Huvt.js";import{R as $}from"./refresh-cw-CZ_9FRpU.js";import{C as Ne}from"./circle-alert-BqhM6ffv.js";import{L as Q,S as je}from"./ProjectPage-2URjkyCj.js";import{S as se}from"./shield-alert-DR0OwBTR.js";import{F as ye}from"./file-code-corner-1D-LeA_0.js";import{C as V}from"./clock-CK6yBr-X.js";import{C as re}from"./check-BaHWRoFS.js";import"./ErrorBoundary-pOL7Vuv2.js";import"./TerminalOutput-DQug-ZN5.js";import"./lock-Dbi-okF-.js";import"./package-C5m2TO7-.js";import"./file-plus-C13TfPSr.js";import"./activity-CXqxbEYH.js";import"./scroll-text-DnTznFUB.js";import"./bot-BmoTiQie.js";import"./loader-circle-BMRJRTe3.js";import"./hammer-BDvg0Bpo.js";import"./dollar-sign-Cf1Wg3hh.js";import"./globe-D-bdUWR9.js";import"./trash-2-LDV528Je.js";import"./upload-DMl7KGNJ.js";import"./plus-D30AFrWv.js";import"./rotate-ccw-GKppHg9k.js";import"./code-xml-Cfpz-EBt.js";import"./trending-up-r9twANK7.js";import"./layers-CvZLTWTW.js";import"./trending-down-CivTGd3Q.js";import"./server-Dz8p0Af6.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.